From cc3480d4aac4175b1072060dd2d6d398d3451ae8 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 30 Dec 2018 01:27:53 +0200 Subject: Working on dispenserssssssss --- .../Contracts/IMainView.cs | 21 + .../Tango.MachineStudio.MachineDesigner.csproj | 26 +- .../ViewModels/MainViewVM.cs | 839 +++++++++------------ .../Views/ConfigurationView.xaml | 718 ++++++++++++++++++ .../Views/ConfigurationView.xaml.cs | 172 +++++ .../Views/MachineDetailsView.xaml | 44 ++ .../Views/MachineDetailsView.xaml.cs | 28 + .../Views/MachineView.xaml | 2 +- .../Views/MachinesView.xaml | 73 ++ .../Views/MachinesView.xaml.cs | 28 + .../Views/MainView.xaml | 811 +------------------- .../Views/MainView.xaml.cs | 148 +--- 12 files changed, 1475 insertions(+), 1435 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs new file mode 100644 index 000000000..392b557c4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Contracts/IMainView.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.MachineDesigner.Contracts +{ + public enum MachineDesignerNavigationView + { + MachinesView, + MachineDetailsView, + ConfigurationView, + } + + public interface IMainView : IView + { + void NavigateTo(MachineDesignerNavigationView view); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index 3fa7c60cf..8ced2e510 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -76,19 +76,37 @@ GlobalVersionInfo.cs + + + MachineDetailsView.xaml + + + MachinesView.xaml + MachineVersionDialog.xaml MachineView.xaml + + ConfigurationView.xaml + + MainView.xaml - + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -97,6 +115,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -232,7 +254,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index 5a5df0d0f..e2924a185 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -18,45 +18,38 @@ using Tango.MachineStudio.Common; using Tango.BL; using Tango.AutoComplete.Editors; using System.Data.Entity; +using Tango.BL.Builders; +using Tango.MachineStudio.MachineDesigner.Contracts; namespace Tango.MachineStudio.MachineDesigner.ViewModels { - public class MainViewVM : StudioViewModel + public class MainViewVM : StudioViewModel { private INotificationProvider _notification; - private ObservablesContext _db; - private Configuration _original_configuration; + private ObservablesContext _dbContext; + private ObservablesContext _machineContext; + private ObservablesContext _configContext; #region Properties - private ObservablesStaticCollections _adapter; + private ObservableCollection _machines; /// - /// Gets or sets the db static adapter. + /// Gets or sets the machines. /// - public ObservablesStaticCollections Adapter + public ObservableCollection Machines { - get { return _adapter; } - set { _adapter = value; RaisePropertyChangedAuto(); } + get { return _machines; } + set { _machines = value; RaisePropertyChangedAuto(); } } - private bool _canWork; + private ObservableCollection _dispensers; /// - /// Gets or sets a value indicating whether this instance can work. + /// Gets or sets the dispensers. /// - public bool CanWork + public ObservableCollection Dispensers { - get { return _canWork; } - set { _canWork = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } - } - - private Machine _machine; - /// - /// Gets or sets the current editable machine. - /// - public Machine Machine - { - get { return _machine; } - set { _machine = value; RaisePropertyChangedAuto(); } + get { return _dispensers; } + set { _dispensers = value; RaisePropertyChangedAuto(); } } private Machine _selectedMachine; @@ -70,11 +63,24 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (_selectedMachine != value) { - _selectedMachine = value; RaisePropertyChangedAuto(); OnSelectedMachineChanged(); + _selectedMachine = value; + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); } } } + private Machine _activeMachine; + /// + /// Gets or sets the active machine. + /// + public Machine ActiveMachine + { + get { return _activeMachine; } + set { _activeMachine = value; RaisePropertyChangedAuto(); } + } + + private Configuration _configuration; /// /// Gets or sets the editable machine configuration. @@ -95,29 +101,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _selectedIds = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } - private ObservableCollection _history; + private String _dispensersFilter; /// - /// Gets or sets the machine configuration history. + /// Gets or sets the dispensers filter. /// - public ObservableCollection History + public String DispensersFilter { - get { return _history; } - set { _history = value; RaisePropertyChangedAuto(); } - } - - private Configuration _selectedHistoryConfiguration; - /// - /// Gets or sets the machine selected configuration from history. - /// - public Configuration SelectedHistoryConfiguration - { - get { return _selectedHistoryConfiguration; } - set { _selectedHistoryConfiguration = value; RaisePropertyChangedAuto(); OnHistoryConfigurationSelected(); } + get { return _dispensersFilter; } + set { _dispensersFilter = value; RaisePropertyChangedAuto(); OnDispensersFilterChanged(); } } private String _filter; /// - /// Gets or sets the configuration components filter. + /// Gets or sets the machines filter. /// public String Filter { @@ -125,11 +121,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } } - /// - /// Gets or sets the machines provider. - /// - public ISuggestionProvider MachinesProvider { get; set; } - #endregion #region Commands @@ -150,19 +141,19 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public RelayCommand RemoveIdsCommand { get; set; } /// - /// Gets or sets the set version configuration command. + /// Gets or sets the remove machine command. /// - public RelayCommand SetVersionConfigurationCommand { get; set; } + public RelayCommand RemoveMachineCommand { get; set; } /// - /// Gets or sets the set as default command. + /// Gets or sets the add machine command. /// - public RelayCommand SetAsDefaultCommand { get; set; } + public RelayCommand AddMachineCommand { get; set; } /// - /// Gets or sets the reset command. + /// Gets or sets the edit machine command. /// - public RelayCommand ResetCommand { get; set; } + public RelayCommand EditMachineCommand { get; set; } #endregion @@ -178,195 +169,95 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// public MainViewVM(INotificationProvider notification) { - CanWork = true; - + _dbContext = ObservablesContext.CreateDefault(); _notification = notification; - Configuration = new Configuration(); - Configuration.Name = "Untitled"; - Machine = new Machine(); - Machine.Configuration = Configuration; - - SaveCommand = new RelayCommand(Save, (x) => CanWork); - AddIdsCommand = new RelayCommand(AddIds, (x) => CanWork && Configuration.IdsPacks.Count < 8); - RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => CanWork && SelectedIds != null); - SetVersionConfigurationCommand = new RelayCommand(SetVersionConfiguration, (x) => CanWork); - SetAsDefaultCommand = new RelayCommand(SetAsDefaultConfiguration, (x) => CanWork); - ResetCommand = new RelayCommand(Reset, () => CanWork); + //SaveCommand = new RelayCommand(Save); + AddIdsCommand = new RelayCommand(AddIds, (x) => Configuration != null && Configuration.IdsPacks.Count < 8); + RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => SelectedIds != null); + EditMachineCommand = new RelayCommand(EditSelectedMachine, () => SelectedMachine != null); + } - MachinesProvider = new SuggestionProvider((filter) => + private async void EditSelectedMachine() + { + using (_notification.PushTaskItem("Loading machine details...")) { - try - { - return _db.Machines.Where(x => x.SerialNumber.StartsWith(filter)).ToList(); - } - catch + IsFree = false; + + if (_machineContext != null) { - return new List(); + _machineContext.Dispose(); } - }); + + _machineContext = ObservablesContext.CreateDefault(); + ActiveMachine = (await new MachineBuilder(_machineContext).Set(SelectedMachine).WithOrganization().WithConfiguration().BuildAsync()); + View.NavigateTo(MachineDesignerNavigationView.MachineDetailsView); + + IsFree = true; + } } #endregion #region Application Ready - public async override void OnApplicationReady() + public override void OnApplicationReady() { - await InitCollections(); + } #endregion - private Task InitCollections() - { - return Task.Factory.StartNew(() => - { - CanWork = false; - - _db = ObservablesContext.CreateDefault(); - - Adapter = new ObservablesStaticCollections(); - Adapter.ApplicationDisplayPanelVersions = _db.ApplicationDisplayPanelVersions.ToObservableCollection(); - Adapter.ApplicationFirmwareVersions = _db.ApplicationFirmwareVersions.ToObservableCollection(); - Adapter.ApplicationOsVersions = _db.ApplicationOsVersions.ToObservableCollection(); - Adapter.EmbeddedFirmwareVersions = _db.EmbeddedFirmwareVersions.ToObservableCollection(); - Adapter.DispenserTypes = _db.DispenserTypes.ToObservableCollection(); - Adapter.LiquidTypes = _db.LiquidTypes.ToObservableCollection(); - Adapter.MidTankTypes = _db.MidTankTypes.ToObservableCollection(); - Adapter.CartridgeTypes = _db.CartridgeTypes.ToObservableCollection(); - Adapter.IdsPackFormulas = _db.IdsPackFormulas.ToObservableCollection(); - Adapter.HardwareVersions = _db.HardwareVersions.ToObservableCollection(); - Adapter.MachineVersions = _db.MachineVersions.ToObservableCollection(); - Adapter.Organizations = _db.Organizations.ToObservableCollection(); - - Adapter.InitCollectionSources(); - - CanWork = true; - }); - } + //private Task InitCollections() + //{ + // return Task.Factory.StartNew(() => + // { + // CanWork = false; + + // _dbContext = ObservablesContext.CreateDefault(); + + // Adapter = new ObservablesStaticCollections(); + // Adapter.ApplicationDisplayPanelVersions = _dbContext.ApplicationDisplayPanelVersions.ToObservableCollection(); + // Adapter.ApplicationFirmwareVersions = _dbContext.ApplicationFirmwareVersions.ToObservableCollection(); + // Adapter.ApplicationOsVersions = _dbContext.ApplicationOsVersions.ToObservableCollection(); + // Adapter.EmbeddedFirmwareVersions = _dbContext.EmbeddedFirmwareVersions.ToObservableCollection(); + // Adapter.DispenserTypes = _dbContext.DispenserTypes.ToObservableCollection(); + // Adapter.LiquidTypes = _dbContext.LiquidTypes.ToObservableCollection(); + // Adapter.MidTankTypes = _dbContext.MidTankTypes.ToObservableCollection(); + // Adapter.CartridgeTypes = _dbContext.CartridgeTypes.ToObservableCollection(); + // Adapter.IdsPackFormulas = _dbContext.IdsPackFormulas.ToObservableCollection(); + // Adapter.HardwareVersions = _dbContext.HardwareVersions.ToObservableCollection(); + // Adapter.MachineVersions = _dbContext.MachineVersions.ToObservableCollection(); + // Adapter.Organizations = _dbContext.Organizations.ToObservableCollection(); + + // Adapter.InitCollectionSources(); + + // CanWork = true; + // }); + //} private void Reset() { - using (_notification.PushTaskItem("Resetting designer...")) - { - SelectedMachine = null; - Machine = new Machine(); - Configuration = new Configuration(); - History = new ObservableCollection(); - SelectedHistoryConfiguration = null; - Filter = String.Empty; - InitCollections(); - } + //using (_notification.PushTaskItem("Resetting designer...")) + //{ + // SelectedMachine = null; + // Machine = new Machine(); + // Configuration = new Configuration(); + // InitCollections(); + //} } - #region Virtual Methods - - /// - /// Called when the selected machine has changed. - /// - protected virtual void OnSelectedMachineChanged() + private async void OnDispensersFilterChanged() { - if (SelectedMachine != null) + if (!String.IsNullOrWhiteSpace(DispensersFilter)) { - CanWork = false; - - using (_notification.PushTaskItem("Loading machine configuration...")) - { - Task.Factory.StartNew(() => - { - InitCollections().Wait(); - Machine = _db.Machines.Where(x => x.Guid == SelectedMachine.Guid).Include(x => x.Organization).SingleOrDefault(x => x.Guid == SelectedMachine.Guid); - Configuration = _db.Adapter.GetConfiguration(x => x.Guid == Machine.ConfigurationGuid); - - SetHistory(); - - _original_configuration = Configuration.Clone(); - }); - } - - CanWork = true; - } - else - { - History = new ObservableCollection(); - } - } - - /// - /// Called when the history configuration has been selected - /// - protected virtual void OnHistoryConfigurationSelected() - { - if (SelectedHistoryConfiguration != null && CanWork) - { - using (_notification.PushTaskItem("Loading Configuration...")) - { - Task.Factory.StartNew(() => - { - CanWork = false; - - SelectedHistoryConfiguration = _db.Adapter.GetConfiguration(x => x.Guid == SelectedHistoryConfiguration.Guid); - Configuration = SelectedHistoryConfiguration; - Machine.Configuration = Configuration; - - CanWork = true; - }); - } + IsFree = false; + Dispensers = (await _configContext.Dispensers.Where(x => x.SerialNumber.ToLower().StartsWith(DispensersFilter.ToLower())).ToListAsync()).ToObservableCollection(); + IsFree = true; } } - /// - /// Called when the filter has changed - /// - protected virtual void OnFilterChanged() - { - List collections = new List(); - collections.Add(Adapter.ApplicationFirmwareVersionsViewSource); - collections.Add(Adapter.ApplicationDisplayPanelVersionsViewSource); - collections.Add(Adapter.ApplicationOsVersionsViewSource); - collections.Add(Adapter.EmbeddedFirmwareVersionsViewSource); - collections.Add(Adapter.DispenserTypesViewSource); - collections.Add(Adapter.CartridgeTypesViewSource); - collections.Add(Adapter.LiquidTypesViewSource); - collections.Add(Adapter.MidTankTypesViewSource); - collections.Add(Adapter.HardwareVersionsViewSource); - - foreach (var collection in collections) - { - collection.Filter = (x) => - { - foreach (var prop in x.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(y => y.PropertyType == typeof(String))) - { - String value = prop.GetValue(x).ToStringSafe(); - - if (value != null && Filter != null) - { - if (value.ToLower().Contains(Filter.ToLower())) - { - return true; - } - } - } - - return false; - }; - } - } - - #endregion - - #region Public Methods - - /// - /// Sets the selected machine without any further processing. - /// - /// The machine. - public void SetSelectedMachine(Machine machine) - { - _machine = machine; - RaisePropertyChanged(nameof(Machine)); - } + #region Virtual Methods #endregion @@ -433,25 +324,25 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } /// - /// Drops the type of the cartridge. + /// Drops the dispenser. /// - /// Type of the cartridge. + /// The dispenser. /// The ids pack. - public void DropCartridgeType(CartridgeType cartridgeType, IdsPack idsPack) + public void DropDispenser(Dispenser dispenser, IdsPack idsPack) { - idsPack.CartridgeType = cartridgeType; - idsPack.CartridgeTypeGuid = cartridgeType.Guid; + idsPack.Dispenser = dispenser; + idsPack.DispenserGuid = dispenser.Guid; } /// - /// Drops the dispenser. + /// Drops the type of the cartridge. /// - /// The dispenser. + /// Type of the cartridge. /// The ids pack. - public void DropDispenserType(DispenserType dispenserType, IdsPack idsPack) + public void DropCartridgeType(CartridgeType cartridgeType, IdsPack idsPack) { - idsPack.DispenserType = dispenserType; - idsPack.DispenserTypeGuid = dispenserType.Guid; + idsPack.CartridgeType = cartridgeType; + idsPack.CartridgeTypeGuid = cartridgeType.Guid; } /// @@ -497,7 +388,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// private void RemoveIds() { - _db.IdsPacks.Remove(SelectedIds); + _dbContext.IdsPacks.Remove(SelectedIds); SelectedIds = null; } @@ -506,277 +397,251 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels /// private void AddIds() { - _db.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); + _dbContext.IdsPacks.Add(new IdsPack() { Configuration = Configuration }); InvalidateRelayCommands(); } - /// - /// Saves the current machine configuration. - /// - private async void Save() - { - foreach (var ids in Configuration.IdsPacks) - { - ids.PackIndex = Configuration.IdsPacks.IndexOf(ids); - ids.Configuration = Configuration; - ids.ConfigurationGuid = Configuration.Guid; - } - - //Validate - - List errors = new List(); - - if (Machine.MachineVersion == null) - { - errors.Add("Machine version is required."); - } - - if (Machine.Name.IsNullOrWhiteSpace()) - { - errors.Add("Machine name is required."); - } - - if (Machine.Organization == null) - { - errors.Add("Machine organization is required."); - } - - if (Machine.SerialNumber.IsNullOrWhiteSpace()) - { - errors.Add("Machine serial number is required."); - } - - if (Configuration.Name.IsNullOrWhiteSpace()) - { - errors.Add("Configuration name is required."); - } - - if (Configuration.ApplicationDisplayPanelVersion == null) - { - errors.Add("Touch Panel is required."); - } - - if (Configuration.ApplicationFirmwareVersion == null) - { - errors.Add("Application firmware is required."); - } - - if (Configuration.ApplicationOsVersion == null) - { - errors.Add("Application operation system is required."); - } - - if (Configuration.EmbeddedFirmwareVersion == null) - { - errors.Add("Embedded firmware is required."); - } - - if (Configuration.HardwareVersion == null) - { - errors.Add("Hardware version is required."); - } - - foreach (var pack in Configuration.IdsPacks) - { - if (pack.LiquidType != null || pack.CartridgeType != null || pack.DispenserType != null || pack.IdsPackFormula != null || pack.MidTankType != null) - { - if (pack.Name.IsNullOrWhiteSpace()) - { - errors.Add(String.Format("Name is required on IDS pack number '{0}'.", Configuration.IdsPacks.IndexOf(pack) + 1)); - continue; - } - if (pack.CartridgeType == null) - { - errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.DispenserType == null) - { - errors.Add(String.Format("Dispenser type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.LiquidType == null) - { - errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.MidTankType == null) - { - errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.Name)); - } - if (pack.IdsPackFormula == null) - { - errors.Add(String.Format("Formula type is required on IDS pack '{0}'.", pack.Name)); - } - - pack.IsEmpty = false; - } - else - { - pack.IsEmpty = true; - pack.Name = String.Empty; - } - } - - if (errors.Count > 0) - { - String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; - errorsString += String.Join(Environment.NewLine, errors); - _notification.ShowError(errorsString); - return; - } + ///// + ///// Saves the current machine configuration. + ///// + //private async void Save() + //{ + // foreach (var ids in Configuration.IdsPacks) + // { + // ids.PackIndex = Configuration.IdsPacks.IndexOf(ids); + // ids.Configuration = Configuration; + // ids.ConfigurationGuid = Configuration.Guid; + // } + + // //Validate + + // List errors = new List(); + + // if (Machine.MachineVersion == null) + // { + // errors.Add("Machine version is required."); + // } + + // if (Machine.Name.IsNullOrWhiteSpace()) + // { + // errors.Add("Machine name is required."); + // } + + // if (Machine.Organization == null) + // { + // errors.Add("Machine organization is required."); + // } + + // if (Machine.SerialNumber.IsNullOrWhiteSpace()) + // { + // errors.Add("Machine serial number is required."); + // } + + // if (Configuration.Name.IsNullOrWhiteSpace()) + // { + // errors.Add("Configuration name is required."); + // } + + // if (Configuration.ApplicationDisplayPanelVersion == null) + // { + // errors.Add("Touch Panel is required."); + // } + + // if (Configuration.ApplicationFirmwareVersion == null) + // { + // errors.Add("Application firmware is required."); + // } + + // if (Configuration.ApplicationOsVersion == null) + // { + // errors.Add("Application operation system is required."); + // } + + // if (Configuration.EmbeddedFirmwareVersion == null) + // { + // errors.Add("Embedded firmware is required."); + // } + + // if (Configuration.HardwareVersion == null) + // { + // errors.Add("Hardware version is required."); + // } + + // foreach (var pack in Configuration.IdsPacks) + // { + // if (pack.LiquidType != null || pack.CartridgeType != null || pack.Dispenser != null || pack.IdsPackFormula != null || pack.MidTankType != null) + // { + // if (pack.CartridgeType == null) + // { + // errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.Dispenser == null) + // { + // errors.Add(String.Format("Dispenser is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.LiquidType == null) + // { + // errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.MidTankType == null) + // { + // errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + // if (pack.IdsPackFormula == null) + // { + // errors.Add(String.Format("Formula type is required on IDS pack '{0}'.", pack.PackIndex)); + // } + + // pack.IsEmpty = false; + // } + // else + // { + // pack.IsEmpty = true; + // } + // } + + // if (errors.Count > 0) + // { + // String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; + // errorsString += String.Join(Environment.NewLine, errors); + // _notification.ShowError(errorsString); + // return; + // } + + // //Validate + + // try + // { + // CanWork = false; + + // using (_notification.PushTaskItem("Saving Machine Configuration...")) + // { + // if (!_dbContext.Machines.Any(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower())) + // { + // if (!_notification.ShowQuestion("The specified machine serial number does not exist. Do you wish to create a new machine?")) + // { + // CanWork = true; + // return; + // } + // else + // { + // Machine.Configuration = Configuration; + // Configuration.CreationDate = DateTime.UtcNow; + // Machine.ProductionDate = DateTime.UtcNow; + + // _dbContext.Machines.Add(Machine); + // } + // } + + // await _dbContext.SaveChangesAsync(); + // OnSelectedMachineChanged(); + + // } + // } + // catch (Exception ex) + // { + // _notification.ShowError("An error occurred while trying to save the configuration" + Environment.NewLine + ex.Message); + // } + // finally + // { + // CanWork = true; + // InvalidateRelayCommands(); + // } + //} + + ///// + ///// Sets the current configuration to the selected machine version default configuration. + ///// + //private async void SetVersionConfiguration() + //{ + // if (Machine.MachineVersion != null) + // { + // using (_notification.PushTaskItem("Applying default configuration...")) + // { + // CanWork = false; + + // await Task.Factory.StartNew(() => + // { + // var version = _dbContext.MachineVersions.Where(x => x.Guid == Machine.MachineVersion.Guid).Include(x => x.DefaultConfiguration).FirstOrDefault(); + // var version_config = _dbContext.Adapter.GetConfiguration(x => x.Guid == version.DefaultConfiguration.Guid); + // Configuration = version_config.Clone(); + // Machine.Configuration = Configuration; + // }); + + // CanWork = true; + // } + // } + // else + // { + // _notification.ShowError("No machine version selected."); + // } + //} + + ///// + ///// Sets the current configuration as a default machine version configuration. + ///// + //private void SetAsDefaultConfiguration() + //{ + // _notification.ShowModalDialog(async (vm) => + // { + // CanWork = false; + + // try + // { + // using (_notification.PushTaskItem("Saving Default Configuration...")) + // { + // if (vm.SelectedVersion != null) + // { + // var version = _dbContext.MachineVersions.Where(x => x.Guid == vm.SelectedVersion.Guid).Include(x => x.DefaultConfiguration).SingleOrDefault(x => x.Guid == vm.SelectedVersion.Guid); + + // _dbContext.Configurations.Remove(version.DefaultConfiguration); + + // var cloned = Configuration.Clone(); + // _dbContext.Configurations.Add(cloned); + // version.DefaultConfiguration = cloned; + + // await _dbContext.SaveChangesAsync(); + // } + // else + // { + // MachineVersion newVersion = new MachineVersion(); + // newVersion.Version = vm.Version; + // newVersion.Name = vm.VersionName; + + // var cloned = Configuration.Clone(); + + // _dbContext.Configurations.Add(cloned); + // newVersion.DefaultConfiguration = cloned; + // _dbContext.MachineVersions.Add(newVersion); + // await _dbContext.SaveChangesAsync(); + // } + // } + // } + // catch (Exception ex) + // { + // _notification.ShowError(ex.Message); + // } + // finally + // { + // CanWork = true; + // } + + // }, () => + // { + + // }); + //} - //Validate - - try - { - CanWork = false; - - using (_notification.PushTaskItem("Saving Machine Configuration...")) - { - if (!_db.Machines.Any(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower())) - { - if (!_notification.ShowQuestion("The specified machine serial number does not exist. Do you wish to create a new machine?")) - { - CanWork = true; - return; - } - else - { - Machine.Configuration = Configuration; - Configuration.CreationDate = DateTime.UtcNow; - Machine.ProductionDate = DateTime.UtcNow; - - _db.Machines.Add(Machine); - _db.MachinesConfigurations.Add(new MachinesConfiguration() - { - Configuration = Configuration, - Machine = Machine, - }); - } - } - else - { - bool add_history = History.Count == 0 || _original_configuration.Name != Configuration.Name; - - if (add_history) - { - _db.Configurations.Add(_original_configuration); - - _db.MachinesConfigurations.Add(new MachinesConfiguration() - { - Configuration = _original_configuration, - Machine = Machine - }); - } - } - - await _db.SaveChangesAsync(); - OnSelectedMachineChanged(); - - } - } - catch (Exception ex) - { - _notification.ShowError("An error occurred while trying to save the configuration" + Environment.NewLine + ex.Message); - } - finally - { - CanWork = true; - InvalidateRelayCommands(); - } - } - - /// - /// Sets the specified machine history. - /// - /// The machine. - private void SetHistory() - { - History = _db.MachinesConfigurations.Where(x => x.MachineGuid == Machine.Guid).Select(x => x.Configuration).ToObservableCollection(); - //History.Insert(0, Machine.Configuration); - } + #endregion - /// - /// Sets the current configuration to the selected machine version default configuration. - /// - private async void SetVersionConfiguration() + private async void OnFilterChanged() { - if (Machine.MachineVersion != null) - { - using (_notification.PushTaskItem("Applying default configuration...")) - { - CanWork = false; - - await Task.Factory.StartNew(() => - { - var version = _db.MachineVersions.Where(x => x.Guid == Machine.MachineVersion.Guid).Include(x => x.DefaultConfiguration).FirstOrDefault(); - var version_config = _db.Adapter.GetConfiguration(x => x.Guid == version.DefaultConfiguration.Guid); - Configuration = version_config.Clone(); - Machine.Configuration = Configuration; - }); - - CanWork = true; - } - } - else + if (!String.IsNullOrWhiteSpace(Filter)) { - _notification.ShowError("No machine version selected."); + IsFree = false; + Machines = (await _dbContext.Machines.Where(x => x.SerialNumber.StartsWith(Filter)).ToListAsync()).ToObservableCollection(); + IsFree = true; } } - - /// - /// Sets the current configuration as a default machine version configuration. - /// - private void SetAsDefaultConfiguration() - { - _notification.ShowModalDialog(async (vm) => - { - CanWork = false; - - try - { - using (_notification.PushTaskItem("Saving Default Configuration...")) - { - if (vm.SelectedVersion != null) - { - var version = _db.MachineVersions.Where(x => x.Guid == vm.SelectedVersion.Guid).Include(x => x.DefaultConfiguration).SingleOrDefault(x => x.Guid == vm.SelectedVersion.Guid); - - _db.Configurations.Remove(version.DefaultConfiguration); - - var cloned = Configuration.Clone(); - _db.Configurations.Add(cloned); - version.DefaultConfiguration = cloned; - - await _db.SaveChangesAsync(); - } - else - { - MachineVersion newVersion = new MachineVersion(); - newVersion.Version = vm.Version; - newVersion.Name = vm.VersionName; - - var cloned = Configuration.Clone(); - - _db.Configurations.Add(cloned); - newVersion.DefaultConfiguration = cloned; - _db.MachineVersions.Add(newVersion); - await _db.SaveChangesAsync(); - } - } - } - catch (Exception ex) - { - _notification.ShowError(ex.Message); - } - finally - { - CanWork = true; - } - - }, () => - { - - }); - } - - #endregion } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml new file mode 100644 index 000000000..a96cd4685 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml @@ -0,0 +1,718 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hardware Version + + + + + + Add IDS + + + + + + Remove IDS + + + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NO IDS PACKS + + + + + + + + + + + + + + + + + + + + + Touch Panel + + + + + + Embedded Firmware + + + + + + Dispensers + + + + + + Mid Tanks + + + + + + Cartridges + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IDS PACKS + + + + + + + PACK: # + + + + + Dispenser: + + + + Mid Tank: + + + + Cartridge: + + + + Liquid: + + + + Formula: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + v + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs new file mode 100644 index 000000000..941a2792d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/ConfigurationView.xaml.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +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.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.BL.Entities; +using Tango.DragAndDrop; +using Tango.MachineStudio.MachineDesigner.ViewModels; + +namespace Tango.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class ConfigurationView : UserControl + { + private MainViewVM _vm; + private Rectangle _highlightRect; + private bool _highlightShown; + private DoubleAnimation _highlightAnimation; + + public ColumnDefinition PanelColumnDefinition { get; set; } + + public ConfigurationView() + { + InitializeComponent(); + + PanelColumnDefinition = panelColumnDefinition; + + DraggingSurface = dragSufrace; + this.Loaded += (x, y) => + { + _vm = DataContext as MainViewVM; + }; + + DragAndDropService.DragStarted += DragAndDropService_DragStarted; + DragAndDropService.DragEnded += DragAndDropService_DragEnded; + + _highlightRect = new Rectangle(); + _highlightRect.IsHitTestVisible = false; + _highlightRect.Stroke = Application.Current.Resources["AccentColorBrush"] as Brush; + _highlightRect.StrokeThickness = 2; + _highlightRect.StrokeDashArray = new DoubleCollection(new double[] { 3, 3, 3, 3 }); + } + + private void DragAndDropService_DragEnded(object sender, FrameworkElement e) + { + canvas.Children.Remove(_highlightRect); + _highlightShown = false; + _highlightRect.BeginAnimation(Rectangle.OpacityProperty, null); + } + + private void DragAndDropService_DragStarted(object sender, FrameworkElement e) + { + if (e.DataContext is HardwareVersion) + { + SetHighlightRegion(hardwareGrid); + } + else if (e.DataContext is ApplicationOsVersion || e.DataContext is ApplicationDisplayPanelVersion || e.DataContext is ApplicationFirmwareVersion) + { + SetHighlightRegion(gridTablet); + } + else if (e.DataContext is EmbeddedFirmwareVersion) + { + SetHighlightRegion(gridEmbedded); + } + else if (e.DataContext is DispenserType || e.DataContext is CartridgeType || e.DataContext is LiquidType || e.DataContext is MidTankType || e.DataContext is IdsPackFormula) + { + SetHighlightRegion(gridIds); + } + } + + public DraggingSurface DraggingSurface + { + get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } + set { SetValue(DraggingSurfaceProperty, value); } + } + public static readonly DependencyProperty DraggingSurfaceProperty = + DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); + + private void OnDropOnIdsPack(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is Dispenser) + { + _vm.DropDispenser(e.Draggable.DataContext as Dispenser, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is LiquidType) + { + _vm.DropLiquidType(e.Draggable.DataContext as LiquidType, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is CartridgeType) + { + _vm.DropCartridgeType(e.Draggable.DataContext as CartridgeType, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is MidTankType) + { + _vm.DropMidTankType(e.Draggable.DataContext as MidTankType, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is IdsPackFormula) + { + _vm.DropIdsFormula(e.Draggable.DataContext as IdsPackFormula, e.Droppable.DataContext as IdsPack); + } + else if (e.Draggable.DataContext is IdsPack) + { + _vm.DropIdsPack(e.Draggable.DataContext as IdsPack, e.Droppable.DataContext as IdsPack); + } + } + + private void OnTabletDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is ApplicationDisplayPanelVersion) + { + _vm.DropTouchPanel(e.Draggable.DataContext as ApplicationDisplayPanelVersion); + } + else if (e.Draggable.DataContext is ApplicationOsVersion) + { + _vm.DropApplicationOsVersion(e.Draggable.DataContext as ApplicationOsVersion); + } + else if (e.Draggable.DataContext is ApplicationFirmwareVersion) + { + _vm.DropApplicationFirmwareVersion(e.Draggable.DataContext as ApplicationFirmwareVersion); + } + } + + private void OnEmbeddedDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is EmbeddedFirmwareVersion) + { + _vm.DropEmbeddedFirmware(e.Draggable.DataContext as EmbeddedFirmwareVersion); + } + } + + private void MachineDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is HardwareVersion) + { + _vm.DropHardwareVersion(e.Draggable.DataContext as HardwareVersion); + } + } + + private void SetHighlightRegion(FrameworkElement element) + { + if (!_highlightShown) + { + _highlightRect.Width = element.Width; + _highlightRect.Height = element.Height; + Canvas.SetLeft(_highlightRect, Canvas.GetLeft(element)); + Canvas.SetTop(_highlightRect, Canvas.GetTop(element)); + canvas.Children.Add(_highlightRect); + _highlightShown = true; + _highlightAnimation = new DoubleAnimation(); + _highlightAnimation.From = 0; + _highlightAnimation.To = 1; + _highlightAnimation.Duration = TimeSpan.FromSeconds(0.2); + _highlightAnimation.AutoReverse = true; + _highlightAnimation.RepeatBehavior = RepeatBehavior.Forever; + _highlightRect.BeginAnimation(Rectangle.OpacityProperty, _highlightAnimation); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml new file mode 100644 index 000000000..320ce58aa --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml @@ -0,0 +1,44 @@ + + + + + + + + MACHINE + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml.cs new file mode 100644 index 000000000..07d012966 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineDetailsView.xaml.cs @@ -0,0 +1,28 @@ +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 Tango.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for MachineDetailsView.xaml + /// + public partial class MachineDetailsView : UserControl + { + public MachineDetailsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml index 1ea8d2a74..ded14930a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml @@ -133,7 +133,7 @@ + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml.cs new file mode 100644 index 000000000..776a922ca --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml.cs @@ -0,0 +1,28 @@ +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 Tango.MachineStudio.MachineDesigner.Views +{ + /// + /// Interaction logic for MachinesView.xaml + /// + public partial class MachinesView : UserControl + { + public MachinesView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml index e25a64c5e..0ffcf400a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml @@ -3,812 +3,17 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" xmlns:global="clr-namespace:Tango.MachineStudio.MachineDesigner" - xmlns:fa="http://schemas.fontawesome.io/icons/" - xmlns:providers="clr-namespace:Tango.MachineStudio.MachineDesigner.AutoComplete" - xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" - xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" - xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" - xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - - - - - - - - - + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> - - - - - - - - - - - - - - - - - - - - - - MACHINE DESIGNER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hardware Version - - - - - - Add IDS - - - - - - Remove IDS - - - - - - - - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NO IDS PACKS - - - - - - - - - - - - - - - - - - - - - Touch Panel - - - - - - Embedded Firmware - - - - - - Dispensers - - - - - - Mid Tanks - - - - - - Cartridges - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IDS PACKS - - - - - - - - - - Dispenser: - - - - Mid Tank: - - - - Cartridge: - - - - Liquid: - - - - Formula: - - - - - - - - - - - - - - - - - - - - - - - - - Serial Number - - - Machine Name - - - Machine Version - - - - - - - - - - Organization - - - - Enable Synchronization - - - - Configuration Name - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - v - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs index 9c7496484..7e1b60a28 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -10,163 +9,28 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; -using Tango.BL.Entities; -using Tango.DragAndDrop; -using Tango.MachineStudio.MachineDesigner.ViewModels; +using Tango.Core.DI; +using Tango.MachineStudio.MachineDesigner.Contracts; namespace Tango.MachineStudio.MachineDesigner.Views { /// /// Interaction logic for MainView.xaml /// - public partial class MainView : UserControl + public partial class MainView : UserControl , IMainView { - private MainViewVM _vm; - private Rectangle _highlightRect; - private bool _highlightShown; - private DoubleAnimation _highlightAnimation; - - public ColumnDefinition PanelColumnDefinition { get; set; } - public MainView() { InitializeComponent(); - - PanelColumnDefinition = panelColumnDefinition; - - DraggingSurface = dragSufrace; - this.Loaded += (x, y) => - { - _vm = DataContext as MainViewVM; - }; - - DragAndDropService.DragStarted += DragAndDropService_DragStarted; - DragAndDropService.DragEnded += DragAndDropService_DragEnded; - - _highlightRect = new Rectangle(); - _highlightRect.IsHitTestVisible = false; - _highlightRect.Stroke = Application.Current.Resources["AccentColorBrush"] as Brush; - _highlightRect.StrokeThickness = 2; - _highlightRect.StrokeDashArray = new DoubleCollection(new double[] { 3, 3, 3, 3 }); - } - - private void DragAndDropService_DragEnded(object sender, FrameworkElement e) - { - canvas.Children.Remove(_highlightRect); - _highlightShown = false; - _highlightRect.BeginAnimation(Rectangle.OpacityProperty, null); - } - - private void DragAndDropService_DragStarted(object sender, FrameworkElement e) - { - if (e.DataContext is HardwareVersion) - { - SetHighlightRegion(hardwareGrid); - } - else if (e.DataContext is ApplicationOsVersion || e.DataContext is ApplicationDisplayPanelVersion || e.DataContext is ApplicationFirmwareVersion) - { - SetHighlightRegion(gridTablet); - } - else if (e.DataContext is EmbeddedFirmwareVersion) - { - SetHighlightRegion(gridEmbedded); - } - else if (e.DataContext is DispenserType || e.DataContext is CartridgeType || e.DataContext is LiquidType || e.DataContext is MidTankType || e.DataContext is IdsPackFormula) - { - SetHighlightRegion(gridIds); - } - } - - public DraggingSurface DraggingSurface - { - get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } - set { SetValue(DraggingSurfaceProperty, value); } - } - public static readonly DependencyProperty DraggingSurfaceProperty = - DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); - - private void OnDropOnIdsPack(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is DispenserType) - { - _vm.DropDispenserType(e.Draggable.DataContext as DispenserType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is LiquidType) - { - _vm.DropLiquidType(e.Draggable.DataContext as LiquidType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is CartridgeType) - { - _vm.DropCartridgeType(e.Draggable.DataContext as CartridgeType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is MidTankType) - { - _vm.DropMidTankType(e.Draggable.DataContext as MidTankType, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is IdsPackFormula) - { - _vm.DropIdsFormula(e.Draggable.DataContext as IdsPackFormula, e.Droppable.DataContext as IdsPack); - } - else if (e.Draggable.DataContext is IdsPack) - { - _vm.DropIdsPack(e.Draggable.DataContext as IdsPack, e.Droppable.DataContext as IdsPack); - } - } - - private void OnTabletDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is ApplicationDisplayPanelVersion) - { - _vm.DropTouchPanel(e.Draggable.DataContext as ApplicationDisplayPanelVersion); - } - else if (e.Draggable.DataContext is ApplicationOsVersion) - { - _vm.DropApplicationOsVersion(e.Draggable.DataContext as ApplicationOsVersion); - } - else if (e.Draggable.DataContext is ApplicationFirmwareVersion) - { - _vm.DropApplicationFirmwareVersion(e.Draggable.DataContext as ApplicationFirmwareVersion); - } - } - - private void OnEmbeddedDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is EmbeddedFirmwareVersion) - { - _vm.DropEmbeddedFirmware(e.Draggable.DataContext as EmbeddedFirmwareVersion); - } - } - - private void MachineDrop(object sender, DropEventArgs e) - { - if (e.Draggable.DataContext is HardwareVersion) - { - _vm.DropHardwareVersion(e.Draggable.DataContext as HardwareVersion); - } + TangoIOC.Default.Register(this); } - private void SetHighlightRegion(FrameworkElement element) + public void NavigateTo(MachineDesignerNavigationView view) { - if (!_highlightShown) - { - _highlightRect.Width = element.Width; - _highlightRect.Height = element.Height; - Canvas.SetLeft(_highlightRect, Canvas.GetLeft(element)); - Canvas.SetTop(_highlightRect, Canvas.GetTop(element)); - canvas.Children.Add(_highlightRect); - _highlightShown = true; - _highlightAnimation = new DoubleAnimation(); - _highlightAnimation.From = 0; - _highlightAnimation.To = 1; - _highlightAnimation.Duration = TimeSpan.FromSeconds(0.2); - _highlightAnimation.AutoReverse = true; - _highlightAnimation.RepeatBehavior = RepeatBehavior.Forever; - _highlightRect.BeginAnimation(Rectangle.OpacityProperty, _highlightAnimation); - } + navigationControl.NavigateTo(view.ToString()); } } } -- cgit v1.3.1