Exemple #1
0
 protected GraphicsBase(int x, int y, int width, int height, IStroke stroke, params GraphicOption[] options)
     : this(width, height, options)
 {
     Left   = x;
     Top    = y;
     Stroke = stroke;
 }
        private void UpdateWidth(double value)
        {
            if (_ignoreChanges)
            {
                return;
            }
            IStroke stroke = ccStrokes.SelectedStroke;

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

            if (ss != null)
            {
                ss.Width = dblWidth.Value;
            }
            // only call if changed, or else we will create an infinite loop here
            if (dblWidth.Value != value)
            {
                dblWidth.Value = value;
            }
            if (dblWidthCartographic.Value != value)
            {
                dblWidthCartographic.Value = value;
            }
            UpdatePreview();
        }
        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();
        }
Exemple #4
0
 protected GraphicsBase(int x, int y, int width, int height, IStroke stroke, params GraphicOption[] options)
     : this(width, height, options)
 {
     Left = x;
     Top = y;
     Stroke = stroke;
 }
Exemple #5
0
        private void CopyProperties(IStroke stroke, IStroke other)
        {
            if (stroke == null || other == null)
            {
                if (stroke.StrokeStyle == other.StrokeStyle)
                {
                    stroke.CopyProperties(other);
                }
                else
                {
                    switch (stroke.StrokeStyle)
                    {
                    case StrokeStyle.Simple:
                        ISimpleStroke simpleStroke = stroke as ISimpleStroke;
                        if (other is ISimpleStroke otherSimpleStroke)
                        {
                            CopyProperties(simpleStroke, otherSimpleStroke);
                        }
                        break;

                    case StrokeStyle.Cartographic:
                        break;

                    case StrokeStyle.Marker:
                        break;

                    default:     // notimplement
                        break;
                    }
                }
            }
        }
        private void LbxItemsDrawItem(object sender, DrawItemEventArgs e)
        {
            Rectangle outer = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, outer);
            }
            else
            {
                using (Brush b = new SolidBrush(BackColor))
                {
                    e.Graphics.FillRectangle(b, outer);
                }
            }

            Rectangle inner = new Rectangle(e.Bounds.X + 5, e.Bounds.Y + 1, e.Bounds.Width - 10, e.Bounds.Height - 3);

            e.Graphics.FillRectangle(Brushes.White, inner);
            e.Graphics.DrawRectangle(Pens.Black, inner);
            IStroke stroke = _lbxItems.Items[e.Index] as IStroke;

            if (stroke == null)
            {
                return;
            }
            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddLine(new Point(e.Bounds.X + 10, e.Bounds.Y + (e.Bounds.Height / 2)), new Point(e.Bounds.Width - 10, e.Bounds.Y + (e.Bounds.Height / 2)));
                stroke.DrawPath(e.Graphics, gp, 1);
            }
        }
