Exemplo n.º 1
0
        private void ButtonEditConfirm_Click(object sender, RoutedEventArgs e)
        {
            if (editMode == EditMode.EditString || editMode == EditMode.EditTab)
            {
                if (editMode == EditMode.EditTab)
                {
                    Object tab = ListBox_Tab.SelectedItem;
                    if (tab != null)
                    {
                        TabItemModel item = (TabItemModel)tab;

                        item.Data.Name        = TextBox_Name.Text;
                        item.Data.Description = TextBox_Description.Text;
                        item.SetPropertyChanged("Data");
                    }
                }
                else
                {
                    Object str = ListBox_Str.SelectedItem;
                    if (str != null)
                    {
                        StrItemModel item = (StrItemModel)str;
                        item.Data.Name        = TextBox_Name.Text;
                        item.Data.Description = TextBox_Description.Text;
                        item.Data.Text        = TextBox_Command.Text;
                        item.SetPropertyChanged("Data");
                    }
                }
            }
            else
            {
                if (editMode == EditMode.AddTab)
                {
                    CustomStrTab newTab = new CustomStrTab(TextBox_Name.Text);
                    newTab.Description = TextBox_Description.Text;
                    TabList.Add(newTab);
                    TabItemModel newModel = new TabItemModel(newTab);
                    tabListBoxViewModel.ModelCollection.Add(newModel);
                    ListBox_Tab.SelectedItem = newModel;
                }
                else
                {
                    CustomStrData newStr = new CustomStrData(TextBox_Name.Text, TextBox_Description.Text, TextBox_Command.Text);
                    Object        tab    = ListBox_Tab.SelectedItem;
                    if (tab != null)
                    {
                        TabItemModel item = (TabItemModel)tab;
                        item.Data.StrList.Add(newStr);
                        TabStrRefresh(item.Data.StrList);
                        ListBox_Str.SelectedIndex = item.Data.StrList.Count - 1;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void ItemInfoUpdate(EditMode mode)
        {
            bool addItem = false;
            bool isNull  = false;

            switch (mode)
            {
            case EditMode.EditTab:
                TabItemModel tab = (TabItemModel)this.ListBox_Tab.SelectedItem;
                if (tab != null)
                {
                    this.TextBox_Command.Text       = null;
                    this.TextBox_Command.Visibility = Visibility.Hidden;
                    this.TextBox_Name.Text          = tab.Data.Name;
                    this.TextBox_Description.Text   = tab.Data.Description;
                }
                else
                {
                    isNull = true;
                }
                break;

            case EditMode.EditString:
                StrItemModel str = (StrItemModel)this.ListBox_Str.SelectedItem;
                if (str != null)
                {
                    this.TextBox_Command.Text       = str.Data.Text;
                    this.TextBox_Command.Visibility = Visibility.Visible;
                    this.TextBox_Name.Text          = str.Data.Name;
                    this.TextBox_Description.Text   = str.Data.Description;
                }
                else
                {
                    isNull = true;
                }
                break;

            case EditMode.AddTab:
                addItem = true;

                this.TextBox_Command.Text       = "";
                this.TextBox_Command.Visibility = Visibility.Hidden;
                this.TextBox_Name.Text          = "New Tab";
                this.TextBox_Description.Text   = "無";
                break;

            case EditMode.AddString:
                addItem = true;
                this.TextBox_Command.Text       = "";
                this.TextBox_Command.Visibility = Visibility.Visible;
                this.TextBox_Name.Text          = "New String";
                this.TextBox_Description.Text   = "無";
                break;
            }
            if (addItem)
            {
                TextBox_Name.Focus();
                EditApplyIcon.Kind  = MaterialDesignThemes.Wpf.PackIconKind.AddThick;
                EditCancelIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.CloseThick;
            }
            else
            {
                EditApplyIcon.Kind  = MaterialDesignThemes.Wpf.PackIconKind.CheckBold;
                EditCancelIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.ArrowRotateLeft;
            }
            if (!isNull)
            {
                editMode = mode;
            }

            InfoChangeCheck();
        }