//the function handels the case that the user pressed on one of the apps icons in the window, it opens a defintions window for the app
        private void SuggestedPressed(object sender, SelectionChangedEventArgs e)
        {
            if (IconListView.SelectedItem != null)
            {
                string appName = ((ListApp)IconListView.SelectedItem).appName;
                if (appName.EndsWith("..."))
                {
                    appName = appName.Substring(0, appName.Length - 3);

                    foreach (string item in nameList)
                    {
                        string sub = item;
                        if (sub.Length > 18)
                        {
                            sub = sub.Substring(0, 16);
                        }
                        if (sub == appName)
                        {
                            appName = item;
                        }
                    }
                }
                ImageSource appIcon = ((ListApp)IconListView.SelectedItem).iconImg;
                Console.WriteLine(appName);
                DefineWindow2 window1 = new DefineWindow2(appName, appIcon, "");
                window1.ShowDialog();
                IconListView.SelectedItem = null;
            }
        }
Exemple #2
0
 //the function manages a case when the user pressed on an app's icon
 private void SuggestedPressed(object sender, SelectionChangedEventArgs e)
 {
     if (IconListView.SelectedItem != null)
     {
         string      appName = ((ListApp)IconListView.SelectedItem).appName;
         ImageSource appIcon = ((ListApp)IconListView.SelectedItem).iconImg;
         Console.WriteLine(appName);
         DefineWindow2 window1 = new DefineWindow2(appName, appIcon, "");
         window1.ShowDialog();
         txtAuto.BorderBrush = System.Windows.Media.Brushes.Gray;
         if (window1.saveButton.Content.ToString() == "1")
         {
             Console.WriteLine("1");
             DefinedNames();
             LoadImages();
         }
         IconListView.SelectedItem = null;
     }
 }
Exemple #3
0
 //the function creates the define button
 private void DefineButton_Click(object sender, RoutedEventArgs e)
 {
     if (File.Exists(txtAuto.Text))
     {
         string[] appsLines = System.IO.File.ReadAllLines(Globals.APPS_PATH);
         int      count     = 0;
         string   name      = "";
         bool     inApps    = false;
         foreach (string line in appsLines)
         {
             if (count % 2 == 0)
             {
                 name = line;
             }
             else
             {
                 if (line == txtAuto.Text)
                 {
                     inApps = true;
                     break;
                 }
             }
             count++;
         }
         if (inApps)
         {
             int         index = nameList.IndexOf(name);
             ImageSource icon  = Icon.ExtractAssociatedIcon(pathList[index]).ToImageSource();
             //DefineWindow window1 = new DefineWindow(name, iconsList[index], "");
             DefineWindow2 window1 = new DefineWindow2(name, icon, "");
             window1.ShowDialog();
             if (window1.saveButton.Content.ToString() == "1")
             {
                 Console.WriteLine("1");
                 DefinedNames();
                 LoadImages();
             }
             txtAuto.Text = "";
         }
         else
         {
             string        path    = txtAuto.Text;
             Icon          icon    = Icon.ExtractAssociatedIcon(path);
             string        appName = System.IO.Path.GetFileNameWithoutExtension(path);
             DefineWindow2 window1 = new DefineWindow2(appName, icon.ToImageSource(), txtAuto.Text);
             window1.ShowDialog();
             if (window1.saveButton.Content.ToString() == "1")
             {
                 Console.WriteLine("1");
                 DefinedNames();
                 LoadImages();
             }
             txtAuto.Text        = "";
             txtAuto.BorderBrush = System.Windows.Media.Brushes.Gray;
         }
     }
     else if (nameList.Contains(txtAuto.Text))
     {
         int         index = nameList.IndexOf(txtAuto.Text);
         ImageSource icon  = Icon.ExtractAssociatedIcon(pathList[index]).ToImageSource();
         //DefineWindow window1 = new DefineWindow(txtAuto.Text, iconsList[index], "");
         DefineWindow2 window1 = new DefineWindow2(txtAuto.Text, icon, "");
         window1.ShowDialog();
         if (window1.saveButton.Content.ToString() == "1")
         {
             Console.WriteLine("1");
             DefinedNames();
             LoadImages();
         }
         txtAuto.Text        = "";
         txtAuto.BorderBrush = System.Windows.Media.Brushes.Gray;
     }
     else
     {
         txtAuto.BorderBrush = System.Windows.Media.Brushes.Red;
     }
 }