Пример #1
0
        private void olvLists_CellEditFinished(object sender, ObjectListView.CellEditEventArgs e)
        {
            ApplicationList list = e.RowObject as ApplicationList;

            if (list != null)
            {
                list.Save();
            }
        }
Пример #2
0
        private void bRemoveApp_Click(object sender, EventArgs e)
        {
            ApplicationList currentList = olvLists.SelectedObject as ApplicationList;

            if (currentList != null)
            {
                foreach (ApplicationJob app in olvApps.SelectedObjects)
                {
                    currentList.Applications.Remove(app);
                    olvApps.RemoveObject(app);
                    currentList.Save();
                    UpdateAppList(currentList);
                }
            }
        }
Пример #3
0
        private void olvLists_DragDrop(object sender, DragEventArgs e)
        {
            ApplicationJob job = e.Data.GetData(typeof(ApplicationJob).FullName) as ApplicationJob;

            if (job != null)
            {
                OLVColumn   column;
                Point       actualPoint = olvLists.PointToClient(new Point(e.X, e.Y));
                OLVListItem targetItem  = olvLists.GetItemAt(actualPoint.X, actualPoint.Y, out column);
                if (targetItem != null)
                {
                    ApplicationList list = targetItem.RowObject as ApplicationList;
                    list.Applications.Add(job);
                    list.Save();
                    UpdateAppList(list);
                }
            }
        }
Пример #4
0
 private void bAddApp_Click(object sender, EventArgs e)
 {
     using (SelectApplicationDialog dialog = new SelectApplicationDialog())
     {
         dialog.Applications = this.lists[0].Applications.ToArray();
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             ApplicationList list = olvLists.SelectedObject as ApplicationList;
             foreach (ApplicationJob app in dialog.SelectedApplications)
             {
                 list.Applications.Add(app);
             }
             list.Save();
             UpdateAppList(list);
             olvApps.SetObjects(list.Applications);
         }
     }
 }
Пример #5
0
        /// <summary>
        /// Integrates a new application list into the GUI and
        /// saves it to the database.
        /// </summary>
        /// <param name="newList"></param>
        private void CreateNewAppList(ApplicationList newList, bool edit)
        {
            AddAppToList(newList);
            newList.Save();
            olvLists.AddObject(newList);
            olvLists.SelectedObject = newList;

            OLVListItem selectedItem = olvLists.SelectedItem as OLVListItem;

            if (selectedItem != null)
            {
                selectedItem.EnsureVisible();
                if (edit)
                {
                    olvLists.EditSubItem(selectedItem, 0);
                }
            }
        }
Пример #6
0
        public static void ImportFromFile(string filename)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(filename);

            // Import settings from file as dictionary
            XmlElement settingsElem = doc.SelectSingleNode("//Settings/dictionary") as XmlElement;
            if (settingsElem == null)
            {
                // Backward compatibility
                settingsElem = doc.SelectSingleNode("//dictionary") as XmlElement;
            }

            if (settingsElem != null)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary<string, string>));

                using (StringReader textReader = new StringReader(settingsElem.OuterXml))
                {
                    DbManager.SetSettings(serializer.Deserialize(textReader) as Dictionary<string, string>);
                }
            }
            
            // Import global variables
            XmlElement varNodes = doc.SelectSingleNode("//GlobalVariables") as XmlElement;
            if (varNodes != null)
            {
                UrlVariable.GlobalVariables.Clear();

                foreach (XmlElement varElem in doc.SelectNodes("//GlobalVariables/Variable"))
                {
                    UrlVariable newVar = new UrlVariable();
                    newVar.Name = varElem.GetAttribute("Name");
                    newVar.CachedContent = varElem.GetAttribute("Content");
                    UrlVariable.GlobalVariables[newVar.Name] = newVar;
                }

                UrlVariable.GlobalVariables.Save();
            }

            // Import code snippets
            XmlElement snippetNodes = doc.SelectSingleNode("//CodeSnippets") as XmlElement;
            if (snippetNodes != null)
            {
                using (SQLiteCommand comm = DbManager.Connection.CreateCommand())
                {
                    comm.CommandText = "DELETE FROM snippets";
                    comm.ExecuteNonQuery();
                }

                foreach (XmlElement snippetElem in doc.SelectNodes("//CodeSnippets/Snippet"))
                {
                    Snippet snippet = new Snippet();
                    snippet.Guid = new Guid(snippetElem.GetAttribute("Guid"));
                    snippet.Name = snippetElem.GetAttribute("Name");
                    snippet.Type = (ScriptType)Convert.ToInt32(snippetElem.GetAttribute("Type"));
                    snippet.Text = snippetElem.InnerText;
                    snippet.Save();
                }
            }

            XmlElement setupNodes = doc.SelectSingleNode("//SetupLists") as XmlElement;
            if (setupNodes != null)
            {
                ApplicationJob[] apps = DbManager.GetJobs();

                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists_applications";
                    command.ExecuteNonQuery();
                }

                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists";
                    command.ExecuteNonQuery();
                }

                foreach (XmlElement listElem in doc.SelectNodes("//SetupLists/List"))
                {
                    ApplicationList list = new ApplicationList();
                    list.Name = listElem.GetAttribute("Name");
                    list.Guid = new Guid(listElem.GetAttribute("Guid"));

                    foreach (XmlElement appListElem in listElem.SelectNodes("Applications/Application"))
                    {
                        Guid guid = new Guid(appListElem.GetAttribute("Guid"));

                        ApplicationJob job = DbManager.GetJob(guid);
                        if (job != null)
                        {
                            list.Applications.Add(job);
                        }
                    }

                    list.Save();
                }
            }            
        }
