コード例 #1
0
        //-------------------------------------------------------------------------

        private void PopulateLinkedShortcutsLists(Project project,
                                                  TemplateShortcutEntry entry)
        {
            // linked shortcuts
            foreach (string desc in entry.LinkedShortcuts)
            {
                TemplateShortcutEntry tmpEntry = project.Template.GetEntryWithDescription(desc) as TemplateShortcutEntry;

                if (tmpEntry == entry || tmpEntry == null)
                {
                    continue;
                }

                linkedShortcutList.Items.Add(tmpEntry);
            }

            // unlinked shortcuts
            foreach (TemplateShortcutEntry tmpEntry in project.Template.FileShortcuts)
            {
                if (tmpEntry == entry)
                {
                    continue;
                }

                if (linkedShortcutList.Items.Contains(tmpEntry) == false)
                {
                    shortcutsList.Items.Add(tmpEntry);
                }
            }
        }
コード例 #2
0
        //-------------------------------------------------------------------------

        private void resetBtn_Click(object sender, EventArgs e)
        {
            if (entryList.SelectedItem == null)
            {
                return;
            }

            TemplateShortcutEntry entry = entryList.SelectedItem as TemplateShortcutEntry;

            if (entry != null)
            {
                DateTime runTime =
                    new DateTime(DateTime.Now.Year,
                                 DateTime.Now.Month,
                                 DateTime.Now.Day,
                                 runTimePicker.Value.Hour,
                                 runTimePicker.Value.Minute,
                                 0);

                entry.NextScheduledRunTime = runTime;

                while (entry.NextScheduledRunTime < DateTime.Now)
                {
                    entry.NextScheduledRunTime = entry.NextScheduledRunTime.AddDays(1.0);
                }

                entry.Project.WriteToFile();
            }

            RefreshDisplayedInfo();
        }
コード例 #3
0
ファイル: TemplateXml.cs プロジェクト: melzatkinson/Alice
        //-------------------------------------------------------------------------

        public void LoadFromFile(string fullFilename)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(fullFilename);

            // template info
            XmlNodeList nodes       = xmlDoc.GetElementsByTagName("Info");
            XmlElement  infoElement = nodes[0] as XmlElement;

            m_name = infoElement.Attributes["name"].Value;

            if (infoElement.HasAttribute("isArchived"))
            {
                m_isArchived = Boolean.Parse(infoElement.Attributes["isArchived"].Value);
            }

            // entries
            XmlNodeList entryElements = xmlDoc.GetElementsByTagName("Entry");

            foreach (XmlNode xmlNode in entryElements)
            {
                TemplateEntry newEntry = null;

                // get the type
                XmlElement entryElement = (xmlNode as XmlElement);

                string type = entryElement.Attributes["type"].Value;

                // create the specified type of entry
                switch (type)
                {
                case TemplateShortcutEntry.c_typeName:
                    newEntry = new TemplateShortcutEntry(entryElement);
                    break;

                case TemplateCommonValueCollectionEntry.c_typeName:
                    newEntry = new TemplateCommonValueCollectionEntry(entryElement);
                    break;
                }

                // add it to the list
                if (newEntry != null)
                {
                    AddEntry(newEntry);
                }
            }
        }
コード例 #4
0
        //-------------------------------------------------------------------------

        private void removeBtn_Click(object sender, EventArgs e)
        {
            if (entryList.SelectedItem == null)
            {
                return;
            }

            TemplateShortcutEntry entry = entryList.SelectedItem as TemplateShortcutEntry;

            if (entry != null)
            {
                entry.ScheduledRunEnabled = false;
                entry.Project.WriteToFile();
            }

            PopulateEntriesList();
        }
コード例 #5
0
        //-------------------------------------------------------------------------

        private void RefreshDisplayedInfo()
        {
            if (entryList.SelectedItem == null)
            {
                projectLbl.Text = "";
                nextRunLbl.Text = "";
                return;
            }

            TemplateShortcutEntry entry = entryList.SelectedItem as TemplateShortcutEntry;

            if (entry != null)
            {
                projectLbl.Text     = entry.Project.Name;
                nextRunLbl.Text     = entry.NextScheduledRunTime.ToString();
                runTimePicker.Value = entry.NextScheduledRunTime;
            }
        }
