public VisibleCheckBox(IChkVisibleItem item)
        {
            MyListItem listItem = (MyListItem)item;

            listItem.AddCtr(this);
            this.CheckChanged      += () => item.ItemVisible = this.Checked;
            listItem.ParentChanged += (sender, e) =>
            {
                if (listItem.IsDisposed)
                {
                    return;
                }
                if (listItem.Parent == null)
                {
                    return;
                }
                this.Checked = item.ItemVisible;
                if (listItem is FoldSubItem subItem && subItem.FoldGroupItem != null)
                {
                    return;
                }
                if (listItem.FindForm() is ShellStoreDialog.ShellStoreForm)
                {
                    return;
                }
                if (AppConfig.HideDisabledItems)
                {
                    listItem.Visible = this.Checked;
                }
            };
        }
Esempio n. 2
0
        public DeleteButton(IBtnDeleteItem item) : base(AppImage.Delete)
        {
            MyListItem listItem = (MyListItem)item;

            listItem.AddCtr(this);
            this.MouseDown += (sender, e) =>
            {
                if (AppMessageBox.Show(AppString.Message.ConfirmDelete, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    item.DeleteMe();
                }
            };
        }
Esempio n. 3
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);
                    }
                }
            };
        }
Esempio n. 4
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) => ExternalProgram.JumpExplorer(SendToPath);
            item.AddCtr(btnPath);
            this.InsertItem(item, 1);
        }
        public DeleteButton(IBtnDeleteItem item) : base(AppImage.Delete)
        {
            MyListItem listItem = (MyListItem)item;

            listItem.AddCtr(this);
            this.MouseDown += (sender, e) =>
            {
                if (MessageBoxEx.Show(AppString.Message.ConfirmDelete,
                                      MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    MyList list  = (MyList)listItem.Parent;
                    int    index = list.GetItemIndex(listItem);
                    index -= (index < list.Controls.Count - 1) ? 0 : 1;
                    item.DeleteMe();
                    list.HoveredItem = (MyListItem)list.Controls[index];
                }
            };
        }
Esempio n. 6
0
        public VisibleCheckBox(IChkVisibleItem item)
        {
            MyListItem listItem = (MyListItem)item;

            listItem.AddCtr(this);
            this.MouseDown += (sender, e) =>
            {
                if (e.Button == MouseButtons.Left)
                {
                    item.ItemVisible = !this.Checked;
                    this.Checked     = item.ItemVisible;
                }
            };
            listItem.ParentChanged += (sender, e) =>
            {
                if (listItem.IsDisposed)
                {
                    return;
                }
                if (listItem.Parent == null)
                {
                    return;
                }
                if (listItem is IFoldSubItem subItem && subItem.FoldGroupItem != null)
                {
                    return;
                }
                if (listItem.FindForm() is ShellStoreDialog.ShellStoreForm)
                {
                    return;
                }
                if (AppConfig.HideDisabledItems)
                {
                    listItem.Visible = item.ItemVisible;
                }
            };
        }
Esempio n. 7
0
        private void AddDirItem()
        {
            MyListItem item = new MyListItem
            {
                Text  = Path.GetFileNameWithoutExtension(SendToPath),
                Image = ResourceIcon.GetFolderIcon(SendToPath).ToBitmap()
            };
            PictureButton btnPath = new PictureButton(AppImage.Open);

            ToolTipBox.SetToolTip(btnPath, AppString.Menu.FileLocation);
            btnPath.MouseDown += (sender, e) => ExternalProgram.OpenDirectory(SendToPath);
            item.AddCtr(btnPath);
            this.InsertItem(item, 1);
            item.ContextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem tsiRestoreDefault = new ToolStripMenuItem(AppString.Menu.RestoreDefault);

            item.ContextMenuStrip.Items.Add(tsiRestoreDefault);
            tsiRestoreDefault.Enabled = Directory.Exists(DefaultSendToPath);
            tsiRestoreDefault.Click  += (sender, e) =>
            {
                if (AppMessageBox.Show(AppString.Message.RestoreDefault, MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    File.SetAttributes(SendToPath, FileAttributes.Normal);
                    Directory.Delete(SendToPath, true);
                    Directory.CreateDirectory(SendToPath);
                    File.SetAttributes(SendToPath, File.GetAttributes(DefaultSendToPath));
                    foreach (string srcPath in Directory.GetFiles(DefaultSendToPath))
                    {
                        string dstPath = $@"{SendToPath}\{Path.GetFileName(srcPath)}";
                        File.Copy(srcPath, dstPath);
                    }
                    this.ClearItems();
                    this.LoadItems();
                }
            };
        }