コード例 #1
0
ファイル: frmGScriptManager.cs プロジェクト: daxnet/guluwin
        private void EventHandler_New(object sender, System.EventArgs e)
        {
            try
            {
                TreeNode node = gscriptTreeView.SelectedNode;
                if (node != null)
                {
                    ScriptTreeNodeProperty prop = (ScriptTreeNodeProperty)node.Tag;
                    if (prop != null)
                    {
                        ScriptType type;
                        if (prop.Type == ScriptTreeNodeType.G ||
                            prop.Type == ScriptTreeNodeType.GRoot)
                        {
                            type = ScriptType.G;
                        }
                        else
                        {
                            type = ScriptType.Simple;
                        }

                        string name = StringInputBox.GetInputString(Resources.TEXT_INPUTNAME,
                                                                    Resources.TEXT_INPUTNAME_TITLE,
                                                                    SunnyChen.Common.RegularExpressions.RegularExpressionSet.IDENTIFIER);

                        if (name.Trim().Equals(string.Empty))
                        {
                            return;
                        }
                        string fileName = FileSystemScriptRepository.GetScriptFileName(name, type);
                        if (File.Exists(fileName))
                        {
                            MessageBox.Show(Resources.TEXT_SCRIPT_ALREADY_EXISTS,
                                            Resources.TEXT_ERROR,
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);

                            return;
                        }
                        frmCodeEditor codeEditor = new frmCodeEditor(parent__, compiler__, configReader__);
                        codeEditor.CreateNewCode(name, fileName, type);
                        codeEditor.Show();
                        toolbarsManager.Tools["mnuDelete"].SharedProps.Enabled  = false;
                        toolbarsManager.Tools["mnuRun"].SharedProps.Enabled     = false;
                        toolbarsManager.Tools["mnuCompile"].SharedProps.Enabled = false;
                    }
                }
            }
            catch
            {
            }
        }
コード例 #2
0
ファイル: frmCodeEditor.cs プロジェクト: daxnet/guluwin
        /// <summary>
        /// Loads the script code into code editor.
        /// </summary>
        /// <param name="_name">Name of the script.</param>
        /// <param name="_scriptType">Type of the script.</param>
        /// <param name="_openReadOnly">Determines if the script should be opened read-only.</param>
        public void LoadExistingCode(string _name, ScriptType _scriptType, bool _openReadOnly)
        {
            using (new LengthyOperation(parent__))
            {
                try
                {
                    name__ = _name;
                    type__ = _scriptType;
                    Text   = string.Format(SunnyChen.Gulu.Win.Properties.Resources.TEXT_CODEEDITOR_TITLE, name__, type__);

                    string content = scriptRepository__.GetContent(_name, _scriptType);
                    syntaxDocument1.Text = content;
                    editor.ReadOnly      = _openReadOnly;
                    this.BuildCodeStruct(content);
                    editor.Focus();

                    fileName__ = FileSystemScriptRepository.GetScriptFileName(_name, _scriptType);
                }
                catch
                {
                }
            }
        }