public static void SaveJson(QuickApp quickApp, int index = -1)
        {
            if (index != -1)
            {
                quickApps.RemoveAt(index);
            }

            quickApps.Add(quickApp);

            string json = JsonConvert.SerializeObject(quickApps, Formatting.Indented);

            File.WriteAllText(QuickLaunchPath + @"\SavedApps.json", json);
        }
Exemple #2
0
        public CreateApp(QuickApp quickApp, int index)
        {
            InitializeComponent();
            Deletebutton.IsEnabled = true;

            load();

            if (quickApp.paths.Count == 0)
            {
                return;
            }

            this.index   = index;
            name         = quickApp.name;
            Appname.Text = quickApp.name;

            // paths
            string paths = "";

            for (int i = 0; i < quickApp.paths.Count - 1; i++)
            {
                paths += quickApp.paths[i] + ";\n";
            }

            byte lastIndexpath = Convert.ToByte(quickApp.paths.Count - 1);

            paths           += quickApp.paths[lastIndexpath];
            pathTextbox.Text = paths;

            try { if (quickApp.tasks.Count == 0)
                  {
                      return;
                  }
            } catch { return; }

            // tasks
            string tasks = "";

            for (int i = 0; i < quickApp.tasks.Count - 1; i++)
            {
                tasks += quickApp.tasks[i] + ";\n";
            }

            byte lastIndex = Convert.ToByte(quickApp.tasks.Count - 1);

            tasks            += quickApp.tasks[lastIndex];
            tasksTextbox.Text = tasks;
        }
Exemple #3
0
        private void Save(object x, dynamic y)
        {
            if (nameisEmpty)
            {
                Popup popup = new Popup("Name can't be Empty");
                popup.Show();
            }
            else if (addedAppsisEmpty)
            {
                Popup popup = new Popup("Path can't be Empty");
                popup.Show();
            }
            else if (CheckList(MainWindow.quickApps, name) && index == -1)
            {
                Popup popup = new Popup("Appname already exists");
                popup.Show();
            }
            else
            {
                // Save App
                string Context;

                paths = paths.Replace(@"""", "");

                List <string> pathsList = new List <string>();

                var arraypath = paths.Split(";");
                pathsList = arraypath.OfType <string>().ToList();

                List <string> tasksList = new List <string>();

                var arraytask = tasks.Split(";");
                tasksList = arraytask.OfType <string>().ToList();

                if (tasksList[0].Contains("Example: "))
                {
                    tasksList = null;
                }

                QuickApp quickApp = new QuickApp()
                {
                    name = name, paths = pathsList, tasks = tasksList
                };

                // Replace
                if (index != -1)
                {
                    MainWindow.SaveJson(quickApp, index: index);
                    Context = "App Edited";
                }
                else
                {
                    MainWindow.SaveJson(quickApp);
                    Context = "App Saved";
                }
                Popup popup = new Popup(Context);
                Close();
                CloseMainWindowNow();
                OpenMainWindowNow();
                popup.Show();
            }
        }