/// <summary>
        /// Create the animation and add it to the master timeline
        /// </summary>
        protected override void CreateAnimation()
        {
            var geometry = new PathGeometry();
            geometry.AddGeometry(Geometry.Parse("M 10,100 C 10,300 300,-200 300,100"));

            var animationX = new DoubleAnimationUsingPath
                {
                    PathGeometry = geometry,
                    Duration = new Duration(this.AnimationConfiguration.Duration),
                    Source = PathAnimationSource.X
                };

            var animationY = new DoubleAnimationUsingPath
            {
                PathGeometry = geometry,
                Duration = new Duration(this.AnimationConfiguration.Duration),
                Source = PathAnimationSource.Y
            };

            Storyboard.SetTargetProperty(animationX, new PropertyPath(Canvas.LeftProperty));
            Storyboard.SetTargetProperty(animationY, new PropertyPath(Canvas.TopProperty));

            animationX.Freeze();
            animationY.Freeze();

            this.MasterStoryboard.Children.Add(animationX);
            this.MasterStoryboard.Children.Add(animationY);
        }
Example #2
0
		protected override void OnRender(DrawingContext drawingContext) {
			base.OnRender(drawingContext);
			if (hexBox.Selection == null || hexBox.VisibleBytesPerLine < 1)
				return;

			ulong selStart = hexBox.Selection.Value.StartOffset;
			ulong selEnd = hexBox.Selection.Value.EndOffset;
			int lines = hexBox.VisibleLinesPerPage;
			ulong bpl = (ulong)hexBox.VisibleBytesPerLine;
			ulong visibleStart = hexBox.TopOffset;
			ulong visibleEnd = NumberUtils.AddUInt64(NumberUtils.AddUInt64(visibleStart, NumberUtils.MulUInt64(bpl, NumberUtils.SubUInt64((ulong)lines, 1))), NumberUtils.SubUInt64(bpl, 1));
			if (selStart > visibleEnd || selEnd < visibleStart)
				return;

			ulong offset = Math.Max(selStart, visibleStart);
			ulong endOffset = Math.Min(selEnd, visibleEnd);
			double x = -hexBox.CharacterWidth * hexBox.LeftColumn;
			double y = (offset - hexBox.TopOffset) / bpl * hexBox.CharacterHeight;
			var path = new PathGeometry();
			double hexByteX = hexBox.GetHexByteColumnIndex() * hexBox.CharacterWidth;
			double asciiX = hexBox.GetAsciiColumnIndex() * hexBox.CharacterWidth;
			while (offset <= endOffset) {
				ulong byteIndex = hexBox.GetLineByteIndex(offset);
				ulong count = Math.Min(bpl - byteIndex, endOffset - offset + 1);

				double dx = byteIndex * hexBox.CharacterWidth;
				var rectGeo = new RectangleGeometry(new Rect(x + dx * 3 + hexByteX + hexBox.CharacterWidth, y, count * hexBox.CharacterWidth * 3 - hexBox.CharacterWidth, hexBox.CharacterHeight));
				rectGeo.Freeze();
				path.AddGeometry(rectGeo);

				if (hexBox.ShowAscii) {
					rectGeo = new RectangleGeometry(new Rect(x + dx + asciiX, y, count * hexBox.CharacterWidth, hexBox.CharacterHeight));
					rectGeo.Freeze();
					path.AddGeometry(rectGeo);
				}

				if (offset + bpl - byteIndex < offset)
					break;
				offset += bpl - byteIndex;
				y += hexBox.CharacterHeight;
			}

			path.Freeze();
			drawingContext.DrawGeometry(Background, null, path);
		}
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PathGeometry pathData = new PathGeometry();

            if ((Status)value == Status.Connected)
            {
                pathData.AddGeometry(Geometry.Parse(""));
            }
            else if ((Status)value == Status.Disconnected)
            {
                pathData.AddGeometry(Geometry.Parse("F1 M 58.5832,55.4172L 17.4169,55.4171C 15.5619,53.5621 15.5619,50.5546 17.4168,48.6996L 35.201,15.8402C 37.056,13.9852 40.0635,13.9852 41.9185,15.8402L 58.5832,48.6997C 60.4382,50.5546 60.4382,53.5622 58.5832,55.4172 Z M 34.0417,25.7292L 36.0208,41.9584L 39.9791,41.9583L 41.9583,25.7292L 34.0417,25.7292 Z M 38,44.3333C 36.2511,44.3333 34.8333,45.7511 34.8333,47.5C 34.8333,49.2489 36.2511,50.6667 38,50.6667C 39.7489,50.6667 41.1666,49.2489 41.1666,47.5C 41.1666,45.7511 39.7489,44.3333 38,44.3333 Z"));
            }
            else
            {
                pathData.AddGeometry(Geometry.Parse("F1 M 37.2083,49.0833C 39.3945,49.0833 41.1667,50.8555 41.1667,53.0417C 41.1667,55.2278 39.3945,57 37.2083,57C 35.0222,57 33.25,55.2278 33.25,53.0417C 33.25,50.8555 35.0222,49.0833 37.2083,49.0833 Z M 38,17.4167C 44.9956,17.4167 50.6666,21.9416 50.6666,28.5C 50.6666,30.875 49.0833,34.8333 45.9167,36.4167C 42.75,38 41.1667,40.1267 41.1667,42.75L 41.1667,45.9167L 33.25,45.9167L 33.25,43.5417C 33.25,38.1571 38,34.8333 39.5833,33.25C 42.75,30.0833 42.75,29.644 42.75,28.5C 42.75,25.8767 40.6233,23.75 38,23.75C 35.3766,23.75 33.25,25.8767 33.25,28.5L 33.25,30.875L 25.3333,30.875L 25.3333,29.2917C 25.3333,22.7333 31.0044,17.4167 38,17.4167 Z"));
            }

            return pathData;
        }
        internal override PathGeometry GetAsPathGeometry()
        {
            PathGeometry pg = new PathGeometry();
            pg.AddGeometry(this);

            pg.FillRule = FillRule;

            Debug.Assert(pg.CanFreeze);

            return pg;
        }
Example #5
0
        public void AddPath(IGraphicsPath path, bool connect = false)
        {
            if (path.IsEmpty)
            {
                return;
            }

            var wpfPath = path.ToWpf();

            if (!wpfPath.Transform.Value.IsIdentity)
            {
                var newpath = new swm.PathGeometry();
                newpath.AddGeometry(wpfPath);
                wpfPath = newpath;
            }
            var en = wpfPath.Figures.GetEnumerator();

            if (connect)
            {
                // merge current figure (if any) and first figure of new path, if they are not closed paths
                if (figure != null && !figure.IsClosed && en.MoveNext())
                {
                    var firstFigure = en.Current;
                    if (!firstFigure.IsClosed)
                    {
                        figure.Segments.Add(new swm.LineSegment(firstFigure.StartPoint, true));
                        foreach (var seg in firstFigure.Segments)
                        {
                            figure.Segments.Add(seg);
                        }
                    }
                    else
                    {
                        Control.Figures.Add(firstFigure);
                    }
                }
            }
            swm.PathFigure pathFigure = null;
            while (en.MoveNext())
            {
                pathFigure = en.Current;
                Control.Figures.Add(pathFigure);
            }

            // continue with last figure of new path if not closed
            if (pathFigure != null && !pathFigure.IsClosed)
            {
                figure = pathFigure;
            }
            else
            {
                figure = null;
            }
        }
        public string GetAllToTogether(string[] paths)
        {
            PathGeometry result = new PathGeometry();
            foreach (var item in paths)
            {
                result.AddGeometry (  PathGeometry.Parse(item));

            }

            return result.ToString();
        }
Example #7
0
        public void DrawCircle(Point center, DrawingContext drawingContext, Size windowSize, bool drawCircle)
        {
            var rectangle = new Rect(center.X - Radius, center.Y - Radius, Radius * 2, Radius * 2);
            var path = new PathGeometry();
            path.AddGeometry(new EllipseGeometry(rectangle));
            drawingContext.PushClip(path);
            var windowRect = new Rect(windowSize);
            drawingContext.DrawImage(Bitmap, windowRect);

            if (drawCircle)
                drawingContext.DrawEllipse(Brushes.Transparent, new Pen(Brushes.Red, 1.5), center, Radius, Radius);
        }