Exemple #7
0
        private void displayLine_CheckedChanged(object sender, EventArgs e)
        {
            if (m_inUpdate)
            {
                return;
            }

            if (lineStyleEditor.displayLine.Checked)
            {
                m_item.Stroke = previousStroke ?? _factory.CreateDefaultStroke();
            }
            else
            {
                if (m_item.Stroke != null)
                {
                    previousStroke = m_item.Stroke;
                }
                m_item.Stroke = null;
            }
            UpdatePreviewResult();
            if (Changed != null)
            {
                Changed(this, new EventArgs());
            }
        }
        private void UpdateDisplayForSelected()
        {
            bool prevUpdate = m_inUpdate;

            try
            {
                m_inUpdate = true;
                IStroke st = this.CurrentStrokeType;
                sizeGroup.Enabled            =
                    lineGroup.Enabled        =
                        previewGroup.Enabled =
                            st != null;

                RemoveStyleButton.Enabled = st != null && m_item.Count > 1;

                if (st != null)
                {
                    sizeUnitsCombo.SelectedValue = st.Unit.ToString();

                    //sizeContextCombo.SelectedValue = st.SizeContext.ToString();

                    if (st.Color == null)
                    {
                        lineStyleEditor.colorCombo.ColorExpression = Utility.SerializeHTMLColor(Color.Black, true);
                    }
                    else
                    {
                        lineStyleEditor.colorCombo.ColorExpression = st.Color;
                    }

                    foreach (object i in lineStyleEditor.fillCombo.Items)
                    {
                        if (i as ImageStylePicker.NamedImage != null && (i as ImageStylePicker.NamedImage).Name == st.LineStyle)
                        {
                            lineStyleEditor.fillCombo.SelectedItem = i;
                            break;
                        }
                    }

                    lineStyleEditor.thicknessCombo.Text = st.Thickness;

                    sizeContextCombo.Enabled = true;
                    var st2 = st as IStroke2;
                    if (st2 != null)
                    {
                        sizeContextCombo.SelectedValue = st2.SizeContext;
                    }
                    else
                    {
                        sizeContextCombo.Enabled = false;
                    }
                }
                UpdatePreviewResult();
            }
            finally
            {
                m_inUpdate = prevUpdate;
            }
        }
        void ILineRule.AddStroke(IStroke stroke)
        {
            var st = stroke as StrokeType;

            if (st != null)
            {
                this.Items.Add(st);
            }
        }
        void ILineRule.RemoveStroke(IStroke stroke)
        {
            var st = stroke as StrokeType;

            if (st != null)
            {
                this.Items.Remove(st);
            }
        }
Exemple #11
0
        /// <summary>
        /// This gets a single color that attempts to represent the specified
        /// category.  For polygons, for example, this is the fill color (or central fill color)
        /// of the top pattern.  If an image is being used, the color will be gray.
        /// </summary>
        /// <returns>The System.Color that can be used as an approximation to represent this category.</returns>
        public override Color GetColor()
        {
            if (Symbolizer == null || Symbolizer.Strokes == null || Symbolizer.Strokes.Count == 0)
            {
                return(Color.Gray);
            }
            IStroke p = Symbolizer.Strokes[0];

            return(p.GetColor());
        }
 /// <summary>
 /// Calculates a matching score between stroke1 and stroke2.
 /// </summary>
 /// <param name="stroke1">The first stroke.</param>
 /// <param name="stroke2">The second stroke.</param>
 /// <returns>Matching score as a double value.</returns>
 public double Match(IStroke stroke1, IStroke stroke2)
 {
     double r = double.MaxValue;
     if ((stroke1 is Stroke) && (stroke2 is Stroke))
     {
         TimeWarping tw = new TimeWarping(stroke1 as Stroke, stroke2 as Stroke);
         tw.CalculateDistances((p1, p2) => p1.Distance(p2));
         tw.CalculateCumulativeDistance();
         r = tw.WarpingDistance;
     }
     return r;
 }
Exemple #13
0
        private void drawingPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                currentStroke  = new Stroke(e.Location);
                lastDrawnPoint = e.Location;

                graphics.FillRectangle(significantPointBrush, lastDrawnPoint.X - 4, lastDrawnPoint.Y - 4, 9, 9);

                strokes.Add(currentStroke);
            }
        }
Exemple #14
0
        /// <summary>
        /// Defines this stroke as a new kind of stroke.
        /// </summary>
        /// <param name="style"></param>
        public void CreateNew(StrokeStyle style)
        {
            switch (style)
            {
            case StrokeStyle.Simple:
                _innerStroke = new SimpleStroke();
                break;

            case StrokeStyle.Catographic:
                _innerStroke = new CartographicStroke();
                break;
            }
        }
        /// <summary>
        /// Calculates a matching score between stroke1 and stroke2.
        /// </summary>
        /// <param name="stroke1">The first stroke.</param>
        /// <param name="stroke2">The second stroke.</param>
        /// <returns>Matching score as a double value.</returns>
        public double Match(IStroke stroke1, IStroke stroke2)
        {
            double r = double.MaxValue;

            if ((stroke1 is Stroke) && (stroke2 is Stroke))
            {
                TimeWarping tw = new TimeWarping(stroke1 as Stroke, stroke2 as Stroke);
                tw.CalculateDistances((p1, p2) => p1.Distance(p2));
                tw.CalculateCumulativeDistance();
                r = tw.WarpingDistance;
            }
            return(r);
        }
        private void BtnUpClick(object sender, EventArgs e)
        {
            IStroke stroke = _lbxItems.SelectedItem as IStroke;

            if (stroke == null)
            {
                return;
            }
            _strokes.IncreaseIndex(stroke);
            RefreshList();
            _lbxItems.SelectedItem = stroke;
            OnOrderChanged();
        }
        public List <Tuple <Point, Point> > GetStrokeSegments(IStroke stroke)
        {
            var significantPoints = stroke.GetSignificantPoints();
            var strokeSegments    = new List <Tuple <Point, Point> >();

            for (int i = 1; i < significantPoints.Count; i++)
            {
                var p1 = significantPoints[i - 1];
                var p2 = significantPoints[i];

                strokeSegments.Add(new Tuple <Point, Point>(p1, p2));
            }

            return(strokeSegments);
        }
