diff --git a/Solution/clientApp/Input_UI.xaml b/Solution/clientApp/Input_UI.xaml new file mode 100644 index 0000000..d0a670a --- /dev/null +++ b/Solution/clientApp/Input_UI.xaml @@ -0,0 +1,26 @@ +<Window x:Class="Autodesk.Inventor.IO.Input_UI" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + Title="Inventor IO Demo Application" Icon="/Resources/Inventor.ico" Height="300" Width="450" MinHeight="300" MinWidth="500" > + <Grid ShowGridLines="False"> + <Grid.ColumnDefinitions> + <ColumnDefinition></ColumnDefinition> + <ColumnDefinition></ColumnDefinition> + <ColumnDefinition></ColumnDefinition> + <ColumnDefinition></ColumnDefinition> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition></RowDefinition> + <RowDefinition></RowDefinition> + <RowDefinition></RowDefinition> + </Grid.RowDefinitions> + <Image Grid.Row ="0" Grid.Column="0" Grid.RowSpan="3" Grid.ColumnSpan="2" Source="/Resources/Capture.bmp" Margin="10,0,0,10.4" VerticalAlignment="Bottom" /> + <Button x:Name="Apply_btn" Grid.Row ="2" Grid.Column="2" Content="Apply" Margin="10.4,40,5,10.4" Click="Apply_btn_Click" /> + <Button x:Name="Cancel_btn" Grid.Row ="2" Grid.Column="3" Content="Cancel" Margin="5,40,19.6,10.4" Click="Cancel_btn_Click" /> + <Label x:Name="Height_lbl" Content="Height (inch)" Grid.Row ="1" Grid.Column="2" FontSize="18" VerticalAlignment="Center" /> + <Label x:Name="Width_lbl" Content="Width (inch)" Grid.Row ="0" Grid.Column="2" FontSize="18" VerticalAlignment="Bottom" /> + <TextBox x:Name="width_textbox" Grid.Row="0" Grid.Column ="3" TextWrapping="Wrap" Text="20" MaxLength="2" MinWidth="50" FontSize="18" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="28.4,0,28.6,3.4" PreviewTextInput="width_textbox_PreviewTextInput" /> + <TextBox x:Name="height_textbox" Grid.Row="1" Grid.Column ="3" TextWrapping="Wrap" Text="16" MaxLength="2" MinWidth="50" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center" PreviewTextInput="height_textbox_PreviewTextInput"/> + + </Grid> +</Window> diff --git a/Solution/clientApp/Input_UI.xaml.cs b/Solution/clientApp/Input_UI.xaml.cs new file mode 100644 index 0000000..d431de6 --- /dev/null +++ b/Solution/clientApp/Input_UI.xaml.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Autodesk.Inventor.IO +{ + /// <summary> + /// Interaction logic for Input_UI.xaml + /// </summary> + public partial class Input_UI : Window + { + public string Input_height { get; set; } = "16"; + public string Input_width { get; set; } = "12"; + + public bool IsCancelled { get; set; } = false; + public Input_UI() + { + InitializeComponent(); + } + private void Cancel_btn_Click(object sender, RoutedEventArgs e) + { + this.Close(); + IsCancelled = true; + } + + private void width_textbox_PreviewTextInput(object sender, TextCompositionEventArgs e) + { + bool approvedDecimalPoint = false; + + if (e.Text == ".") + { + if (!((TextBox)sender).Text.Contains(".")) + approvedDecimalPoint = true; + } + + if (!(char.IsDigit(e.Text, e.Text.Length - 1) || approvedDecimalPoint)) + e.Handled = true; + } + + private void height_textbox_PreviewTextInput(object sender, TextCompositionEventArgs e) + { + bool approvedDecimalPoint = false; + + if (e.Text == ".") + { + if (!((TextBox)sender).Text.Contains(".")) + approvedDecimalPoint = true; + } + + if (!(char.IsDigit(e.Text, e.Text.Length - 1) || approvedDecimalPoint)) + e.Handled = true; + } + + private void Apply_btn_Click(object sender, RoutedEventArgs e) + { + // MessageBox.Show("Hieght:" + height_textbox.Text + "Width:" + width_textbox.Text); + if (height_textbox.Text.Trim() != string.Empty && width_textbox.Text.Trim() != string.Empty) + { + Input_height = height_textbox.Text.Trim(); + Input_width = width_textbox.Text.Trim(); + } + this.Close(); + } + } +} diff --git a/Solution/clientApp/Program.cs b/Solution/clientApp/Program.cs index 894f837..90a3491 100644 --- a/Solution/clientApp/Program.cs +++ b/Solution/clientApp/Program.cs @@ -71,6 +71,9 @@ class Program static ForgeDmClient s_ForgeDmClient; static readonly string s_alias = "prod"; static string s_nickname; + // added below 2 attributes for UI. + static string height; + static string width; static void DownloadToDocs(string url, string localFile) { @@ -380,7 +383,7 @@ private static async Task<string> CreatePartWorkItem() )), // This shows passing parameters and values into the plug-in new JProperty($"{s_Config.ParamArgName}", new JObject( - new JProperty("url", "data:application/json,{\"height\":\"16 in\", \"width\":\"10 in\"}") + new JProperty("url", "data:application/json,{\"height\":\""+height+" in\", \"width\":\""+width+" in\"}") // code changed to UI inputs )), // must match the output parameter in activity new JProperty(s_Config.OutputPartArgName, new JObject( @@ -436,7 +439,8 @@ private static async Task<string> CreateAssemblyWorkItem() )), // This shows passing parameters and values into the plug-in new JProperty($"{s_Config.ParamArgName}", new JObject( - new JProperty("url", "data:application/json,{\"handleOffset\":\"9 in\", \"height\":\"16 in\"}") + // code changed for UI input. Added 'width' param in assy as well. handleoffset param still remains hard coded. + new JProperty("url", "data:application/json,{\"handleOffset\":\"9 in\", \"height\":\""+height+" in\", \"width\":\""+width+" in\"}") )), // must match the output parameter in activity new JProperty(s_Config.OutputAssemblyArgName, new JObject( @@ -485,8 +489,19 @@ static void LoadConfig() } } + [STAThread] static void Main(string[] args) { + // Below 4 lines are for UI Input. + Input_UI UI = new Input_UI(); + UI.ShowDialog(); + if (UI.IsCancelled) + { + return; + }; + height = UI.Input_height; + width = UI.Input_width; + Task t = MainAsync(args); t.Wait(); } diff --git a/Solution/clientApp/Properties/Resources.Designer.cs b/Solution/clientApp/Properties/Resources.Designer.cs new file mode 100644 index 0000000..6c7e620 --- /dev/null +++ b/Solution/clientApp/Properties/Resources.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Autodesk.Inventor.IO.Properties { + using System; + + + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autodesk.Inventor.IO.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// </summary> + internal static System.Drawing.Bitmap Capture { + get { + object obj = ResourceManager.GetObject("Capture", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// <summary> + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// </summary> + internal static System.Drawing.Icon Inventor { + get { + object obj = ResourceManager.GetObject("Inventor", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + } +} diff --git a/Solution/clientApp/Properties/Resources.resx b/Solution/clientApp/Properties/Resources.resx new file mode 100644 index 0000000..5988810 --- /dev/null +++ b/Solution/clientApp/Properties/Resources.resx @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <data name="Capture" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\Capture.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="Inventor" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\Inventor.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> +</root> \ No newline at end of file diff --git a/Solution/clientApp/Resources/Capture.bmp b/Solution/clientApp/Resources/Capture.bmp new file mode 100644 index 0000000..ecc0488 Binary files /dev/null and b/Solution/clientApp/Resources/Capture.bmp differ diff --git a/Solution/clientApp/Resources/Inventor.ico b/Solution/clientApp/Resources/Inventor.ico new file mode 100644 index 0000000..3e0dcc3 Binary files /dev/null and b/Solution/clientApp/Resources/Inventor.ico differ diff --git a/Solution/clientApp/clientApp.csproj b/Solution/clientApp/clientApp.csproj index 07e1632..723674a 100644 --- a/Solution/clientApp/clientApp.csproj +++ b/Solution/clientApp/clientApp.csproj @@ -40,11 +40,14 @@ <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> <Reference Include="RestSharp, Version=106.4.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL"> <HintPath>..\packages\RestSharp.106.4.0\lib\net452\RestSharp.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Drawing" /> <Reference Include="System.Net" /> <Reference Include="System.Net.Http" /> <Reference Include="System.Runtime.Serialization" /> @@ -54,16 +57,26 @@ </Reference> <Reference Include="System.Web" /> <Reference Include="System.Web.Extensions" /> + <Reference Include="System.Xaml" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> + <Reference Include="WindowsBase" /> </ItemGroup> <ItemGroup> <Compile Include="ForgeDaClient.cs" /> + <Compile Include="Input_UI.xaml.cs"> + <DependentUpon>Input_UI.xaml</DependentUpon> + </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> </ItemGroup> <ItemGroup> <None Include="App.config"> @@ -82,6 +95,24 @@ <ItemGroup> <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> </ItemGroup> + <ItemGroup> + <Page Include="Input_UI.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <Resource Include="Resources\Inventor.ico" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Resources\Capture.bmp" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup>