예제 #1
0
 /// <summary>
 /// Translate OnSubFieldMouseMove events into OnSubFieldMouseEnter and OnSubFieldMouseMove
 /// events
 /// </summary>
 public virtual void OnSubFieldMouseMove(ShapeField field, ShapeSubField subField, DiagramMouseEventArgs e)
 {
     if (HasSubFieldMouseEnterLeaveHover)
     {
         ShapeSubField oldSubField = ActiveShapeSubField;
         if (oldSubField != null)
         {
             if (PendingShapeSubField.Token.SubFieldEquals(oldSubField))
             {
                 ActiveShapeSubField = subField;
                 ActiveShapeField    = field;
                 base.OnMouseLeave(e);
                 OnSubFieldMouseEnter(field, subField, e);
             }
             else if (!oldSubField.SubFieldEquals(subField))
             {
                 OnSubFieldMouseLeave(ActiveShapeField, oldSubField, e);
                 ActiveShapeSubField = subField;
                 ActiveShapeField    = field;
                 OnSubFieldMouseEnter(field, subField, e);
             }
         }
         else
         {
             ActiveShapeSubField = subField;
             ActiveShapeField    = field;
             OnSubFieldMouseEnter(field, subField, e);
         }
         e.Handled = true;                 // Must mark as handled, or the framework will forward this OnMouseMove
     }
 }
예제 #2
0
 /// <summary>
 /// Fired when the mouse leaves a subfield. This is called directly
 /// by OnMouseLeave.
 ///
 /// If HasSubFieldHighlighting is set, the default implementation automatically
 /// removes the DiagramItem representing this subfield from the HighlightedShapes
 ///  of the active view. The subfield item will be invalidated and repainted. It is
 /// up to shapefield to check the HighlightedShapes collection and draw the subfield
 /// highlighting explicitly.
 ///
 /// Note that introducing a new ShapeSubField-derived base class would allow this
 /// to be called as the default implementation of an OnMouseLeave event on that class.
 /// However, this would need to be done at the framework level because ShapeSubField
 /// is already inherited from. Another alternative is to introduce an interface for
 /// the Enter/Leave/Hover events along with a stock implementation to help implement it.
 /// </summary>
 /// <param name="field">The parent ShapeField</param>
 /// <param name="subField">The subfield being left</param>
 /// <param name="e">Forwarded from the OnMouseLeave event</param>
 public virtual void OnSubFieldMouseLeave(ShapeField field, ShapeSubField subField, DiagramPointEventArgs e)
 {
     if (this.HasSubFieldHighlighting)
     {
         e.DiagramClientView.HighlightedShapes.Remove(new DiagramItem(this, field, subField));
     }
 }