Example #8
0
        internal override PathGeometry GetAsPathGeometry()
        {
            PathGeometry pg = new PathGeometry();

            pg.AddGeometry(this);

            pg.FillRule = FillRule;

            Debug.Assert(pg.CanFreeze);

            return(pg);
        }
        private void CreateAutoShape(object sender, RoutedEventArgs e)
        {
            PathGeometry sendingPath = new PathGeometry(); 
            PathFigure pathFigure = new PathFigure();
            pathFigure.StartPoint = new Point(47.7778, 48.6667);
            pathFigure.IsClosed = true;
            LineSegment lineSegment1 = new LineSegment();
            lineSegment1.Point = new Point(198, 48.6667);
            pathFigure.Segments.Add(lineSegment1);
            LineSegment lineSegment2 = new LineSegment();
            lineSegment2.Point = new Point(198, 102);
            pathFigure.Segments.Add(lineSegment2);
            BezierSegment bezierSegment1 = new BezierSegment();
            bezierSegment1.Point1 = new Point(174.889, 91.3334);
            bezierSegment1.Point2 = new Point(157.111, 79.7778);
            bezierSegment1.Point3 = new Point(110.889, 114.444);
            pathFigure.Segments.Add(bezierSegment1);
            BezierSegment bezierSegment2 = new BezierSegment();
            bezierSegment2.Point1 = new Point(64.667, 149.111);
            bezierSegment2.Point2 = new Point(58.4444, 130.444);
            bezierSegment2.Point3 = new Point(47.7778, 118.889);
            pathFigure.Segments.Add(bezierSegment2);
            sendingPath.Figures.Add(pathFigure);

            PathGeometry pathGeometry = new PathGeometry();
            if (sendingPath.FillRule != null)
                pathGeometry.FillRule = sendingPath.FillRule;
            else pathGeometry.FillRule = FillRule.Nonzero;
            pathGeometry.Figures = sendingPath.Figures;

            var newThumb = new SandRibbonInterop.AutoShape();
            var safePathGeometry = (Geometry)(new GeometryConverter().ConvertFromString(pathGeometry.ToString()));
            var safePathData = new PathGeometry();
            safePathData.AddGeometry(safePathGeometry);
            newThumb.PathData = safePathData;
            newThumb.Background = Brushes.LightGreen;
            newThumb.Foreground = Brushes.Green;
            newThumb.StrokeThickness = 5;
            newThumb.Height = 100;
            newThumb.Width = 100;
            
            Commands.AddAutoShape.Execute(newThumb);
        }
        protected override void OnRefresh()
        {
            LineDecoration lineDecoration = Visual as LineDecoration;
            if (lineDecoration != null)
            {
                _pathPen = new Pen(new SolidColorBrush(lineDecoration.LineColor), lineDecoration.Thickness);
                _path = new PathGeometry();

                Point startPoint = new Point(lineDecoration.Start.X - lineDecoration.Left, lineDecoration.Start.Y - lineDecoration.Top);
                Point endPoint = new Point(lineDecoration.End.X - lineDecoration.Left, lineDecoration.End.Y - lineDecoration.Top);

                if (lineDecoration.Curve)
                {
                    // Create a vector representing the direction of the line
                    Vector v1 = lineDecoration.End - lineDecoration.Start;
                    double length = v1.Length;

                    // Normalize so it can be used to construct control points
                    v1.Normalize();

                    // Create a matrix to rotate arm perpendicular
                    Matrix m1 = new Matrix();
                    m1.Rotate(-90);

                    Point curvePoint1 = (startPoint + (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);
                    Point curvePoint2 = (endPoint - (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);

                    //_path.Figures.Add(QuadraticBezierFromIntersection(startPoint, curvePoint1, endPoint));
                    _path.Figures.Add(BezierFromIntersection(startPoint,curvePoint1,curvePoint2,endPoint));
                }
                else
                {
                    LineGeometry line = new LineGeometry(startPoint, endPoint);
                    _path.AddGeometry(line);
                }                
            }
        }
Example #11
0
		public void AddPath (IGraphicsPath path, bool connect = false)
		{
			if (path.IsEmpty)
				return;

			var wpfPath = path.ToWpf ();
			if (!wpfPath.Transform.Value.IsIdentity) {
				var newpath = new swm.PathGeometry ();
				newpath.AddGeometry (wpfPath);
				wpfPath = newpath;
			}
			var en = wpfPath.Figures.GetEnumerator ();
			if (connect) {
				// merge current figure (if any) and first figure of new path, if they are not closed paths
				if (figure != null && !figure.IsClosed && en.MoveNext ()) {
					var firstFigure = en.Current;
					if (!firstFigure.IsClosed) {
						figure.Segments.Add (new swm.LineSegment (firstFigure.StartPoint, true));
						foreach (var seg in firstFigure.Segments)
							figure.Segments.Add (seg);
					} else {
						Control.Figures.Add (firstFigure);
					}
				}
			}
			swm.PathFigure pathFigure = null;
			while (en.MoveNext ()) {
				pathFigure = en.Current;
				Control.Figures.Add (pathFigure);
			}
			
			// continue with last figure of new path if not closed
			if (pathFigure != null && !pathFigure.IsClosed)
				figure = pathFigure;
			else
				figure = null;
		}
Example #12
0
        /// <summary>
        /// 构造steiner树的几何图形
        /// </summary>
        /// <param name="st">steinertree类</param>
        /// <param name="gm">GraphManager类</param>
        /// <param name="radius">每个点的半径</param>
        /// <param name="fontsize">每个点说明文字的大小</param>
        /// <returns>几何图形组。[0]为点集,[1]为边集</returns>
        public PathGeometry[] ConstructSteinterGeometry(SteinerTree st, GraphManager gm, int radius, int fontsize)
        {
            steinertreeShape = new PathGeometry();
            steinertreeLine = new PathGeometry();
            //i即要绘制的节点
            foreach (int i in st.steinerTreeNode)
            {
                steinertreeShape.AddGeometry(new EllipseGeometry((Point)gm.arrayPos.GetValue(i), radius, radius));
                Point ptext = new Point(((Point)gm.arrayPos.GetValue(i)).X - H_GAP, ((Point)gm.arrayPos.GetValue(i)).Y - V_GAP);
                steinertreeShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptext, fontsize).BuildGeometry());
            }
            //画线
            foreach (edge i in st.steinerTreeEdge)
            {
                steinertreeLine.AddGeometry(new LineGeometry((Point)gm.arrayPos.GetValue(i.x), (Point)gm.arrayPos.GetValue(i.y)));
            }

            return new PathGeometry[] { steinertreeShape, steinertreeLine };
        }
Example #13
0
        /// <summary>
        /// 从数据图构造几何图形
        /// </summary>
        /// <param name="gm">数据图GraphManager</param>
        /// <param name="radius">每個點的半徑</param>
        /// <param name="fontsize">字体大小</param>
        /// <returns></returns>
        public PathGeometry[] ConstructGeometrySimple(GraphManager gm, int radius, int fontsize)
        {
            #region 画点
            int PCount = 0;
            int ACount = 0;
            int WCount = 0;
            int CCount = 0;
            dataGraphShape = new PathGeometry();
            dataGraphLine = new PathGeometry();

            for (int i = 0; i < gm.nodeNum; i++)
            {
                if (gm.arrayKey.GetValue(i).ToString()[0] == 't')
                {
                    Point centerP = new Point(H_DIST * PCount + H_DIST, 2 * V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerP, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * PCount + H_DIST, 2 * V_DIST), i);
                    Point ptextP = new Point(H_DIST * PCount + H_DIST - H_GAP, 2 * V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextP, fontsize).BuildGeometry());
                    PCount++;
                }
                if (gm.arrayKey.GetValue(i).ToString()[0] == 'a')
                {
                    Point centerA = new Point(H_DIST * ACount + H_DIST, 4 * V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerA, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * ACount + H_DIST, 4 * V_DIST), i);
                    Point ptextA = new Point(H_DIST * ACount + H_DIST - H_GAP, 4 * V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextA, fontsize).BuildGeometry());
                    ACount++;
                }
                if (gm.arrayKey.GetValue(i).ToString()[0] == 'C')
                {
                    Point centerC = new Point(H_DIST * CCount + H_DIST, V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerC, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * CCount + H_DIST, V_DIST), i);
                    Point ptextC = new Point(H_DIST * CCount + H_DIST - H_GAP, V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextC, fontsize).BuildGeometry());
                    CCount++;
                }
                if (gm.arrayKey.GetValue(i).ToString()[0] == 'W')
                {
                    Point centerW = new Point(H_DIST * WCount + H_DIST, 3 * V_DIST);
                    dataGraphShape.AddGeometry(new EllipseGeometry(centerW, radius, radius));
                    gm.arrayPos.SetValue(new Point(H_DIST * WCount + H_DIST, 3 * V_DIST), i);
                    Point ptextW = new Point(H_DIST * WCount + H_DIST - H_GAP, 3 * V_DIST - V_GAP);
                    dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextW, fontsize).BuildGeometry());
                    WCount++;
                }
            }
            #endregion

            #region 画线
            for (int i = 0; i < gm.nodeNum; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    if (gm.graph[i, j] == 1)
                    {
                        dataGraphLine.AddGeometry(new LineGeometry((Point)gm.arrayPos.GetValue(i), (Point)gm.arrayPos.GetValue(j)));
                    }
                }
            }
            #endregion

            return new PathGeometry[] { dataGraphShape, dataGraphLine };
        }
