Exemplo n.º 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");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent"></param>
        private void AddContractOption(TreeNode parent)
        {
            TreeNodeValue tag = (TreeNodeValue)parent.Tag;
            if (tag == null)
                return;
            if (tag.Type != TreeNodeType.ApplicationContract)
                return;
            if (tag.Value == null)
                return;

            ContractSetting contractSetting = (ContractSetting)tag.Value;

            string optionName = StringInputBox.GetInputString(
                "Please input the name of the option. The first character " +
                "must be either a letter or an underscore, other characters " +
                "can be a letter, a digit or an underscore. For example, " +
                "NoLogo, noLogo, _NoLogo, NoLogo0, etc.",
                "Add Contract Option",
                EditorProject.NAME_PATTERN);

            if (optionName.Trim().Equals(string.Empty))
                return;

            bool hasOption =
                contractSetting.ContractOptionSettings.Count(
                (os) =>
                {
                    if (this.project.CaseSensitive)
                        return os.PropertyName.Equals(optionName);
                    else
                        return os.PropertyName.ToUpper().Equals(optionName);
                }) != 0;

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

            OptionSetting optionSetting = new OptionSetting(this.project, optionName);
            contractSetting.ContractOptionSettings.Add(optionSetting);

            TreeNode node = new TreeNode(optionName);
            node.SelectedImageKey =
                node.StateImageKey =
                node.ImageKey = KEY_OPTION;
            node.Tag = new TreeNodeValue(TreeNodeType.ApplicationContractOption, optionSetting);
            parent.Nodes.Add(node);
        }