예제 #3
0
        public override void OnFieldDoubleClick(ShapeField field, DiagramPointEventArgs e)
        {
            string property_Name        = this.ModelElement.GetProperties()["Name"].GetValue(this.ModelElement.GetProperties()["Name"]).ToString();
            string property_Description = this.ModelElement.GetProperties()["Description"].GetValue(this.ModelElement.GetProperties()["Description"]).ToString();

            ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType property_Type = (ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType) this.ModelElement.GetProperties()["Type"].GetValue(this.ModelElement.GetProperties()["Type"]);

            ArtifactProperties artifactProperties = new ArtifactProperties();

            artifactProperties.NameTextBox        = property_Name;
            artifactProperties.DescriptionTextBox = property_Description;
            artifactProperties.TypeComboBox       = property_Type.ToString();

            if (artifactProperties.ShowDialog() == DialogResult.OK)
            {
                this.ModelElement.GetProperties()["Name"].SetValue(this.ModelElement.GetProperties()["Name"], artifactProperties.NameTextBox);
                this.ModelElement.GetProperties()["Description"].SetValue(this.ModelElement.GetProperties()["Description"], artifactProperties.DescriptionTextBox);
                switch (artifactProperties.TypeComboBox)
                {
                case "Asset":
                    this.ModelElement.GetProperties()["Type"].SetValue(this.ModelElement.GetProperties()["Type"], ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType.Asset);
                    break;

                case "Tool":
                    this.ModelElement.GetProperties()["Type"].SetValue(this.ModelElement.GetProperties()["Type"], ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType.Tool);
                    break;

                case "WorkProduct":
                    this.ModelElement.GetProperties()["Type"].SetValue(this.ModelElement.GetProperties()["Type"], ISpySoft.SFSchemaLanguage.DomainModel.ArtifactType.WorkProduct);
                    break;
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Fired when the mouse enters a subfield. This is called directly
 /// by OnMouseEnter.
 ///
 /// If HasSubFieldHighlighting is set, the default implementation automatically
 /// sets the HighlightedShapes of the active view to the DiagramItem representing
 /// this subfield. The subfield item will be invalidated and repainted. It is
 /// up to shapefield to check the HighlightedShapes collection and draw the subfield
 /// highlighting explicitly.
 ///
 /// Note that introducing a new ShapeSubField-derived base class would allow this
 /// to be called as the default implementation of an OnMouseEnter event on that class.
 /// However, this would need to be done at the framework level because ShapeSubField
 /// is already inherited from. Another alternative is to introduce an interface for
 /// the Enter/Leave/Hover events along with a stock implementation to help implement it.
 /// </summary>
 /// <param name="field">The parent ShapeField</param>
 /// <param name="subField">The subfield being entered</param>
 /// <param name="e">Forwarded from the OnMouseEnter event</param>
 public virtual void OnSubFieldMouseEnter(ShapeField field, ShapeSubField subField, DiagramPointEventArgs e)
 {
     if (this.HasSubFieldHighlighting)
     {
         DiagramClientView view = e.DiagramClientView;
         if (view != null)
         {
             view.HighlightedShapes.Set(new DiagramItem(this, field, subField));
         }
     }
 }
예제 #5
0
 /// <summary>
 /// Translate mouse events into OnSubFieldMouseEnter/OnSubFieldMouseLeave events
 /// </summary>
 /// <param name="e">DiagramPointEventArgs</param>
 public override void OnMouseLeave(DiagramPointEventArgs e)
 {
     base.OnMouseLeave(e);
     if (HasSubFieldMouseEnterLeaveHover)
     {
         ShapeSubField subField = ActiveShapeSubField;
         ActiveShapeSubField = null;
         if (subField != null && !PendingShapeSubField.Token.SubFieldEquals(subField))
         {
             ShapeField shapeField = ActiveShapeField;
             ActiveShapeField = null;
             OnSubFieldMouseLeave(shapeField, subField, e);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Initialize the collection of shape fields associated with this shape type.
        /// </summary>
        protected override void InitializeShapeFields(global::System.Collections.Generic.IList <ShapeField> shapeFields)
        {
            base.InitializeShapeFields(shapeFields);

            ImageField titleIconField = new ImageField("WidgetTitleIcon");

            titleIconField.DefaultSelectable = false;
            titleIconField.DefaultFocusable  = false;
            //titleIconField.DefaultImage = ImageHelper.GetImage(MVCViewDesignerDomainModel.SingletonResourceManager.GetObject("GridLayoutToolToolboxBitmap"));
            titleIconField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.02);
            titleIconField.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.02);
            shapeFields.Add(titleIconField);

            TextField titleTextField = new TextField("WidgetTitleText");

            titleTextField.DefaultText      = string.Empty;
            titleTextField.DefaultFocusable = true;
            titleTextField.DefaultAutoSize  = true;
            titleTextField.AnchoringBehavior.MinimumHeightInLines     = 1;
            titleTextField.AnchoringBehavior.MinimumWidthInCharacters = 1;
            titleTextField.DefaultAccessibleState = global::System.Windows.Forms.AccessibleStates.Invisible;
            titleTextField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.02);
            titleTextField.AnchoringBehavior.SetLeftAnchor(titleIconField, AnchoringBehavior.Edge.Right, 0.02);
            titleTextField.DefaultFontId = new StyleSetResourceId(string.Empty, "ShapeTextBold9");
            shapeFields.Add(titleTextField);

            // more title icons
            ShapeField leftSibling = titleTextField;

            for (int i = 0; i < ADDITIONAL_TITLE_ICON_COUNT; i++)
            {
                VDTitleImageField moreTitleIconField = new VDTitleImageField("WidgetTitleIcon" + i, i);
                moreTitleIconField.DefaultSelectable = false;
                moreTitleIconField.DefaultFocusable  = false;
                moreTitleIconField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.02);
                moreTitleIconField.AnchoringBehavior.SetLeftAnchor(leftSibling, AnchoringBehavior.Edge.Right, 0.02);
                shapeFields.Add(moreTitleIconField);
                leftSibling = moreTitleIconField;
            }

            PinButtonField pinField = new PinButtonField("WidgetTitlePinIcon");

            pinField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.02);
            pinField.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, 0.02);
            pinField.DefaultSelectable = false;
            pinField.DefaultFocusable  = false;
            shapeFields.Add(pinField);
        }
        public override void OnFieldDoubleClick(ShapeField field, DiagramPointEventArgs e)
        {
            string property_Name        = this.ModelElement.GetProperties()["Name"].GetValue(this.ModelElement.GetProperties()["Name"]).ToString();
            string property_Description = this.ModelElement.GetProperties()["Description"].GetValue(this.ModelElement.GetProperties()["Description"]).ToString();

            MappingProperties mappingProperties = new MappingProperties();

            mappingProperties.NameTextBox        = property_Name;
            mappingProperties.DescriptionTextBox = property_Description;

            if (mappingProperties.ShowDialog() == DialogResult.OK)
            {
                this.ModelElement.GetProperties()["Name"].SetValue(this.ModelElement.GetProperties()["Name"], mappingProperties.NameTextBox);
                this.ModelElement.GetProperties()["Description"].SetValue(this.ModelElement.GetProperties()["Description"], mappingProperties.DescriptionTextBox);
            }
        }
