Exemplo n.º 1
0
        // Handles all RadioButton clicks for Routing and Curve.
        private void LinkRadioButton_Click(object sender, EventArgs e)
        {
            if (myDiagram.SelectedLink == null)
            {
                return;
            }
            RadioButton rb = (RadioButton)sender as RadioButton;

            if (rb == null)
            {
                return;
            }
            MyLinkData mld = myDiagram.SelectedLink.Data as MyLinkData;

            if (mld != null)
            {
                myDiagram.StartTransaction("Modify Routing and Curve");
                // Check the RadioButtons that specify LinkRouting.
                if (rb == NormalRoutingRB)
                {
                    mld.Routing = LinkRouting.Normal;
                }
                if (rb == OrthogonalRoutingRB)
                {
                    mld.Routing = LinkRouting.Orthogonal;
                }
                if (rb == AvoidsNodesRoutingRB)
                {
                    mld.Routing = LinkRouting.AvoidsNodes;
                }
                // Check the RadioButtons that specify LinkCurve.
                if (rb == NoneCurveRB)
                {
                    mld.Curve = LinkCurve.None;
                }
                if (rb == JumpOverCurveRB)
                {
                    mld.Curve = LinkCurve.JumpOver;
                }
                if (rb == JumpGapCurveRB)
                {
                    mld.Curve = LinkCurve.JumpGap;
                }
                if (rb == BezierCurveRB)
                {
                    mld.Curve = LinkCurve.Bezier;
                }
                myDiagram.CommitTransaction("Modify Routing and Curve");
            }
        }
Exemplo n.º 2
0
        // Handles any change in (To/)FromArrowBox by changing SelectedLink.Data.(To/)FromArrow
        private void ArrowheadChanged(object sender, EventArgs e)
        {
            if (myDiagram.SelectedLink == null)
            {
                return;
            }
            MyLinkData mld = myDiagram.SelectedLink.Data as MyLinkData;

            if (mld != null)
            {
                myDiagram.StartTransaction("Modify Arrow");
                if (sender == ToArrowBox)
                {
                    Arrowhead arrow = (Arrowhead)ToArrowBox.SelectedItem;
                    mld.ToArrow = arrow;
                }
                else if (sender == FromArrowBox)
                {
                    Arrowhead arrow = (Arrowhead)FromArrowBox.SelectedItem;
                    mld.FromArrow = arrow;
                }
                myDiagram.CommitTransaction("Modify Arrow");
            }
        }
