Esempio n. 1
0
        private List <IAEAction> GetCurrentSetup()
        {
            var list        = new List <IAEAction>();
            var currentList = manager.GetCurrentAEActionList();

            if (currentList != null)
            {
                foreach (var setup in currentList)
                {
                    list.Add(setup.ConvertBackToAction());
                }
            }

            return(list);
        }
Esempio n. 2
0
        private void InitializeCommandAndEvents()
        {
            CopyCommand = new RelayCommand(p =>
            {
                this.copyAEAction = this.SelectedAEAction;
            }, p => SelectedAEAction != null);

            ApplyCommand = new RelayCommand(p =>
            {
                foreach (var action in AEActionList.GetSelectedElement())
                {
                    if (action.AEAction == copyAEAction.AEAction)
                    {
                        action.CopyOntoSelf(copyAEAction);
                    }
                }
                ;
            }, p => this.copyAEAction != null);

            this.macroManager.SelectChanged += (sender, e) =>
            {
                if (AEActionList == null)
                {
                    AEActionList = new ObservableCollection <IAEActionViewModel>();
                }

                AEActionList.Clear();

                foreach (var a in macroManager.GetCurrentAEActionList())
                {
                    AEActionList.Add(a);
                }

                this.copyAEAction = null;
            };
        }
Esempio n. 3
0
        private void InitializeCommandAndEvents()
        {
            CopyCommand = new RelayCommand(p =>
            {
                this.copyAEAction = this.SelectedAEAction;
            }, p => SelectedAEAction != null);

            ApplyCommand = new RelayCommand(p =>
            {
                foreach (var action in AEActionList.GetSelectedElement())
                {
                    if (action.AEAction == copyAEAction.AEAction)
                    {
                        action.CopyOntoSelf(copyAEAction);
                    }
                }
                ;
            }, p => this.copyAEAction != null);

            OpenSavedDialogCommand = new RelayCommand(p =>
            {
                IsSavedSetupDialogOpen = true;
            }, p => SelectedAEAction != null);

            CloseSavedDialogCommand = new RelayCommand(p =>
            {
                IsSavedSetupDialogOpen = false;
            }, p => IsSavedSetupDialogOpen == true);

            SaveCommand = new RelayCommand(p =>
            {
                var action  = this.SelectedAEAction.ConvertBackToAction();
                action.Name = SavedSetupName;
                repository.Add(action);

                if (!repository.SaveChange())
                {
                    messageBoxService.ShowMessageBox("Can not save your setup. Check the permission to the folder", "ERROR", MessageButton.OK, MessageImage.Error);
                }
                else
                {
                    SavedAEActions.Add(action);
                    IsSavedSetupDialogOpen = false;
                }
            }, p => SelectedAEAction != null && !string.IsNullOrWhiteSpace(SavedSetupName));

            LoadCommand = new RelayCommand(p =>
            {
                if (!(p is IAEAction aeAction))
                {
                    return;
                }

                foreach (var action in AEActionList.GetSelectedElement())
                {
                    if (action.AEAction == aeAction.AEAction)
                    {
                        action.ConvertFromAction(aeAction);
                    }
                }
                ;
            }, p => SavedAEActions.Count > 0);

            RemoveCommand = new RelayCommand(p =>
            {
                if (!(p is IAEAction aeAction))
                {
                    return;
                }

                repository.Remove(aeAction);

                if (!repository.SaveChange())
                {
                    messageBoxService.ShowMessageBox("Can not remove the saved setup. Check the permission to the folder", "ERROR", MessageButton.OK, MessageImage.Error);
                }
                else
                {
                    SavedAEActions?.Remove(aeAction);
                }
            }, p => SavedAEActions.Count > 0);

            this.macroManager.SelectChanged += (sender, e) =>
            {
                var newList = macroManager.GetCurrentAEActionList();

                AEActionList.Clear();

                if (newList != null)
                {
                    foreach (var a in newList)
                    {
                        AEActionList.Add(a);
                    }
                }

                this.copyAEAction = null;
            };

            this.macroManager.BeforeMacroReloaded += (sender, e) =>
            {
                oldList = new List <IAEActionViewModel>(AEActionList);
            };

            this.macroManager.AfterMacroReloaded += (sender, e) =>
            {
                if (oldList != null)
                {
                    var count = oldList.Count < AEActionList.Count ? oldList.Count : AEActionList.Count;

                    for (int i = 0; i < count; i++)
                    {
                        AEActionList[i].CopyOntoSelf(oldList[i]);
                    }
                }
            };

            this.macroManager.MacroProfileSelected += (sender, e) =>
            {
                if (e == null || e.Profile.Setups?.Count == 0)
                {
                    return;
                }

                ApplyProfile(e.Profile);
            };

            this.macroManager.MacroSaveLoaded += (sender, e) =>
            {
                if (e == null || e.Save == null)
                {
                    return;
                }

                ApplyProfile(e.Save.DefaultProfile);
            };
        }