private void SetProfileName(TextProfileInfo info, string newName)
 {
     if (info is object && !string.IsNullOrEmpty(base.Text))
     {
         info.Name = newName;
         UpdateItems(info);
     }
 }
        private void EditProfile(TextProfileInfo info)
        {
            var editor = new TextProfileEditor()
            {
                ProfileInfo = info
            };

            editor.ShowDialog();
            MyTextProfiles.SaveTextProfile(info);
        }
Beispiel #3
0
        public void RemoveTextProfile(TextProfileInfo p)
        {
            if (filePaths.ContainsKey(p))
            {
                File.Delete(filePaths[p]);
                filePaths.Remove(p);
            }

            Manager.RemoveTextProfile(p);
            ids.RemoveIfContainsKey(p);
        }
        private BaseItem AddToItemPanel(TextProfileInfo info)
        {
            var btn = new ButtonItem()
            {
                Tag  = info,
                Text = info.Name
            };

            btn.Click += (sender, e) => ItemPanel_Profiles.SelectedItem = (BaseItem)sender;
            ItemPanel_Profiles.Items.Add(btn);
            return(btn);
        }
        private void LoadProfile(TextProfileInfo info)
        {
            bool isNull  = info is null;
            bool canEdit = !isNull && info != MyTextProfiles.Manager.DefaultTextProfileInfo;

            ButtonX_Delete.Enabled        = canEdit;
            ButtonX_Export.Enabled        = canEdit;
            ButtonX_Edit.Enabled          = canEdit;
            TextBoxX_ProfileName.Enabled  = !isNull;
            TextBoxX_ProfileName.ReadOnly = !canEdit;
            TextBoxX_ProfileName.Text     = isNull ? string.Empty : info.Name;
        }
        private void Export(TextProfileInfo info)
        {
            var sfd_ExportTextProfileInfo = new SaveFileDialog()
            {
                Filter = IMPORT_EXPORT_DIALOG_FILTER
            };

            if (sfd_ExportTextProfileInfo.ShowDialog() == DialogResult.OK)
            {
                MyTextProfiles.Export(info, sfd_ExportTextProfileInfo.FileName);
            }
        }
        private void UpdateItems(TextProfileInfo info)
        {
            ItemPanel_Profiles.BeginUpdate();
            foreach (BaseItem item in ItemPanel_Profiles.Items)
            {
                if (item.Tag == info)
                {
                    item.Text = info.Name;
                }
            }

            ItemPanel_Profiles.EndUpdate();
        }
        private void RemoveProfile(TextProfileInfo info)
        {
            MyTextProfiles.RemoveTextProfile(info);
            var items = new BaseItem[ItemPanel_Profiles.Items.Count];

            ItemPanel_Profiles.Items.CopyTo(items, 0);
            ItemPanel_Profiles.BeginUpdate();
            foreach (BaseItem item in items)
            {
                if (item?.Tag == info)
                {
                    ItemPanel_Profiles.Items.Remove(item);
                }
            }

            ItemPanel_Profiles.EndUpdate();
        }
Beispiel #9
0
        public void SaveTextProfile(TextProfileInfo info)
        {
            string myPath;

            if (info != Manager.DefaultTextProfileInfo)
            {
                if (filePaths.ContainsKey(info))
                {
                    myPath = filePaths[info];
                }
                else
                {
                    myPath = Path.Combine(MyTextEditorPath, GetID(info) + ".json");
                    filePaths.Add(info, myPath);
                }

                Manager.SaveToFile(info, myPath);
            }
        }
Beispiel #10
0
        private string GetID(TextProfileInfo info)
        {
            if (ids.ContainsKey(info))
            {
                return(ids[info]);
            }
            else
            {
                bool ende = false;
                var  id   = default(int);
                while (!ende)
                {
                    id = rnd.Next();
                    if (!ids.Values.Contains(Conversions.ToString(id)))
                    {
                        ende = true;
                    }
                }

                ids.Add(info, Conversions.ToString(id));
                return(Conversions.ToString(id));
            }
        }
Beispiel #11
0
 public void RemoveTextProfile(TextProfileInfo p)
 {
     textProfiles.RemoveIfContains(p);
 }
Beispiel #12
0
 public void SaveToFile(TextProfileInfo info, string outputFile)
 {
     File.WriteAllText(Path.Combine(outputFile), JObject.FromObject(info).ToString());
 }
Beispiel #13
0
 private TextProfileInfo Clone(TextProfileInfo info)
 {
     return(JObject.FromObject(info).ToObject <TextProfileInfo>());
 }
Beispiel #14
0
 public void Export(TextProfileInfo info, string outputFile)
 {
     Manager.SaveToFile(info, outputFile);
 }