Пример #1
0
        /// <summary>
        /// Create A Project
        /// </summary>
        /// <param name="guiGoodLog"></param>
        /// <param name="treeView1"></param>
        /// <returns></returns>
        public Tuple <string, string> CreateProject(RichTextBox guiGoodLog, TreeView treeView1, string ProjectName)
        {
            string ProjectPath = "";

            //Create a new Project
            ProjectName = FunctionsLibrary.ShowDialog("Please enter the name of the Project:", "New Project");
            if (ProjectName == null || ProjectName == "")
            {
                return(null);
            }
            if (Directory.Exists(ProjectName) == false && File.Exists(ProjectName) == false)
            {
                DirectoryInfo path = Directory.CreateDirectory(ProjectName);
                ProjectPath = Environment.CurrentDirectory.ToString() + "\\" + path.ToString();
            }
            else
            {
                FunctionsLibrary.AppendText(guiGoodLog, "That project name already exists. \n", Color.Red);
                MessageBox.Show("That name already exists.");
            }
            treeView1.Nodes.Clear();
            TreeNode rootNode = new TreeNode("Project Suite '" + ProjectName + "' (0 Script(s))");

            rootNode.ImageIndex = 0;
            treeView1.Nodes.Add(rootNode);
            treeView1.ExpandAll();
            FunctionsLibrary.AppendText(guiGoodLog, "Project created. \n", Color.Blue);
            return(new Tuple <string, string>(ProjectName, ProjectPath));
        }
Пример #2
0
 /// <summary>
 /// Scan Process for Objects
 /// </summary>
 /// <param name="ProcessName"></param>
 /// <param name="listView2"></param>
 /// <param name="userControl"></param>
 /// <param name="guiGoodLog"></param>
 /// <returns></returns>
 public bool ScanProcess(string ProcessName, ListView listView2, UserControl userControl, RichTextBox guiGoodLog)
 {
     listView2.Items.Clear();
     userControl.LoadObjects(ProcessName, listView2);
     ProcessNameTemp = ProcessName;
     if (listView2.Items.Count > 0)
     {
         FunctionsLibrary.AppendText(guiGoodLog, "Retrieved Components from Process: " + ProcessName + " ... " + listView2.Items.Count.ToString() + " Control(s) found. \n", Color.Blue);
     }
     return(true);
 }
