コード例 #1
0
        private void Action(string tag)
        {
            switch (tag)
            {
            case "NEW_PROF":
                //NewProfile();
                break;

            case "CREATE_ENV":
                using (NewEnvForm env = new NewEnvForm()) {
                    if (env.ShowDialog().Equals(DialogResult.OK))
                    {
                        // Check if exist name

                        if (_envVariables.SetEnvironmentVariable(env.EnvName, env.EnvValue))
                        {
                            using (RestartForm r = new RestartForm(env.EnvName, tag)) {
                                if (r.ShowDialog().Equals(DialogResult.OK))
                                {
                                    Application.Restart();
                                }
                                else
                                {
                                    InitEnvironmentVariables();
                                }
                            }
                        }
                    }
                }
                break;

            case "ENV_UPDATE":
                DialogResult resu = MessageBox.Show(string.Format("Are you sure you want to update {0} in environment variable?", txtEnvName.Text), "Update Environment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (resu.Equals(DialogResult.Yes))
                {
                    if (_envVariables.SetEnvironmentVariable(txtEnvName.Text, txtEnvValue.Text))
                    {
                        using (RestartForm r = new RestartForm(txtEnvName.Text, tag)) {
                            if (r.ShowDialog().Equals(DialogResult.OK))
                            {
                                InitEnvironmentVariables();
                            }
                        }
                    }
                }
                break;

            case "ENV_DELETE":
                DialogResult resd = MessageBox.Show(string.Format("Are you sure you want to delete {0} in environment variable?", txtEnvName.Text), "Delete Environment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (resd.Equals(DialogResult.Yes))
                {
                    if (_envVariables.DeleteEnvironmentVariable(txtEnvName.Text))
                    {
                        using (RestartForm r = new RestartForm(txtEnvName.Text, tag)) {
                            if (r.ShowDialog().Equals(DialogResult.OK))
                            {
                                InitEnvironmentVariables();
                            }
                        }
                    }
                }
                break;

            case "FIND":
                break;

            case "SAVE":
                if (_isLoading)
                {
                    return;
                }
                using (NewArchive na = new NewArchive()) {
                    if (na.ShowDialog().Equals(DialogResult.OK))
                    {
                    }
                }
                break;

            case "ADD_FILE":
                AddFiles(AddFile.FILES);
                break;

            case "ADD_FOLDER":
                AddFiles(AddFile.FOLDER);
                break;

            case "REFRESH":
                InitWorkspace();
                break;

            case "SERVER_CONFIG":
            case "OPTIONS":
                using (ConfigServerForm config = new ConfigServerForm(tag.Equals("SERVER_CONFIG") ? 1 : 0)) {
                    if (config.ShowDialog().Equals(DialogResult.OK))
                    {
                        InitSettings();
                    }
                }
                break;

            case "EXIT":
                Close();
                break;

            case "ABOUT":
                using (AboutForm about = new AboutForm()) {
                    about.ShowDialog();
                }
                break;

            case "HELP":
                using (HelpForm help = new HelpForm()) {
                    help.ShowDialog();
                }
                break;

            case "TOOLBAR":
                RegConfig.Set <bool>("Toolbar", hideToolbarToolStripMenuItem.Checked);
                toolStripUploader.Visible = hideToolbarToolStripMenuItem.Checked;
                break;

            case "STATUSBAR":
                RegConfig.Set <bool>("Statusbar", hideStatusbarToolStripMenuItem.Checked);
                statusStripUploader.Visible = hideStatusbarToolStripMenuItem.Checked;
                break;

            case "PROFILE_DETAILS":
                break;

            case "PROFILE_EXPLORER":
                RegConfig.Set <bool>("ProfileExplorer", profileExplorerToolStripMenuItem.Checked);
                splitContainer1.Panel1Collapsed = !profileExplorerToolStripMenuItem.Checked;
                break;

            case "LOGS":
                RegConfig.Set <bool>("Logs&Details", logsToolStripMenuItem.Checked);
                splitContainer2.Panel2Collapsed = !logsToolStripMenuItem.Checked;
                break;

            case "CLEAR_WORKSPACE":
                if (_archives != null)
                {
                    if (MessageBox.Show("Workspace will be deleted permanently!\nAre you sure you want to clear all workspace?", "Clear Workspace", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                        List <Archive> ws = _archives.GetProfiles();
                        if (ws.Count > 0)
                        {
                            foreach (Archive w in ws)
                            {
                            }
                        }
                        _archives.ClearWorkspaces();
                        InitWorkspace();
                    }
                }
                break;

            case "CLEAR_LOGS":
                if (_logs != null)
                {
                    if (MessageBox.Show("Logs will be deleted permanently!\nAre you sure you want to clear all logs?", "Clear Logs", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                        _logs.ClearAllLog();
                        _logs.Initialize(logsListBox);
                    }
                }
                break;

            case "CLEAR_HISTORY":
                if (_selectedArchive != null)
                {
                    if (MessageBox.Show("History will be deleted permanently!\nAre you sure you want to clear all history?", "Clear History", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes))
                    {
                    }
                }
                break;

            case "SOURCE_EXT":
            case "SOURCE_FOLDER":

                break;

            default:
                break;
            }
        }