Exemple #18
0
        private void BtnMarkerClick(object sender, EventArgs e)
        {
            IStroke stroke = ccStrokes.SelectedStroke;

            switch (stroke.StrokeStyle)
            {
            case StrokeStyle.Marker:
                IMarkerStroke             markerStroke = stroke as IMarkerStroke;
                DetailedPointSymbolDialog dpd          = new DetailedPointSymbolDialog(markerStroke.Marker);
                dpd.ChangesApplied += (x, y) => { UpdatePreview(); };
                dpd.ShowDialog();
                break;

            default:
                return;
            }
        }
Exemple #19
0
        /// <summary>
        /// Updates the opacity of the simple/cartographic stroke.
        /// </summary>
        /// <param name="value">THe floating point value to use for the opacity, where 0 is transparent and 1 is opaque.</param>
        private void UpdateOpacity(float value)
        {
            if (_ignoreChanges)
            {
                return;
            }
            IStroke stroke = ccStrokes.SelectedStroke;

            if (stroke is ISimpleStroke ss)
            {
                if (ss.Opacity != value)
                {
                    ss.Opacity                = value;
                    cbColorSimple.Color       = ss.Color;
                    cbColorCartographic.Color = ss.Color;
                }
            }
        }
Exemple #20
0
        private void CmbStartCapSelectedIndexChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            if (ccStrokes.SelectedStroke == null)
            {
                return;
            }
            IStroke stroke = ccStrokes.SelectedStroke;

            if (stroke is ICartographicStroke cs && cmbStartCap.SelectedIndex != -1)
            {
                cs.StartCap = (LineCap)cmbStartCap.SelectedItem;
            }

            UpdatePreview();
        }
Exemple #21
0
        private void RadLineJoinValueChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            if (ccStrokes.SelectedStroke == null)
            {
                return;
            }
            IStroke stroke = ccStrokes.SelectedStroke;

            if (stroke is ICartographicStroke cs)
            {
                cs.JoinType = radLineJoin.Value;
            }

            UpdatePreview();
        }
Exemple #22
0
        private void CmbStrokeTypeSelectedIndexChanged(object sender, EventArgs e)
        {
            if (_ignoreChanges)
            {
                return;
            }
            var oldStroke      = ccStrokes.SelectedStroke;
            var oldStrokeStyle = oldStroke.StrokeStyle;
            int index          = ccStrokes.Strokes.IndexOf(ccStrokes.SelectedStroke);

            if (index == -1)
            {
                return;
            }
            StrokeStyle strokeStyle = Global.ParseEnum <StrokeStyle>(cmbStrokeType.SelectedIndex);
            IStroke     newStroke   = null;

            switch (strokeStyle)
            {
            case StrokeStyle.Cartographic:
                newStroke = new CartographicStroke();
                break;

            case StrokeStyle.Simple:
                newStroke = new SimpleStroke();
                break;

            case StrokeStyle.Marker:
                newStroke = new MarkerStroke();
                break;

            default:
                cmbStrokeType.SelectedIndex = Global.GetEnumIndex(oldStrokeStyle);
                MessageBox.Show("暂未实现");
                return;
            }
            StrokeStyle newStrokeStyle = newStroke.StrokeStyle;

            newStroke.CopyProperties(oldStroke);
            ccStrokes.Strokes[index] = newStroke;
            ccStrokes.RefreshList();
            ccStrokes.SelectedStroke = newStroke;
        }
        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 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();
        }
        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (_lbxItems.SelectedItem == null)
            {
                return;
            }
            IStroke stroke = _lbxItems.SelectedItem as IStroke;
            int     index  = _strokes.IndexOf(stroke);

            _strokes.Remove(stroke);
            RefreshList();
            if (_strokes.Count == 0)
            {
                return;
            }
            if (index >= _strokes.Count)
            {
                index -= 1;
            }
            _lbxItems.SelectedIndex = index;
            OnRemoveClick();
        }
 public void AddStrokeAsTimeDependentControlPoint(IStroke stroke)
 {
     enumerators.Add(stroke.GetEnumerator());
 }
