Ejemplo n.º 1
0
        private void AddNewItem()
        {
            MyListItem newItem = new MyListItem
            {
                Text  = AppString.Item.AddGuidBlockedItem,
                Image = AppImage.AddNewItem
            };
            PictureButton btnAddNewItem = new PictureButton(AppImage.AddNewItem);

            newItem.AddCtr(btnAddNewItem);
            newItem.SetNoClickEvent();
            this.AddItem(newItem);
            MyToolTip.SetToolTip(btnAddNewItem, newItem.Text);
            btnAddNewItem.MouseDown += (sender, e) =>
            {
                using (InputDialog dlg = new InputDialog {
                    Title = AppString.Dialog.InputGuid
                })
                {
                    if (GuidEx.TryParse(Clipboard.GetText(), out Guid guid))
                    {
                        dlg.Text = guid.ToString();
                    }
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    if (GuidEx.TryParse(dlg.Text, out guid))
                    {
                        Array.ForEach(GuidBlockedItem.BlockedPaths, path =>
                        {
                            Registry.SetValue(path, guid.ToString("B"), string.Empty);
                        });
                        for (int i = 1; i < Controls.Count; i++)
                        {
                            if (((GuidBlockedItem)Controls[i]).Guid.Equals(guid))
                            {
                                MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded);
                                return;
                            }
                        }
                        this.InsertItem(new GuidBlockedItem(dlg.Text), 1);
                        ExplorerRestarter.NeedRestart = true;
                    }
                    else
                    {
                        MessageBoxEx.Show(AppString.MessageBox.MalformedGuid);
                    }
                }
            };
        }
Ejemplo n.º 2
0
        private void AddDirItem()
        {
            MyListItem item = new MyListItem
            {
                Text  = Path.GetFileNameWithoutExtension(SendToPath),
                Image = ResourceIcon.GetFolderIcon(SendToPath).ToBitmap()
            };
            PictureButton btnPath = new PictureButton(AppImage.Open);

            MyToolTip.SetToolTip(btnPath, AppString.Menu.FileLocation);
            btnPath.MouseDown += (sender, e) => Process.Start(SendToPath);
            item.AddCtr(btnPath);
            item.SetNoClickEvent();
            this.InsertItem(item, 1);
        }