Example #14
0
		private void ConstructCaretGeometry()
		{
			PathGeometry geometry = new PathGeometry();
			geometry.AddGeometry(new RectangleGeometry(new Rect(0, 0, base.Width, base.Height)));
			if (InputLanguageManager.Current.CurrentInputLanguage.TextInfo.IsRightToLeft)
			{
				PathFigure figure = new PathFigure();
				figure.StartPoint = new Point(0, 0);
				figure.Segments.Add(new LineSegment(new Point(-2, 0), true));
				figure.Segments.Add(new LineSegment(new Point(0, base.Height / 10), true));
				figure.IsClosed = true;
				geometry.Figures.Add(figure);
			}
			_caretGeometry = geometry;
			if (_caretGeometry.CanFreeze)
			{
				_caretGeometry.Freeze();
			}
			base.InvalidateVisual();
		}
Example #15
0
        public MainWindow()
        {
            bool startWithLogo = true;

            InitializeComponent();
            onChangeNavigateLink += gotoNextContent;  
            

            foreach (string arg in App.startupArguments)
            {
                switch (arg)
                {
                    case "-nologo":
                        startWithLogo = false;
                        break;
                }
            }

            //отображать нам лого?
            bool tempLogo = true;
            try
            {
            tempLogo = RegistryWorker.GetKeyValue<int>(Microsoft.Win32.RegistryHive.LocalMachine, VentsConst._SETTINGSLOCATION, "StartLogoCHKB") == 1 ? false : true;
            }
            catch (System.IO.IOException) {}
            catch(Exception ex)
            {
                _log.Error(ex.Message + " (чтение из реестра)");
            }
            if (startWithLogo && tempLogo)
            {
                LogoWindow LW = new LogoWindow(main);
                LW.ShowInTaskbar = false;
                LW.Show();
            }
            else
                main.Visibility = Visibility.Visible;

            VentsTools.onChangeActionString += this.UpdateMainLinkGroup;

            VentsTools.currentActionString = "";
            PathGeometry p1 = new PathGeometry();
            PathGeometry p2 = new PathGeometry();
            PathGeometry p3 = new PathGeometry();
            PathGeometry p4 = new PathGeometry();
            PathGeometry p5 = new PathGeometry();
           // Path p6 = new Path();
            p1.AddGeometry(Geometry.Parse("M 0.00 0.00 L 83.00 0.00 L 83.00 77.00 L 0.00 77.00 L 0.00 0.00 M 39.23 5.21 C 34.51 6.32 32.01 12.80 35.61 16.40 C 38.69 20.70 45.89 19.57 47.75 14.70 C 50.19 9.57 44.54 3.42 39.23 5.21 M 19.54 50.14 C 22.69 58.90 30.27 66.88 40.00 67.47 C 40.00 62.86 40.01 58.26 40.00 53.66 C 36.61 53.02 33.37 51.41 31.24 48.64 C 24.19 39.84 25.15 25.06 34.45 18.18 C 31.95 15.45 31.32 11.70 32.19 8.15 C 18.07 16.32 13.93 35.56 19.54 50.14 M 49.91 8.41 C 50.59 11.93 49.96 15.57 47.47 18.26 C 56.72 25.09 57.63 39.78 50.70 48.55 C 48.66 51.29 45.48 52.87 42.22 53.63 C 42.22 58.21 42.26 62.79 42.18 67.38 C 48.76 66.86 54.67 62.79 58.31 57.40 C 62.61 51.44 64.32 44.07 64.63 36.83 C 61.99 35.78 59.31 34.81 56.74 33.58 C 59.19 32.32 61.63 31.05 64.01 29.67 C 62.18 21.15 57.63 12.88 49.91 8.41 M 35.87 21.10 C 35.89 30.40 35.87 39.70 35.87 49.00 C 39.40 48.96 42.92 48.97 46.45 49.00 C 46.48 39.69 46.47 30.37 46.45 21.05 C 43.14 22.84 39.16 23.06 35.87 21.10 Z"));
            //p1.Data = Geometry.Parse("M 0.00 0.00 L 83.00 0.00 L 83.00 77.00 L 0.00 77.00 L 0.00 0.00 M 39.23 5.21 C 34.51 6.32 32.01 12.80 35.61 16.40 C 38.69 20.70 45.89 19.57 47.75 14.70 C 50.19 9.57 44.54 3.42 39.23 5.21 M 19.54 50.14 C 22.69 58.90 30.27 66.88 40.00 67.47 C 40.00 62.86 40.01 58.26 40.00 53.66 C 36.61 53.02 33.37 51.41 31.24 48.64 C 24.19 39.84 25.15 25.06 34.45 18.18 C 31.95 15.45 31.32 11.70 32.19 8.15 C 18.07 16.32 13.93 35.56 19.54 50.14 M 49.91 8.41 C 50.59 11.93 49.96 15.57 47.47 18.26 C 56.72 25.09 57.63 39.78 50.70 48.55 C 48.66 51.29 45.48 52.87 42.22 53.63 C 42.22 58.21 42.26 62.79 42.18 67.38 C 48.76 66.86 54.67 62.79 58.31 57.40 C 62.61 51.44 64.32 44.07 64.63 36.83 C 61.99 35.78 59.31 34.81 56.74 33.58 C 59.19 32.32 61.63 31.05 64.01 29.67 C 62.18 21.15 57.63 12.88 49.91 8.41 M 35.87 21.10 C 35.89 30.40 35.87 39.70 35.87 49.00 C 39.40 48.96 42.92 48.97 46.45 49.00 C 46.48 39.69 46.47 30.37 46.45 21.05 C 43.14 22.84 39.16 23.06 35.87 21.10 Z");
            //p1.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFFFF"));
            //p2.Data = Geometry.Parse("M 39.23 5.21 C 44.54 3.42 50.19 9.57 47.75 14.70 C 45.89 19.57 38.69 20.70 35.61 16.40 C 32.01 12.80 34.51 6.32 39.23 5.21 Z");
            p2.AddGeometry(Geometry.Parse("M 39.23 5.21 C 44.54 3.42 50.19 9.57 47.75 14.70 C 45.89 19.57 38.69 20.70 35.61 16.40 C 32.01 12.80 34.51 6.32 39.23 5.21 Z"));
            //p2.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFE8541"));
           // p3.Data = Geometry.Parse("M 35.87 21.10 C 39.16 23.06 43.14 22.84 46.45 21.05 C 46.47 30.37 46.48 39.69 46.45 49.00 C 42.92 48.97 39.40 48.96 35.87 49.00 C 35.87 39.70 35.89 30.40 35.87 21.10 Z");
            p3.AddGeometry(Geometry.Parse("M 35.87 21.10 C 39.16 23.06 43.14 22.84 46.45 21.05 C 46.47 30.37 46.48 39.69 46.45 49.00 C 42.92 48.97 39.40 48.96 35.87 49.00 C 35.87 39.70 35.89 30.40 35.87 21.10 Z"));
            // p3.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFE8541"));
            //p4.Data = Geometry.Parse("M 19.54 50.14 C 13.93 35.56 18.07 16.32 32.19 8.15 C 31.32 11.70 31.95 15.45 34.45 18.18 C 25.15 25.06 24.19 39.84 31.24 48.64 C 33.37 51.41 36.61 53.02 40.00 53.66 C 40.01 58.26 40.00 62.86 40.00 67.47 C 30.27 66.88 22.69 58.90 19.54 50.14 Z");
            p4.AddGeometry(Geometry.Parse("M 19.54 50.14 C 13.93 35.56 18.07 16.32 32.19 8.15 C 31.32 11.70 31.95 15.45 34.45 18.18 C 25.15 25.06 24.19 39.84 31.24 48.64 C 33.37 51.41 36.61 53.02 40.00 53.66 C 40.01 58.26 40.00 62.86 40.00 67.47 C 30.27 66.88 22.69 58.90 19.54 50.14 Z"));
           // p4.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF038244"));
            //p5.Data = Geometry.Parse("M 49.91 8.41 C 57.63 12.88 62.18 21.15 64.01 29.67 C 61.63 31.05 59.19 32.32 56.74 33.58 C 59.31 34.81 61.99 35.78 64.63 36.83 C 64.32 44.07 62.61 51.44 58.31 57.40 C 54.67 62.79 48.76 66.86 42.18 67.38 C 42.26 62.79 42.22 58.21 42.22 53.63 C 45.48 52.87 48.66 51.29 50.70 48.55 C 57.63 39.78 56.72 25.09 47.47 18.26 C 49.96 15.57 50.59 11.93 49.91 8.41 Z");
            p5.AddGeometry(Geometry.Parse("M 49.91 8.41 C 57.63 12.88 62.18 21.15 64.01 29.67 C 61.63 31.05 59.19 32.32 56.74 33.58 C 59.31 34.81 61.99 35.78 64.63 36.83 C 64.32 44.07 62.61 51.44 58.31 57.40 C 54.67 62.79 48.76 66.86 42.18 67.38 C 42.26 62.79 42.22 58.21 42.22 53.63 C 45.48 52.87 48.66 51.29 50.70 48.55 C 57.63 39.78 56.72 25.09 47.47 18.26 C 49.96 15.57 50.59 11.93 49.91 8.41 Z"));
            //p5.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF038244"));
            p1.FillRule = FillRule.Nonzero;
            p2.FillRule = FillRule.Nonzero;
            p3.FillRule = FillRule.Nonzero;
            p4.FillRule = FillRule.Nonzero;
            p5.FillRule = FillRule.Nonzero;


            Geometry g1 = Geometry.Combine(p2, p3, GeometryCombineMode.Union, null);
            Geometry g2 = Geometry.Combine(g1, p4, GeometryCombineMode.Union, null);
            Geometry g3 = Geometry.Combine(g2, p5, GeometryCombineMode.Union, null);

            main.LogoData = g3;
        }
        private void _UpdateHighlightBackground(DrawingContext dc, ArrayList highlights)
        {
            Debug.Assert(highlights != null);

            PathGeometry highlightGeometry = null;
            Brush highlightBrush = null;

            Rect combinedRect = Rect.Empty;

            foreach (FixedHighlight fh in highlights)
            {
                Brush bg = null;

                if (fh.HighlightType == FixedHighlightType.None)
                {
#if NEVER
                    // use this code if you want to see unrecognized highlights
                    bg = Brushes.Yellow;
#else
                    continue;
#endif
                }

                Rect backgroundRect = fh.ComputeDesignRect();

                if (backgroundRect == Rect.Empty)
                {
                    continue;
                }

                GeneralTransform transform = fh.Element.TransformToAncestor(_page);
                // This is a workaround. We should really look into changing 
                Transform t = transform.AffineTransform;
                if (t == null)
                {
                    t = Transform.Identity;
                }

                // Inflate by 1 pixel on each side to have a better selection visual for continuous lines
                // backgroundRect.Inflate(1,1);

                Glyphs g = fh.Glyphs;

                if (fh.HighlightType == FixedHighlightType.TextSelection)
                {
                    bg = (g == null) ? SelectionHighlightInfo.ObjectMaskBrush : SelectionHighlightInfo.BackgroundBrush;
                } 
                else if (fh.HighlightType == FixedHighlightType.AnnotationHighlight)
                {
                    bg = fh.BackgroundBrush;
                }

                
                
                // can add cases for new types of highlights
                if (fh.Element.Clip != null)
                {
                    Rect clipRect = fh.Element.Clip.Bounds;
                    backgroundRect.Intersect(clipRect);
                    //thisGeometry = Geometry.Combine(thisGeometry, fh.Element.Clip, GeometryCombineMode.Intersect, t);
                }
                
                Geometry thisGeometry = new RectangleGeometry(backgroundRect);
                thisGeometry.Transform = t;

                backgroundRect = transform.TransformBounds(backgroundRect);


                // used to cut down on calls to Geometry.Combine for complex geometries
                // involving multiple non-intersecting paths

                Debug.Assert(bg != null);
                if (bg != highlightBrush || backgroundRect.Top > combinedRect.Bottom + .1 || backgroundRect.Bottom + .1 < combinedRect.Top
                    || backgroundRect.Left > combinedRect.Right + .1 || backgroundRect.Right + .1 < combinedRect.Left)
                {
                    if (highlightBrush != null)
                    {
                        Debug.Assert(highlightGeometry != null);
                        highlightGeometry.FillRule = FillRule.Nonzero;
                        dc.DrawGeometry(highlightBrush, null, highlightGeometry);
                    }
                    highlightBrush = bg;
                    highlightGeometry = new PathGeometry();
                    highlightGeometry.AddGeometry(thisGeometry);
                    combinedRect = backgroundRect;
                }
                else
                {
                    highlightGeometry.AddGeometry(thisGeometry);
                    combinedRect.Union(backgroundRect);
                }
            }

            if (highlightBrush != null)
            {
                Debug.Assert(highlightGeometry != null);
                highlightGeometry.FillRule = FillRule.Nonzero;
                dc.DrawGeometry(highlightBrush, null, highlightGeometry);
            }
            
        }