Exemple #27
0
 /// <summary>
 /// Defines this stroke as a new kind of stroke.
 /// </summary>
 /// <param name="style"></param>
 public void CreateNew(StrokeStyles style)
 {
     switch (style)
     {
         case StrokeStyles.Simple: 
             _innerStroke = new SimpleStroke();
             break;
         case StrokeStyles.Catographic:
             _innerStroke = new CartographicStroke();
             break;
     }
 }
Exemple #28
0
 public Fractal(int x, int y, int width, int height, IStroke stroke, params GraphicOption[] options) : base(x, y, width, height, stroke, options)
 {
 }
Exemple #29
0
 /// <summary>
 /// Calculates the matching score between two IStrokes
 /// </summary>
 /// <param name="stroke">The second stroke.</param>
 /// <param name="strokematcher">An instance of a strokematcher class.</param>
 /// <returns>double: matching value</returns>
 public double MatchingScore(IStroke stroke, IStrokeMatcher strokematcher)
 {
     return strokematcher.Match(this, stroke);
 }
 public static void AssertPointPresence(IStroke s, SPoint[] points, int count = 1)
 {
     AssertPointPresence(s.ToArray(), points, count);
 }
Exemple #31
0
 public Ellipse(IStroke stroke, params GraphicOption[] options) : base(stroke, options)
 {
 }
Exemple #32
0
 /// <summary>
 /// Provides information about if the stroke intersects the circle.
 /// </summary>
 /// <param name="stroke">The stroke.</param>
 /// <returns>
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Unknown"/> if status is unknown.
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Disjoint"/> if the stroke lies outside the circle.
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Overlap"/> if the stroke lies inside, intersects or is a tangent of the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.AEnclosesB"/> if the stroke lies completely inside the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Intersect"/> if the stroke intersects the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Tangents"/> if the stroke is a tangent of the circle.
 /// </returns>
 public static AreaCode Intersect(Circle2D circle2D, IStroke stroke)
 {
     throw new NotImplementedException();
 }
Exemple #33
0
 protected GraphicsBase(int width, int height, IFill fill, IStroke stroke, params GraphicOption[] options)
     : this(width, height, options)
 {
     Fill = fill;
     Stroke = stroke;
 }
Exemple #34
0
 public Rect(IFill fill, IStroke stroke, params GraphicOption[] options) : base(fill, stroke, options)
 {
 }
        private void displayLine_CheckedChanged(object sender, EventArgs e)
        {
            if (m_inUpdate)
                return;

            if (lineStyleEditor.displayLine.Checked)
                m_item.Stroke = previousStroke == null ? _factory.CreateDefaultStroke() : previousStroke;
            else
            {
                if (m_item.Stroke != null)
                    previousStroke = m_item.Stroke;
                m_item.Stroke = null;
            }
            UpdatePreviewResult();
            if (Changed != null)
                Changed(this, new EventArgs());
        }
Exemple #36
0
 public Rect(int x, int y, int width, int height, IFill fill, IStroke stroke, params GraphicOption[] options) : base(x, y, width, height, fill, stroke, options)
 {
 }
