Exemple #1
0
        private void CopyProperties(ICartographicStroke stroke, ICartographicStroke other)
        {
            if (stroke == null || other == null)
            {
                if (stroke.StrokeStyle == other.StrokeStyle)
                {
                    stroke.CopyProperties(other);
                }
                else
                {
                    CopyProperties(stroke as ISimpleStroke, other as ISimpleStroke);
                    stroke.Color     = other.Color;
                    stroke.DashStyle = other.DashStyle;
                    stroke.Opacity   = other.Opacity;
                    stroke.Width     = other.Width;

                    stroke.CompoundArray   = other.CompoundArray.Copy();
                    stroke.CompoundButtons = other.CompoundButtons.Copy();
                    stroke.DashButtons     = other.DashButtons.Copy();
                    stroke.DashCap         = other.DashCap;
                    stroke.DashPattern     = other.DashPattern.Copy();
                    stroke.Decorations     = new List <ILineDecoration>(other.Decorations);
                    stroke.EndCap          = other.EndCap;
                    stroke.JoinType        = other.JoinType;
                    stroke.Offset          = other.Offset;
                    stroke.StartCap        = other.StartCap;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Sets the pattern of squares for this pen by working with the given dash and compound patterns.
        /// </summary>
        /// <param name="stroke">Completely defines the ICartographicStroke that is being used to set the pattern.</param>
        public void SetPattern(ICartographicStroke stroke)
        {
            _lineColor = stroke.Color;
            _lineWidth = stroke.Width;

            if (stroke.DashButtons == null)
            {
                _horizontalButtons         = null;
                _horizontalSlider.Position = new PointF(50F, 0F);
            }
            else
            {
                SetHorizontalPattern(stroke.DashButtons);
            }
            if (stroke.CompoundButtons == null)
            {
                _verticalButtons         = null;
                _verticalSlider.Position = new PointF(0F, 20F);
            }
            else
            {
                SetVerticalPattern(stroke.CompoundButtons);
            }

            CalculatePattern();
            Invalidate();
        }
        private void dashControl1_PatternChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            IStroke stroke = ccStrokes.SelectedStroke;

            if (stroke == null)
            {
                return;
            }
            ICartographicStroke cs = stroke as ICartographicStroke;

            if (cs != null)
            {
                cs.DashStyle       = DashStyle.Custom;
                cs.DashPattern     = dashControl1.GetDashPattern();
                cs.DashButtons     = dashControl1.DashButtons;
                cs.CompoundButtons = dashControl1.CompoundButtons;
                cs.CompoundArray   = dashControl1.GetCompoundArray();
                cs.Width           = cs.CompoundButtons.Length;
            }
            UpdatePreview();
        }
        private void DblStrokeOffsetTextChanged(object sender, EventArgs e)
        {
            ICartographicStroke cs = ccStrokes?.SelectedStroke as ICartographicStroke;

            if (cs == null)
            {
                return;
            }
            cs.Offset = (float)dblStrokeOffset.Value;
            UpdatePreview();
        }
        private void ccDecorations_AddClicked(object sender, EventArgs e)
        {
            ICartographicStroke currentStroke = ccStrokes.SelectedStroke as ICartographicStroke;

            if (currentStroke != null)
            {
                LineDecoration decoration = new LineDecoration();
                currentStroke.Decorations.Add(decoration);
                ccDecorations.RefreshList();
                ccDecorations.SelectedDecoration = decoration;
            }
        }
        private void UpdatePreview()
        {
            Graphics g = lblPreview.CreateGraphics();

            UpdatePreview(g);
            g.Dispose();

            ICartographicStroke cs = ccStrokes.SelectedStroke as ICartographicStroke;

            if (cs != null)
            {
                g = lblDecorationPreview.CreateGraphics();
                UpdateDecorationPreview(g);
                g.Dispose();
            }
        }
        private void cmbEndCap_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            if (ccStrokes.SelectedStroke == null)
            {
                return;
            }
            IStroke             stroke = ccStrokes.SelectedStroke;
            ICartographicStroke cs     = stroke as ICartographicStroke;

            if (cs != null && cmbEndCap.SelectedIndex != -1)
            {
                cs.EndCap = (LineCap)cmbEndCap.SelectedItem;
            }
            UpdatePreview();
        }
        private void radLineJoin_ValueChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            if (ccStrokes.SelectedStroke == null)
            {
                return;
            }
            IStroke             stroke = ccStrokes.SelectedStroke;
            ICartographicStroke cs     = stroke as ICartographicStroke;

            if (cs != null)
            {
                cs.JoinType = radLineJoin.Value;
            }
            UpdatePreview();
        }
