public WindowEditRule(MyTask task)
        {
            Task = task;
            InitializeComponent();
            Move.SelectedItem   = Task.MoveOnly;
            Naming.SelectedItem = Task.Rule;

            AddExtItem.Command = new RelayCommand(o => {
                var addExtensionDialog = new WindowAddPattern {
                    Owner = this
                };
                addExtensionDialog.ShowDialog();
                if (!string.IsNullOrWhiteSpace(addExtensionDialog.NewExtension))
                {
                    Task.PatternCollection.Add(addExtensionDialog.NewExtension);
                }
            });
            EditExtItem.Command = new RelayCommand(o => PatternList.SelectedIndex != -1, o => {
                var addExtensionDialog = new WindowAddPattern(Task.PatternCollection[PatternList.SelectedIndex].Clone() as string)
                {
                    Owner = this
                };
                addExtensionDialog.ShowDialog();
                if (!string.IsNullOrWhiteSpace(addExtensionDialog.NewExtension))
                {
                    Task.PatternCollection.RemoveAt(PatternList.SelectedIndex);
                    Task.PatternCollection.Add(addExtensionDialog.NewExtension);
                }
            });
            RemoveExtItem.Command = new RelayCommand(o => PatternList.SelectedIndex != -1, o => {
                Task.PatternCollection.RemoveAt(PatternList.SelectedIndex);
            });
        }
示例#2
0
        public WindowMain()
        {
            InitializeComponent();

            (Top, Left)     = Preferences.Default.LastMainWindowPosition;
            (Height, Width) = Preferences.Default.MainWindowSize;

            #region Menu Population

            Pref.Command = new RelayCommand(o => {
                var preferences = new WindowPreferences {
                    Owner = this
                };
                preferences.ShowDialog();
                Topmost         = Preferences.Default.MainWindowTopmost;
                appIcon.Visible = Preferences.Default.AlwaysShowTrayIcon;
            });

            AddRuleItem.Command = FileNew.Command = new RelayCommand(true, o => {
                var editRule = new WindowEditRule(new MyTask())
                {
                    Owner = this
                };
                editRule.ShowDialog();
                Tasks.Add(WindowEditRule.Task);
            });
            AddExtItem.Command = AddExtension.Command = new RelayCommand(o => ItemsGrid.SelectedIndex != -1, o => {
                var addExtensionDialog = new WindowAddPattern {
                    Owner = this
                };
                addExtensionDialog.ShowDialog();
                if (!string.IsNullOrWhiteSpace(addExtensionDialog.NewExtension))
                {
                    PatternCollection.Add(addExtensionDialog.NewExtension);
                }
            });

            EditRuleItem.Command = EditRule.Command = new RelayCommand(o => ItemsGrid.SelectedIndex != -1, o => {
                var editRule = new WindowEditRule(Tasks[ItemsGrid.SelectedIndex])
                {
                    Owner = this
                };
                editRule.ShowDialog();
                if (!Tasks.Contains(WindowEditRule.Task))
                {
                    Tasks.Add(WindowEditRule.Task);
                }
            });
            EditExtItem.Command = EditExtension.Command = new RelayCommand(o => PatternList.SelectedIndex != -1 && ItemsGrid.SelectedIndex != -1, o => {
                var addExtensionDialog = new WindowAddPattern(PatternCollection[PatternList.SelectedIndex].Clone() as string)
                {
                    Owner = this
                };
                addExtensionDialog.ShowDialog();
                if (!string.IsNullOrWhiteSpace(addExtensionDialog.NewExtension))
                {
                    PatternCollection.RemoveAt(PatternList.SelectedIndex);
                    PatternCollection.Add(addExtensionDialog.NewExtension);
                }
            });
            RemoveRuleItem.Command = RemoveRule.Command = new RelayCommand(o => ItemsGrid.SelectedIndex != -1, o => {
                Tasks[ItemsGrid.SelectedIndex].IsMoving = false;
                Tasks.RemoveAt(ItemsGrid.SelectedIndex);
            });
            RemoveExtItem.Command = RemoveExtension.Command = new RelayCommand(o => PatternList.SelectedIndex != -1 && ItemsGrid.SelectedIndex != -1, o => {
                PatternCollection.RemoveAt(PatternList.SelectedIndex);
            });

            #endregion
        }