Beispiel #1
0
        /// <summary>
        /// Called by VS whenever the user clicks on the ellipsis in the
        /// properties window for a property to which this editor is linked.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(
            System.ComponentModel.ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            // Get a reference to the underlying property element
            ElementPropertyDescriptor descriptor = context.PropertyDescriptor as ElementPropertyDescriptor;
            ModelElement underlyingModelElent    = descriptor.ModelElement;

            // context.Instance also returns a model element, but this will either
            // be the shape representing the underlying element (if you selected
            // the element via the design surface), or the underlying element
            // itself (if you selected the element via the model explorer)
            ModelElement element               = context.Instance as ModelElement;
            string       property_Name         = element.GetProperties()["Name"].GetValue(element.GetProperties()["Name"]).ToString();
            FeatureKind  property_Kind         = (FeatureKind)element.GetProperties()["Kind"].GetValue(element.GetProperties()["Kind"]);
            string       property_Condition    = element.GetProperties()["Condition"].GetValue(element.GetProperties()["Condition"]).ToString();
            string       property_Constraint   = element.GetProperties()["Constraint"].GetValue(element.GetProperties()["Constraint"]).ToString();
            string       property_Requirements = element.GetProperties()["Requirements"].GetValue(element.GetProperties()["Requirements"]).ToString();

            FeatureProperties featureProperties = new FeatureProperties();

            featureProperties.NameTextBox.Text         = property_Name;
            featureProperties.ConditionTextBox.Text    = property_Condition;
            featureProperties.ConstraintTextBox.Text   = property_Constraint;
            featureProperties.RequirementsTextBox.Text = property_Requirements;
            featureProperties.KindComboBox.Text        = property_Kind.ToString();

            if (featureProperties.ShowDialog() == DialogResult.OK)
            {
                element.GetProperties()["Name"].SetValue(element.GetProperties()["Name"], featureProperties.NameTextBox.Text);
                switch (featureProperties.KindComboBox.Text)
                {
                case "Mandatory":
                    element.GetProperties()["Kind"].SetValue(element.GetProperties()["Kind"], FeatureKind.Mandatory);
                    break;

                case "Optional":
                    element.GetProperties()["Kind"].SetValue(element.GetProperties()["Kind"], FeatureKind.Optional);
                    break;

                case "FeatureSetFeature":
                    element.GetProperties()["Kind"].SetValue(element.GetProperties()["Kind"], FeatureKind.FeatureSetFeature);
                    break;
                }
                element.GetProperties()["Condition"].SetValue(element.GetProperties()["Condition"], featureProperties.ConditionTextBox.Text);
                element.GetProperties()["Constraint"].SetValue(element.GetProperties()["Constraint"], featureProperties.ConstraintTextBox.Text);
                element.GetProperties()["Requirements"].SetValue(element.GetProperties()["Requirements"], featureProperties.RequirementsTextBox.Text);
            }

            return(value);
        }
        public override void OnFieldDoubleClick(ShapeField field, DiagramPointEventArgs e)
        {
            string      property_Name         = this.ModelElement.GetProperties()["Name"].GetValue(this.ModelElement.GetProperties()["Name"]).ToString();
            FeatureKind property_Kind         = (FeatureKind)this.ModelElement.GetProperties()["Kind"].GetValue(this.ModelElement.GetProperties()["Kind"]);
            string      property_Condition    = this.ModelElement.GetProperties()["Condition"].GetValue(this.ModelElement.GetProperties()["Condition"]).ToString();
            string      property_Constraint   = this.ModelElement.GetProperties()["Constraint"].GetValue(this.ModelElement.GetProperties()["Constraint"]).ToString();
            string      property_Requirements = this.ModelElement.GetProperties()["Requirements"].GetValue(this.ModelElement.GetProperties()["Requirements"]).ToString();

            FeatureProperties featureProperties = new FeatureProperties();


            featureProperties.NameTextBox.Text         = property_Name;
            featureProperties.ConditionTextBox.Text    = property_Condition;
            featureProperties.ConstraintTextBox.Text   = property_Constraint;
            featureProperties.RequirementsTextBox.Text = property_Requirements;
            featureProperties.KindComboBox.Text        = property_Kind.ToString();

            if (featureProperties.ShowDialog() == DialogResult.OK)
            {
                this.ModelElement.GetProperties()["Name"].SetValue(this.ModelElement.GetProperties()["Name"], featureProperties.NameTextBox.Text);
                switch (featureProperties.KindComboBox.Text)
                {
                case "Mandatory":
                    this.ModelElement.GetProperties()["Kind"].SetValue(this.ModelElement.GetProperties()["Kind"], FeatureKind.Mandatory);
                    break;

                case "Optional":
                    this.ModelElement.GetProperties()["Kind"].SetValue(this.ModelElement.GetProperties()["Kind"], FeatureKind.Optional);
                    break;

                case "FeatureSetFeature":
                    this.ModelElement.GetProperties()["Kind"].SetValue(this.ModelElement.GetProperties()["Kind"], FeatureKind.FeatureSetFeature);
                    break;
                }
                this.ModelElement.GetProperties()["Condition"].SetValue(this.ModelElement.GetProperties()["Condition"], featureProperties.ConditionTextBox.Text);
                this.ModelElement.GetProperties()["Constraint"].SetValue(this.ModelElement.GetProperties()["Constraint"], featureProperties.ConstraintTextBox.Text);
                this.ModelElement.GetProperties()["Requirements"].SetValue(this.ModelElement.GetProperties()["Requirements"], featureProperties.RequirementsTextBox.Text);
            }
        }