Example #17
0
    /// <summary>
    /// Translates origin of coordinate space to a box of size 220pp x 140pp.
    /// </summary>
    protected void BeginBox(DrawingContext dc, int n, BoxOptions options, string description)
    {
      double dx = (WidthInPU - 2 * BoxWidth) / 3;
      double dy = (HeightInPU - 4 * BoxHeight) / 5;
      double x = (1 - n % 2) * BoxWidth + (2 - n % 2) * dx;
      double y = ((n + 1) / 2 - 1) * BoxHeight + ((n + 1) / 2) * dy;
      dc.PushTransform(new TranslateTransform(x, y));

      Brush tileBrush = new SolidColorBrush(Color.FromRgb(204, 204, 204));
      //if (options != BoxOptions.None)
      //{
      //  double strokeWidth = 0.75;
      //  double adjust = strokeWidth / 2;
      //  Pen pen = new Pen(tileBrush, 0.75);
      //  //pen.DashStyle = DashStyles.DashDot;
      //  dc.DrawRectangle(null, pen, new Rect(0 + adjust, 0 + adjust, BoxWidth - strokeWidth, BoxHeight - strokeWidth));
      //}
      switch (options)
      {
        case BoxOptions.None:
          break;

        case BoxOptions.Box:
          {
            Pen pen = new Pen(tileBrush, 3);
            dc.DrawLine(pen, new Point(0, 0), new Point(BoxWidth, 0));
            dc.DrawLine(pen, new Point(BoxWidth, 0), new Point(BoxWidth, BoxHeight));
            dc.DrawLine(pen, new Point(BoxWidth, BoxHeight), new Point(0, BoxHeight));
            dc.DrawLine(pen, new Point(0, BoxHeight), new Point(0, 0));
          }
          break;

        case BoxOptions.DrawX:
          {
            Pen pen = new Pen(tileBrush, 3);
            dc.DrawLine(pen, new Point(0, 0), new Point(BoxWidth, BoxHeight));
            dc.DrawLine(pen, new Point(0, BoxHeight), new Point(BoxWidth, 0));
          }
          break;

        case BoxOptions.Fill:
          {
            dc.DrawRectangle(tileBrush, null, new Rect(0, 0, BoxWidth, BoxHeight));
          }
          break;

        case BoxOptions.Tile:
          {
#if true
            double delta = 8;
            PathGeometry path = new PathGeometry();
            for (double xx = 0; xx < BoxWidth; xx += 2 * delta)
              path.AddGeometry(new RectangleGeometry(new Rect(xx, 0, delta, BoxHeight)));
            for (double yy = 0; yy < BoxHeight; yy += 2 * delta)
              path.AddGeometry(new RectangleGeometry(new Rect(0, yy, BoxWidth, delta)));
            dc.DrawGeometry(tileBrush, null, path);
#else
            double delta = 5;
            bool draw1 = true;
            for (double yy = 0; yy < BoxHeight; yy += delta, draw1 = !draw1)
            {
              bool draw2 = true;
              for (double xx = 0; xx < BoxWidth; xx += delta, draw2 = !draw2)
                if ((draw1 && draw2) || (!draw1 && !draw2))
                  dc.DrawRectangle(tileBrush, null, new Rect(xx, yy, delta, delta));
            }
#endif
          }
          break;
      }
      if (options != BoxOptions.None && !String.IsNullOrEmpty(description))
        dc.DrawText(new FormattedText(description, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Arial"), 7.5, Brushes.Black), new Point(0, BoxHeight + 0));
    }
Example #18
0
 private PathGeometry BuildSpanGeometry(SnapshotSpan span)
 {
     PathGeometry path = new PathGeometry();
       path.FillRule = FillRule.Nonzero;
       foreach ( var line in this.view.TextViewLines ) {
     if ( line.Start > span.End ) break;
     if ( LineIntersectsSpan(line, span) ) {
       var lineGeometry = BuildLineGeometry(span, line);
       path.AddGeometry(lineGeometry);
     }
       }
       return path;
 }
        protected override void OnRefresh()
        {
            IndicatorPushButton pushButton = Visual as IndicatorPushButton;

            if (pushButton != null)
            {
                _imageRect.Width = pushButton.Width;
                _imageRect.Height = pushButton.Height;
                _image = ConfigManager.ImageManager.LoadImage(pushButton.Image);
                _pushedImage = ConfigManager.ImageManager.LoadImage(pushButton.PushedImage);
                _indicatorOnImage = ConfigManager.ImageManager.LoadImage(pushButton.IndicatorOnImage);
                _pushedIndicatorOnImage = ConfigManager.ImageManager.LoadImage(pushButton.PushedIndicatorOnImage);
                _onTextBrush = new SolidColorBrush(pushButton.OnTextColor);
                _offTextBrush = new SolidColorBrush(pushButton.TextColor);

                _onGlyphBrush = new SolidColorBrush(pushButton.OnGlyphColor);
                _onGlyphPen = new Pen(_onGlyphBrush, pushButton.GlyphThickness);

                _offGlyphBrush = new SolidColorBrush(pushButton.GlyphColor);
                _offGlyphPen = new Pen(_offGlyphBrush, pushButton.GlyphThickness);

                Point center = new Point(pushButton.Width / 2d, pushButton.Height / 2d);
                _glyphPath = new PathGeometry();
                switch (pushButton.Glyph)
                {
                    case PushButtonGlyph.Circle:
                        double radius = (Math.Min(pushButton.Width, pushButton.Height) / 2d) * pushButton.GlyphScale;
                        EllipseGeometry ellipse = new EllipseGeometry(center, radius, radius);
                        _onGlyphBrush = null;
                        _offGlyphBrush = null;
                        _glyphPath.AddGeometry(ellipse);
                        break;

                    case PushButtonGlyph.RightArrow:
                        _glyphPath.Figures.Add(GetArrowFigure(true, pushButton));
                        break;

                    case PushButtonGlyph.LeftArrow:
                        _glyphPath.Figures.Add(GetArrowFigure(false, pushButton));
                        break;

                    case PushButtonGlyph.UpCaret:
                        double offsetX = center.X * pushButton.GlyphScale;
                        double offsetY = offsetX / 2d;
                        PathFigure figure = new PathFigure();
                        figure.IsClosed = false;
                        figure.IsFilled = false;
                        figure.StartPoint = new Point(center.X - offsetX, center.Y + offsetY);
                        figure.Segments.Add(new LineSegment(new Point(center.X, center.Y - offsetY), true));
                        figure.Segments.Add(new LineSegment(new Point(center.X + offsetX, center.Y + offsetY), true));
                        _glyphPath.Figures.Add(figure);
                        break;
                }
            }
            else
            {
                _image = null;
                _pushedImage = null;
                _onTextBrush = null;
                _offTextBrush = null;
                _onTextBrush = null;
                _onGlyphPen = null;
                _offTextBrush = null;
                _offGlyphPen = null;
                _glyphPath = null;
                _indicatorOnImage = null;
                _pushedIndicatorOnImage = null;
            }
        }
Example #20
0
        /// <summary>
        /// Constructor. Initializes all the class fields.
        /// </summary>
        public XYLineChart()
        {
            // This assumes that you are navigating to this scene.
            // If you will normally instantiate it via code and display it
            // manually, you either have to call InitializeComponent by hand or
            // uncomment the following line.

            InitializeComponent();

            primitiveList = new List<ChartPrimitive>();

            // Set the Chart Geometry Clip region
            chartClip = new PathGeometry();
            chartClip.AddGeometry(
                new RectangleGeometry(new Rect(0, 0, clippedPlotCanvas.ActualWidth, clippedPlotCanvas.ActualHeight)));
            shapeTransform = new MatrixTransform();
            adorner = new AdornerCursorCoordinateDrawer(this, clippedPlotCanvas, shapeTransform);

            optimalGridLineSpacing = new Point(150, 75);

            panZoomCalculator =
                new PanZoomCalculator(new Rect(0, 0, clippedPlotCanvas.ActualWidth, clippedPlotCanvas.ActualHeight));
            panZoomCalculator.Window = new Rect(0, 0, clippedPlotCanvas.ActualWidth, clippedPlotCanvas.ActualHeight);
            panZoomCalculator.PanZoomChanged += panZoomCalculator_PanZoomChanged;

            closestPointPicker = new ClosestPointPicker(new Size(13, 13));
            closestPointPicker.ClosestPointChanged += closestPointPicker_ClosestPointChanged;

            Cursor = Cursors.None;

            // Set up all the message handlers for the clipped plot canvas
            AttachEventsToCanvas(this);
            clippedPlotCanvas.IsVisibleChanged += clippedPlotCanvas_IsVisibleChanged;
            clippedPlotCanvas.SizeChanged += clippedPlotCanvas_SizeChanged;
        }
Example #21
0
        /// <summary>
        /// Render all the plot lines from the collection of Chart Primitives
        /// </summary>
        /// <param name="canvas"></param>
        protected void RenderPlotLines(Canvas canvas)
        {
            // Draw the Chart Plot Points

            // Fill in the background
            canvas.Children.Clear();

            foreach (ChartPrimitive primitive in primitiveList)
            {
                if (primitive.Points.Count > 0)
                {
                    var path = new Path();
                    var pathGeometry = new PathGeometry {Transform = shapeTransform};
                    
                    pathGeometry.AddGeometry(primitive.PathGeometry);
                    if (primitive.Filled)
                    {
                        path.Stroke = null;
                        if (primitive.Dashed)
                            path.Fill = ChartUtilities.CreateHatch50(primitive.Color, new Size(2, 2));
                        else
                        {
                            var brush = new SolidColorBrush(primitive.Color) {Opacity = primitive.FillOpacity};
                            path.Fill = brush;
                            path.Stroke = new SolidColorBrush(primitive.Color);
                            path.StrokeThickness = primitive.LineThickness;
                        }
                    }
                    else
                    {
                        path.Stroke = new SolidColorBrush(primitive.Color);
                        path.StrokeThickness = primitive.LineThickness;
                        path.Fill = null;
                        if (primitive.Dashed)
                            path.StrokeDashArray = new DoubleCollection(new double[] {2, 2});
                    }
                    path.Data = pathGeometry;
                    path.Clip = chartClip;
                    canvas.Children.Add(path);

                    if (primitive.ShowIndividualPoints)
                    {
                        path = new Path {Fill = new SolidColorBrush(primitive.Color) {Opacity = primitive.FillOpacity}};

                        var gm = new GeometryGroup {Transform = shapeTransform};
                        foreach (var point in primitive.Points)
                            gm.Children.Add(NewPointGeometry(point, shapeTransform.Matrix));

                        path.Data = gm;
                        path.Clip = chartClip;
                        canvas.Children.Add(path);
                    }
                }
            }
        }
Example #22
0
        private static Geometry ApplyTransform(Geometry geometry, double bt, Size renderSize)
        {
            var pathGeometry = new PathGeometry();
            pathGeometry.AddGeometry(geometry);

            var hbt = bt * 0.5;
            //var scaleY = ((hbt * 100) / renderSize.Height) / 100;
            var scaleY = hbt / renderSize.Height;
            pathGeometry.Transform = new ScaleTransform(1, scaleY + 1, renderSize.Width * 0.5, 0);
            pathGeometry.Freeze();
            return pathGeometry;
        }
Example #23
0
        public static DrawingImage CreateImage(PointPattern[] pointPatterns, Size size, Color color)
        {
            if (pointPatterns == null)
                throw new Exception("You must provide a gesture before trying to generate a thumbnail");

            DrawingGroup drawingGroup = new DrawingGroup();
            for (int i = 0; i < pointPatterns.Length; i++)
            {
                PathGeometry pathGeometry = new PathGeometry();

                color.A = (byte)(0xFF - i * 0x55);
                SolidColorBrush brush = new SolidColorBrush(color);
                Pen drawingPen = new Pen(brush, 3 + i * 2) { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round };

                if (pointPatterns[i].Points == null) return null;
                for (int j = 0; j < pointPatterns[i].Points.Count; j++)
                {
                    if (pointPatterns[i].Points[j].Count == 1)
                    {
                        Geometry ellipse = new EllipseGeometry(new Point(size.Width * j + size.Width / 2, size.Height / 2),
                            drawingPen.Thickness / 2, drawingPen.Thickness / 2);
                        pathGeometry.AddGeometry(ellipse);
                        continue;
                    }
                    StreamGeometry sg = new StreamGeometry { FillRule = FillRule.EvenOdd };
                    using (StreamGeometryContext sgc = sg.Open())
                    {
                        // Create new size object accounting for pen width
                        Size szeAdjusted = new Size(size.Width - drawingPen.Thickness - 1,
                            (size.Height - drawingPen.Thickness - 1));

                        Size scaledSize;
                        Point[] scaledPoints = ScaleGesture(pointPatterns[i].Points[j], szeAdjusted.Width - 10, szeAdjusted.Height - 10,
                            out scaledSize);

                        // Define size that will mark the offset to center the gesture
                        double iLeftOffset = (size.Width / 2) - (scaledSize.Width / 2);
                        double iTopOffset = (size.Height / 2) - (scaledSize.Height / 2);
                        Vector sizOffset = new Vector(iLeftOffset + j * size.Width, iTopOffset);
                        sgc.BeginFigure(Point.Add(scaledPoints[0], sizOffset), false, false);
                        foreach (Point p in scaledPoints)
                        {
                            sgc.LineTo(Point.Add(p, sizOffset), true, true);
                        }
                        DrawArrow(sgc, scaledPoints, sizOffset, drawingPen.Thickness);
                    }
                    sg.Freeze();
                    pathGeometry.AddGeometry(sg);
                }
                pathGeometry.Freeze();
                GeometryDrawing drawing = new GeometryDrawing(null, drawingPen, pathGeometry);
                drawing.Freeze();
                drawingGroup.Children.Add(drawing);
            }
            //  myPath.Data = sg;
            drawingGroup.Freeze();
            DrawingImage drawingImage = new DrawingImage(drawingGroup);
            drawingImage.Freeze();

            return drawingImage;
        }
        /// <summary>
        /// <see cref="TextViewBase.GetTightBoundingGeometryFromTextPositions"/>
        /// </summary>
        internal override Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition)
        {
            PathGeometry boundingGeometry = new PathGeometry();
            Debug.Assert(startPosition != null && this.Contains(startPosition));
            Debug.Assert(endPosition != null && this.Contains(endPosition));
            Dictionary<FixedPage, ArrayList> highlights = new Dictionary<FixedPage,ArrayList>();
            FixedTextPointer startftp = this.Container.VerifyPosition(startPosition);
            FixedTextPointer endftp = this.Container.VerifyPosition(endPosition);
            
            this.Container.GetMultiHighlights(startftp, endftp, highlights, FixedHighlightType.TextSelection, null, null);

            ArrayList highlightList;

            highlights.TryGetValue(this.FixedPage, out highlightList);

            if (highlightList != null)
            {
                foreach (FixedHighlight fh in highlightList)
                {
                    if (fh.HighlightType == FixedHighlightType.None)
                    {
                        continue;
                    }

                    Rect backgroundRect = fh.ComputeDesignRect();

                    if (backgroundRect == Rect.Empty)
                    {
                        continue;
                    }

                    GeneralTransform transform = fh.Element.TransformToAncestor(this.FixedPage);

                    Transform t = transform.AffineTransform;
                    if (t == null)
                    {
                        t = Transform.Identity;
                    }

                    Glyphs g = fh.Glyphs;

                    if (fh.Element.Clip != null)
                    {
                        Rect clipRect = fh.Element.Clip.Bounds;
                        backgroundRect.Intersect(clipRect);
                    }
                    
                    Geometry thisGeometry = new RectangleGeometry(backgroundRect);
                    thisGeometry.Transform = t;

                    backgroundRect = transform.TransformBounds(backgroundRect);

                    boundingGeometry.AddGeometry(thisGeometry);
                }
            }

            return boundingGeometry;
        }
Example #25
0
        /// <summary>
        /// グラフを描画します。
        /// </summary>
        /// <param name="dg">描画に使用する<see cref="DrawingContext"/>のインスタンス</param>
        /// <param name="isResultUpdateRequired">計算結果の更新を必要とするかどうかを指定します。</param>
        public void Draw(DrawingContext dc, bool isResultUpdateRequired)
        {
            #region Error Check
            if (GridLineX <= 0
                || GridLineY <= 0
                || (EnableSubGridLine && (SubGridLineX <= 0 || SubGridLineY <= 0)))
            {
                FormattedText ft = new FormattedText(
                        "Drawing Error",
                        System.Globalization.CultureInfo.InvariantCulture,
                        FlowDirection.LeftToRight,
                        timesNewRomanFace,
                        18,
                        Brushes.DarkRed);
                dc.DrawRectangle(Brushes.LightGray, new Pen(Brushes.DarkRed, 2.0), new Rect(CanvasSize));
                dc.DrawText(ft, new Point((CanvasSize.Width - ft.Width) / 2, (CanvasSize.Height - ft.Height) / 2));
                return;
            }
            #endregion

            double xAxis = Center.X + OffsetX;
            double yAxis = Center.Y + OffsetY;

            #region Draw Sub Grid Lines
            if (EnableSubGridLine)
            {
                Pen subGridPen = new Pen(SubGridLineBrush, SubGridLineThickness);
                subGridPen.Freeze();

                if (0 <= xAxis && xAxis <= CanvasSize.Width)
                    DrawVerticalLine(dc, xAxis, subGridPen);
                if (0 <= yAxis && yAxis <= CanvasSize.Height)
                    DrawHorizontalLine(dc, yAxis, subGridPen);

                #region Draw X Sub-Grid Line
                int subGridCountX = (int)((CanvasSize.Width - Center.X) / SubGridLineX);
                for (int i = 1; i <= subGridCountX; i++)
                {
                    double leftSide = Center.X - (SubGridLineX * i) + OffsetX;
                    if (0 <= leftSide && leftSide <= CanvasSize.Width)
                        DrawVerticalLine(dc, leftSide, subGridPen);

                    double rightSide = Center.X + (SubGridLineX * i) + OffsetX;
                    if (0 <= rightSide && rightSide <= CanvasSize.Width)
                        DrawVerticalLine(dc, rightSide, subGridPen);
                }
                #endregion

                #region Draw Y Sub-Grid Line
                int subGridCountY = (int)((CanvasSize.Height - Center.Y) / SubGridLineY);
                for (int i = 1; i <= subGridCountY; i++)
                {
                    double upSide = Center.Y - (SubGridLineY * i) + OffsetY;
                    if (0 <= upSide && upSide <= CanvasSize.Height)
                        DrawHorizontalLine(dc, upSide, subGridPen);

                    double downSide = Center.Y + (SubGridLineY * i) + OffsetY;
                    if (0 <= downSide && downSide <= CanvasSize.Height)
                        DrawHorizontalLine(dc, downSide, subGridPen);
                }
                #endregion
            }
            #endregion

            #region Draw Grid Lines
            if (EnableGridLine)
            {
                Pen gridPen = new Pen(GridLineBrush, GridLineThickness);
                gridPen.Freeze();

                #region Draw X Grid Line
                int gridCountX = (int)((CanvasSize.Width - Center.X + Math.Abs(OffsetX)) / GridLineX);
                if (0 <= xAxis && xAxis <= CanvasSize.Width)
                    DrawVerticalLine(dc, xAxis, gridPen);

                for (int i = 1; i <= gridCountX; i++)
                {
                    double leftSide = Center.X - (GridLineX * i) + OffsetX;
                    if (0 <= leftSide && leftSide <= CanvasSize.Width)
                    {
                        DrawVerticalLine(dc, leftSide, gridPen);
                        xLeftLimit = -i;
                        if (ScaleX > 0 && i % ScaleX == 0 && leftSide + scaleMarginX <= CanvasSize.Width)
                        {
                            double scalePosY;
                            if (0 <= yAxis && yAxis + scaleMarginY <= CanvasSize.Height)
                                scalePosY = yAxis;
                            else if (yAxis < 0)
                                scalePosY = 0;
                            else
                                scalePosY = CanvasSize.Height - scaleMarginY;
                            dc.DrawText(new FormattedText(
                                (-i).ToString(),
                                System.Globalization.CultureInfo.InvariantCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Times New Roman"),
                                18,
                                Brushes.DarkMagenta),
                                new Point(leftSide, scalePosY));
                        }
                    }

                    double rightSide = Center.X + (GridLineX * i) + OffsetX;
                    if (0 <= rightSide && rightSide <= CanvasSize.Width)
                    {
                        DrawVerticalLine(dc, rightSide, gridPen);
                        xRightLimit = i;
                        if (ScaleX > 0 && i % ScaleX == 0 && rightSide + scaleMarginX <= CanvasSize.Width)
                        {
                            double scalePosY;
                            if (0 <= yAxis && yAxis + scaleMarginY <= CanvasSize.Height)
                                scalePosY = yAxis;
                            else if (yAxis < 0)
                                scalePosY = 0;
                            else
                                scalePosY = CanvasSize.Height - scaleMarginY;
                            dc.DrawText(new FormattedText(
                                i.ToString(),
                                System.Globalization.CultureInfo.InvariantCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Times New Roman"),
                                18,
                                Brushes.DarkMagenta),
                                new Point(rightSide, scalePosY));
                        }
                    }
                }
                #endregion

                #region Draw Y Grid Line
                int gridCountY = (int)((CanvasSize.Height - Center.Y + Math.Abs(OffsetY)) / GridLineY);
                if (0 <= yAxis && yAxis <= CanvasSize.Height)
                    DrawHorizontalLine(dc, yAxis, gridPen);
                for (int i = 1; i <= gridCountY; i++)
                {
                    double upSide = Center.Y - (GridLineY * i) + OffsetY;
                    if (0 <= upSide && upSide <= CanvasSize.Height)
                    {
                        DrawHorizontalLine(dc, upSide, gridPen);
                        if (ScaleY > 0 && i % ScaleY == 0 && upSide + scaleMarginY <= CanvasSize.Height)
                        {
                            double scalePosX;
                            if (0 <= xAxis && xAxis + scaleMarginX <= CanvasSize.Width)
                                scalePosX = xAxis;
                            else if (xAxis < 0)
                                scalePosX = 0;
                            else
                                scalePosX = CanvasSize.Width - scaleMarginX;
                            dc.DrawText(new FormattedText(
                                i.ToString(),
                                System.Globalization.CultureInfo.InvariantCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Times New Roman"),
                                18,
                                Brushes.Brown),
                                new Point(scalePosX, upSide));
                        }
                    }

                    double downSide = Center.Y + (GridLineY * i) + OffsetY;
                    if (0 <= downSide && downSide <= CanvasSize.Height)
                    {
                        DrawHorizontalLine(dc, downSide, gridPen);
                        if (ScaleY > 0 && i % ScaleY == 0 && downSide + scaleMarginY <= CanvasSize.Height)
                        {
                            double scalePosX;
                            if (0 <= xAxis && xAxis + scaleMarginX <= CanvasSize.Width)
                                scalePosX = xAxis;
                            else if (xAxis < 0)
                                scalePosX = 0;
                            else
                                scalePosX = CanvasSize.Width - scaleMarginX;
                            dc.DrawText(new FormattedText(
                                (-i).ToString(),
                                System.Globalization.CultureInfo.InvariantCulture,
                                FlowDirection.LeftToRight,
                                new Typeface("Times New Roman"),
                                18,
                                Brushes.Brown),
                                new Point(scalePosX, downSide));
                        }
                    }
                }
                #endregion
            }
            #endregion

            #region Draw Axis Line
            Pen axisPen = new Pen(AxisLineBrush, AxisLineThickness);
            axisPen.Freeze();
            if (0 <= xAxis && xAxis <= CanvasSize.Width)
                DrawVerticalLine(dc, xAxis, axisPen);
            if (0 <= yAxis && yAxis <= CanvasSize.Height)
                DrawHorizontalLine(dc, Center.Y + OffsetY, axisPen);
            if ((0 <= xAxis && xAxis + scaleMarginX <= CanvasSize.Width) && (0 <= yAxis && yAxis + scaleMarginY <= CanvasSize.Height))
                dc.DrawText(
                    new FormattedText(
                        "O",
                        System.Globalization.CultureInfo.InvariantCulture,
                        FlowDirection.LeftToRight,
                        new Typeface("Times New Roman"),
                        18,
                        Brushes.Black),
                        new Point(xAxis, yAxis));
            #endregion

            #region Draw Graph Line
            if (isResultUpdateRequired)
                Result = new Dictionary<double, double>(Calculator.CalculateRange(new Range(xLeftLimit - 1, xRightLimit + 1, step)));
            if (IsDrawGraphLine)
            {
                PathGeometry geometry = new PathGeometry();
                for (int i = 0; i < Result.Count - 1; i++)
                {
                    KeyValuePair<double, double> r1 = Result.ElementAt(i);
                    KeyValuePair<double, double> r2 = Result.ElementAt(i + 1);
                    Point p1 = new Point((r1.Key * GridLineX) + Center.X + OffsetX, (-r1.Value * GridLineY) + Center.Y + OffsetY);
                    Point p2 = new Point((r2.Key * GridLineX) + Center.X + OffsetX, (-r2.Value * GridLineY) + Center.Y + OffsetY);
                    geometry.AddGeometry(new LineGeometry(p1, p2));
                }
                dc.DrawGeometry(null, new Pen(GraphBrush, GraphThickness), geometry);
            }
            else
            {
                foreach (var r in Result)
                {
                    double x = (r.Key * GridLineX) + Center.X + OffsetX;
                    double y = (-r.Value * GridLineY) + Center.Y + OffsetY;
                    if (0 <= x - GraphThickness && x + GraphThickness <= CanvasSize.Width && 0 <= y - GraphThickness && y + GraphThickness <= CanvasSize.Height)
                        dc.DrawEllipse(GraphBrush, null, new Point(x, y), GraphThickness, GraphThickness);
                }
            }
            #endregion

            #if DEBUG
            dc.DrawRectangle(null, new Pen(Brushes.Red, 1.0), new Rect(CanvasSize));
            #endif
        }
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="span"/> is less than zero or greater than the buffer length for the associated <see cref="ISourceEditorView"/>.</para>
		/// </exception>
		public Geometry GetMarkerGeometry(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			if ((span.Start < 0) || (span.End > _editorView.TextBuffer.Length))
			{
				throw new ArgumentOutOfRangeException("span");
			}
			if (span.IsEmpty)
			{
				return null;
			}
			PathGeometry geometry = new PathGeometry();
			geometry.FillRule = FillRule.Nonzero;
			IList<ITextLine> textLines = _editorView.TextLines;
			if (textLines.Count == 0)
			{
				return null;
			}
			if ((span.Start > base.LastRenderedCharacter) || (span.End < base.FirstRenderedCharacter))
			{
				return null;
			}
			ITextLine item = null;
			ITextLine textLineClosestTo = null;
			if (span.Start < base.FirstRenderedCharacter)
			{
				item = textLines[0];
			}
			if (span.End > base.LastRenderedCharacter)
			{
				textLineClosestTo = textLines[textLines.Count - 1];
			}
			if (item == null)
			{
				item = base.GetTextLineClosestTo(span.Start);
			}
			if (textLineClosestTo == null)
			{
				textLineClosestTo = base.GetTextLineClosestTo(span.End);
			}
			if (item == textLineClosestTo)
			{
				foreach (TextBounds bounds in item.GetTextBounds(span))
				{
					RectangleGeometry geometry2 = new RectangleGeometry(new Rect(bounds.Left - 0.2, bounds.Top - 1, bounds.Width + 0.4, bounds.Height + 1), 0.6, 0.6);
					geometry2.Freeze();
					geometry.AddGeometry(geometry2);
				}
			}
			else
			{
				foreach (TextBounds bounds2 in item.GetTextBounds(span))
				{
					RectangleGeometry geometry3 = new RectangleGeometry(new Rect(bounds2.Left - 0.2, bounds2.Top - 1, bounds2.Width + 0.4, bounds2.Height + 1), 0.6, 0.6);
					geometry3.Freeze();
					geometry.AddGeometry(geometry3);
				}
				Int32 num = textLines.IndexOf(item) + 1;
				Int32 index = textLines.IndexOf(textLineClosestTo);
				for (Int32 i = num; i < index; i++)
				{
					ITextLine line3 = textLines[i];
					RectangleGeometry geometry4 = new RectangleGeometry(new Rect(-0.2, line3.VerticalOffset - 0.2, line3.Width, line3.Height + 0.4), 0.6, 0.6);
					geometry4.Freeze();
					geometry.AddGeometry(geometry4);
				}
				foreach (TextBounds bounds3 in textLineClosestTo.GetTextBounds(span))
				{
					RectangleGeometry geometry5 = new RectangleGeometry(new Rect(bounds3.Left - 0.2, bounds3.Top - 1, bounds3.Width + 0.4, bounds3.Height + 1), 0.6, 0.6);
					geometry5.Freeze();
					geometry.AddGeometry(geometry5);
				}
			}
			geometry.Freeze();
			return geometry.GetOutlinedPathGeometry();
		}
Example #27
0
 Geometry DoubleCircle() {
     var box = Node.BoundingBox;
     double w = box.Width;
     double h = box.Height;
     var pathGeometry = new PathGeometry();
     var r = new Rect(box.Left, box.Bottom, w, h);
     pathGeometry.AddGeometry(new EllipseGeometry(r));
     var inflation = Math.Min(5.0, Math.Min(w/3, h/3));
     r.Inflate(-inflation, -inflation);
     pathGeometry.AddGeometry(new EllipseGeometry(r));
     return pathGeometry;
 }
Example #28
0
        public static void SizeGeometry(PathGeometry pg, Size size)
        {
            if (size.Height > 0 && size.Height > 0)
            {
                PathFigure[] sizeFigures =
                {
                    new PathFigure(new Point(size.Width, size.Height), Enumerable.Empty<PathSegment>(), true),
                    new PathFigure(new Point(0,0), Enumerable.Empty<PathSegment>(), true),
                };

                var newGeo = new PathGeometry(sizeFigures.Concat(pg.Figures), pg.FillRule, null);//pg.Transform do not add transform here, it will recalculate all the Points
                pg.Clear();
                pg.AddGeometry(newGeo);
                //return new PathGeometry(sizeFigures.Concat(pg.Figures), pg.FillRule, pg.Transform);
            }
        }
Example #29
0
 Geometry DoubleCircle()
 {
     double w = Node.BoundingBox.Width;
     double h = Node.BoundingBox.Height;
     var pathGeometry = new PathGeometry();
     var r = new Rect(-w/2, -h/2, w, h);
     pathGeometry.AddGeometry(new EllipseGeometry(r));
     r.Inflate(-5, -5);
     pathGeometry.AddGeometry(new EllipseGeometry(r));
     return pathGeometry;
 }
Example #30
0
        private UIElement ConvertCustomPathToPath(XElement path)
        {
            System.Windows.Shapes.Path customPath = new System.Windows.Shapes.Path();

            var geometryData = new PathGeometry();

            if (path.Attribute("transform") != null)
            {
                var matrixTransformationValues = Helper.GetMatrixValuesFromXml(path, Helper.MatrixType.PathMatrix);

                MatrixTransform matrixTransform = new MatrixTransform(double.Parse(matrixTransformationValues[0]),
                    double.Parse(matrixTransformationValues[1]),
                    double.Parse(matrixTransformationValues[2]),
                    double.Parse(matrixTransformationValues[3]),
                    double.Parse(matrixTransformationValues[4]),
                    double.Parse(matrixTransformationValues[5]));

                geometryData.Transform = matrixTransform;
            }

            if (path.Attribute("d") != null)
            {
                geometryData.AddGeometry(Geometry.Parse(path.Attribute("d").Value));
            }
            if (path.Attribute("fill") != null)
            {
                customPath.Fill = GetBrushFromXElement(path, "fill");
            }
            else
            {
                customPath.Fill = Brushes.Black;
            }
            if (path.Attribute("stroke") != null)
            {
                customPath.Stroke = GetBrushFromXElement(path, "stroke");
            }
            if (path.Attribute("stroke-width") != null)
            {
                customPath.StrokeThickness = double.Parse(path.Attribute("stroke-width").Value);
            }


            customPath.Opacity = GetOpacityFromXElement(path);

            customPath.Data = geometryData;

            string fillData = string.Empty;

            Brush brush = customPath.Fill;

            if (brush is LinearGradientBrush || brush is RadialGradientBrush)
            {
                GradientBrush linearBrush = brush as GradientBrush;

                foreach (var gradientStop in linearBrush.GradientStops)
                {
                    fillData += "Stop: " + gradientStop.Offset + " Colour: " + gradientStop.Color + Environment.NewLine;
                }
            }
            else
            {
                fillData = brush.ToString();
            }

            customPath.Tag = "Data: " + customPath.Data + Environment.NewLine +
            "Stroke: " + customPath.Stroke + Environment.NewLine +
                              "Fill: " + fillData + Environment.NewLine;

            customPath.PreviewMouseUp += customPath_MouseUp;


            return customPath;
        }
Example #31
0
        /// <summary>
        /// Routine used to draw the cylinder.
        /// </summary>
        public void DrawCylinder(System.Windows.Controls.Canvas cnv, double xOffset, double yOffset)
        {
            double ellipseHeight = 12;
                //Doesn't work with ChatPainter: Convert.ToInt32(Math.Floor(cylinderRadius * 0.3));
            Point ptUpperLeft;
            Point ptUpperRight;
            Point ptLowerLeft;
            Point ptLowerRight;
            Point ptC;

            ptUpperLeft = new Point(xOffset, ellipseHeight * 2);
            ptUpperRight = new Point(xOffset + (cylinderRadius * 2), ptUpperLeft.Y);
            ptLowerLeft = new Point(xOffset, ptUpperLeft.Y + cylinderHeight);
            ptLowerRight = new Point(ptUpperLeft.X + (cylinderRadius * 2), ptUpperLeft.Y + cylinderHeight);
            ptC = new Point(xOffset + cylinderRadius, ptUpperLeft.Y);

            ptUpperLeft.Y += yOffset;
            ptUpperRight.Y += yOffset;
            ptLowerLeft.Y += yOffset;
            ptLowerRight.Y += yOffset;
            ptC.Y += yOffset;

            Path pth = new Path();

            //Draw cylinder body.
            LineSegment ln = new LineSegment(ptLowerLeft, true);
            ArcSegment arc = new ArcSegment(ptLowerRight, new Size(cylinderRadius, ellipseHeight), 0, false, System.Windows.Media.SweepDirection.Counterclockwise, true);

            PathFigure pf = new PathFigure();
            pf.StartPoint = ptUpperLeft;
            //Add left side of cylinder.
            pf.Segments.Add(ln);
            //Add bottom arc of cylinder.
            pf.Segments.Add(arc);

            ln = new LineSegment(ptUpperRight, true);
            //Add right side of cylinder.
            pf.Segments.Add(ln);

            PathGeometry pg = new PathGeometry();
            pg.Figures.Add(pf);

            pth.Stroke = new SolidColorBrush(gridLineColor);
            pth.StrokeThickness = 2;
            pth.Fill = new SolidColorBrush(fillingColor);
            pth.Data = pg;
            cnv.Children.Add(pth);

            //Add top ellipse.
            pth = new Path();
            pth.Stroke = new SolidColorBrush(gridLineColor);
            pth.StrokeThickness = 2;
            pth.Fill = new SolidColorBrush(fillingColor);
            pg = new PathGeometry();
            pg.AddGeometry(new EllipseGeometry(ptC, cylinderRadius, ellipseHeight));
            pth.Data = pg;
            cnv.Children.Add(pth);

            #region Gridlines
            if (drawGridLines) { //If drawing grid lines within the Cylinder's body is enabled
                //Add gridlines on cylinder body.
                double i;
                double HorizontalPostion;
                double TopOfLine;
                double BottomOfLine;

                pth = new Path();
                pth.Stroke = new SolidColorBrush(gridLineColor);
                pth.StrokeThickness = 1;
                pg = new PathGeometry();

                for (i = 0; i <= cylinderDivisions / 2; i++)
                {
                    HorizontalPostion = Convert.ToInt32(cylinderRadius - (Math.Cos(Math.PI * 2 / cylinderDivisions * i) * cylinderRadius) + ptUpperLeft.X);
                    TopOfLine = Convert.ToInt32(Math.Sin(Math.PI * 2 / cylinderDivisions * i) * ellipseHeight + ptUpperLeft.Y);
                    BottomOfLine = TopOfLine + cylinderHeight;

                    pg.AddGeometry(new LineGeometry(new Point(HorizontalPostion, TopOfLine), new Point(HorizontalPostion, BottomOfLine)));

                }
                pth.Data = pg;
                cnv.Children.Add(pth);

                //Add radial gridlines on top of cylinder.
                pth = new Path();
                pth.Stroke = new SolidColorBrush(gridLineColor);
                pth.StrokeThickness = 1;
                pg = new PathGeometry();

                for (i = 0; i <= cylinderDivisions; i++)
                {
                    HorizontalPostion = Convert.ToInt32(cylinderRadius - (Math.Cos(Math.PI * 2 / cylinderDivisions * i) * cylinderRadius) + ptUpperLeft.X);
                    TopOfLine = Convert.ToInt32(Math.Sin(Math.PI * 2 / cylinderDivisions * i) * ellipseHeight + ptUpperLeft.Y);

                    pg.AddGeometry(new LineGeometry(new Point(HorizontalPostion, TopOfLine), ptC));

                }
                pth.Data = pg;
                cnv.Children.Add(pth);

                //Add circumferential gridlines on top of cylinder.
                pth = new Path();
                pth.Stroke = new SolidColorBrush(gridLineColor);
                pth.StrokeThickness = 1;
                pg = new PathGeometry();

                double circDivisions = 4;
                double multiplier;

                for (i = 1; i <= circDivisions - 1; i++)
                {
                    multiplier = i / Convert.ToDouble(circDivisions);

                    pg.AddGeometry(new EllipseGeometry(ptC, cylinderRadius * multiplier, ellipseHeight * multiplier));

                }
                pth.Data = pg;
                cnv.Children.Add(pth);

                double positionAdder;
                Point ptStart;
                Point ptEnd;

                //Add circumferential gridlines on body of cylinder.
                pth = new Path();
                pth.Stroke = new SolidColorBrush(gridLineColor);
                pth.StrokeThickness = 1;
                pg = new PathGeometry();

                for (i = 1; i <= cylinderDivisions / 2; i++)
                {
                    positionAdder = i * (cylinderHeight / (cylinderDivisions / 2));
                    ptStart = new Point(ptUpperLeft.X, ptUpperLeft.Y + positionAdder);
                    ptEnd = new Point(ptUpperRight.X, ptUpperRight.Y + positionAdder);

                    arc = new ArcSegment(ptEnd, new Size(cylinderRadius, ellipseHeight), 0, false, System.Windows.Media.SweepDirection.Counterclockwise, true);

                    pf = new PathFigure();
                    pf.StartPoint = ptStart;
                    //Add arc.
                    pf.Segments.Add(arc);

                    pg.Figures.Add(pf);

                }

                pth.Data = pg;
                cnv.Children.Add(pth);
            }
            #endregion
        }