Пример #1
0
 private void OnItemSelectionChanged(ListViewItem item, MouseEventArgs mouse)
 {
     if (mouse.Button == MouseButtons.Left)
     {
         if (item.ImageKey == "addIcon")
         {
             OpenFileDialog openDialog = new OpenFileDialog();
             openDialog.Title  = "Select application to open:";
             openDialog.Filter = "Applications|*.exe|All Files|*.*";
             if (openDialog.ShowDialog() == DialogResult.OK)
             {
                 DefaultApp app = new DefaultApp(openDialog.FileName, currentApp.FileExtension);
                 settings.AddDefaultApp(app);
                 settings.SaveSettings();
                 app.StartProgram(currentApp);
                 Application.Exit();
             }
         }
         else if (item.ImageKey != "delIcon")
         {
             DefaultApp app = (DefaultApp)item.Tag;
             app.StartProgram(currentApp);
             Application.Exit();
         }
     }
 }
Пример #2
0
        private void AddItem(string imageKey, Image icon, DefaultApp defaultApp = null)
        {
            imgListIcons.Images.Add(imageKey, icon);
            ListViewItem item = new ListViewItem();

            item.ImageKey = imageKey;
            if (defaultApp != null)
            {
                item.Text = defaultApp.GetApplicationName();
                item.Tag  = defaultApp;
            }
            listViewApps.Items.Add(item);
        }
Пример #3
0
 public void DelDefaultApp(DefaultApp app, string extension)
 {
     if (defaultApps.Exists(s => s.FilePath == app.FilePath))
     {
         DefaultApp defApp = defaultApps.Find(s => s.FilePath == app.FilePath);
         if (defApp.OpenExtensions.Contains(extension))
         {
             defApp.OpenExtensions.Remove(extension);
         }
         if (defApp.OpenExtensions.Count == 0)
         {
             defaultApps.Remove(defApp);
         }
     }
 }
Пример #4
0
 public void AddDefaultApp(DefaultApp app)
 {
     if (defaultApps.Exists(s => s.FilePath == app.FilePath))
     {
         DefaultApp defApp = defaultApps.Find(s => s.FilePath == app.FilePath);
         if (!defApp.OpenExtensions.Contains(app.OpenExtensions.First()))
         {
             defApp.OpenExtensions.Add(app.OpenExtensions.First());
         }
     }
     else
     {
         defaultApps.Add(app);
     }
 }