예제 #1
0
        private void cmdAddShortcut_Click(object sender, EventArgs e)
        {
            lblErrorShortcut.Visible = false; // resetting error msg

            if (ShortcutList.Count >= 20)
            {
                lblErrorMaxShortcuts.Text = "Max 20 shortcuts in one group";
                lblErrorMaxShortcuts.BringToFront();
                lblErrorMaxShortcuts.Visible = true;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select exe file
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu),
                Title            = "Create New Shortcut",
                CheckFileExists  = true,
                CheckPathExists  = true,
                DefaultExt       = "exe",
                Filter           = "Program (.exe)|*.exe",
                FilterIndex      = 2,
                RestoreDirectory = true,

                ReadOnlyChecked = true,
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                ProgramShortcut programShortcut = new ProgramShortcut(openFileDialog.FileName); //create new shortcut obj
                this.ShortcutList.Add(programShortcut);                                         // add to panel shortcut list
                LoadShortcuts();
            }
        }
예제 #2
0
        // Adding shortcut by button
        private void pnlAddShortcut_Click(object sender, EventArgs e)
        {
            lblErrorShortcut.Visible = false; // resetting error msg

            if (Category.ShortcutList.Count >= 20)
            {
                lblErrorShortcut.Text = "Max 20 shortcuts in one group";
                lblErrorShortcut.BringToFront();
                lblErrorShortcut.Visible = true;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select exe file
            {
                InitialDirectory = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs",
                Title            = "Create New Shortcut",
                CheckFileExists  = true,
                CheckPathExists  = true,
                Multiselect      = true,
                DefaultExt       = "exe",
                Filter           = "Exe or Shortcut (.exe, .lnk)|*.exe;*.lnk",
                FilterIndex      = 2,
                RestoreDirectory = true,
                ReadOnlyChecked  = true,
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (String file in openFileDialog.FileNames)
                {
                    ProgramShortcut psc = new ProgramShortcut(Environment.ExpandEnvironmentVariables(file)); //create new shortcut obj
                    Category.ShortcutList.Add(psc);                                                          // add to panel shortcut list
                    LoadShortcut(psc, Category.ShortcutList.Count - 1);
                }
            }
        }
예제 #3
0
        private void pnlAddShortcut_Click(object sender, EventArgs e)
        {
            lblErrorShortcut.Visible = false; // resetting error msg

            if (Category.ShortcutList.Count >= 20)
            {
                lblErrorShortcut.Text = "Max 20 shortcuts in one group";
                lblErrorShortcut.BringToFront();
                lblErrorShortcut.Visible = true;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select exe file
            {
                InitialDirectory = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs",
                Title            = "Create New Shortcut",
                CheckFileExists  = true,
                CheckPathExists  = true,
                DefaultExt       = "exe",
                Filter           = "Exe (.exe)|*.exe",
                FilterIndex      = 2,
                RestoreDirectory = true,
                //ShowReadOnly = true,
                ReadOnlyChecked = true,
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                ProgramShortcut programShortcut = new ProgramShortcut(openFileDialog.FileName); //create new shortcut obj
                Category.ShortcutList.Add(programShortcut);                                     // add to panel shortcut list
                pnlShortcuts.Controls.Clear();
                LoadShortcuts();
                pnlShortcuts.ScrollControlIntoView(pnlShortcuts.Controls[0]); // scroll to the latest created control
            }
        }
예제 #4
0
        // Adding shortcut by button
        private void pnlAddShortcut_Click(object sender, EventArgs e)
        {
            resetSelection();

            lblErrorShortcut.Visible = false; // resetting error msg

            if (Category.ShortcutList.Count >= 20)
            {
                lblErrorShortcut.Text = "Max 20 shortcuts in one group";
                lblErrorShortcut.BringToFront();
                lblErrorShortcut.Visible = true;
            }


            OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select exe file
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms),
                Title            = "Create New Shortcut",
                CheckFileExists  = true,
                CheckPathExists  = true,
                Multiselect      = true,
                DefaultExt       = "exe",
                Filter           = "Exe or Shortcut (.exe, .lnk)|*.exe;*.lnk;*.url",
                RestoreDirectory = true,
                ReadOnlyChecked  = true,
                DereferenceLinks = false
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (String file in openFileDialog.FileNames)
                {
                    addShortcut(file);
                }
                resetSelection();
            }

            if (pnlShortcuts.Controls.Count != 0)
            {
                pnlShortcuts.ScrollControlIntoView(pnlShortcuts.Controls[0]);
            }
        }