Exemplo n.º 1
0
        private static void InitButton(Button button, FileSystemInfo info)
        {
            if (info == null || !info.Exists)
            {
                button.Enabled = false;
                return;
            }

            FileSystemContextMenuStrip menu = null;

            if (info is FileInfo)
            {
                menu = new FileContextMenuStrip(info);
            }

            if (info is DirectoryInfo)
            {
                menu = new DirectoryContextMenuStrip(info);
            }

            if (menu == null)
            {
                return;
            }

            button.Click += (sender, args) => menu.Show(button, 0, button.Height);
        }
Exemplo n.º 2
0
        private static void InitButton(Button button, FileSystemInfo info)
        {
            if (info == null || !info.Exists)
            {
                button.Enabled = false;
                return;
            }

            FileSystemContextMenuStrip menu = null;

            if (info is FileInfo)
                menu = new FileContextMenuStrip(info);

            if (info is DirectoryInfo)
                menu = new DirectoryContextMenuStrip(info);

            if (menu == null)
                return;

            button.Click += (sender, args) => menu.Show(button, 0, button.Height);
        }