Exemplo n.º 3
0
        // Handles changes in all of the TextBoxes associated with the Link control Sliders
        private void SliderText_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (myDiagram.SelectedLink == null)
            {
                return;
            }
            MyLinkData mld = myDiagram.SelectedLink.Data as MyLinkData;

            if (mld == null)
            {
                return;
            }
            myDiagram.StartTransaction("Modify Link Route");
            if (sender == CurvinessTextBox && CurvinessSlider != null)
            {
                try {
                    double curv = double.Parse(CurvinessTextBox.Text);
                    if (curv > CurvinessSlider.Maximum)
                    {
                        curv = CurvinessSlider.Maximum;
                    }
                    if (curv < CurvinessSlider.Minimum)
                    {
                        curv = CurvinessSlider.Minimum;
                    }
                    mld.Curviness         = curv;
                    CurvinessSlider.Value = curv;
                } catch (FormatException) {
                    mld.Curviness         = CurvinessSlider.Minimum;
                    CurvinessSlider.Value = CornerSlider.Minimum;
                }
            }
            else if (sender == CornerTextBox && CornerSlider != null)
            {
                try {
                    double corner = double.Parse(CornerTextBox.Text);
                    if (corner > CornerSlider.Maximum)
                    {
                        corner = CornerSlider.Maximum;
                    }
                    if (corner < CornerSlider.Minimum)
                    {
                        corner = CornerSlider.Minimum;
                    }
                    mld.Corner         = corner;
                    CornerSlider.Value = corner;
                } catch (FormatException) {
                    mld.Corner         = CornerSlider.Minimum;
                    CornerSlider.Value = CornerSlider.Minimum;
                }
            }
            else if (sender == SmoothnessTextBox && SmoothnessSlider != null)
            {
                try {
                    double smoothness = double.Parse(SmoothnessTextBox.Text);
                    if (smoothness > SmoothnessSlider.Maximum)
                    {
                        smoothness = SmoothnessSlider.Maximum;
                    }
                    if (smoothness < SmoothnessSlider.Minimum)
                    {
                        smoothness = SmoothnessSlider.Minimum;
                    }
                    mld.Smoothness         = smoothness;
                    SmoothnessSlider.Value = smoothness;
                } catch (FormatException) {
                    mld.Smoothness         = SmoothnessSlider.Minimum;
                    SmoothnessSlider.Value = SmoothnessSlider.Minimum;
                }
            }
            else if (sender == FromArrowScaleBox && FromArrowScaleSlider != null)
            {
                try {
                    double arrowScale = double.Parse(FromArrowScaleBox.Text);
                    if (arrowScale > FromArrowScaleSlider.Maximum)
                    {
                        arrowScale = FromArrowScaleSlider.Maximum;
                    }
                    if (arrowScale < FromArrowScaleSlider.Minimum)
                    {
                        arrowScale = FromArrowScaleSlider.Minimum;
                    }
                    mld.FromArrowScale         = arrowScale;
                    FromArrowScaleSlider.Value = arrowScale;
                } catch (FormatException) {
                    mld.FromArrowScale         = FromArrowScaleSlider.Minimum;
                    FromArrowScaleSlider.Value = FromArrowScaleSlider.Value;
                }
            }
            else if (sender == ToArrowScaleBox && ToArrowScaleSlider != null)
            {
                try {
                    double arrowScale = double.Parse(ToArrowScaleBox.Text);
                    if (arrowScale > ToArrowScaleSlider.Maximum)
                    {
                        arrowScale = ToArrowScaleSlider.Maximum;
                    }
                    if (arrowScale < ToArrowScaleSlider.Minimum)
                    {
                        arrowScale = ToArrowScaleSlider.Minimum;
                    }
                    mld.ToArrowScale         = arrowScale;
                    ToArrowScaleSlider.Value = arrowScale;
                } catch (FormatException) {
                    mld.ToArrowScale         = ToArrowScaleSlider.Minimum;
                    ToArrowScaleSlider.Value = ToArrowScaleSlider.Value;
                }
            }
            else if (sender == FromEndSegmentLengthBox && FromEndSegmentLengthSlider != null)
            {
                try {
                    double endSegmentLength = double.Parse(FromEndSegmentLengthBox.Text);
                    if (endSegmentLength > FromEndSegmentLengthSlider.Maximum)
                    {
                        endSegmentLength = FromEndSegmentLengthSlider.Maximum;
                    }
                    if (endSegmentLength < FromEndSegmentLengthSlider.Minimum)
                    {
                        endSegmentLength = FromEndSegmentLengthSlider.Minimum;
                    }
                    mld.FromEndSegmentLength         = endSegmentLength;
                    FromEndSegmentLengthSlider.Value = endSegmentLength;
                } catch (FormatException) {
                    mld.FromEndSegmentLength         = FromEndSegmentLengthSlider.Minimum;
                    FromEndSegmentLengthSlider.Value = FromEndSegmentLengthSlider.Minimum;
                }
            }
            else if (sender == ToEndSegmentLengthBox && ToEndSegmentLengthSlider != null)
            {
                try {
                    double endSegmentLength = double.Parse(ToEndSegmentLengthBox.Text);
                    if (endSegmentLength > ToEndSegmentLengthSlider.Maximum)
                    {
                        endSegmentLength = ToEndSegmentLengthSlider.Maximum;
                    }
                    if (endSegmentLength < ToEndSegmentLengthSlider.Minimum)
                    {
                        endSegmentLength = ToEndSegmentLengthSlider.Minimum;
                    }
                    mld.ToEndSegmentLength         = endSegmentLength;
                    ToEndSegmentLengthSlider.Value = endSegmentLength;
                } catch (FormatException) {
                    mld.ToEndSegmentLength         = ToEndSegmentLengthSlider.Minimum;
                    ToEndSegmentLengthSlider.Value = ToEndSegmentLengthSlider.Minimum;
                }
            }
            else if (sender == FromShortLengthBox && FromShortLengthSlider != null)
            {
                try {
                    double shortLength = double.Parse(FromShortLengthBox.Text);
                    if (shortLength > FromShortLengthSlider.Maximum)
                    {
                        shortLength = FromShortLengthSlider.Maximum;
                    }
                    if (shortLength < FromShortLengthSlider.Minimum)
                    {
                        shortLength = FromShortLengthSlider.Minimum;
                    }
                    mld.FromShortLength         = shortLength;
                    FromShortLengthSlider.Value = shortLength;
                } catch (FormatException) {
                    mld.FromShortLength         = FromShortLengthSlider.Minimum;
                    FromShortLengthSlider.Value = FromShortLengthSlider.Minimum;
                }
            }
            else if (sender == ToShortLengthBox && ToShortLengthSlider != null)
            {
                try {
                    double shortLength = double.Parse(ToShortLengthBox.Text);
                    if (shortLength > ToShortLengthSlider.Maximum)
                    {
                        shortLength = ToShortLengthSlider.Maximum;
                    }
                    if (shortLength < ToShortLengthSlider.Minimum)
                    {
                        shortLength = ToShortLengthSlider.Minimum;
                    }
                    mld.ToShortLength         = shortLength;
                    ToShortLengthSlider.Value = shortLength;
                } catch (FormatException) {
                    mld.ToShortLength         = ToShortLengthSlider.Minimum;
                    ToShortLengthSlider.Value = ToShortLengthSlider.Minimum;
                }
            }
            myDiagram.CommitTransaction("Modify Link Route");
        }