예제 #8
0
 /// <summary>
 /// Translate mouse events into OnSubFieldMouseEnter/OnSubFieldMouseLeave events
 /// </summary>
 /// <param name="e">DiagramMouseEventArgs</param>
 public override void OnMouseMove(DiagramMouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (HasSubFieldMouseEnterLeaveHover)
     {
         Debug.Assert(e.DiagramHitTestInfo.HitDiagramItem.SubField == null);                 // Should be in OnSubFieldMouseMove, not here
         ShapeSubField oldSubField = ActiveShapeSubField;
         if (oldSubField != null && !PendingShapeSubField.Token.SubFieldEquals(oldSubField))
         {
             ShapeField oldShapeField = ActiveShapeField;
             ActiveShapeField    = null;
             ActiveShapeSubField = PendingShapeSubField.Token;
             OnSubFieldMouseLeave(oldShapeField, oldSubField, e);
             base.OnMouseEnter(e);
         }
     }
 }
예제 #9
0
        private static void MoveSubFieldSelectionOnOrderChange(ShapeElement parentShape, ElementListCompartment compartment, int oldIndex, int newIndex)
        {
            Diagram     diagram;
            DiagramView view;
            SelectedShapesCollection selection;

            if (null != (diagram = parentShape.Diagram) &&
                null != (view = diagram.ActiveDiagramView) &&
                null != (selection = view.Selection))
            {
                ShapeField testField = compartment.ListField;
                foreach (DiagramItem selectedItem in selection)
                {
                    ListItemSubField testSubField;
                    if (selectedItem.Shape == compartment &&
                        selectedItem.Field == testField &&
                        null != (testSubField = selectedItem.SubField as ListItemSubField))
                    {
                        int testRow = testSubField.Row;
                        if (testRow == oldIndex)
                        {
                            testSubField.Row = newIndex;
                        }
                        else
                        {
                            int adjustRow = testRow;
                            if (testRow > oldIndex)
                            {
                                --adjustRow;
                            }
                            if (adjustRow >= newIndex)
                            {
                                ++adjustRow;
                            }
                            if (adjustRow != testRow)
                            {
                                testSubField.Row = adjustRow;
                            }
                        }
                    }
                }
            }
        }
        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);
            }
        }
예제 #11
0
 /// <summary>
 /// Translate mouse events into OnSubFieldMouseEnter/OnSubFieldMouseLeave events
 /// </summary>
 /// <param name="e">DiagramPointEventArgs</param>
 public override void OnMouseEnter(DiagramPointEventArgs e)
 {
     base.OnMouseEnter(e);
     if (HasSubFieldMouseEnterLeaveHover)
     {
         DiagramItem   item       = e.DiagramHitTestInfo.HitDiagramItem;
         ShapeSubField subField   = item.SubField;
         ShapeField    shapeField = item.Field;
         // Note that we ignore any existing cached fields here. They
         // should be null at this point, but ignoring them guards against
         // the possibility that a leave event did not fire.
         if (subField == null || shapeField == null)
         {
             ActiveShapeSubField = PendingShapeSubField.Token;
             ActiveShapeField    = null;
         }
         else
         {
             ActiveShapeSubField = subField;
             ActiveShapeField    = shapeField;
             OnSubFieldMouseEnter(shapeField, subField, e);
         }
     }
 }