Exemple #9
0
        private void UpdatePreview()
        {
            using (Graphics g = lblPreview.CreateGraphics())
            {
                g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                UpdatePreview(g);
            }

            ICartographicStroke cs = ccStrokes.SelectedStroke as ICartographicStroke;

            if (cs != null)
            {
                using (Graphics g = lblDecorationPreview.CreateGraphics())
                {
                    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    UpdateDecorationPreview(g);
                }
            }
        }
        private void SetColor(Color color)
        {
            if (_ignoreChanges)
            {
                return;
            }
            IStroke stroke = ccStrokes.SelectedStroke;

            if (stroke == null)
            {
                return;
            }
            ISimpleStroke ss = stroke as ISimpleStroke;

            if (ss != null)
            {
                ss.Color = color;
            }

            ICartographicStroke cs = stroke as ICartographicStroke;

            if (cs != null)
            {
                dashControl1.LineColor = color;
            }

            // only call if changed, or we will create an infinite loop here
            if (cbColorSimple.Color != color)
            {
                cbColorSimple.Color = color;
            }
            if (cbColorCartographic.Color != color)
            {
                cbColorCartographic.Color = color;
            }
            sldOpacityCartographic.MaximumColor = Color.FromArgb(255, color);
            sldOpacitySimple.MaximumColor       = Color.FromArgb(255, color);
            sldOpacityCartographic.Invalidate();
            sldOpacitySimple.Invalidate();
            UpdatePreview();
        }
 /// <summary>
 /// Sets the pattern of squares for this pen by working with the given dash and compound patterns.
 /// </summary>
 /// <param name="stroke">Completely defines the ICartographicStroke that is being used to set the pattern.</param>
 public void SetPattern(ICartographicStroke stroke)
 {
     _lineColor = stroke.Color;
     _lineWidth = stroke.Width;
     
     if (stroke.DashButtons == null)
     {
         _horizontalButtons = null;
         _horizontalSlider.Position = new PointF(50F, 0F);
     }
     else
     {
         SetHorizontalPattern(stroke.DashButtons);
     }
     if (stroke.CompoundButtons == null)
     {
         _verticalButtons = null;
         _verticalSlider.Position = new PointF(0F, 20F);
     }
     else
     {
         SetVerticalPattern(stroke.CompoundButtons);
     }
     
     CalculatePattern();
     Invalidate();
 }
        /// <summary>
        /// When the stroke is changed, this updates the controls to match it.
        /// </summary>
        private void UpdateStrokeControls()
        {
            _ignoreChanges = true;
            ICartographicStroke cs = ccStrokes.SelectedStroke as ICartographicStroke;

            if (cs != null)
            {
                cmbStrokeType.SelectedItem = "Cartographic";
                if (tabStrokeProperties.TabPages.Contains(tabSimple))
                {
                    tabStrokeProperties.TabPages.Remove(tabSimple);
                }
                if (tabStrokeProperties.TabPages.Contains(tabCartographic) == false)
                {
                    tabStrokeProperties.TabPages.Add(tabCartographic);
                }
                if (tabStrokeProperties.TabPages.Contains(tabDash) == false)
                {
                    tabStrokeProperties.TabPages.Add(tabDash);
                }
                if (tabStrokeProperties.TabPages.Contains(tabDecoration) == false)
                {
                    tabStrokeProperties.TabPages.Add(tabDecoration);
                }

                // Cartographic Tab Page
                if (cmbStartCap.Items.Count == 0)
                {
                    LoadLineCaps();
                }
                cmbStartCap.SelectedItem = cs.StartCap;
                cmbEndCap.SelectedItem   = cs.EndCap;
                radLineJoin.Value        = cs.JoinType;
                dblStrokeOffset.Value    = cs.Offset;

                // Template Tab Page
                dashControl1.SetPattern(cs);
                dashControl1.Invalidate();

                // Decoration Tab Page
                ccDecorations.Decorations = cs.Decorations;
                if (cs.Decorations != null && cs.Decorations.Count > 0)
                {
                    ccDecorations.SelectedDecoration = cs.Decorations[0];
                }
            }
            else
            {
                cmbStrokeType.SelectedItem = "Simple";
                if (tabStrokeProperties.TabPages.Contains(tabDash))
                {
                    tabStrokeProperties.TabPages.Remove(tabDash);
                }
                if (tabStrokeProperties.TabPages.Contains(tabCartographic))
                {
                    tabStrokeProperties.TabPages.Remove(tabCartographic);
                }
                if (tabStrokeProperties.TabPages.Contains(tabDecoration))
                {
                    tabStrokeProperties.TabPages.Remove(tabDecoration);
                }
                if (tabStrokeProperties.TabPages.Contains(tabSimple) == false)
                {
                    tabStrokeProperties.TabPages.Add(tabSimple);
                }
            }
            ISimpleStroke ss = ccStrokes.SelectedStroke as ISimpleStroke;

            if (ss != null)
            {
                // Simple Tab Page
                cbColorSimple.Color                 = ss.Color;
                cbColorCartographic.Color           = ss.Color;
                dblWidthCartographic.Value          = ss.Width;
                dblWidth.Value                      = ss.Width;
                cmbStrokeStyle.SelectedIndex        = (int)ss.DashStyle;
                sldOpacityCartographic.MaximumColor = Color.FromArgb(255, ss.Color.R, ss.Color.G, ss.Color.B);
                sldOpacitySimple.MaximumColor       = Color.FromArgb(255, ss.Color.R, ss.Color.G, ss.Color.B);
                sldOpacitySimple.Value              = ss.Opacity;
                sldOpacityCartographic.Value        = ss.Opacity;
                sldOpacityCartographic.Invalidate();
                sldOpacitySimple.Invalidate();
            }

            _ignoreChanges = false;
        }