public void RemoveProfile(SavedAEProfile profile)
        {
            if (savedAESetup == null || profile == null)
            {
                return;
            }

            savedAESetup.Profiles.Remove(profile);
        }
        public void AddProfile(SavedAEProfile profile)
        {
            if (savedAESetup == null || profile == null)
            {
                return;
            }

            savedAESetup.Profiles.Add(profile);
        }
Exemple #3
0
        private void ApplyProfile(SavedAEProfile profile)
        {
            if (profile == null)
            {
                return;
            }

            var count = profile.Setups.Count < AEActionList.Count ? profile.Setups.Count : AEActionList.Count;

            for (int i = 0; i < count; i++)
            {
                AEActionList[i].ConvertFromAction(profile.Setups[i]);
            }
        }
Exemple #4
0
 public void InvokeLoadMacroProfile(SavedAEProfile profile)
 {
     this.MacroProfileSelected?.Invoke(null, new MacroProfileSelectedEventArgs(selectedMacro, profile));
 }
Exemple #5
0
 public MacroProfileSelectedEventArgs(MacroTemplate currentTemplate, SavedAEProfile profile)
 {
     Macro   = currentTemplate;
     Profile = profile;
 }
Exemple #6
0
        private void InitializeCommandsAndEvents()
        {
            OpenProfilePopupCommand = new RelayCommand(p =>
            {
                IsCreateNewProfile ^= true;
            }, p => Save != null);

            NewProfileCommand = new RelayCommand(p =>
            {
                var currentTemplate = manager.GetCurrentTemplate();

                if (string.IsNullOrWhiteSpace(NewProfileName) || !AEMGHelpers.IsValidFilename(NewProfileName) || currentTemplate == null)
                {
                    return;
                }

                var newProfile = new SavedAEProfile
                {
                    Id        = Guid.NewGuid().ToString(),
                    IsDefault = true,
                    Name      = NewProfileName,
                    Setups    = GetCurrentSetup(),
                };

                repository.ResetProfileDefault();
                repository.AddProfile(newProfile);
                repository.SaveChange();

                RefreshSave();
                IsCreateNewProfile = false;
            }, p => Save != null);

            RemoveProfileCommand = new RelayCommand(p =>
            {
                if (!(p is SavedAEProfile save))
                {
                    return;
                }

                repository.RemoveProfile(save);
                repository.SaveChange();

                RefreshSave();
            }, p => Save != null);

            LoadProfileCommand = new RelayCommand(p =>
            {
                if (!(p is SavedAEProfile save))
                {
                    return;
                }

                repository.ResetProfileDefault();
                save.IsDefault = true;
                repository.SaveChange();

                manager.InvokeLoadMacroProfile(save);
            }, p => Save != null);

            UpdateCurrentProfileCommand = new RelayCommand(p =>
            {
                if (repository.CurrentSave()?.DefaultProfile == null)
                {
                    return;
                }

                var oldSetups     = repository.CurrentSave().DefaultProfile.Setups;
                var currentSetups = GetCurrentSetup();

                //merge setups
                if (currentSetups.Count >= oldSetups.Count)
                {
                    repository.CurrentSave().DefaultProfile.Setups = currentSetups;
                }
                else
                {
                    for (int i = 0; i < currentSetups.Count; i++)
                    {
                        if (i < oldSetups.Count)
                        {
                            oldSetups[i] = currentSetups[i];
                        }
                    }
                }

                repository.SaveChange();
            }, p => repository.CurrentSave()?.DefaultProfile != null);

            manager.SelectChanged += (sender, test) =>
            {
                if (test.NewMacro == null)
                {
                    Save = null;
                    Profiles?.Clear();
                    return;
                }

                Save     = repository.FindByMacroPath(test.SelectedMacroPath);
                Profiles = new ObservableCollection <SavedAEProfile>(Save.Profiles);

                //Fire event to load default save profile
                if (Profiles.Count > 0)
                {
                    manager.InvokeSaveLoaded(repository.CurrentSave());
                }
            };
        }