Exemple #37
0
 public Rect(int width, int height, IStroke stroke, params GraphicOption[] options) : base(width, height, stroke, options)
 {
 }
Exemple #38
0
 public Rect(IFill fill, IStroke stroke) : base(fill, stroke)
 {
 }
Exemple #39
0
 internal static AreaCode Intersect(Rectangle2D rectangle2D, IStroke stroke)
 {
     throw new NotImplementedException();
 }
Exemple #40
0
 internal static AreaCode Intersect(Rectangle2D rectangle2D, IStroke stroke)
 {
     throw new NotImplementedException();
 }
Exemple #41
0
 public void Draw(Mat img, IStroke stroke, bool connectPoints)
 {
     Draw(img, stroke.ToArray(), connectPoints);
 }
Exemple #42
0
 protected GraphicsBase(IFill fill, IStroke stroke, params GraphicOption[] options)
     :this(options)
 {
     Fill = fill;
     Stroke = stroke;
 }
 public DashedStroke(IStroke delegateStroke, int periodLength)
 {
     this.delegateStroke = delegateStroke;
     this.periodLength   = periodLength;
 }
Exemple #44
0
 public Ellipse(IFill fill, IStroke stroke) : base(fill, stroke)
 {
 }
Exemple #45
0
 /// <summary>
 /// Provides information about if the stroke intersects the circle.
 /// </summary>
 /// <param name="stroke">The stroke.</param>
 /// <returns>
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Unknown"/> if status is unknown.
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Disjoint"/> if the stroke lies outside the circle.
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Overlap"/> if the stroke lies inside, intersects or is a tangent of the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.AEnclosesB"/> if the stroke lies completely inside the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Intersect"/> if the stroke intersects the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Tangents"/> if the stroke is a tangent of the circle.
 /// </returns>
 public AreaCode Intersect(IStroke stroke)
 {
     return(Area.Intersect(this, stroke));
 }
        private void displayLine_CheckedChanged(object sender, EventArgs e)
        {
            if (m_inUpdate)
                return;

            if (m_item.Symbol.Type == PointSymbolType.Mark)
            {
                if (lineStyleEditor.displayLine.Checked)
                    ((IMarkSymbol)m_item.Symbol).Edge = previousEdge == null ? _factory.CreateDefaultStroke() : previousEdge;
                else
                {
                    if (((IMarkSymbol)m_item.Symbol).Edge != null)
                        previousEdge = ((IMarkSymbol)m_item.Symbol).Edge;
                    ((IMarkSymbol)m_item.Symbol).Edge = null;
                }
            }
            UpdatePreviewResult();
            if (Changed != null)
                Changed(this, new EventArgs());
        }
Exemple #47
0
 /// <summary>
 /// Provides information about if the stroke intersects the circle.
 /// </summary>
 /// <param name="stroke">The stroke.</param>
 /// <returns>
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Unknown"/> if status is unknown.
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Disjoint"/> if the stroke lies outside the circle.
 /// <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Overlap"/> if the stroke lies inside, intersects or is a tangent of the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.AEnclosesB"/> if the stroke lies completely inside the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Intersect"/> if the stroke intersects the circle.
 /// Additionally to Overlap: <see cref="Kanji.DesktopApp.Interfaces.AreaCode.Tangents"/> if the stroke is a tangent of the circle.
 /// </returns>
 public static AreaCode Intersect(Circle2D circle2D, IStroke stroke)
 {
     throw new NotImplementedException();
 }
Exemple #48
0
 protected GraphicsBase(IStroke stroke, params GraphicOption[] options)
     : this(options)
 {
     Stroke = stroke;
 }
Exemple #49
0
 public Fractal(int width, int height, IFill fill, IStroke stroke, params GraphicOption[] options) : base(width, height, fill, stroke, options)
 {
 }
Exemple #50
0
 public Fractal(IStroke stroke, params GraphicOption[] options) : base(stroke, options)
 {
 }
Exemple #51
0
 public Rect(IStroke stroke, params GraphicOption[] options) : base(stroke, options)
 {
 }
Exemple #52
0
 public Fractal(IFill fill, IStroke stroke) : base(fill, stroke)
 {
 }