コード例 #6
0
        //-------------------------------------------------------------------------

        private void copyToClipboardArgStringBtn_Click(object sender, EventArgs e)
        {
            try
            {
                UpdateArgEnabledStates();

                Project prj = (projectCbo.SelectedItem as Project);

                string filePath = prj.GetCommonValue(fullFilenameTxt.Text, false);

                string argStr = TemplateShortcutEntry.GetArgumentString(m_args, m_argStates, prj);

                Clipboard.SetText(filePath + " " + argStr);
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
コード例 #7
0
        //-------------------------------------------------------------------------

        public TemplateShortcutSetupForm(Project project,
                                         bool canChangeProject,
                                         TemplateShortcutEntry entry)
        {
            try
            {
                InitializeComponent();

                projectCbo.Enabled = canChangeProject;

                m_args      = new Dictionary <string, string>(entry.Arguments);
                m_argStates = new Dictionary <string, bool>(entry.ArgumentStates);
                m_vars      = new Dictionary <string, string>(entry.EnvironmentVars);
                m_varStates = new Dictionary <string, bool>(entry.EnvironmentVarStates);

                shortcutNameTxt.Text = entry.Description;
                groupCbo.Text        = entry.UiGroupName;
                fullFilenameTxt.Text = entry.Filename;
                confirmBeforeRunningChkBox.Checked = entry.ConfirmBeforeRunning;
                scheduledRunChkBox.Checked         = entry.ScheduledRunEnabled;

                try
                {
                    scheduledRunTimePicker.Value = entry.NextScheduledRunTime;
                }
                catch
                {
                    // do nothing
                }

                PopulateProjects(project);
                PopulateGroups(project);
                PopulateCommonValues();
                PopulateLinkedShortcutsLists(project, entry);

                RefreshArgsList();
                RefreshVarsList();
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
コード例 #8
0
        //-------------------------------------------------------------------------

        private void viewArgStringBtn_Click(object sender, EventArgs e)
        {
            try
            {
                UpdateArgEnabledStates();

                Project prj = (projectCbo.SelectedItem as Project);

                string filePath = prj.GetCommonValue(fullFilenameTxt.Text, false);

                string argStr = TemplateShortcutEntry.GetArgumentString(m_args, m_argStates, prj);

                MessageBox.Show(filePath + " " + argStr,
                                "Argument String",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: melzatkinson/Alice
        //-------------------------------------------------------------------------

        private void deleteShortcutBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (shortcutTree.SelectedNode == null)
                {
                    return;
                }

                if (projectList.SelectedItem != null)
                {
                    TemplateShortcutEntry entry = (shortcutTree.SelectedNode.Tag as TemplateShortcutEntry);

                    if (entry == null)
                    {
                        return;
                    }

                    if (MessageBox.Show("Delete shortcut '" + entry.Description + "'?",
                                        "Delete Shortcut?",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Exclamation,
                                        MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        Project prj = (projectList.SelectedItem as Project);

                        prj.Template.DeleteEntry(entry);
                        prj.WriteToFile();

                        RefreshShortcutTree();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
コード例 #10
0
ファイル: MainForm.cs プロジェクト: melzatkinson/Alice
        //-------------------------------------------------------------------------

        private void copyShortcutBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (shortcutTree.SelectedNode == null)
                {
                    return;
                }

                // get the project
                Project prj = (projectList.SelectedItem as Project);

                // do the new template shortcut dialog
                TemplateShortcutEntry copy = (shortcutTree.SelectedNode.Tag as TemplateShortcutEntry).CreateCopy();

                TemplateShortcutSetupForm form = new TemplateShortcutSetupForm(prj, true, copy);

                bool showDlg = true;

                while (showDlg) // keep showing the dialog until user input is ok
                {
                    form.ShowDialog();

                    if (form.DialogResult == DialogResult.OK)
                    {
                        // may have changed if user is copying to a different project
                        prj = form.Project;

                        // check name doesn't already exist
                        showDlg = false;

                        foreach (TemplateEntry entry in prj.Template.FileShortcuts)
                        {
                            if (entry.Description.ToLower() == form.Description.ToLower())
                            {
                                showDlg = true;

                                ErrorMsg("Name '" + entry.Description + "' already exists.");
                            }
                        }
                    }
                    else // user cancelled the dlg
                    {
                        return;
                    }
                }

                // update the project
                copy.Project              = form.Project;
                copy.Description          = form.Description;
                copy.Filename             = form.Filename;
                copy.UiGroupName          = form.Group;
                copy.Arguments            = new Dictionary <string, string>(form.Arguments);
                copy.ArgumentStates       = new Dictionary <string, bool>(form.ArgumentStates);
                copy.EnvironmentVars      = new Dictionary <string, string>(form.EnvironmentVars);
                copy.EnvironmentVarStates = new Dictionary <string, bool>(form.EnvironmentVarStates);
                copy.LinkedShortcuts      = new List <string>(form.LinkedShortcuts);
                copy.ConfirmBeforeRunning = form.ConfirmBeforeRunning;
                copy.ScheduledRunEnabled  = form.ScheduledRunEnabled;
                copy.NextScheduledRunTime = form.ScheduledRunTime;

                prj = form.Project;

                prj.Template.AddEntry(copy);
                prj.WriteToFile();

                form.Close();
                form.Dispose();

                RefreshShortcutTree();
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
            }
        }
コード例 #11
0
        //-------------------------------------------------------------------------

        public TemplateShortcutEntry CreateCopy()
        {
            TemplateShortcutEntry copy = new TemplateShortcutEntry();

            copy.Description            = "Copy of " + Description;
            copy.Filename               = m_filename;
            copy.m_uiGroupName          = m_uiGroupName;
            copy.m_confirmBeforeRunning = m_confirmBeforeRunning;
            copy.m_scheduledRunEnabled  = m_scheduledRunEnabled;
            copy.m_nextScheduledRunTime = m_nextScheduledRunTime;

            foreach (string key in m_args.Keys)
            {
                string value = "";
                if (m_args.TryGetValue(key, out value))
                {
                    copy.Arguments.Add(key, value);
                }
                else
                {
                    // TODO
                }
            }

            foreach (string key in m_environmentVars.Keys)
            {
                string value = "";
                if (m_environmentVars.TryGetValue(key, out value))
                {
                    copy.EnvironmentVars.Add(key, value);
                }
                else
                {
                    // TODO
                }
            }

            foreach (string key in m_argStates.Keys)
            {
                bool enabled;
                if (m_argStates.TryGetValue(key, out enabled))
                {
                    copy.ArgumentStates.Add(key, enabled);
                }
                else
                {
                    // TODO
                }
            }

            foreach (string key in m_environmentVarStates.Keys)
            {
                bool enabled;
                if (m_environmentVarStates.TryGetValue(key, out enabled))
                {
                    copy.EnvironmentVarStates.Add(key, enabled);
                }
                else
                {
                    // TODO
                }
            }

            foreach (string entry in m_linkedShortcutDescriptions)
            {
                copy.LinkedShortcuts.Add(entry);
            }

            return(copy);
        }
コード例 #12
0
        //-------------------------------------------------------------------------

        private void createBtn_Click(object sender, EventArgs e)
        {
            //-- Validate input.
            if (typeCbo.Text == "" ||
                masterconfigTxt.Text == "" ||
                nameTxt.Text == "" ||
                sourceFolderTxt.Text == "" ||
                sourceFolderTxt.Text == c_exampleSourceFolder)
            {
                ErrorMsg("Incomplete information!");
                return;
            }

            //-- Create a Project.
            try
            {
                m_project = Program.g_projectManager.CreateProject(nameTxt.Text);
            }
            catch (Exception ex)
            {
                ErrorMsg(ex.Message);
                return;
            }

            //-- Profiles?
            bool useTestProfileOnly = (profilesCbo.Text == "TEST ONLY");

            //-- Create profiles.
            TemplateCommonValueCollectionEntry newProfile = new TemplateCommonValueCollectionEntry();

            newProfile.Description = "TEST";
            newProfile.Values.Add("PRJ_PROFILE", "TEST");
            newProfile.Values.Add("PRJ_DEVELOPER_MODE", "0");
            newProfile.Values.Add("PRJ_FOLDER_DEPOLOYED_PROJECT", deployedFolderTxt.Text);
            newProfile.Values.Add("PRJ_MASTERCONFIG", deployedFolderTxt.Text + masterconfigTxt.Text + ".masterconfig");
            newProfile.Values.Add("PRJ_LAUNCH_BAT", projectFolderTxt.Text + "Launch.bat");
            m_project.Template.AddEntry(newProfile);

            if (useTestProfileOnly == false)
            {
                newProfile             = new TemplateCommonValueCollectionEntry();
                newProfile.Description = "DEV";
                newProfile.Values.Add("PRJ_PROFILE", "DEV");
                newProfile.Values.Add("PRJ_DEVELOPER_MODE", "1");
                newProfile.Values.Add("PRJ_FOLDER_DEPOLOYED_PROJECT", m_devDeployFolder);
                newProfile.Values.Add("PRJ_MASTERCONFIG", m_devDeployFolder + masterconfigTxt.Text + ".masterconfig");
                newProfile.Values.Add("PRJ_LAUNCH_BAT", projectFolderTxt.Text + "Launch.bat");
                m_project.Template.AddEntry(newProfile);
            }

            //-- Create shortcuts.
            TemplateShortcutEntry newShortcut = new TemplateShortcutEntry();

            newShortcut.Description          = "Build (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = projectFolderTxt.Text + "Build.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = true;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Gather (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = projectFolderTxt.Text + "Gather.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = true;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Deploy (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = projectFolderTxt.Text + "Deploy.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = false;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Deploy Binder Art";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = Program.g_driveLetter + @":\dev\main\Source\Sim400\Bin\SimDeploy_BinderArt.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = false;
            m_project.Template.AddEntry(newShortcut);

            newShortcut                      = new TemplateShortcutEntry();
            newShortcut.Description          = "Launch (PRJ_PROFILE)";
            newShortcut.Type                 = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename             = @"ALICE_APP_PATH\res\DevMasterConfigLaunch.bat";
            newShortcut.UiGroupName          = "Shortcuts";
            newShortcut.ConfirmBeforeRunning = false;
            newShortcut.EnvironmentVars.Add("DEVELOPERMODE", "PRJ_DEVELOPER_MODE");
            newShortcut.EnvironmentVarStates.Add("DEVELOPERMODE", true);
            newShortcut.EnvironmentVars.Add("MASTERCONFIGPATH", "PRJ_MASTERCONFIG");
            newShortcut.EnvironmentVarStates.Add("MASTERCONFIGPATH", true);
            newShortcut.EnvironmentVars.Add("LAUNCHPATH", "PRJ_LAUNCH_BAT");
            newShortcut.EnvironmentVarStates.Add("LAUNCHPATH", true);
            m_project.Template.AddEntry(newShortcut);

            //-- Create folder shortcuts.
            newShortcut             = new TemplateShortcutEntry();
            newShortcut.Description = "Project";
            newShortcut.Type        = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename    = projectFolderTxt.Text;
            newShortcut.UiGroupName = "Folders";
            m_project.Template.AddEntry(newShortcut);

            newShortcut             = new TemplateShortcutEntry();
            newShortcut.Description = "Deployed Project";
            newShortcut.Type        = TemplateEntry.EntryType.Type_Shortcut;
            newShortcut.Filename    = "PRJ_FOLDER_DEPOLOYED_PROJECT";
            newShortcut.UiGroupName = "Folders";
            m_project.Template.AddEntry(newShortcut);

            //-- Save.
            m_project.WriteToFile();

            //-- Copy the files to the project folder.
            try
            {
                // Build .bat file.
                string batFilenameSrc  = Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Build.bat";
                string batFilenameDest = projectFolderTxt.Text + "Build.bat";

                // File already exists?
                if (File.Exists(batFilenameDest))
                {
                    if (MessageBox.Show("'" + batFilenameDest + "' already exists, replace?",
                                        "Replace existing file?",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        File.SetAttributes(batFilenameDest, File.GetAttributes(batFilenameDest) & ~FileAttributes.ReadOnly);
                        File.Delete(batFilenameDest);
                    }
                }

                // Copy it.
                File.Copy(batFilenameSrc,
                          batFilenameDest,
                          true);

                // Gather .bat file.
                CreateGatherBatchFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Gather.bat",
                                                  projectFolderTxt.Text + "Gather.bat");

                // Gather .deploy files.
                CreateGatherDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Gather.deploy",
                                                   projectFolderTxt.Text + "Gather.deploy",
                                                   false);

                if (useTestProfileOnly == false)
                {
                    CreateGatherDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Gather.deploy",
                                                       projectFolderTxt.Text + "DEV_Gather.deploy",
                                                       true);
                }

                // Deploy .bat file.
                string newDeployFilename = projectFolderTxt.Text + "Deploy.bat";
                bool   copyDeployFile    = true;

                // File already exists?
                if (File.Exists(newDeployFilename))
                {
                    if (MessageBox.Show("'" + newDeployFilename + "' already exists, replace?",
                                        "Replace existing file?",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        File.SetAttributes(newDeployFilename, File.GetAttributes(newDeployFilename) & ~FileAttributes.ReadOnly);
                        File.Delete(newDeployFilename);
                    }
                    else
                    {
                        copyDeployFile = false;
                    }
                }

                if (copyDeployFile)
                {
                    File.Copy(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Deploy.bat", newDeployFilename);
                }

                // SimDeploy.xml files.
                CreateSimDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\SimDeploy.xml",
                                                projectFolderTxt.Text + "SimDeploy.xml",
                                                false);

                if (useTestProfileOnly == false)
                {
                    CreateSimDeployFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\SimDeploy.xml",
                                                    projectFolderTxt.Text + "DEV_SimDeploy.xml",
                                                    true);
                }

                // Launch .bat file.
                CreateLaunchBatchFileFromTemplate(Program.g_path + @"\res\GenerateContainerProject\" + typeCbo.Text + @"\Launch.bat",
                                                  projectFolderTxt.Text + "Launch.bat");
            }
            catch (Exception ex)
            {
                ErrorMsg("Error while copying batch files to the project folder:\n\n" + ex.Message);
            }

            //-- Done.
            Hide();
        }