Exemplo n.º 4
0
        // Updates all controls when the primary selected part, SelectedPart, changes
        private void SelectedPartsChanged(object sender, EventArgs e)
        {
            if (myDiagram.SelectedPart == null)
            {
                return;
            }

            MyNodeData mnd = myDiagram.SelectedPart.Data as MyNodeData;

            if (mnd != null) // if SelectedPart is a Node
            {
                FigureBox.SelectedItem = mnd.Figure;

                this.IgnoreCheckBoxChanges = true;
                Spot from = mnd.FromSpot;
                if (from.IsSide)
                {
                    FromLeftCB.IsChecked   = from.IncludesSide(Spot.LeftSide);
                    FromTopCB.IsChecked    = from.IncludesSide(Spot.TopSide);
                    FromRightCB.IsChecked  = from.IncludesSide(Spot.RightSide);
                    FromBottomCB.IsChecked = from.IncludesSide(Spot.BottomSide);
                    //Deselect all FromSpot RadioButtons
                    FromNone.IsChecked = false;
                }
                else // FromSpot is a specific Spot or Spot.None
                // Sets the IsChecked Property of the corresponding RadioButton
                {
                    SetRadioButton("From", from);
                    FromLeftCB.IsChecked   = false;
                    FromTopCB.IsChecked    = false;
                    FromRightCB.IsChecked  = false;
                    FromBottomCB.IsChecked = false;
                }

                Spot to = mnd.ToSpot;
                if (to.IsSide)
                {
                    ToLeftCB.IsChecked   = to.IncludesSide(Spot.LeftSide);
                    ToTopCB.IsChecked    = to.IncludesSide(Spot.TopSide);
                    ToRightCB.IsChecked  = to.IncludesSide(Spot.RightSide);
                    ToBottomCB.IsChecked = to.IncludesSide(Spot.BottomSide);
                    //Deselect all ToSpot RadioButtons
                    ToNone.IsChecked = false;
                }
                else // ToSpot is a specific Spot or Spot.None
                // Sets the IsChecked Property of the corresponding RadioButton
                {
                    SetRadioButton("To", to);
                    ToLeftCB.IsChecked   = false;
                    ToTopCB.IsChecked    = false;
                    ToRightCB.IsChecked  = false;
                    ToBottomCB.IsChecked = false;
                }
                this.IgnoreCheckBoxChanges = false;
            }

            MyLinkData mld = myDiagram.SelectedPart.Data as MyLinkData;

            if (mld != null) // or SelectedPart is a Link
            {
                CurvinessSlider.Value        = mld.Curviness;
                CornerSlider.Value           = mld.Corner;
                ToArrowBox.SelectedItem      = mld.ToArrow;
                FromArrowBox.SelectedItem    = mld.FromArrow;
                ToArrowScaleBox.Text         = mld.ToArrowScale.ToString();
                FromArrowScaleBox.Text       = mld.FromArrowScale.ToString();
                ToEndSegmentLengthBox.Text   = mld.ToEndSegmentLength.ToString();
                FromEndSegmentLengthBox.Text = mld.FromEndSegmentLength.ToString();
                ToShortLengthBox.Text        = mld.ToShortLength.ToString();
                FromShortLengthBox.Text      = mld.FromShortLength.ToString();

                switch (mld.Routing)
                {
                case LinkRouting.Normal: NormalRoutingRB.IsChecked = true; break;

                case LinkRouting.Orthogonal: OrthogonalRoutingRB.IsChecked = true; break;

                case LinkRouting.AvoidsNodes: AvoidsNodesRoutingRB.IsChecked = true; break;
                }

                switch (mld.Curve)
                {
                case LinkCurve.None: NoneCurveRB.IsChecked = true; break;

                case LinkCurve.JumpOver: JumpOverCurveRB.IsChecked = true; break;

                case LinkCurve.JumpGap: JumpGapCurveRB.IsChecked = true; break;

                case LinkCurve.Bezier: BezierCurveRB.IsChecked = true; break;
                }
            }
        }