diff options
| author | Roy <roy.mail.net@gmail.com> | 2017-12-09 00:31:12 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2017-12-09 00:31:12 +0200 |
| commit | cf7af2bc991e99b9dc82f4f54784d0eaa9a043b0 (patch) | |
| tree | b87a44c720b745294eb021b4393a43d480da3961 /Software | |
| parent | db4db5d05b42cbc795b3a38bba3e6c87f30d583f (diff) | |
| download | Tango-cf7af2bc991e99b9dc82f4f54784d0eaa9a043b0.tar.gz Tango-cf7af2bc991e99b9dc82f4f54784d0eaa9a043b0.zip | |
Stubs execution utility almost done.
Diffstat (limited to 'Software')
33 files changed, 643 insertions, 102 deletions
diff --git a/Software/Graphics/script.ico b/Software/Graphics/script.ico Binary files differnew file mode 100644 index 000000000..b31bb3399 --- /dev/null +++ b/Software/Graphics/script.ico diff --git a/Software/Graphics/script.png b/Software/Graphics/script.png Binary files differnew file mode 100644 index 000000000..74b6d8ec2 --- /dev/null +++ b/Software/Graphics/script.png diff --git a/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs b/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs index f57a8699f..16af1651c 100644 --- a/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs +++ b/Software/Visual_Studio/Tango.Core/Commands/RelayCommand.cs @@ -74,6 +74,12 @@ namespace Tango.Core.Commands public sealed class RelayCommand<T> : ICommand { + #region Events + + public event EventHandler<T> Executed; + + #endregion + #region fields readonly Predicate<object> canExecute; readonly Action<T> execute; @@ -121,6 +127,7 @@ namespace Tango.Core.Commands if (this.execute != null) { this.execute((T)parameter); + Executed?.Invoke(this, (T)parameter); } } #endregion ICommand methods diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 7c418a8c7..a41501f7f 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -11,7 +11,6 @@ using Tango.Logging; using Tango.PMR; using Tango.PMR.Common; using Tango.PMR.Stubs; -using Tango.SharedUI; using Tango.Core.Commands; using Tango.Transport; diff --git a/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj b/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj index 5cd70f974..477d7f983 100644 --- a/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj +++ b/Software/Visual_Studio/Tango.Emulations/Tango.Emulations.csproj @@ -66,10 +66,6 @@ <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> <Name>Tango.PMR</Name> </ProjectReference> - <ProjectReference Include="..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> - <Name>Tango.SharedUI</Name> - </ProjectReference> <ProjectReference Include="..\Tango.Transport\Tango.Transport.csproj"> <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> <Name>Tango.Transport</Name> diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs index 0551de699..97ac4f497 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/ScriptEditorControl.xaml.cs @@ -260,6 +260,28 @@ namespace Tango.SharedUI.Controls public static readonly DependencyProperty SaveCommandProperty = DependencyProperty.Register("SaveCommand", typeof(RelayCommand), typeof(ScriptEditorControl), new PropertyMetadata(null)); + + + public RelayCommand<String> InsertSnippetCommand + { + get { return (RelayCommand<String>)GetValue(InsertSnippetCommandProperty); } + set { SetValue(InsertSnippetCommandProperty, value); } + } + public static readonly DependencyProperty InsertSnippetCommandProperty = + DependencyProperty.Register("InsertSnippetCommand", typeof(RelayCommand<String>), typeof(ScriptEditorControl), new PropertyMetadata(null,(d,e) => (d as ScriptEditorControl).OnInsertScriptCommandChanged())); + + private void OnInsertScriptCommandChanged() + { + if (InsertSnippetCommand != null) + { + InsertSnippetCommand.Executed += (x, snippet) => + { + textEditor.Document.Insert(textEditor.TextArea.Caret.Offset, snippet); + }; + } + } + + #endregion private void textEditor_TextChanged(object sender, EventArgs e) diff --git a/Software/Visual_Studio/Tango.SharedUI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.SharedUI/Properties/AssemblyInfo.cs index f30c525cc..f03484397 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Properties/AssemblyInfo.cs @@ -1,6 +1,55 @@ using System.Reflection; +using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Windows; -[assembly: AssemblyTitle("Tango - Shared UI Components")] -[assembly: ComVisible(false)]
\ No newline at end of file +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.SharedUI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.SharedUI")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file +//inside a <PropertyGroup>. For example, if you are using US english +//in your source files, set the <UICulture> to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Tango.SharedUI/Properties/Resources.Designer.cs b/Software/Visual_Studio/Tango.SharedUI/Properties/Resources.Designer.cs new file mode 100644 index 000000000..66fe59ee1 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// <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 Tango.SharedUI.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", "4.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("Tango.SharedUI.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; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Properties/Resources.resx b/Software/Visual_Studio/Tango.SharedUI/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?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.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: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" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </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" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/Properties/Settings.Designer.cs b/Software/Visual_Studio/Tango.SharedUI/Properties/Settings.Designer.cs new file mode 100644 index 000000000..7f6e32ab3 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// <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 Tango.SharedUI.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Properties/Settings.settings b/Software/Visual_Studio/Tango.SharedUI/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index a164d2b4a..68e6d9a12 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -4,13 +4,14 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> + <ProjectGuid>{8491D07B-C1F6-4B62-A412-41B9FD2D6538}</ProjectGuid> + <OutputType>library</OutputType> <RootNamespace>Tango.SharedUI</RootNamespace> <AssemblyName>Tango.SharedUI</AssemblyName> <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> <TargetFrameworkProfile /> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> @@ -43,35 +44,29 @@ <Reference Include="GalaSoft.MvvmLight.Platform, Version=5.3.0.19032, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL"> <HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath> </Reference> - <Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL"> - <HintPath>..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath> - </Reference> <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> </Reference> - <Reference Include="PresentationCore" /> - <Reference Include="PresentationFramework" /> <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Drawing" /> - <Reference Include="System.Windows" /> - <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Data" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <HintPath>..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> + <HintPath>..\packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll</HintPath> + <Private>True</Private> </Reference> - <Reference Include="System.Xaml" /> + <Reference Include="System.Xml" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="System.Data" /> <Reference Include="System.Net.Http" /> - <Reference Include="System.Xml" /> + <Reference Include="System.Xaml"> + <RequiredTargetFramework>4.0</RequiredTargetFramework> + </Reference> <Reference Include="WindowsBase" /> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> </ItemGroup> <ItemGroup> - <Compile Include="..\Versioning\GlobalVersionInfo.cs"> - <Link>GlobalVersionInfo.cs</Link> - </Compile> <Compile Include="Controls\MultiTransitionControl.xaml.cs"> <DependentUpon>MultiTransitionControl.xaml</DependentUpon> </Compile> @@ -102,9 +97,29 @@ </Compile> <Compile Include="Helpers\ResourceHelper.cs" /> <Compile Include="IView.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> <Compile Include="ViewModel.cs" /> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> <None Include="packages.config" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> </ItemGroup> <ItemGroup> <Page Include="Controls\MultiTransitionControl.xaml"> @@ -125,6 +140,12 @@ </Page> </ItemGroup> <ItemGroup> + <Resource Include="Images\pubclass.gif" /> + <Resource Include="Images\pubevent.gif" /> + <Resource Include="Images\pubmethod.gif" /> + <Resource Include="Images\pubproperty.gif" /> + </ItemGroup> + <ItemGroup> <ProjectReference Include="..\SideChains\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj"> <Project>{6c55b776-26d4-4db3-a6ab-87e783b2f3d1}</Project> <Name>ICSharpCode.AvalonEdit</Name> @@ -134,17 +155,5 @@ <Name>Tango.Core</Name> </ProjectReference> </ItemGroup> - <ItemGroup> - <Resource Include="Images\pubclass.gif" /> - </ItemGroup> - <ItemGroup> - <Resource Include="Images\pubevent.gif" /> - </ItemGroup> - <ItemGroup> - <Resource Include="Images\pubmethod.gif" /> - </ItemGroup> - <ItemGroup> - <Resource Include="Images\pubproperty.gif" /> - </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs index dc8eeff8c..281a6c03d 100644 --- a/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs +++ b/Software/Visual_Studio/Tango.SharedUI/ViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using Tango.Core; @@ -19,13 +20,32 @@ namespace Tango.SharedUI public ViewModel(T view) { View = view; - View.ViewAttached += (x, e) => + View.ViewAttached += (x, e) => { View = (T)e; OnViewAttached(); }; } + public ViewModel(T view, bool delayed) + { + Task.Factory.StartNew(() => + { + while (view == null) + { + Thread.Sleep(10); + } + }).ContinueWith((c) => + { + View = view; + View.ViewAttached += (x, e) => + { + View = (T)e; + OnViewAttached(); + }; + }); + } + protected virtual void OnViewAttached() { diff --git a/Software/Visual_Studio/Tango.SharedUI/packages.config b/Software/Visual_Studio/Tango.SharedUI/packages.config index 713066a7b..b8183f4dd 100644 --- a/Software/Visual_Studio/Tango.SharedUI/packages.config +++ b/Software/Visual_Studio/Tango.SharedUI/packages.config @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="CommonServiceLocator" version="1.3" targetFramework="net46" /> + <package id="CommonServiceLocator" version="1.3" targetFramework="net45" /> <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net45" /> - <package id="MahApps.Metro" version="1.5.0" targetFramework="net46" /> - <package id="MvvmLight" version="5.3.0.0" targetFramework="net46" /> - <package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net46" /> + <package id="MvvmLight" version="5.3.0.0" targetFramework="net45" /> + <package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net45" /> </packages>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Stubs/StubBase.cs b/Software/Visual_Studio/Tango.Stubs/StubBase.cs index 96c50cdc7..fb5c87438 100644 --- a/Software/Visual_Studio/Tango.Stubs/StubBase.cs +++ b/Software/Visual_Studio/Tango.Stubs/StubBase.cs @@ -7,7 +7,7 @@ using System.Text; using System.Threading.Tasks; using Tango.Core; using Tango.Logging; -using Tango.SharedUI; +using Tango.PMR; using Tango.Transport; namespace Tango.Stubs @@ -82,5 +82,10 @@ namespace Tango.Stubs return results; } + + public static List<Type> GetAvailableRequestStubs() + { + return typeof(MessageFactory).Assembly.GetTypes().Where(x => x.Namespace.Contains("Stubs") && x.Name.Contains("Request") && !x.Name.Contains("Reflection")).ToList(); + } } } diff --git a/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj b/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj index de837bbe4..6d4538830 100644 --- a/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj +++ b/Software/Visual_Studio/Tango.Stubs/Tango.Stubs.csproj @@ -78,10 +78,6 @@ <Project>{40073806-914e-4e78-97ab-fa9639308ebe}</Project> <Name>Tango.Protobuf</Name> </ProjectReference> - <ProjectReference Include="..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> - <Name>Tango.SharedUI</Name> - </ProjectReference> <ProjectReference Include="..\Tango.Transport\Tango.Transport.csproj"> <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> <Name>Tango.Transport</Name> diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index f3f5a1abb..0953bcd19 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -122,10 +122,6 @@ <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project> <Name>Tango.Settings</Name> </ProjectReference> - <ProjectReference Include="..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> - <Name>Tango.SharedUI</Name> - </ProjectReference> <ProjectReference Include="..\Tango.Synchronization\Tango.Synchronization.csproj"> <Project>{7ada4e86-cad7-4968-a210-3a8a9e5153ab}</Project> <Name>Tango.Synchronization</Name> diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 01118c563..b8da66fbf 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +VisualStudioVersion = 15.0.26430.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Protobuf", "Tango.Protobuf\Tango.Protobuf.csproj", "{40073806-914E-4E78-97AB-FA9639308EBE}" EndProject @@ -16,8 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Protobuf.UI", "Utilities\Tango.Protobuf.UI\Tango.Protobuf.UI.csproj", "{37E45CE1-A0F6-4ED7-9791-A1BED947602F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.SharedUI", "Tango.SharedUI\Tango.SharedUI.csproj", "{AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Protobuf.CLI", "Utilities\Tango.Protobuf.CLI\Tango.Protobuf.CLI.csproj", "{DE5AB980-A9AD-4273-8272-C4E1E062E3EC}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Logging", "Tango.Logging\Tango.Logging.csproj", "{BC932DBD-7CDB-488C-99E4-F02CF441F55E}" @@ -79,6 +77,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Scripting", "Tango.Scripting\Tango.Scripting.csproj", "{401989E7-AE1E-4002-B0EE-9A9F63740B97}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.SharedUI", "Tango.SharedUI\Tango.SharedUI.csproj", "{8491D07B-C1F6-4B62-A412-41B9FD2D6538}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -125,18 +125,6 @@ Global {37E45CE1-A0F6-4ED7-9791-A1BED947602F}.Release|x64.Build.0 = Release|Any CPU {37E45CE1-A0F6-4ED7-9791-A1BED947602F}.Release|x86.ActiveCfg = Release|Any CPU {37E45CE1-A0F6-4ED7-9791-A1BED947602F}.Release|x86.Build.0 = Release|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Debug|x64.ActiveCfg = Debug|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Debug|x64.Build.0 = Debug|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Debug|x86.ActiveCfg = Debug|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Debug|x86.Build.0 = Debug|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Release|Any CPU.Build.0 = Release|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Release|x64.ActiveCfg = Release|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Release|x64.Build.0 = Release|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Release|x86.ActiveCfg = Release|Any CPU - {AC489889-6E50-4F16-9DBA-FF4C6F9EC72B}.Release|x86.Build.0 = Release|Any CPU {DE5AB980-A9AD-4273-8272-C4E1E062E3EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DE5AB980-A9AD-4273-8272-C4E1E062E3EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {DE5AB980-A9AD-4273-8272-C4E1E062E3EC}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -435,6 +423,18 @@ Global {401989E7-AE1E-4002-B0EE-9A9F63740B97}.Release|x64.Build.0 = Release|Any CPU {401989E7-AE1E-4002-B0EE-9A9F63740B97}.Release|x86.ActiveCfg = Release|Any CPU {401989E7-AE1E-4002-B0EE-9A9F63740B97}.Release|x86.Build.0 = Release|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Debug|x64.ActiveCfg = Debug|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Debug|x64.Build.0 = Debug|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Debug|x86.ActiveCfg = Debug|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Debug|x86.Build.0 = Debug|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Release|Any CPU.Build.0 = Release|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Release|x64.ActiveCfg = Release|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Release|x64.Build.0 = Release|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Release|x86.ActiveCfg = Release|Any CPU + {8491D07B-C1F6-4B62-A412-41B9FD2D6538}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj index bed17584c..7f291de85 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MachineDesigner.UI/Tango.MachineDesigner.UI.csproj @@ -167,7 +167,7 @@ <Name>Tango.Logging</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> </ItemGroup> diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj index 53adba9fb..8442cf3d6 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Tango.MachineEM.UI.csproj @@ -147,7 +147,7 @@ <Name>Tango.Protobuf</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.Stubs\Tango.Stubs.csproj"> diff --git a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/Tango.MobileEM.UI.csproj b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/Tango.MobileEM.UI.csproj index 5b16deb21..a1af9a2a1 100644 --- a/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/Tango.MobileEM.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.MobileEM.UI/Tango.MobileEM.UI.csproj @@ -164,7 +164,7 @@ <Name>Tango.Protobuf</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.Stubs\Tango.Stubs.csproj"> diff --git a/Software/Visual_Studio/Utilities/Tango.Protobuf.UI/Tango.Protobuf.UI.csproj b/Software/Visual_Studio/Utilities/Tango.Protobuf.UI/Tango.Protobuf.UI.csproj index b79e122b8..e767b2400 100644 --- a/Software/Visual_Studio/Utilities/Tango.Protobuf.UI/Tango.Protobuf.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.Protobuf.UI/Tango.Protobuf.UI.csproj @@ -141,7 +141,7 @@ <Name>Tango.Protobuf</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> </ItemGroup> diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/App.xaml b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/App.xaml index 38a7363d2..68bec1795 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/App.xaml +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/App.xaml @@ -11,11 +11,14 @@ <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> + <!-- Accent and AppTheme setting --> - <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Orange.xaml" /> + <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" /> - <ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/Generic.xaml" /> + + <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" /> + <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml" /> <!--View Models--> <ResourceDictionary> diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/MainWindow.xaml index 65897e3ad..4213af333 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/MainWindow.xaml @@ -8,6 +8,12 @@ xmlns:local="clr-namespace:Tango.Stubs.UI" mc:Ignorable="d" Title="Tango Stubs Execution Utility" Height="720" Width="1280" WindowState="Maximized" TitleCaps="False" BorderBrush="Gray" BorderThickness="1" WindowStartupLocation="CenterScreen" Background="#202020" Foreground="Gainsboro" DataContext="{Binding RelativeSource={RelativeSource Self}}"> + <mahapps:MetroWindow.IconTemplate> + <DataTemplate> + <Image Source="script.ico" Width="16" Height="16"></Image> + </DataTemplate> + </mahapps:MetroWindow.IconTemplate> + <Grid> <views:MainView DataContext="{StaticResource MainViewVM}"></views:MainView> </Grid> diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj index 3f34928b3..aabd6e5c4 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Tango.Stubs.UI.csproj @@ -7,7 +7,7 @@ <ProjectGuid>{FC0FB4A1-360E-42B1-8372-9208A3098B2A}</ProjectGuid> <OutputType>WinExe</OutputType> <RootNamespace>Tango.Stubs.UI</RootNamespace> - <AssemblyName>Stubs Execution GUI</AssemblyName> + <AssemblyName>StubsExecutionGUI</AssemblyName> <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> @@ -33,6 +33,9 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup> + <ApplicationIcon>script.ico</ApplicationIcon> + </PropertyGroup> <ItemGroup> <Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL"> <HintPath>..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath> @@ -74,6 +77,7 @@ <Compile Include="StubOnExecuteParameters.cs" /> <Compile Include="ViewModels\CodeTabVM.cs" /> <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="ViewModels\StubSnippetVM.cs" /> <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> @@ -143,7 +147,7 @@ <Name>Tango.Scripting</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.Stubs\Tango.Stubs.csproj"> @@ -155,6 +159,11 @@ <Name>Tango.Transport</Name> </ProjectReference> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <Resource Include="script.ico" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <PropertyGroup> + <PostBuildEvent>$(TargetDir)linkgen.exe -s "$(TargetPath)" -d "$(TargetDir)Utilities\Stubs Execution GUI.lnk"</PostBuildEvent> + </PropertyGroup> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/CodeTabVM.cs b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/CodeTabVM.cs index 5feb564ce..41120e185 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/CodeTabVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/CodeTabVM.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Core.Commands; using Tango.SharedUI; namespace Tango.Stubs.UI.ViewModels @@ -21,10 +23,39 @@ namespace Tango.Stubs.UI.ViewModels public String Title { - get { return _title; } - set { _title = value; RaisePropertyChanged(nameof(Title)); } + get + { + return File != null ? Path.GetFileName(File) : _title; + } + set + { + _title = value; + RaisePropertyChanged(nameof(Title)); + } } + private String _file; + + public String File + { + get { return _file; } + set + { + _file = value; + RaisePropertyChanged(nameof(File)); + RaisePropertyChanged(nameof(Title)); + } + } + + private RelayCommand _insertCodeSnippetCommand; + + public RelayCommand InsertSnippetCommand + { + get { return _insertCodeSnippetCommand; } + set { _insertCodeSnippetCommand = value; RaisePropertyChanged(nameof(InsertSnippetCommand)); } + } + + public CodeTabVM() { Title = "untitled"; diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs index bb0632e56..dcd487b3b 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/MainViewVM.cs @@ -1,12 +1,17 @@ -using System; +using Microsoft.Win32; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; +using System.Windows; using Tango.Core.Commands; using Tango.Scripting; using Tango.SharedUI; +using Tango.Stubs.UI.Views; using Tango.Transport.Adapters; namespace Tango.Stubs.UI.ViewModels @@ -18,6 +23,17 @@ namespace Tango.Stubs.UI.ViewModels public ObservableCollection<CodeTabVM> CodeTabs { get; set; } public ObservableCollection<KeyValuePair<String, Type>> HighlightTypes { get; set; } + public ObservableCollection<StubSnippetVM> StubSnippets { get; set; } + + private StubSnippetVM _selectedStubSnippet; + + public StubSnippetVM SelectedStubSnippet + { + get { return _selectedStubSnippet; } + set { _selectedStubSnippet = value; RaisePropertyChanged(nameof(SelectedStubSnippet)); } + } + + private String _log; public String Log @@ -75,6 +91,11 @@ namespace Tango.Stubs.UI.ViewModels public RelayCommand<CodeTabVM> CloseTabCommand { get; set; } public RelayCommand RunCommand { get; set; } public RelayCommand ToggleConnectionCommand { get; set; } + public RelayCommand OpenCommand { get; set; } + public RelayCommand SaveCommand { get; set; } + public RelayCommand SaveAsCommand { get; set; } + public RelayCommand StubSnippetSelectedCommand { get; set; } + public RelayCommand<String> InsertSnippetCommand { get; set; } public MainViewVM() { @@ -82,11 +103,26 @@ namespace Tango.Stubs.UI.ViewModels NewCommand = new RelayCommand(OnCreateNewTab); CloseTabCommand = new RelayCommand<CodeTabVM>(OnTabClosing); RunCommand = new RelayCommand(OnTabRun); + InsertSnippetCommand = new RelayCommand<string>((x) => { }); HighlightTypes = new ObservableCollection<KeyValuePair<string, Type>>(); HighlightTypes.Add(new KeyValuePair<string, Type>("stubManager", typeof(StubManager))); + StubSnippets = new ObservableCollection<StubSnippetVM>(); + + foreach (var stubType in StubBase.GetAvailableRequestStubs()) + { + StubSnippetVM snippet = new StubSnippetVM(); + snippet.Name = stubType.Name; + snippet.Code = String.Format("stubManager.Run(\"{0}\" ,{1});", stubType.Name, String.Join(", ", stubType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(x => x.PropertyType.Name.ToLower() == "string" ? "\"string\"" : x.PropertyType.Name.ToLower()))); + StubSnippets.Add(snippet); + } + ToggleConnectionCommand = new RelayCommand(ToggleConnection); + OpenCommand = new RelayCommand(OpenFile); + SaveCommand = new RelayCommand(SaveFile); + SaveAsCommand = new RelayCommand(SaveAsFile); + StubSnippetSelectedCommand = new RelayCommand(OnStubSnippetSelected); Ports = new List<string>() { @@ -103,21 +139,89 @@ namespace Tango.Stubs.UI.ViewModels SelectedPort = Ports.First(); - Status = "Read"; + Status = "Ready"; + + OnCreateNewTab(); + } + + private void OnStubSnippetSelected() + { + if (SelectedStubSnippet != null) + { + if (InsertSnippetCommand != null) + { + InsertSnippetCommand.Execute(SelectedStubSnippet.Code); + } + } + } + + private void SaveFile() + { + if (SelectedCodeTab != null) + { + if (SelectedCodeTab.File == null) + { + SaveAsFile(); + } + else + { + File.WriteAllText(SelectedCodeTab.File, SelectedCodeTab.Code); + } + } + } + + private void SaveAsFile() + { + if (SelectedCodeTab != null) + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + dlg.DefaultExt = ".cs"; + if (dlg.ShowDialog().Value) + { + File.WriteAllText(dlg.FileName, SelectedCodeTab.Code); + SelectedCodeTab.File = dlg.FileName; + } + } + } + + private void OpenFile() + { + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "C# Script Files|*.cs"; + dlg.Multiselect = true; + if (dlg.ShowDialog().Value) + { + foreach (var file in dlg.FileNames) + { + var newTab = new CodeTabVM(); + newTab.File = file; + newTab.Code = File.ReadAllText(file); + CodeTabs.Add(newTab); + SelectedCodeTab = newTab; + } + } } private void ToggleConnection() { - if (!IsConnected) + try { - _adapter = new UsbTransportAdapter(SelectedPort); - _adapter.Connect().Wait(); - IsConnected = true; + if (!IsConnected) + { + _adapter = new UsbTransportAdapter(SelectedPort); + _adapter.Connect().Wait(); + IsConnected = true; + } + else + { + _adapter.Disconnect().Wait(); + IsConnected = false; + } } - else + catch (Exception ex) { - _adapter.Disconnect().Wait(); - IsConnected = false; + MessageBox.Show(ex.ToString(), "Tango"); } } diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/StubSnippetVM.cs b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/StubSnippetVM.cs new file mode 100644 index 000000000..46c2f9495 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/ViewModels/StubSnippetVM.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.Stubs.UI.ViewModels +{ + public class StubSnippetVM : ViewModel + { + private String _name; + /// <summary> + /// Gets or sets the name. + /// </summary> + public String Name + { + get { return _name; } + set { _name = value; RaisePropertyChanged(nameof(Name)); } + } + + private String _code; + /// <summary> + /// Gets or sets the code. + /// </summary> + public String Code + { + get { return _code; } + set { _code = value; RaisePropertyChanged(nameof(Code)); } + } + + public override string ToString() + { + return Name; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml index 1657908db..9c7455d05 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml @@ -12,14 +12,20 @@ d:DesignHeight="720" d:DesignWidth="1280"> <UserControl.Resources> + <Style BasedOn="{StaticResource MetroTabItem}" TargetType="{x:Type TabItem}"> + <Style.Triggers> + <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=IsSelected}" Value="True"> + <Setter Property="Background" Value="#007ACC"></Setter> + </DataTrigger> + </Style.Triggers> <Setter Property="mahapps:ControlsHelper.HeaderFontSize" Value="12"></Setter> <Setter Property="HeaderTemplate"> <Setter.Value> <DataTemplate> <Border> <StackPanel Orientation="Horizontal"> - <TextBlock Text="{Binding}" VerticalAlignment="Center"></TextBlock> + <TextBlock Text="{Binding Title}" ToolTip="{Binding File}" Foreground="Gainsboro" VerticalAlignment="Center"></TextBlock> <Button Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.CloseTabCommand}" CommandParameter="{Binding}" Margin="5 0 0 0" Cursor="Hand" Width="24" Height="24" VerticalAlignment="Center" Style="{DynamicResource MetroCircleButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0"> <StackPanel Orientation="Horizontal"> <fa:ImageAwesome Width="10" Height="10" Icon="Close" Foreground="Gainsboro"></fa:ImageAwesome> @@ -34,7 +40,7 @@ <Setter.Value> <DataTemplate> <Grid Background="#181818"> - <controls:ScriptEditorControl Text="{Binding Code,Mode=TwoWay}" HighlightTypes="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.HighlightTypes}" RunCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RunCommand}" /> + <controls:ScriptEditorControl Text="{Binding Code,Mode=TwoWay}" InsertSnippetCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.InsertSnippetCommand,Mode=TwoWay}" SaveCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.SaveCommand}" HighlightTypes="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.HighlightTypes}" RunCommand="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RunCommand}" /> </Grid> </DataTemplate> </Setter.Value> @@ -48,9 +54,13 @@ </Grid.RowDefinitions> <Grid> - <Menu IsMainMenu="True"> + <Menu IsMainMenu="True" BorderThickness="0"> <MenuItem Header="File"> - <MenuItem Header="New" Command="{Binding NewCommand}"></MenuItem> + <MenuItem Header="New" Command="{Binding NewCommand}"> + <MenuItem.Icon> + <fa:ImageAwesome Icon="FileOutline" Width="16" Foreground="Gainsboro" Margin="2" /> + </MenuItem.Icon> + </MenuItem> <Separator/> <MenuItem Header="Open" MinWidth="150" Command="{Binding OpenCommand}"></MenuItem> <Separator/> @@ -83,12 +93,15 @@ </Grid.RowDefinitions> <Grid> - <TabControl Margin="5" ItemsSource="{Binding CodeTabs}" SelectedItem="{Binding SelectedCodeTab}"> + <TabControl x:Name="tabControl" Margin="5" ItemsSource="{Binding CodeTabs}" SelectedItem="{Binding SelectedCodeTab}"> </TabControl> </Grid> <Grid Grid.Column="1" Grid.RowSpan="3"> + <Grid VerticalAlignment="Bottom" Height="25" Background="#007ACC"> + + </Grid> <DockPanel Margin="5"> <StackPanel VerticalAlignment="Top" DockPanel.Dock="Top"> <TextBlock>Connection</TextBlock> @@ -96,7 +109,7 @@ </StackPanel> <StackPanel DockPanel.Dock="Bottom" VerticalAlignment="Bottom"> - <Button Margin="0 0 0 22" Height="50" MinWidth="100" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding ToggleConnectionCommand}"> + <Button Margin="0 0 0 25" Height="50" MinWidth="100" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding ToggleConnectionCommand}"> <Button.Style> <Style TargetType="Button" BasedOn="{StaticResource AccentedSquareButtonStyle}"> <Style.Triggers> @@ -125,6 +138,31 @@ </Button.Style> </Button> </StackPanel> + + <Grid> + <ListBox BorderThickness="0" ItemsSource="{Binding StubSnippets}" HorizontalContentAlignment="Stretch" SelectedItem="{Binding SelectedStubSnippet}"> + <ListBox.ItemContainerStyle> + <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}"> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="Margin" Value="0 2 0 2"></Setter> + <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> + </Style> + </ListBox.ItemContainerStyle> + <ListBox.ItemTemplate> + <DataTemplate> + <Border BorderThickness="1" BorderBrush="#007ACC" Padding="8" Background="Transparent"> + <Border.InputBindings> + <MouseBinding Gesture="LeftDoubleClick" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.StubSnippetSelectedCommand}"/> + </Border.InputBindings> + <Grid> + <fa:ImageAwesome Icon="ArrowLeft" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5 0 0 0" Foreground="#007ACC" Width="16" Height="16"></fa:ImageAwesome> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Name}"></TextBlock> + </Grid> + </Border> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + </Grid> </DockPanel> </Grid> @@ -132,7 +170,7 @@ <GridSplitter.Background> <LinearGradientBrush> <GradientStop/> - <GradientStop Color="#FF848484" Offset="0.5"/> + <GradientStop Color="#007ACC" Offset="0.5"/> <GradientStop Offset="1"/> </LinearGradientBrush> </GridSplitter.Background> @@ -150,7 +188,7 @@ <RowDefinition Height="25"/> </Grid.RowDefinitions> <TextBox x:Name="txtLog" TextChanged="TextBox_TextChanged" Background="Transparent" Text="{Binding Log}" BorderThickness="0" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" Padding="5" IsReadOnly="True" TextWrapping="Wrap" FontSize="11" Foreground="Gainsboro"></TextBox> - <StatusBar Grid.Row="1" Background="#CD5805"> + <StatusBar Grid.Row="1" Background="#007ACC"> <TextBlock Text="{Binding Status}"></TextBlock> </StatusBar> </Grid> diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml.cs index c0919217f..eb3c646dd 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Views/MainView.xaml.cs @@ -13,6 +13,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.SharedUI.Controls; +using Tango.Stubs.UI.ViewModels; namespace Tango.Stubs.UI.Views { @@ -21,16 +23,16 @@ namespace Tango.Stubs.UI.Views /// </summary> public partial class MainView : UserControl { - public MainView() + public MainView() : base() { - InitializeComponent(); + InitializeComponent(); } private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { Task.Factory.StartNew(() => { - Thread.Sleep(100); + Thread.Sleep(50); this.Dispatcher.Invoke(() => { diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/script.ico b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/script.ico Binary files differnew file mode 100644 index 000000000..b31bb3399 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/script.ico diff --git a/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/Tango.Synchronization.UI.csproj b/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/Tango.Synchronization.UI.csproj index c0585bacd..ffb760c3e 100644 --- a/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/Tango.Synchronization.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.Synchronization.UI/Tango.Synchronization.UI.csproj @@ -131,7 +131,7 @@ <Name>Tango.Logging</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.Synchronization\Tango.Synchronization.csproj"> diff --git a/Software/Visual_Studio/Utilities/Tango.TransportRouter.UI/Tango.TransportRouter.UI.csproj b/Software/Visual_Studio/Utilities/Tango.TransportRouter.UI/Tango.TransportRouter.UI.csproj index 6e269dab1..0c039d0f9 100644 --- a/Software/Visual_Studio/Utilities/Tango.TransportRouter.UI/Tango.TransportRouter.UI.csproj +++ b/Software/Visual_Studio/Utilities/Tango.TransportRouter.UI/Tango.TransportRouter.UI.csproj @@ -128,7 +128,7 @@ <Name>Tango.Logging</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.SharedUI\Tango.SharedUI.csproj"> - <Project>{ac489889-6e50-4f16-9dba-ff4c6f9ec72b}</Project> + <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> <ProjectReference Include="..\..\Tango.Transport\Tango.Transport.csproj"> |
