示例#1
0
        static void Main(string[] args)
        {
            EditorProject project = EditorProject.Create();
            project.Name = "test project";
            project.ApplicationProviderSettings = new ApplicationProviderSettings();
            project.ApplicationProviderSettings.Logo = "logo";
            project.ApplicationProviderSettings.Description = "desc";

            project.ApplicationContractSettings = new ApplicationContractSettings();

            OptionSetting optionSetting1 = new OptionSetting(project);
            optionSetting1.PropertyName = "Method";
            optionSetting1.Attributes = new OptionAttribute();
            optionSetting1.Attributes.Name = "/nologo";
            ContractSetting contractSetting1 = new ContractSetting(project);
            contractSetting1.Name = "CalcContract";
            contractSetting1.Attributes = new OptionContractAttribute();
            contractSetting1.Attributes.Argument = "/method;/m";
            contractSetting1.ContractOptionSettings = new ContractOptionSettings();
            contractSetting1.ContractOptionSettings.Add(optionSetting1);

            project.ApplicationContractSettings.Add(contractSetting1);
            project.ApplicationContractSettings.Add(contractSetting1);

            project.ReferencedAssembliesSettings = new ReferencedAssembliesSettings();
            project.ReferencedAssembliesSettings.Add("System.dll");
            project.ReferencedAssembliesSettings.Add("System.Windows.Forms.dll");

            EditorProject.Save("C:\\editorproject.xml", project);

            //EditorProject project = EditorProject.Load("C:\\editorproject.xml");
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent"></param>
        private void AddContract(TreeNode parent)
        {
            // Get the name of the contract from user input.
            string contractName = StringInputBox.GetInputString(
                "Please input the name of the contract. The first character " +
                "must be either a letter or an underscore, other characters " +
                "can be a letter, a digit or an underscore. For example, " +
                "DisplayContract, displayContract, _displayContract, " +
                "DisplayContract0, etc.",
                "Add Contract",
                EditorProject.NAME_PATTERN);

            // Checks the value of the name.
            if (contractName.Trim().Equals(string.Empty))
                return;

            // Checks if the contract already exists.
            bool hasContract =
                this.project.ApplicationContractSettings.Count(
                (cs) =>
                {
                    if (this.project.CaseSensitive)
                        return cs.Name.Equals(contractName);
                    else
                        return cs.Name.ToUpper().Equals(contractName.ToUpper());
                }) != 0;

            if (hasContract)
            {
                MessageBox.Show(string.Format("The contract with the name '{0}' already exists.", contractName),
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // Create the new instance for the contract setting.
            ContractSetting setting = new ContractSetting(this.project, contractName);
            this.project.ApplicationContractSettings.Add(setting);

            // Create the tree node on the UI.
            TreeNode node = new TreeNode(contractName);
            node.SelectedImageKey =
                node.StateImageKey =
                node.ImageKey = KEY_CONTRACT;
            node.Tag = new TreeNodeValue(TreeNodeType.ApplicationContract, setting);
            parent.Nodes.Add(node);
        }