Пример #3
0
        /// <summary>
        /// Save script
        /// </summary>
        /// <param name="ProjectName"></param>
        /// <param name="ProjectPath"></param>
        /// <param name="listView1"></param>
        /// <param name="scriptComboBox"></param>
        /// <param name="tabControl1"></param>
        /// <param name="guiGoodLog"></param>
        /// <returns></returns>
        public bool SaveScript(string ProjectName, string ProjectPath, ListView listView1, ComboBox scriptComboBox, TabControl tabControl1, RichTextBox guiGoodLog)
        {
            //If Project File was Created!
            if (ProjectName != null)
            {
                ScriptRunner.ProjectName = ProjectName;
                ScriptRunner.ProjectPath = ProjectPath;
                switch (tabControl1.SelectedTab.Text)
                {
                //If on Script Creator, save Script
                case "Script Creator":
                    if (scriptComboBox.SelectedIndex != -1)
                    {
                        using (StreamWriter sw = new StreamWriter(ProjectPath + "\\" + scriptComboBox.SelectedItem.ToString(), false))
                        {
                            sw.WriteLine("//GuiScript -- Scripting Edition: 1.0 --");
                            int counter = 1;
                            foreach (ListViewItem item in listView1.Items)
                            {
                                sw.WriteLine("//Path : " + counter.ToString());
                                counter++;
                                sw.WriteLine(item.SubItems[0].Text + "|" + item.SubItems[1].Text + "|" + item.SubItems[2].Text);
                            }
                            sw.WriteLine("//GuiScript -- END --");
                        }
                        FunctionsLibrary.AppendText(guiGoodLog, "Script saved. \n", Color.Blue);
                        return(true);
                    }
                    else
                    {
                        FunctionsLibrary.AppendText(guiGoodLog, "No script selected. \n", Color.Red);
                        MessageBox.Show("No script selected.");
                        return(false);
                    }
                    break;

                //If on Project Viewer, save Project
                case "Project Viewer":
                    return(false);

                    break;
                }
                return(false);
            }
            else
            {
                MessageBox.Show("You have not created a Project!");
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// Create a new Script
        /// </summary>
        /// <param name="ProjectPath"></param>
        /// <param name="guiGoodLog"></param>
        /// <param name="ProjectName"></param>
        /// <param name="scriptComboBox"></param>
        /// <param name="treeView1"></param>
        /// <returns></returns>
        public bool NewScript(string ProjectPath, RichTextBox guiGoodLog, string ProjectName, ComboBox scriptComboBox, TreeView treeView1)
        {
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.InitialDirectory = ProjectPath;
            saveDialog.Filter           = "GuiScript (*.gs)|*.gs";
            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                var myFile = File.Create(saveDialog.FileName);
                myFile.Dispose();
                loadScripts(ProjectPath, ProjectName, scriptComboBox, treeView1);
            }
            saveDialog.Dispose();
            FunctionsLibrary.AppendText(guiGoodLog, "Created a new script. \n", Color.Blue);
            return(true);
        }
Пример #5
0
        /// <summary>
        /// Open a Project
        /// </summary>
        /// <param name="ProjectPath"></param>
        /// <param name="ProjectName"></param>
        /// <param name="scriptComboBox"></param>
        /// <param name="treeView1"></param>
        /// <param name="guiGoodLog"></param>
        /// <returns></returns>
        public Tuple <string, string> OpenProject(string ProjectPath, string ProjectName, ComboBox scriptComboBox, TreeView treeView1, RichTextBox guiGoodLog)
        {
            //Load Project
            FolderBrowserDialog openProject = new FolderBrowserDialog();

            openProject.SelectedPath = Environment.CurrentDirectory;
            if (openProject.ShowDialog() == DialogResult.OK)
            {
                ProjectPath = openProject.SelectedPath;
                ProjectName = System.IO.Path.GetFileName(openProject.SelectedPath);
                ScriptRunner.ProjectName = ProjectName;
                ScriptRunner.ProjectPath = ProjectPath;
                DirectoryInfo d = new DirectoryInfo(openProject.SelectedPath);
                scriptComboBox.Items.Clear();
                foreach (var file in d.GetFiles("*.gs"))
                {
                    scripts.Add(file.Name);
                    scriptComboBox.Items.Add(file.Name);
                }
            }

            numberOfScripts = scripts.Count();
            treeView1.Nodes.Clear();

            //Fill Tree
            TreeNode rootNode = new TreeNode("Project Suite '" + ProjectName + "' (" + numberOfScripts + " Script(s))");

            foreach (var script in scripts)
            {
                //Add Script Node
                TreeNode testNode = new TreeNode(script.ToString());
                testNode.ImageIndex         = 1;
                testNode.SelectedImageIndex = 1;
                rootNode.Nodes.Add(testNode);
            }

            //root Node
            rootNode.ImageIndex = 0;
            treeView1.Nodes.Add(rootNode);
            treeView1.ExpandAll();
            openProject.Dispose();
            FunctionsLibrary.AppendText(guiGoodLog, "Loaded Project \n", Color.Blue);
            return(new Tuple <string, string>(ProjectName, ProjectPath));
        }
Пример #6
0
 /// <summary>
 /// View Script in Viewer
 /// </summary>
 /// <param name="e"></param>
 /// <param name="designView"></param>
 /// <param name="ProjectPath"></param>
 /// <returns></returns>
 public bool ViewScript(TreeNodeMouseClickEventArgs e, RichTextBox designView, string ProjectPath)
 {
     ScriptRunner.ProjectPath = ProjectPath;
     designView.Text          = "";
     if (e.Node != null)
     {
         if (e.Node.Text.Contains(".gs"))
         {
             ScriptRunner.ScriptName = e.Node.Text;
             //Clicked Script
             FunctionsLibrary.AppendText(designView, "GuiScript START :: \n", Color.Black);
             FunctionsLibrary.AppendText(designView, "    [PATH] : \n", Color.Purple);
             try
             {
                 using (StreamReader sw = new StreamReader(ProjectPath + "\\" + e.Node.Text))
                 {
                     string line;
                     while ((line = sw.ReadLine()) != null)
                     {
                         if (!line.StartsWith("//"))
                         {
                             //Parse
                             string[] parsed = line.Split('|');
                             //Object Name
                             FunctionsLibrary.AppendText(designView, "        ", Color.Black);
                             FunctionsLibrary.AppendText(designView, " [NAME] ", Color.Blue);
                             FunctionsLibrary.AppendText(designView, parsed[0], Color.Black);
                             FunctionsLibrary.AppendText(designView, " [INVOKE] ", Color.Blue);
                             FunctionsLibrary.AppendText(designView, parsed[1] + "\n", Color.Black);
                         }
                     }
                     FunctionsLibrary.AppendText(designView, "    [END PATH] : \n", Color.Purple);
                     FunctionsLibrary.AppendText(designView, "GuiScript END :: \n", Color.Black);
                 }
                 return(true);
             }
             catch { return(false); }
         }
         return(false);
     }
     return(false);
 }