Пример #7
0
        public static void ImportFromFile(string filename)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(filename);

            // Import settings from file as dictionary
            XmlElement settingsElem = doc.SelectSingleNode("//Settings/dictionary") as XmlElement ??
                                      doc.SelectSingleNode("//dictionary") as XmlElement;

            if (settingsElem != null)
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary <string, string>));

                using (StringReader textReader = new StringReader(settingsElem.OuterXml))
                {
                    DbManager.SetSettings(serializer.Deserialize(textReader) as Dictionary <string, string>);
                }
            }

            // Import global variables
            XmlElement varNodes = doc.SelectSingleNode("//GlobalVariables") as XmlElement;

            if (varNodes != null)
            {
                UrlVariable.GlobalVariables.Clear();

                foreach (XmlElement varElem in doc.SelectNodes("//GlobalVariables/Variable"))
                {
                    UrlVariable newVar = new UrlVariable
                    {
                        Name          = varElem.GetAttribute("Name"),
                        CachedContent = varElem.GetAttribute("Content")
                    };
                    UrlVariable.GlobalVariables[newVar.Name] = newVar;
                }

                UrlVariable.GlobalVariables.Save();
            }

            // Import code snippets
            XmlElement snippetNodes = doc.SelectSingleNode("//CodeSnippets") as XmlElement;

            if (snippetNodes != null)
            {
                using (SQLiteCommand comm = DbManager.Connection.CreateCommand())
                {
                    comm.CommandText = "DELETE FROM snippets";
                    comm.ExecuteNonQuery();
                }

                foreach (XmlElement snippetElem in doc.SelectNodes("//CodeSnippets/Snippet"))
                {
                    Snippet snippet = new Snippet
                    {
                        Guid = new Guid(snippetElem.GetAttribute("Guid")),
                        Name = snippetElem.GetAttribute("Name"),
                        Type = (ScriptType)Convert.ToInt32(snippetElem.GetAttribute("Type")),
                        Text = snippetElem.InnerText
                    };
                    snippet.Save();
                }
            }

            XmlElement setupNodes = doc.SelectSingleNode("//SetupLists") as XmlElement;

            if (setupNodes != null)
            {
                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists_applications";
                    command.ExecuteNonQuery();
                }

                using (IDbCommand command = DbManager.Connection.CreateCommand())
                {
                    command.CommandText = @"DELETE FROM setuplists";
                    command.ExecuteNonQuery();
                }

                foreach (XmlElement listElem in doc.SelectNodes("//SetupLists/List"))
                {
                    ApplicationList list = new ApplicationList
                    {
                        Name = listElem.GetAttribute("Name"),
                        Guid = new Guid(listElem.GetAttribute("Guid"))
                    };

                    foreach (XmlElement appListElem in listElem.SelectNodes("Applications/Application"))
                    {
                        Guid guid = new Guid(appListElem.GetAttribute("Guid"));

                        ApplicationJob job = DbManager.GetJob(guid);
                        if (job != null)
                        {
                            list.Applications.Add(job);
                        }
                    }

                    list.Save();
                }
            }
        }