예제 #12
0
        public override void OnFieldDoubleClick(ShapeField field, DiagramPointEventArgs e)
        {
            string property_Name         = this.ModelElement.GetProperties()["Name"].GetValue(this.ModelElement.GetProperties()["Name"]).ToString();
            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();

            RootFeatureProperties rootFeatureProperties = new RootFeatureProperties();


            rootFeatureProperties.NameTextBox.Text         = property_Name;
            rootFeatureProperties.ConditionTextBox.Text    = property_Condition;
            rootFeatureProperties.ConstraintTextBox.Text   = property_Constraint;
            rootFeatureProperties.RequirementsTextBox.Text = property_Requirements;


            if (rootFeatureProperties.DialogResult == DialogResult.OK)
            {
                this.ModelElement.GetProperties()["Name"].SetValue(this.ModelElement.GetProperties()["Name"], rootFeatureProperties.NameTextBox.Text);
                this.ModelElement.GetProperties()["Condition"].SetValue(this.ModelElement.GetProperties()["Condition"], rootFeatureProperties.ConditionTextBox.Text);
                this.ModelElement.GetProperties()["Constraint"].SetValue(this.ModelElement.GetProperties()["Constraint"], rootFeatureProperties.ConstraintTextBox.Text);
                this.ModelElement.GetProperties()["Requirements"].SetValue(this.ModelElement.GetProperties()["Requirements"], rootFeatureProperties.RequirementsTextBox.Text);
            }
        }
