private void AddGuidDic()
 {
     using (AddGuidDicDialog dlg = new AddGuidDicDialog())
     {
         dlg.ItemText = GuidInfo.GetText(Item.Guid);
         dlg.ItemIcon = GuidInfo.GetImage(Item.Guid);
         var location = GuidInfo.GetIconLocation(Item.Guid);
         dlg.ItemIconPath  = location.IconPath;
         dlg.ItemIconIndex = location.IconIndex;
         IniWriter writer = new IniWriter
         {
             FilePath            = AppConfig.UserGuidInfosDic,
             DeleteFileWhenEmpty = true
         };
         string     section  = Item.Guid.ToString();
         MyListItem listItem = (MyListItem)Item;
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             if (dlg.IsDelete)
             {
                 writer.DeleteSection(section);
                 GuidInfo.RemoveDic(Item.Guid);
                 listItem.Text  = Item.ItemText;
                 listItem.Image = GuidInfo.GetImage(Item.Guid);
             }
             return;
         }
         if (dlg.ItemText.IsNullOrWhiteSpace())
         {
             AppMessageBox.Show(AppString.Message.TextCannotBeEmpty);
             return;
         }
         dlg.ItemText = ResourceString.GetDirectString(dlg.ItemText);
         if (dlg.ItemText.IsNullOrWhiteSpace())
         {
             AppMessageBox.Show(AppString.Message.StringParsingFailed);
             return;
         }
         else
         {
             GuidInfo.RemoveDic(Item.Guid);
             writer.SetValue(section, "Text", dlg.ItemText);
             writer.SetValue(section, "Icon", dlg.ItemIconLocation);
             listItem.Text  = dlg.ItemText;
             listItem.Image = dlg.ItemIcon;
         }
     }
 }
 protected override bool RunDialog(IntPtr hwndOwner)
 {
     using (SubItemsForm frm = new SubItemsForm())
         using (DetailedEditList list = new DetailedEditList())
         {
             var location = GuidInfo.GetIconLocation(this.GroupGuid);
             frm.Icon    = ResourceIcon.GetIcon(location.IconPath, location.IconIndex);
             frm.Text    = AppString.Dialog.DetailedEdit.Replace("%s", GuidInfo.GetText(this.GroupGuid));
             frm.TopMost = AppConfig.TopMost;
             frm.AddList(list);
             list.GroupGuid  = this.GroupGuid;
             list.UseUserDic = XmlDicHelper.DetailedEditGuidDic[this.GroupGuid];
             list.LoadItems();
             frm.ShowDialog();
         }
     return(false);
 }
예제 #3
0
 private void AddGuidDic()
 {
     using (AddGuidDicDialog dlg = new AddGuidDicDialog())
     {
         dlg.ItemText = GuidInfo.GetText(Item.Guid);
         dlg.ItemIcon = GuidInfo.GetImage(Item.Guid);
         var location = GuidInfo.GetIconLocation(Item.Guid);
         dlg.ItemIconPath  = location.IconPath;
         dlg.ItemIconIndex = location.IconIndex;
         IniWriter writer = new IniWriter
         {
             FilePath            = AppConfig.UserGuidInfosDic,
             DeleteFileWhenEmpty = true
         };
         string section = Item.Guid.ToString();
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             if (dlg.IsDelete)
             {
                 writer.DeleteSection(section);
                 GuidInfo.ItemTextDic.Remove(Item.Guid);
                 GuidInfo.ItemImageDic.Remove(Item.Guid);
                 GuidInfo.IconLocationDic.Remove(Item.Guid);
                 GuidInfo.UserDic.RootDic.Remove(section);
                 ((MyListItem)Item).Text  = Item.ItemText;
                 ((MyListItem)Item).Image = GuidInfo.GetImage(Item.Guid);
             }
             return;
         }
         string name = ResourceString.GetDirectString(dlg.ItemText);
         if (!name.IsNullOrWhiteSpace())
         {
             writer.SetValue(section, "Text", dlg.ItemText);
             ((MyListItem)Item).Text = name;
             if (GuidInfo.ItemTextDic.ContainsKey(Item.Guid))
             {
                 GuidInfo.ItemTextDic[Item.Guid] = name;
             }
             else
             {
                 GuidInfo.ItemTextDic.Add(Item.Guid, name);
             }
         }
         else
         {
             MessageBoxEx.Show(AppString.Message.StringParsingFailed);
             return;
         }
         if (dlg.ItemIconLocation != null)
         {
             writer.SetValue(section, "Icon", dlg.ItemIconLocation);
             location = new GuidInfo.IconLocation {
                 IconPath = dlg.ItemIconPath, IconIndex = dlg.ItemIconIndex
             };
             if (GuidInfo.IconLocationDic.ContainsKey(Item.Guid))
             {
                 GuidInfo.IconLocationDic[Item.Guid] = location;
             }
             else
             {
                 GuidInfo.IconLocationDic.Add(Item.Guid, location);
             }
             ((MyListItem)Item).Image = dlg.ItemIcon;
             if (GuidInfo.ItemImageDic.ContainsKey(Item.Guid))
             {
                 GuidInfo.ItemImageDic[Item.Guid] = dlg.ItemIcon;
             }
             else
             {
                 GuidInfo.ItemImageDic.Add(Item.Guid, dlg.ItemIcon);
             }
         }
     }
 }