Exemplo n.º 1
0
        private void CreateExampleCommandFile()
        {
            Console.WriteLine("Create New Config File");
            if (File.Exists(CommandListFilePath))
            {
                File.Delete(CommandListFilePath);
            }
            // Create a file to write to.
            using (StreamWriter sw = File.CreateText(CommandListFilePath))
            {
                JObject parent   = new JObject();
                JArray  TabArray = new JArray();
                JObject NewTab   = new JObject();
                JArray  StrList  = new JArray();
                parent.Add(new JProperty("CustomStrings", TabArray));

                NewTab.Add(new JProperty("Name", "New Tab"));
                NewTab.Add(new JProperty("Description", ""));
                //NewTab.Add(new JProperty("Index", 0));
                NewTab.Add(new JProperty("StrList", StrList));
                TabArray.Add(NewTab);

                CustomStrData example = new CustomStrData("Example", "No", "Welcome to use Easycom!");
                JObject       newItem = JObject.FromObject(example);
                StrList.Add(newItem);

                sw.WriteLine(parent.ToString());
                sw.Close();
            }
        }
Exemplo n.º 2
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.º 3
0
        private void InfoChangeCheck()
        {
            bool changed = false;
            bool isNull  = false;

            if (editMode == EditMode.EditTab || editMode == EditMode.EditString)
            {
                string Name        = null;
                string Description = null;
                string Command     = null;


                if (editMode == EditMode.EditTab)
                {
                    Object tab = ListBox_Tab.SelectedItem;
                    if (tab != null)
                    {
                        CustomStrTab tabData = ((TabItemModel)tab).Data;

                        Name        = tabData.Name;
                        Description = tabData.Description;
                    }
                    else
                    {
                        isNull = true;
                    }
                }
                else
                {
                    Object str = ListBox_Str.SelectedItem;
                    if (str != null)
                    {
                        CustomStrData strData = ((StrItemModel)str).Data;
                        Name        = strData.Name;
                        Description = strData.Description;
                        Command     = strData.Text;
                    }
                    else
                    {
                        isNull = true;
                    }
                }
                if (!isNull)
                {
                    if (TextBox_Name.Text != Name)
                    {
                        changed = true;
                    }
                    else if (TextBox_Description.Text != Description)
                    {
                        changed = true;
                    }
                    else if (editMode == EditMode.EditString && TextBox_Command.Text != Command)
                    {
                        changed = true;
                    }
                }
                if (changed)
                {
                    ButtonEditConfirm.IsEnabled = (TextBox_Name.Text.Length != 0);
                    ButtonEditCancel.IsEnabled  = true;
                }
                else
                {
                    ButtonEditConfirm.IsEnabled = false;
                    ButtonEditCancel.IsEnabled  = false;
                }
            }
            else
            {
                ButtonEditConfirm.IsEnabled = (TextBox_Name.Text.Length != 0);
                ButtonEditCancel.IsEnabled  = true;
            }
        }