예제 #13
0
        /// <summary>
        /// Reorder compartment items when a attribute is renamed.
        /// </summary>
        private static void AttributeRenamedEvent(object sender, ElementPropertyChangedEventArgs e)
        {
            Barker.Attribute attribute = (Barker.Attribute)e.ModelElement;
            EntityType       barkerEntity;

            if (!attribute.IsDeleted &&
                null != (barkerEntity = attribute.EntityType))
            {
                foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(barkerEntity))
                {
                    BarkerEntityShape shape = pel as BarkerEntityShape;
                    if (shape != null)
                    {
                        foreach (ShapeElement childShape in shape.NestedChildShapes)
                        {
                            AttributeElementListCompartment compartment;
                            OrderedElementList <Barker.Attribute, AttributeElementListCompartment> attributeList;
                            int oldIndex;
                            int newIndex;
                            if (null != (compartment = childShape as AttributeElementListCompartment) &&
                                null != (attributeList = compartment.Items as OrderedElementList <Barker.Attribute, AttributeElementListCompartment>))

                            {
                                if (attributeList.OnElementReorder(attribute, out oldIndex, out newIndex))
                                {
                                    Diagram     diagram;
                                    DiagramView view;
                                    SelectedShapesCollection selection;
                                    if (null != (diagram = shape.Diagram) &&
                                        null != (view = diagram.ActiveDiagramView) &&
                                        null != (selection = view.Selection))
                                    {
                                        ShapeField testField = compartment.ListField;
                                        foreach (DiagramItem selectedItem in selection)
                                        {
                                            ListItemSubField testSubField;
                                            if (selectedItem.Shape == compartment &&
                                                selectedItem.Field == testField &&
                                                null != (testSubField = selectedItem.SubField as ListItemSubField))
                                            {
                                                int testRow = testSubField.Row;
                                                if (testRow == oldIndex)
                                                {
                                                    testSubField.Row = newIndex;
                                                }
                                                else
                                                {
                                                    int adjustRow = testRow;
                                                    if (testRow > oldIndex)
                                                    {
                                                        --adjustRow;
                                                    }
                                                    if (adjustRow >= newIndex)
                                                    {
                                                        ++adjustRow;
                                                    }
                                                    if (adjustRow != testRow)
                                                    {
                                                        testSubField.Row = adjustRow;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
		/// <summary>
		/// Fired when the mouse enters a subfield. This is called directly
		/// by OnMouseEnter.
		/// 
		/// If HasSubFieldHighlighting is set, the default implementation automatically
		/// sets the HighlightedShapes of the active view to the DiagramItem representing
		/// this subfield. The subfield item will be invalidated and repainted. It is
		/// up to shapefield to check the HighlightedShapes collection and draw the subfield
		/// highlighting explicitly.
		/// 
		/// Note that introducing a new ShapeSubField-derived base class would allow this
		/// to be called as the default implementation of an OnMouseEnter event on that class.
		/// However, this would need to be done at the framework level because ShapeSubField
		/// is already inherited from. Another alternative is to introduce an interface for
		/// the Enter/Leave/Hover events along with a stock implementation to help implement it.
		/// </summary>
		/// <param name="field">The parent ShapeField</param>
		/// <param name="subField">The subfield being entered</param>
		/// <param name="e">Forwarded from the OnMouseEnter event</param>
		public virtual void OnSubFieldMouseEnter(ShapeField field, ShapeSubField subField, DiagramPointEventArgs e)
		{
			if (this.HasSubFieldHighlighting)
			{
				DiagramClientView view = e.DiagramClientView;
				if (view != null)
				{
					view.HighlightedShapes.Set(new DiagramItem(this, field, subField));
				}
			}
		}
예제 #15
0
 public sealed override RectangleD GetBounds(ShapeElement parentShape, ShapeField parentField)
 {
     return(RectangleD.Empty);
 }
예제 #16
0
 public sealed override bool GetFocusable(ShapeElement parentShape, ShapeField parentField)
 {
     return(false);
 }
예제 #17
0
        public IShapefileRecord <T> Write(T shape)
        {
            //TODO: Write BoundingBox merge method(s)...
            dynamic shapeBox = shape.Box;

            if (BoundingBox == null)
            {
                BoundingBox = new BoundingBox <PointZ>()
                {
                    Min = new PointZ(shapeBox.Min),
                    Max = new PointZ(shapeBox.Max)
                };
            }
            else
            {
                BoundingBox.Min.Minimize(shapeBox.Min);
                BoundingBox.Max.Maximize(shapeBox.Max);
            }

            var shpRecordOffset  = WordCount.FromBytes(ShpWriter.BaseStream.Position);
            var shpContentOffset = shpRecordOffset + ShpRecordHeaderField.FieldLength;

            var record = new ShapefileRecord <T>()
            {
                RecordNumber = RecordNumber,
                Shape        = shape
            };

            //TODO: Write the SHP header first...
            //      But we have to write the shape, to figure out its length, to add the length to the header...
            var shapeField = new ShapeField(shpContentOffset);

            shapeField.Write(ShpWriter, shape);

            var shpStreamLengthAfterRecordWrite = ShpWriter.BaseStream.Length;

            var shpHeader = new ShpRecordHeader()
            {
                //TODO: The shapeField should just have a Length... vs assuming the writer will be at the correct length...
                ContentLength = WordCount.FromBytes(shpStreamLengthAfterRecordWrite) - shpContentOffset,
                RecordNumber  = RecordNumber
            };

            var shpHeaderField = new ShpRecordHeaderField(shpRecordOffset);

            shpHeaderField.Write(ShpWriter, shpHeader);

            //Reset so we are at the correct position for the next shape...
            ShpWriter.BaseStream.Position = shpStreamLengthAfterRecordWrite;



            var shxRecord = new ShxRecord()
            {
                Offset        = shpRecordOffset,
                ContentLength = WordCount.FromBytes((int)ShpWriter.BaseStream.Position) - shpRecordOffset
            };

            var shxRecordField = new ShxRecordField(WordCount.FromBytes(ShxWriter.BaseStream.Position));

            shxRecordField.Write(ShxWriter, shxRecord);


            RecordNumber++;

            return(record);
        }
예제 #18
0
 /// <summary>
 /// Fired when the mouse hovers over a subfield. This is called directly
 /// by OnMouseHover.
 ///
 /// The default implementation is empty.
 ///
 /// Note that introducing a new ShapeSubField-derived base class would allow this
 /// to be called as the default implementation of an OnMouseHover event on that class.
 /// However, this would need to be done at the framework level because ShapeSubField
 /// is already inherited from. Another alternative is to introduce an interface for
 /// the Enter/Leave/Hover events along with a stock implementation to help implement it.
 /// </summary>
 /// <param name="field">The parent ShapeField</param>
 /// <param name="subField">The subfield being hovered over</param>
 /// <param name="e">Forwarded from the OnMouseHover event</param>
 public virtual void OnSubFieldMouseHover(ShapeField field, ShapeSubField subField, DiagramPointEventArgs e)
 {
 }
		/// <summary>
		/// Translate mouse events into OnSubFieldMouseEnter/OnSubFieldMouseLeave events
		/// </summary>
		/// <param name="e">DiagramPointEventArgs</param>
		public override void OnMouseLeave(DiagramPointEventArgs e)
		{
			base.OnMouseLeave(e);
			if (HasSubFieldMouseEnterLeaveHover)
			{
				ShapeSubField subField = ActiveShapeSubField;
				ActiveShapeSubField = null;
				if (subField != null && !PendingShapeSubField.Token.SubFieldEquals(subField))
				{
					ShapeField shapeField = ActiveShapeField;
					ActiveShapeField = null;
					OnSubFieldMouseLeave(shapeField, subField, e);
				}
			}
		}
			public sealed override bool GetFocusable(ShapeElement parentShape, ShapeField parentField)
			{
				return false;
			}
		/// <summary>
		/// Translate mouse events into OnSubFieldMouseEnter/OnSubFieldMouseLeave events
		/// </summary>
		/// <param name="e">DiagramMouseEventArgs</param>
		public override void OnMouseMove(DiagramMouseEventArgs e)
		{
			base.OnMouseMove(e);
			if (HasSubFieldMouseEnterLeaveHover)
			{
				Debug.Assert(e.DiagramHitTestInfo.HitDiagramItem.SubField == null); // Should be in OnSubFieldMouseMove, not here
				ShapeSubField oldSubField = ActiveShapeSubField;
				if (oldSubField != null && !PendingShapeSubField.Token.SubFieldEquals(oldSubField))
				{
					ShapeField oldShapeField = ActiveShapeField;
					ActiveShapeField = null;
					ActiveShapeSubField = PendingShapeSubField.Token;
					OnSubFieldMouseLeave(oldShapeField, oldSubField, e);
					base.OnMouseEnter(e);
				}
			}
		}
		/// <summary>
		/// Translate mouse events into OnSubFieldMouseEnter/OnSubFieldMouseLeave events
		/// </summary>
		/// <param name="e">DiagramPointEventArgs</param>
		public override void OnMouseEnter(DiagramPointEventArgs e)
		{
			base.OnMouseEnter(e);
			if (HasSubFieldMouseEnterLeaveHover)
			{
				DiagramItem item = e.DiagramHitTestInfo.HitDiagramItem;
				ShapeSubField subField = item.SubField;
				ShapeField shapeField = item.Field;
				// Note that we ignore any existing cached fields here. They
				// should be null at this point, but ignoring them guards against
				// the possibility that a leave event did not fire.
				if (subField == null || shapeField == null)
				{
					ActiveShapeSubField = PendingShapeSubField.Token;
					ActiveShapeField = null;
				}
				else
				{
					ActiveShapeSubField = subField;
					ActiveShapeField = shapeField;
					OnSubFieldMouseEnter(shapeField, subField, e);
				}
			}
		}
		/// <summary>
		/// Translate OnSubFieldMouseMove events into OnSubFieldMouseEnter and OnSubFieldMouseMove
		/// events
		/// </summary>
		public virtual void OnSubFieldMouseMove(ShapeField field, ShapeSubField subField, DiagramMouseEventArgs e)
		{
			if (HasSubFieldMouseEnterLeaveHover)
			{
				ShapeSubField oldSubField = ActiveShapeSubField;
				if (oldSubField != null)
				{
					if (PendingShapeSubField.Token.SubFieldEquals(oldSubField))
					{
						ActiveShapeSubField = subField;
						ActiveShapeField = field;
						base.OnMouseLeave(e);
						OnSubFieldMouseEnter(field, subField, e);
					}
					else if (!oldSubField.SubFieldEquals(subField))
					{
						OnSubFieldMouseLeave(ActiveShapeField, oldSubField, e);
						ActiveShapeSubField = subField;
						ActiveShapeField = field;
						OnSubFieldMouseEnter(field, subField, e);
					}
				}
				else
				{
					ActiveShapeSubField = subField;
					ActiveShapeField = field;
					OnSubFieldMouseEnter(field, subField, e);
				}
				e.Handled = true; // Must mark as handled, or the framework will forward this OnMouseMove
			}
		}
		/// <summary>
		/// Fired when the mouse hovers over a subfield. This is called directly
		/// by OnMouseHover.
		/// 
		/// The default implementation is empty.
		/// 
		/// Note that introducing a new ShapeSubField-derived base class would allow this
		/// to be called as the default implementation of an OnMouseHover event on that class.
		/// However, this would need to be done at the framework level because ShapeSubField
		/// is already inherited from. Another alternative is to introduce an interface for
		/// the Enter/Leave/Hover events along with a stock implementation to help implement it.
		/// </summary>
		/// <param name="field">The parent ShapeField</param>
		/// <param name="subField">The subfield being hovered over</param>
		/// <param name="e">Forwarded from the OnMouseHover event</param>
		public virtual void OnSubFieldMouseHover(ShapeField field, ShapeSubField subField, DiagramPointEventArgs e)
		{
		}
		/// <summary>
		/// Fired when the mouse leaves a subfield. This is called directly
		/// by OnMouseLeave.
		/// 
		/// If HasSubFieldHighlighting is set, the default implementation automatically
		/// removes the DiagramItem representing this subfield from the HighlightedShapes
		///  of the active view. The subfield item will be invalidated and repainted. It is
		/// up to shapefield to check the HighlightedShapes collection and draw the subfield
		/// highlighting explicitly.
		///
		/// Note that introducing a new ShapeSubField-derived base class would allow this
		/// to be called as the default implementation of an OnMouseLeave event on that class.
		/// However, this would need to be done at the framework level because ShapeSubField
		/// is already inherited from. Another alternative is to introduce an interface for
		/// the Enter/Leave/Hover events along with a stock implementation to help implement it.
		/// </summary>
		/// <param name="field">The parent ShapeField</param>
		/// <param name="subField">The subfield being left</param>
		/// <param name="e">Forwarded from the OnMouseLeave event</param>
		public virtual void OnSubFieldMouseLeave(ShapeField field, ShapeSubField subField, DiagramPointEventArgs e)
		{
			if (this.HasSubFieldHighlighting)
			{
				e.DiagramClientView.HighlightedShapes.Remove(new DiagramItem(this, field, subField));
			}
		}
예제 #26
0
        private void flexDesigner_CreateField(object sender, C1.Win.FlexReport.CreateFieldEventArgs e)
        {
            // NOTE: currently add field buttons are used as the keys for inserting fields,
            // i.e. button.Tag/Action are not used. Might want to change that.

            RibbonItem btn      = e.CreateFieldInfo as RibbonItem;
            FieldBase  newField = null;
            string     fldName  = GetUniqueFieldName();

            Action <FieldBase> setFieldBaseProps = (field_) =>
            {
                field_.Name   = fldName;
                field_.Left   = e.FieldBounds.Left;
                field_.Top    = e.FieldBounds.Top;
                field_.Width  = e.FieldBounds.Width;
                field_.Height = e.FieldBounds.Height;
            };

            // Select field type, create field:
            if (btn == rbtnFieldDataField)
            {
                TextField textField = new TextField();
                setFieldBaseProps(textField);
                e.SubSection.Fields.Add(textField);
                newField       = textField;
                textField.Text = _createInfo != null ? ("=" + _createInfo) : string.Empty;
            }
            else if (btn == rbtnFieldCalculated)
            {
                TextField calcField = new TextField();
                setFieldBaseProps(calcField);
                e.SubSection.Fields.Add(calcField);
                CommonFields.SetupField(_flexDesigner.Report, calcField, _createInfo);
                newField = calcField;
            }
            else if (btn == rbtnFieldParagraph)
            {
                ParagraphField paraField = new ParagraphField();
                setFieldBaseProps(paraField);
                e.SubSection.Fields.Add(paraField);
                newField = paraField;
                paraField.Content.Add(_createInfo != null ? ("=" + _createInfo) : string.Empty);
            }
            else if (btn == rbtnFieldRtf)
            {
                RtfField rtfField = new RtfField();
                setFieldBaseProps(rtfField);
                e.SubSection.Fields.Add(rtfField);
                newField      = rtfField;
                rtfField.Text = _createInfo != null ? ("=" + _createInfo) : string.Empty;
            }
            else if (btn == rbtnFieldCheckBox)
            {
                CheckBoxField cbField = new CheckBoxField();
                setFieldBaseProps(cbField);
                e.SubSection.Fields.Add(cbField);
                if (_createInfo != null)
                {
                    cbField.Value = "=" + _createInfo;
                    cbField.Text  = _createInfo;
                }
                newField = cbField;
            }
            else if (btn == rbtnFieldChart)
            {
                ChartField chartField = new ChartField();
                setFieldBaseProps(chartField);
                e.SubSection.Fields.Add(chartField);
                newField = chartField;
            }
#if MAP
            else if (btn == rbtnFieldMap)
            {
                var mapField = new MapField();
                setFieldBaseProps(mapField);
                e.SubSection.Fields.Add(mapField);
                mapField.InitLayout();
                newField = mapField;
            }
#endif
            else if (btn == rbtnFieldBarCode)
            {
                BarCodeField barcodeField = new BarCodeField();
                setFieldBaseProps(barcodeField);
                e.SubSection.Fields.Add(barcodeField);
                barcodeField.Text = _createInfo != null ? ("=" + _createInfo) : "BARCODE";
                // barcodeField.BarCode = C1.Win.C1Document.BarCodeEnum.Code39x; // this was set as default in C1Report designer
                newField = barcodeField;
            }
            else if (btn == rbtnFieldPicture)
            {
                ImageField imageField = new ImageField();
                setFieldBaseProps(imageField);
                e.SubSection.Fields.Add(imageField);
                imageField.Picture = _createInfo;
                newField           = imageField;
            }
            else if (btn == rbtnFieldShape)
            {
                ShapeField shapeField = new ShapeField();
                setFieldBaseProps(shapeField);
                e.SubSection.Fields.Add(shapeField);
                newField = shapeField;
            }
            else if (btn == rbtnFieldSubReport)
            {
                SubreportField subreportField = new SubreportField();
                setFieldBaseProps(subreportField);
                e.SubSection.Fields.Add(subreportField);
                foreach (ReportItem ri in _reportList.Items)
                {
                    if (ri.ToString() == _createInfo && ri.Report != _flexDesigner.Report)
                    {
                        subreportField.Subreport = ri.Report;
                        break;
                    }
                }
                newField = subreportField;
            }
            else if (btn == rbtnFieldLegacy)
            {
                Field legacyField = new Field();
                setFieldBaseProps(legacyField);
                e.SubSection.Fields.Add(legacyField);
                newField = legacyField;
            }
            else if (btn == rbtnFieldFlexChart)
            {
                FlexChartField flexChartField = new FlexChartField();
                setFieldBaseProps(flexChartField);
                flexChartField.Series.Add(new C1.Win.FlexReport.FlexChart.Series()
                {
                    Name        = "DefaultSeries",
                    Label       = "Count",
                    YExpression = "Count()"
                });
                e.SubSection.Fields.Add(flexChartField);
                newField = flexChartField;
            }
            else if (btn.Tag is Field) // custom field
            {
                Field customField = (Field)btn.Tag;
                setFieldBaseProps(customField);
                e.SubSection.Fields.Add(customField);
                newField = customField;
            }
            // else if (btn == rbtnFieldPageBreak) ....
            else
            {
                System.Diagnostics.Debug.Assert(false, "unknown field insert op");
            }

            // select the new field, zap creator
            _flexDesigner.UpdateFromReport();
            _flexDesigner.SelectField(newField, true, true);
            _flexDesigner.CreateFieldInfo = null;
            UpdateCreateFieldButtons(rbtnFieldArrow);
            UpdateUI(false);

            // update report list icons
            if (btn == rbtnFieldSubReport)
            {
                _reportList.UpdateIcons();
            }
        }
			public sealed override RectangleD GetBounds(ShapeElement parentShape, ShapeField parentField)
			{
				return RectangleD.Empty;
			}