Example #1
0
 public void Update(double v, double p)
 {
     this._data.Clear();
     _data.Add(v);
     _data.Add(p);
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(""));
 }
Example #2
0
        DrawPixelAlignedRectangle
        (
            DrawingContext drawingContext,
            Brush brush,
            Pen pen,
            Rect rect
        )
        {
            Debug.Assert(drawingContext != null);
            Debug.Assert(pen != null);

            // This technique was described at "Draw lines excactly on physical
            // device pixels," by Christian Mosers, at
            // http://wpftutorial.net/DrawOnPhysicalDevicePixels.html.

            Double dHalfPenWidth = pen.Thickness / 2.0;

            GuidelineSet     oGuidelineSet = new GuidelineSet();
            DoubleCollection oGuidelinesX  = oGuidelineSet.GuidelinesX;
            DoubleCollection oGuidelinesY  = oGuidelineSet.GuidelinesY;

            oGuidelinesX.Add(rect.Left + dHalfPenWidth);
            oGuidelinesX.Add(rect.Right + dHalfPenWidth);
            oGuidelinesY.Add(rect.Top + dHalfPenWidth);
            oGuidelinesY.Add(rect.Bottom + dHalfPenWidth);

            drawingContext.PushGuidelineSet(oGuidelineSet);
            drawingContext.DrawRectangle(brush, pen, rect);
            drawingContext.Pop();
        }
Example #3
0
        private void AddLinePattern(Line line, DataSeries ds)
        {
            line.Stroke          = ds.LineColor;
            line.StrokeThickness = ds.LineThickness;

            switch (ds.LinePattern)
            {
            case DataSeries.LinePatternEnum.Dash:
                DoubleCollection doubleCollection = new DoubleCollection();
                doubleCollection.Add(4);
                doubleCollection.Add(3);
                line.StrokeDashArray = doubleCollection;
                break;

            case DataSeries.LinePatternEnum.Dot:
                doubleCollection = new DoubleCollection();
                doubleCollection.Add(1);
                doubleCollection.Add(2);
                line.StrokeDashArray = doubleCollection;
                break;

            case DataSeries.LinePatternEnum.DashDot:
                doubleCollection = new DoubleCollection();
                doubleCollection.Add(4);
                doubleCollection.Add(2);
                doubleCollection.Add(1);
                doubleCollection.Add(2);
                line.StrokeDashArray = doubleCollection;
                break;

            case DataSeries.LinePatternEnum.None:
                line.Stroke = new SolidColorBrush(Colors.Transparent);
                break;
            }
        }
Example #4
0
        public void AddLinePattern()
        {
            gridline.Stroke          = GridlineColor;
            gridline.StrokeThickness = 1;

            switch (GridlinePattern)
            {
            case GridlinePatternEnum.Dash:
                DoubleCollection doubleCollection = new DoubleCollection();
                doubleCollection.Add(4);
                doubleCollection.Add(3);
                gridline.StrokeDashArray = doubleCollection;
                break;

            case GridlinePatternEnum.Dot:
                doubleCollection = new DoubleCollection();
                doubleCollection.Add(1);
                doubleCollection.Add(2);
                gridline.StrokeDashArray = doubleCollection;
                break;

            case GridlinePatternEnum.DashDot:
                doubleCollection = new DoubleCollection();
                doubleCollection.Add(4);
                doubleCollection.Add(2);
                doubleCollection.Add(1);
                doubleCollection.Add(2);
                gridline.StrokeDashArray = doubleCollection;
                break;
            }
        }
Example #5
0
        protected void Initialize()
        {
            this.front = new VertexCollection();
            this.front.AddRange(this.goals);
            this.newFront = new VertexCollection();
            this.probs    = new VertexDoublesDictionary();
            this.costs    = new VertexDoublesDictionary();

            foreach (IVertex v in this.TestGraph.Graph.Vertices)
            {
                // setting probs
                DoubleCollection col = new DoubleCollection();
                if (this.Goals.Contains(v))
                {
                    col.Add(0);
                }
                else
                {
                    col.Add(1);
                }

                this.probs.Add(v, col);

                // setting costs
                col = new DoubleCollection();
                col.Add(0);
                this.costs.Add(v, col);
            }

            foreach (IVertex v in this.TestGraph.States)
            {
                this.Strategy.SetChooseEdge(v, 0, null);
            }
        }
Example #6
0
        private void CompendiumMapDepthMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _isLeftMouseButtonDown = true;
            _selectionStartPoint   = translateTransform.Inverse.Transform(e.GetPosition(this));
            _selectionStartPoint   = scaleTransform.Inverse.Transform(_selectionStartPoint);
            if (_selectionRectangle != null)
            {
                this.uxMapSurface.Children.Remove(_selectionRectangle);
                _selectionRectangle = null;
            }
            if (e.ClickCount != 2)
            {
                _selectionRectangle                 = new Rectangle();
                _selectionRectangle.Stroke          = new SolidColorBrush(Colors.Black);
                _selectionRectangle.StrokeThickness = 1.0;
                _selectionRectangle.Opacity         = 0.7;
                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(2);
                dashArray.Add(4);
                _selectionRectangle.StrokeDashArray = dashArray;
                _selectionRectangle.SetValue(Canvas.LeftProperty, _selectionStartPoint.X);
                _selectionRectangle.SetValue(Canvas.TopProperty, _selectionStartPoint.Y);
                this.uxMapSurface.Children.Add(_selectionRectangle);
            }

            ViewManager.CommitNodeName();
        }
Example #7
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(new DoubleCollection());
            }
            double percent = 0;

            if (value is double)
            {
                percent = (double)value;
            }
            else
            {
                string str = value as string;
                if (string.IsNullOrEmpty(str))
                {
                    return(new DoubleCollection());
                }
                percent = double.Parse(str);
            }
            System.Windows.Media.DoubleCollection strokeDashArray = new DoubleCollection();

            //n = (Width - StrokeThickness )*Pi *p
            double n = (Width - StrokeThickness) / StrokeThickness * Math.PI * percent;

            strokeDashArray.Add(n);
            strokeDashArray.Add(double.MaxValue);
            return(strokeDashArray);
        }
Example #8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="adornedElement"></param>
        public ResizingAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            visualChildren = new VisualCollection(this);
            mainrec = new Rectangle();
            SolidColorBrush brush = new SolidColorBrush(Colors.DimGray);

            mainrec.Stroke = Brushes.Firebrick;
            DoubleCollection col = new DoubleCollection();
            col.Add(5.0);
            col.Add(2.30);
            mainrec.StrokeDashArray = col;
            visualChildren.Add(mainrec);

            // Call a helper method to initialize the Thumbs
            // with a customized cursors.
            BuildAdornerCorner(ref topLeft, Cursors.SizeNWSE);
            BuildAdornerCorner(ref topRight, Cursors.SizeNESW);
            BuildAdornerCorner(ref bottomLeft, Cursors.SizeNESW);
            BuildAdornerCorner(ref bottomRight, Cursors.SizeNWSE);

            // Add handlers for resizing.
            bottomLeft.DragDelta += new DragDeltaEventHandler(HandleBottomLeft);
            bottomRight.DragDelta += new DragDeltaEventHandler(HandleBottomRight);
            topLeft.DragDelta += new DragDeltaEventHandler(HandleTopLeft);
            topRight.DragDelta += new DragDeltaEventHandler(HandleTopRight);

            this.MinWidth = 50;

        }
 public MainWindow()
 {
     dottedLine = new DoubleCollection();
     dottedLine.Add(4);
     dottedLine.Add(2);
     InitializeComponent();
 }
Example #10
0
        private void DrawRectangle(Point rectLoc)                  //画矩形
        {
            DoubleCollection dCollection = new DoubleCollection(); //设置线型为虚线

            dCollection.Add(2);
            dCollection.Add(3);

            RectangleGeometry myRectangleGeometry = new RectangleGeometry();//设置矩形属性
            Rect myRect = new Rect();

            myRect.X                 = rectLoc.X * MainWindow._WH_CANVAS / MainWindow.NUM;
            myRect.Y                 = rectLoc.Y * MainWindow._WH_CANVAS / MainWindow.NUM;
            myRect.Width             = MainWindow._WH_CANVAS / MainWindow.NUM;
            myRect.Height            = MainWindow._WH_CANVAS / MainWindow.NUM;
            myRectangleGeometry.Rect = myRect;

            Path myPath = new Path();

            myPath.Stroke          = Brushes.Gray; //边线颜色为灰色
            myPath.StrokeThickness = 1;            //边线宽为1
            myPath.Data            = myRectangleGeometry;
            myPath.StrokeDashArray = dCollection;
            if (isFill)
            {
                myPath.Fill = Brushes.Black;//填充为黑色
            }

            _Temp_Canvas.Children.Add(myPath);//把图像添加到待返回的临时canvas对象上
        }
        //畫虛線模式
        public void DrawPointer(double x1, double y1, double x2, double y2)
        {
            CheckPoint(ref x1, ref x2);
            CheckPoint(ref y1, ref y2);
            float           width            = (float)(x2 - x1);
            float           height           = (float)(y2 - y1);
            Polygon         rectangle        = new Polygon();
            PointCollection pointCollection  = new PointCollection();
            Point           leftTopPoint     = new Point(x1, y1);
            Point           rightTopPoint    = new Point(x2, y1);
            Point           rightBottomPoint = new Point(x2, y2);
            Point           leftBottomPoint  = new Point(x1, y2);

            pointCollection.Add(leftTopPoint);
            pointCollection.Add(rightTopPoint);
            pointCollection.Add(rightBottomPoint);
            pointCollection.Add(leftBottomPoint);
            rectangle.Points = pointCollection;
            rectangle.Stroke = new SolidColorBrush(Colors.Blue);
            DoubleCollection dashCollision = new DoubleCollection();

            dashCollision.Add(2);
            dashCollision.Add(4);
            rectangle.StrokeDashArray = dashCollision;
            _canvas.Children.Add(rectangle);
        }
Example #12
0
        protected void AddSelectionRectangle()
        {
            selection = new Rectangle()
            {
                Visibility        = Visibility.Visible, ClipToBounds = true, Width = 0, Height = 0,
                VerticalAlignment = VerticalAlignment.Top
            };
            SolidColorBrush selectionBrush = new SolidColorBrush()
            {
                Color = Brushes.Aquamarine.Color, Opacity = 0.5
            };

            selection.Fill             = selectionBrush;
            selection.StrokeDashOffset = 5; selection.StrokeThickness = 0.99;
            SolidColorBrush selectionBrush2 = new SolidColorBrush()
            {
                Color = Color.FromArgb(255, 0, 0, 0)
            };

            selection.Stroke = selectionBrush2;
            selection.HorizontalAlignment = HorizontalAlignment.Left;
            DoubleCollection strokeDashArray1 = new DoubleCollection(2);

            strokeDashArray1.Add(3); strokeDashArray1.Add(3);
            selection.StrokeDashArray = strokeDashArray1;
            Canvas.Children.Add(selection);
            selection.SetValue(Canvas.ZIndexProperty, 1000);
        }
        private void drawMOSTTyphoon()
        {
            Point point0 = new Point();
            Point point1 = new Point();
            Point point2 = new Point();

            for (int i = 1; i < cTyphoon.mostPoints.Count; i += 2)
            {
                point0.X = (cTyphoon.mostPoints[i - 1].longitude - minLong) / (maxLong - minLong) * canvasShow.Width;
                point0.Y = canvasShow.Height - (cTyphoon.mostPoints[i - 1].latitude - minLat) / (maxLat - minLat) * canvasShow.Height;
                Ellipse tp = new Ellipse();
                tp.Height          = 10 / scale;
                tp.Width           = 10 / scale;
                tp.Fill            = typhSpeedColor(cTyphoon.mostPoints[i - 1].aveSpeed);
                tp.Stroke          = Brushes.Black;
                tp.StrokeThickness = 1 / scale;
                Canvas.SetLeft(tp, point0.X - 5 / scale);
                Canvas.SetTop(tp, point0.Y - 5 / scale);
                Canvas.SetZIndex(tp, 2);
                canvasShow.Children.Add(tp);
                point1.Y = canvasShow.Height - (cTyphoon.mostPoints[i].latitude - minLat) / (maxLat - minLat) * canvasShow.Height;
                point1.X = (cTyphoon.mostPoints[i].longitude - minLong) / (maxLong - minLong) * canvasShow.Width;
                Line l = new Line();
                l.Stroke          = Brushes.DarkBlue;
                l.StrokeThickness = 2 / scale;
                l.X1 = point0.X; l.X2 = point1.X; l.Y1 = point0.Y; l.Y2 = point1.Y;
                Canvas.SetZIndex(l, 1);
                canvasShow.Children.Add(l);

                point2.Y = canvasShow.Height - (cTyphoon.mostPoints[i + 1].latitude - minLat) / (maxLat - minLat) * canvasShow.Height;
                point2.X = (cTyphoon.mostPoints[i + 1].longitude - minLong) / (maxLong - minLong) * canvasShow.Width;
                DoubleCollection dc = new DoubleCollection();
                dc.Add(2);
                dc.Add(2);
                Line dl = new Line();
                dl.Stroke          = Brushes.DarkBlue;
                dl.StrokeThickness = 2 / scale;
                dl.X1 = point1.X; dl.X2 = point2.X; dl.Y1 = point1.Y; dl.Y2 = point2.Y;
                dl.StrokeDashArray = dc;
                canvasShow.Children.Add(dl);
                Canvas.SetZIndex(dl, 1);
            }
            #region 画预测轨迹
            CMostTyphoonPoint p6h = cTyphoon.ShortTimePredict(6);
            point0.X = (cTyphoon.points[cTyphoon.POINTSNUM - 1].longitude - minLong) / (maxLong - minLong) * canvasShow.Width;
            point0.Y = canvasShow.Height - (cTyphoon.points[cTyphoon.POINTSNUM - 1].latitude - minLat) / (maxLat - minLat) * canvasShow.Height;
            point1.Y = canvasShow.Height - (p6h.latitude - minLat) / (maxLat - minLat) * canvasShow.Height;
            point1.X = (p6h.longitude - minLong) / (maxLong - minLong) * canvasShow.Width;
            Line lp = new Line();
            lp.Stroke          = Brushes.Red;
            lp.StrokeThickness = 2 / scale;
            lp.X1 = point0.X; lp.X2 = point1.X; lp.Y1 = point0.Y; lp.Y2 = point1.Y;
            Canvas.SetZIndex(lp, 1);
            DoubleCollection dcl = new DoubleCollection();
            dcl.Add(2);
            dcl.Add(2);
            lp.StrokeDashArray = dcl;
            canvasShow.Children.Add(lp);
            #endregion
        }
Example #14
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="adornedElement"></param>
        public ResizingAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            visualChildren = new VisualCollection(this);
            mainrec        = new Rectangle();
            SolidColorBrush brush = new SolidColorBrush(Colors.DimGray);

            mainrec.Stroke = Brushes.Firebrick;
            DoubleCollection col = new DoubleCollection();

            col.Add(5.0);
            col.Add(2.30);
            mainrec.StrokeDashArray = col;
            visualChildren.Add(mainrec);

            // Call a helper method to initialize the Thumbs
            // with a customized cursors.
            BuildAdornerCorner(ref topLeft, Cursors.SizeNWSE);
            BuildAdornerCorner(ref topRight, Cursors.SizeNESW);
            BuildAdornerCorner(ref bottomLeft, Cursors.SizeNESW);
            BuildAdornerCorner(ref bottomRight, Cursors.SizeNWSE);

            // Add handlers for resizing.
            bottomLeft.DragDelta  += new DragDeltaEventHandler(HandleBottomLeft);
            bottomRight.DragDelta += new DragDeltaEventHandler(HandleBottomRight);
            topLeft.DragDelta     += new DragDeltaEventHandler(HandleTopLeft);
            topRight.DragDelta    += new DragDeltaEventHandler(HandleTopRight);

            this.MinWidth = 50;
        }
        /// <summary>
        /// Draw lines from ais to the pointer
        /// </summary>
        /// <param name="point">Pointer position</param>
        /// <param name="canvas">Canas where to draw</param>
        public void DrawPointerLine(System.Windows.Point point, Canvas canvas)
        {
            if (pointerLineX != null)
            {
                canvas.Children.Remove(pointerLineX);
            }
            if (pointerLineZ != null)
            {
                canvas.Children.Remove(pointerLineZ);
            }

            pointerLineX = new Line();
            DoubleCollection col = new DoubleCollection();

            col.Add(4);
            col.Add(2);
            pointerLineX.StrokeDashArray = col;
            pointerLineX.StrokeThickness = 1;
            pointerLineX.Stroke          = blackBrush;
            pointerLineX.X1 = point.X;
            pointerLineX.Y1 = point.Y;
            pointerLineX.X2 = point.X;
            pointerLineX.Y2 = canvas.ActualHeight - CANVAS_PADDING;
            canvas.Children.Add(pointerLineX);

            pointerLineZ = new Line();
            pointerLineZ.StrokeDashArray = col;
            pointerLineZ.StrokeThickness = 1;
            pointerLineZ.Stroke          = blackBrush;
            pointerLineZ.X1 = point.X;
            pointerLineZ.Y1 = point.Y;
            pointerLineZ.X2 = CANVAS_PADDING;
            pointerLineZ.Y2 = point.Y;
            canvas.Children.Add(pointerLineZ);
        }
Example #16
0
        public void AddLinePattern()
        {
            LineSeries.Stroke          = LineColor;
            LineSeries.StrokeThickness = LineThickness;

            switch (LinePattern)
            {
            case LinePatternEnum.Dash:
                DoubleCollection doubleCollection = new DoubleCollection();
                doubleCollection.Add(4);
                doubleCollection.Add(3);
                LineSeries.StrokeDashArray = doubleCollection;
                break;

            case LinePatternEnum.Dot:
                doubleCollection = new DoubleCollection();
                doubleCollection.Add(1);
                doubleCollection.Add(2);
                LineSeries.StrokeDashArray = doubleCollection;
                break;

            case LinePatternEnum.DashDot:
                doubleCollection = new DoubleCollection();
                doubleCollection.Add(4);
                doubleCollection.Add(2);
                doubleCollection.Add(1);
                doubleCollection.Add(2);
                LineSeries.StrokeDashArray = doubleCollection;
                break;

            case LinePatternEnum.None:
                LineSeries.Stroke = new SolidColorBrush(Colors.Transparent);
                break;
            }
        }
Example #17
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            HueSlider = GetTemplateChild("HueSlider") as ColorPickerSlider;
            HueSlider.ValueChanged += delegate(object sender, RoutedPropertyChangedEventArgs <double> e) {
                SaveToConfig();
            };

            HueSlider.StartedDragging += delegate() { StartedDragging?.Invoke(); };
            HueSlider.StoppedDragging += delegate() { StoppedDragging?.Invoke(); };

            DoubleCollection ticks = new DoubleCollection();

            // Add a tick at the minimum value, which is a negative value.  This is the
            // tick for white.
            ticks.Add(HueSlider.Minimum);

            // Add a tick for 0-359.  Don't add 360, since that's the same as 0.
            for (int i = 0; i < 360; ++i)
            {
                ticks.Add(i);
            }
            HueSlider.Ticks = ticks;

            OnConfigChange onConfigChange;

            onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
                int pad = SelectedPanel < 9? 0:1;
                LoadUIFromConfig(args.controller[pad].config);
            });
        }
Example #18
0
        public void DoMultiSelect(Point pt)
        {
            shapes = new List <Shape>();
            RectangleGeometry HitTestArea = new RectangleGeometry(new Rect(
                                                                      Canvas.GetLeft(activeShape), Canvas.GetTop(activeShape),
                                                                      activeShape.Width, activeShape.Height));

            VisualTreeHelper.HitTest(canvas, null,
                                     result =>
            {
                var shape = result.VisualHit as Shape;

                if (shape != null && shape != activeShape)
                {
                    shapes.Add(shape);
                }

                return(HitTestResultBehavior.Continue);
            },
                                     new GeometryHitTestParameters(HitTestArea));
            if (shapes.Count > 0)
            {
                DoubleCollection dc = new DoubleCollection(2);
                dc.Add(2); dc.Add(2);
                pointsInitial = new List <Point>();
                foreach (Shape shape in shapes)
                {
                    shape.StrokeDashArray = dc;
                    pointsInitial.Add(new Point(Canvas.GetLeft(shape), Canvas.GetTop(shape)));
                }
                pointStart = pt;
            }
            DeactivateShape();
            toolMode = NToolMode.Move;
        }
Example #19
0
        public void DoSelect(Point pt, bool doubleclick = false)
        {
            DeactivateShape();
            HitTestResult result = VisualTreeHelper.HitTest(canvas, pt);

            if (result != null && result.VisualHit is Shape)
            {
                activeShape = (result.VisualHit as Shape);
                DoubleCollection dc = new DoubleCollection(2);
                dc.Add(2); dc.Add(2);
                activeShape.StrokeDashArray = dc;
                pointInitial = new Point(Canvas.GetLeft(activeShape), Canvas.GetTop(activeShape));
                pointStart   = pt;
                if (activeShape is Polyline)
                {//start polyline editing
                    linePointIndex = GetPolylinePointIndex(activeShape as Polyline, pt, doubleclick);
                }
            }
            else
            {
                toolMode     = NToolMode.Pan;
                pointInitial = new Point((canvas.RenderTransform as TranslateTransform).X, (canvas.RenderTransform as TranslateTransform).Y);
                pointStart   = canvas.TranslatePoint(pt, null);
                Debug.WriteLine("start pan: " + pointStart);
                canvas.CaptureMouse();
            }
        }
Example #20
0
        public void MouseDown(Point pt, bool multiselect, bool doubleclick)
        {
            if (multiselect)
            {
                toolMode = NToolMode.MultiSelect;
            }
            switch (toolMode)
            {
            case NToolMode.Rect: DoRect(pt); break;

            case NToolMode.Select: DoSelect(pt, doubleclick); break;

            case NToolMode.Pan: DoSelect(pt, doubleclick); break;

            case NToolMode.Delete: DoDelete(pt); break;

            case NToolMode.Scale: DoScale(pt); break;

            case NToolMode.Rotate: DoRotate(pt); break;

            case NToolMode.Line: DoLine(pt); break;

            case NToolMode.Move: pointStart = pt; break;

            case NToolMode.MultiSelect:
                DoRect(pt);
                activeShape.Fill = new SolidColorBrush();
                DoubleCollection dc = new DoubleCollection(2);
                dc.Add(5); dc.Add(2);
                activeShape.StrokeDashArray = dc;
                break;
            }
        }
Example #21
0
 void CreateLine(bool isHorizontal)
 {
     if (isHorizontal)
     {
         HLine = new Line();
         HLine.StrokeThickness = 3;
         HLine.Stroke          = new SolidColorBrush(Colors.MediumPurple);
         HLine.Opacity         = 0.7;
         DoubleCollection dashSize = new DoubleCollection();
         dashSize.Add(1);
         dashSize.Add(1);
         HLine.StrokeDashArray  = dashSize;
         HLine.StrokeDashOffset = 0;
     }
     else
     {
         WLine = new Line();
         WLine.StrokeThickness = 3;
         WLine.Stroke          = new SolidColorBrush(Colors.Orange);
         WLine.Opacity         = 0.7;
         DoubleCollection dashSize = new DoubleCollection();
         dashSize.Add(1);
         dashSize.Add(1);
         WLine.StrokeDashArray  = dashSize;
         WLine.StrokeDashOffset = 0;
     }
 }
Example #22
0
        private void DrawCircle(Point CENTER_XY, double RADIUS)    //画一个圆
        {
            DoubleCollection dCollection = new DoubleCollection(); //设置线型为虚线

            dCollection.Add(2);
            dCollection.Add(3);

            EllipseGeometry myEllipseGeometry = new EllipseGeometry();

            myEllipseGeometry.Center  = CENTER_XY; //设置圆心坐标
            myEllipseGeometry.RadiusX = RADIUS;    //设置X方向径长
            myEllipseGeometry.RadiusY = RADIUS;    //设置Y方向径长
            Path myPath = new Path();

            myPath.Stroke          = Brushes.Gray; //边线颜色为灰色
            myPath.StrokeThickness = 1;            //边线宽为1
            myPath.Data            = myEllipseGeometry;
            myPath.StrokeDashArray = dCollection;
            if (isFill)
            {
                myPath.Fill = Brushes.Black;//填充为黑色
            }

            _Temp_Canvas.Children.Add(myPath);//把图像添加到待返回的临时canvas对象上
        }
        public moveMoldPart()
        {
            InitializeComponent();

            valmoWin.dv.MldPr[621].addHandle(refush);
            valmoWin.dv.SysPr[109].addHandle(MoldChanged);

            LineRef = new Line();
            LineRef.Stroke = new SolidColorBrush(Colors.Red);
            LineRef.X1 = 0;
            LineRef.X2 = 400;
            LineRef.Y1 = 400;
            LineRef.SnapsToDevicePixels = true;
            LineRef.ClipToBounds = true;
            LineRef.StrokeThickness = 1;
            DoubleCollection DashArray = new DoubleCollection();
            DashArray.Add(2);
            DashArray.Add(2);
            LineRef.StrokeDashArray = DashArray;
            cvsCurve.Children.Add(LineRef);

            for (int i = 0; i < 11; i++)
            {
                Rectangle rec = new Rectangle();
                rec.Height = 6;
                rec.Width = 6;
                rec.Fill = new SolidColorBrush(Colors.Black);
                cvsCurve.Children.Add(rec);
                lstRec.Add(rec);
                Canvas.SetLeft(rec, i * 40 - 3);
                Canvas.SetBottom(rec, -3);
            }

            for (int i = 0; i < 10; i++)
            {
                Line line = new Line();
                line.Stroke = new SolidColorBrush(Colors.Black);
                line.X1 = i * 40;
                line.X2 = (i + 1) * 40;
                line.SnapsToDevicePixels = true;
                line.ClipToBounds = true;
                line.StrokeThickness = 1;
                lstLine.Add(line);
                cvsCurve.Children.Add(line);
            }

            lstLine[0].Y1 = 400;

            valmoWin.dv.MldPr[170].addHandle(refushPoint1);
            valmoWin.dv.MldPr[171].addHandle(refushPoint2);
            valmoWin.dv.MldPr[172].addHandle(refushPoint3);
            valmoWin.dv.MldPr[173].addHandle(refushPoint4);
            valmoWin.dv.MldPr[174].addHandle(refushPoint5);
            valmoWin.dv.MldPr[175].addHandle(refushPoint6);
            valmoWin.dv.MldPr[176].addHandle(refushPoint7);
            valmoWin.dv.MldPr[177].addHandle(refushPoint8);
            valmoWin.dv.MldPr[178].addHandle(refushPoint9);
            valmoWin.dv.MldPr[179].addHandle(refushPoint10);
        }
        /// <summary>
        /// Gets the stroke dash array.
        /// </summary>
        private DoubleCollection GetStrokeDashArray()
        {
            DoubleCollection strokeDashArray = new DoubleCollection();

            strokeDashArray.Add(Definitions.SELECTION_BORDER_DASH_PATTERN_FIRST_VALUE);
            strokeDashArray.Add(Definitions.SELECTION_BORDER_DASH_PATTERN_SECOND_VALUE);
            return(strokeDashArray);
        }
Example #25
0
        //-- Define Hidden Line Pattern for use as outer circle of Tapped Holes
        public static DoubleCollection HiddenLinePattern(double LineTypeScaleFactor)
        {
            var PatternDef = new DoubleCollection();

            PatternDef.Add(5 * LineTypeScaleFactor);
            PatternDef.Add(5 * LineTypeScaleFactor);
            return(PatternDef);
        }
        public MyVisual()
        {
            VisualXSnappingGuidelines = new DoubleCollection();
            double mm = 50;

            VisualXSnappingGuidelines.Add(mm);
            mm = -50;
            VisualXSnappingGuidelines.Add(mm);
        }
        public WindowWpfExampleTableMyVisual()
        {
            VisualXSnappingGuidelines = new DoubleCollection();
            double mm = 50;

            VisualXSnappingGuidelines.Add(mm);
            mm = -50;
            VisualXSnappingGuidelines.Add(mm);
        }
        private void transformCanvas()
        {
            double width  = maxX - minX;
            double height = maxY - minY;

            if (width > this.canvas.ActualWidth)
            {
                this.canvas.Width = width;
            }
            else
            {
                width = this.canvas.ActualWidth;
            }
            if (height > this.canvas.ActualHeight)
            {
                this.canvas.Height = height;
            }
            else
            {
                height = this.canvas.ActualHeight;
            }
            transformGroup = new TransformGroup();
            double scaleX = width > 0 ? this.canvasWidth / width : 1;
            double scaleY = height > 0 ? this.canvasHeight / height : 1;

            scale = Math.Max(scaleX, scaleY);
            ScaleTransform scaleTransform = new ScaleTransform();

            scaleTransform.ScaleX = scaleX;
            scaleTransform.ScaleY = scaleY;

            TranslateTransform translateTransform = new TranslateTransform();

            translateTransform.X  = -minX;
            translateTransform.Y  = -minY;
            strokeThickness       = 2 / scale;
            path1.StrokeThickness = 2 * strokeThickness;
            path2.StrokeThickness = strokeThickness;
            DoubleCollection strokeDashArray1 = new DoubleCollection();

            strokeDashArray1.Add(1000 / scale);
            strokeDashArray1.Add(500 / scale);
            path1.StrokeDashArray = strokeDashArray1;

            DoubleCollection strokeDashArray2 = new DoubleCollection();

            strokeDashArray2.Add(1000 / scale);
            strokeDashArray2.Add(500 / scale);
            path2.StrokeDashArray = strokeDashArray2;

            transformGroup.Children.Add(translateTransform);
            transformGroup.Children.Add(scaleTransform);

            canvas.RenderTransform = transformGroup;
        }
Example #29
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                //Create a Bezier;
                connector                 = new Path();
                connector.Stroke          = Brushes.Black;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity         = .8;

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve  = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1      = connectorPoints.StartPoint;
                connectorCurve.Point2      = connectorPoints.StartPoint;
                connectorCurve.Point3      = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(this, 300);

                //register an event listener for the start port update
                //this will tell the connector to set the elements at either
                //end to be equal if pStart and pEnd are not null
                //pStart.Owner.Outputs[pStart.Index].dynElementUpdated += new Dynamo.Elements.dynElementUpdatedHandler(StartPortUpdated);
            }
            else
            {
                throw new InvalidPortException();
            }
        }
        /// <summary>
        /// Handles the Loaded event of the AssociatedObject control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
        {
            DoubleCollection strokeArray;

            strokeArray = new DoubleCollection();
            strokeArray.Add(15);
            strokeArray.Add(15);
            AssociatedObject.Gantt.CurrentDateLine.StrokeDashArray    = strokeArray;
            AssociatedObject.Gantt.CurrentDateLine.Stroke             = Brushes.Red;
            this.AssociatedObject.CurrentDateLineCB.SelectionChanged += new SelectionChangedEventHandler(CurrentDateLineCB_SelectionChanged);
        }
        // 劃出標示線
        private void DrawMarkLines(DrawingModel.Point startPoint, DrawingModel.Point endPoint)
        {
            DoubleCollection dashCollection = new DoubleCollection();

            dashCollection.Add(Constant.TWO);
            dashCollection.Add(Constant.TWO);
            Windows.UI.Xaml.Shapes.Rectangle rectangle = GetRectangle(startPoint, endPoint);
            rectangle.StrokeDashArray = dashCollection;
            rectangle.Stroke          = new SolidColorBrush(Colors.Red);
            _canvas.Children.Add(rectangle);
        }
Example #32
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                //Create a Bezier;
                connector = new Path();
                connector.Stroke = Brushes.Black;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity = .8;

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1 = connectorPoints.StartPoint;
                connectorCurve.Point2 = connectorPoints.StartPoint;
                connectorCurve.Point3 = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(this, 300);

                //register an event listener for the start port update
                //this will tell the connector to set the elements at either
                //end to be equal if pStart and pEnd are not null
                //pStart.Owner.Outputs[pStart.Index].dynElementUpdated += new Dynamo.Elements.dynElementUpdatedHandler(StartPortUpdated);
            }
            else
            {
                throw new InvalidPortException();
            }
        }
Example #33
0
 private void style3_Checked(object sender, RoutedEventArgs e)
 {
     dashes = new DoubleCollection();
     dashes.Clear();
     dashes.Add(4);
     dashes.Add(3);
     if (adlayer != null)
     {
         shape.ChangeDash(dashes);
     }
 }
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if ((bool)value)
       {
     var dc = new DoubleCollection();
     dc.Add(1);
     dc.Add(3);
     return dc;
       }
       else
     return null;
 }
Example #35
0
        public void Draw(
            GridRange range,
            IPoints points) {

            DrawingContext drawingContext = RenderOpen();
            DoubleCollection xCollection = new DoubleCollection();
            DoubleCollection yCollection = new DoubleCollection();

            try {
                // vertical line
                double renderHeight = points.yPosition[range.Rows.Start + range.Rows.Count] - points.yPosition[range.Rows.Start];
                Rect verticalLineRect = new Rect(new Size(GridLineThickness, renderHeight));
                foreach (int i in range.Columns.GetEnumerable()) {
                    verticalLineRect.X = points.xPosition[i + 1] - GridLineThickness;
                    drawingContext.DrawRectangle(GridLineBrush, null, verticalLineRect);
                    xCollection.Add(verticalLineRect.X);
                }

                // horizontal line
                double renderWidth = points.xPosition[range.Columns.Start + range.Columns.Count] - points.xPosition[range.Columns.Start];
                Rect horizontalLineRect = new Rect(new Size(renderWidth, GridLineThickness));
                foreach (int i in range.Rows.GetEnumerable()) {
                    horizontalLineRect.Y = points.yPosition[i + 1] - GridLineThickness;
                    drawingContext.DrawRectangle(GridLineBrush, null, horizontalLineRect);
                    yCollection.Add(horizontalLineRect.Y);
                }

                XSnappingGuidelines = xCollection;
                YSnappingGuidelines = yCollection;
            } finally {
                drawingContext.Close();
            }
        }
 protected void AddSelectionRectangle()
 {
     selection = new Rectangle() { Visibility = Visibility.Visible, ClipToBounds = true, Width = 0, Height = 0, 
         VerticalAlignment = VerticalAlignment.Top };
     SolidColorBrush selectionBrush = new SolidColorBrush() { Color = Brushes.Aquamarine.Color, Opacity = 0.5 };
     selection.Fill = selectionBrush;
     selection.StrokeDashOffset = 5; selection.StrokeThickness = 0.99;
     SolidColorBrush selectionBrush2 = new SolidColorBrush() { Color = Color.FromArgb(255, 0, 0, 0) };
     selection.Stroke = selectionBrush2;
     selection.HorizontalAlignment = HorizontalAlignment.Left;
     DoubleCollection strokeDashArray1 = new DoubleCollection(2);
     strokeDashArray1.Add(3); strokeDashArray1.Add(3);
     selection.StrokeDashArray = strokeDashArray1;
     Canvas.Children.Add(selection);
     selection.SetValue(Canvas.ZIndexProperty, 1000);
 }
        public ScreenBrightInfo()
        {
            DoubleCollection collection = new DoubleCollection();
            collection.Add(3000);
            collection.Add(5000);
            collection.Add(6500);
            collection.Add(9300);
            ColorTempTicksCollection = collection;

            #region 命令绑定

            CmdSetDefaultColorTemp = new RelayCommand<double>(OnCmdSetDefaultColorTemp);
            CmdSetGamma = new RelayCommand<int>(OnCmdSetGamma);
            CmdSetGlobalBright = new RelayCommand<int>(OnCmdSetGlobalBright);
            CmdSetRedBright = new RelayCommand<int>(OnCmdSetRedBright);
            CmdSetGreenBright = new RelayCommand<int>(OnCmdSetGreenBright);
            CmdSetBlueBright = new RelayCommand<int>(OnCmdSetBlueBright);
            CmdSetCurrentGain = new RelayCommand(OnCmdSetCurrentGain);
            CmdSetSyncBright = new RelayCommand<bool>(OnCmdSetSyncBright);
            CmdSetSyncGain = new RelayCommand<bool>(OnCmdSetSyncGain);
            CmdSetColorTemp = new RelayCommand<int>(OnCmdSetColorTemp);
            CmdReadScanBdProp = new RelayCommand(OnCmdReadScanBdProp);
            CmdSetDefalutCurGain = new RelayCommand(OnCmdSetDefalutCurGain);

            CmdAddTimingAdjustData = new RelayCommand(OnAddTimingAdjustData);
            CmdEditTimingAdjustData = new RelayCommand(OnEditSmartBrightItemData, CanEditTimingAdjustData);
            CmdDeleteSelectedTimingAdjustData = new RelayCommand(OnDeleteSelectedTimingAdjustData, CanDeleteSelectedTimingAdjustData);
            CmdClearTimingAdjustData = new RelayCommand(OnClearTimingAdjustData, CanClearTimingAdjustData);
            CmdOK = new RelayCommand<string>(OnOk);

            CmdReadFromDB = new RelayCommand<string>(OnCmdReadFromDB);

            CmdPeripheralsSetting = new RelayCommand(OnCmdPeripheralsSetting);

            CmdBrightAdjustModeClick = new RelayCommand(OnCmdBrightAdjustModeClick);
            #endregion

            #region 初始化
            if (!this.IsInDesignMode)
            {
                _colorTempRGBMapDict = _globalParams.ColorTempRGBMappingDict;

                //SelectedBrightAdjustMode = BrightAdjustMode.SmartBright;

            }
            #endregion
        }
Example #38
0
        /// <summary>
        /// InkCanvasFeedbackAdorner Constructor
        /// </summary>
        /// <param name="inkCanvas">The adorned InkCanvas</param>
        internal InkCanvasFeedbackAdorner(InkCanvas inkCanvas)
            : base(( inkCanvas != null ? inkCanvas.InnerCanvas : null ))
        {
            if ( inkCanvas == null )
                throw new ArgumentNullException("inkCanvas");

            // Initialize the internal data
            _inkCanvas = inkCanvas;

            _adornerBorderPen = new Pen(Brushes.Black, 1.0);
            DoubleCollection dashes = new DoubleCollection( );
            dashes.Add(4.5);
            dashes.Add(4.5);
            _adornerBorderPen.DashStyle = new DashStyle(dashes, 2.25);
            _adornerBorderPen.DashCap = PenLineCap.Flat;

        }
Example #39
0
 private void DrawLine( double x1, double y1, double x2, double y2, bool dotted )
 {
     Line line = new Line();
     line.X1 = x1;
     line.Y1 = y1;
     line.X2 = x2;
     line.Y2 = y2;
     line.Stroke = Brushes.Red;
     line.StrokeThickness = 1.0;
     if ( dotted )
     {
         DoubleCollection collection = new DoubleCollection();
         collection.Add( 3 );
         collection.Add( 3 );
         line.StrokeDashArray = collection;
     }
     screen.Children.Add( line );
 }
Example #40
0
  void OnClickNonUniform(object sender, RoutedEventArgs e)
  {
      Slider hslider = new Slider();
      hslider.Orientation = Orientation.Horizontal;
      hslider.Width = 100;
      hslider.IsMoveToPointEnabled = false;
      DoubleCollection tickMarks = new DoubleCollection();
      tickMarks.Add(1.1);
      tickMarks.Add(1.3);
      tickMarks.Add(2.0);
      tickMarks.Add(7.0);
      tickMarks.Add(10.0);
      hslider.Ticks = tickMarks;
      hslider.TickPlacement = TickPlacement.BottomRight;
      hslider.AutoToolTipPlacement =
        AutoToolTipPlacement.TopLeft;
      hslider.AutoToolTipPrecision = 2;
      hslider.IsSnapToTickEnabled = true;
      cv2.Children.Add(hslider);
 }
Example #41
0
		public ChartCanvas()
		{
			RebuildDisabled = true;

			//Background = new SolidColorBrush(Color.FromArgb(0xf0, 0x3f, 0x3f, 0x3f));
			GradientStopCollection gradient = new GradientStopCollection();
			gradient.Add(new GradientStop(Color.FromRgb(203, 231, 227), 0));
			gradient.Add(new GradientStop(Color.FromRgb(241, 230, 168), 0.6));
			gradient.Add(new GradientStop(Color.FromRgb(236, 213, 186), 1));
			LinearGradientBrush back = new LinearGradientBrush(gradient, new Point(0,0), new Point(0, 1));
			Background = back;
			Offset = 0;
			XRange = 50;
			CandleWidth = 9;
			CandleSpacing = 3;
			YMin = 0;
			YMax = 100;

			LeftMargin = 10;
			RightMargin = 40;
			TopMargin = 10;
			BottomMargin = 10;

			_gridPattern = new DoubleCollection(2);
			_gridPattern.Add(5);
			_gridPattern.Add(5);

			ShowGridLines();
			this.PreviewMouseLeftButtonDown += CustomCanvas_PreviewMouseLeftButtonDown;
			this.PreviewMouseLeftButtonUp += CustomCanvas_PreviewMouseLeftButtonUp;
			this.PreviewMouseMove += CustomCanvas_PreviewMouseMove;

			this.SizeChanged += ChartCanvas_SizeChanged;

			RebuildDisabled = false;
		}
 /// <summary>${WP_utility_DoubleCollectionConverter_method_Convert_D}</summary>
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value == null)
     {
         return null;
     }
     if (targetType != typeof(DoubleCollection))
     {
         throw new NotSupportedException();
     }
     DoubleCollection doubles = (DoubleCollection)value;
     DoubleCollection doubles2 = new DoubleCollection();
     foreach (double num in doubles)
     {
         doubles2.Add(num);
     }
     return doubles2;
 }
Example #43
0
        public static Curve2dCollection To2dCurve(this Grevit.Types.Component curve)
        {
            Curve2dCollection curveArray = new Curve2dCollection();

            if (curve.GetType() == typeof(Grevit.Types.Line))
            {
                Grevit.Types.Line baseline = (Grevit.Types.Line)curve;
                curveArray.Add(new Line2d(baseline.from.ToPoint2d(), baseline.to.ToPoint2d()));
            }
            else if (curve.GetType() == typeof(Grevit.Types.Arc))
            {
                Grevit.Types.Arc baseline = (Grevit.Types.Arc)curve;
                curveArray.Add(new CircularArc2d(baseline.center.ToPoint2d(), baseline.radius, baseline.start, baseline.end, Vector2d.XAxis, true));
            }
            else if (curve.GetType() == typeof(Grevit.Types.Curve3Points))
            {
                Grevit.Types.Curve3Points baseline = (Grevit.Types.Curve3Points)curve;
                curveArray.Add(new CircularArc2d(baseline.a.ToPoint2d(), baseline.c.ToPoint2d(), baseline.b.ToPoint2d()));
            }
            else if (curve.GetType() == typeof(Grevit.Types.PLine))
            {
                Grevit.Types.PLine baseline = (Grevit.Types.PLine)curve;
                for (int i = 0; i < baseline.points.Count - 1; i++)
                {
                    curveArray.Add(new Line2d(baseline.points[i].ToPoint2d(), baseline.points[i + 1].ToPoint2d()));
                }
            }
            else if (curve.GetType() == typeof(Grevit.Types.Spline))
            {
                Grevit.Types.Spline s = (Grevit.Types.Spline)curve;
                Point2dCollection points = new Point2dCollection();
                foreach (Grevit.Types.Point p in s.controlPoints) points.Add(p.ToPoint2d());
                DoubleCollection dc = new DoubleCollection();
                foreach (double dbl in s.weights) dc.Add(dbl);
                NurbCurve2d sp = new NurbCurve2d(s.degree, new KnotCollection(), points, dc, s.isPeriodic);
                curveArray.Add(sp);
            }

            return curveArray;
        }
        public PollIntervalSlider() 
        {
            this.IsSnapToTickEnabled = true;
            this.Minimum = 15;
            //this.Minimum = 1; //testing
            this.Maximum = 1440;
            this.TickPlacement = TickPlacement.BottomRight;
            this.AutoToolTipPlacement = AutoToolTipPlacement.BottomRight;

            // Manually add ticks to the slider.
            DoubleCollection tickMarks = new DoubleCollection();
            //tickMarks.Add(1); //testing
            //tickMarks.Add(2); //testing
            //tickMarks.Add(5); //testing
            tickMarks.Add(15);
            tickMarks.Add(30);
            tickMarks.Add(60);
            tickMarks.Add(120);
            tickMarks.Add(240);
            tickMarks.Add(480);
            tickMarks.Add(720);
            tickMarks.Add(1440);
            this.Ticks = tickMarks;        
        }
Example #45
0
        /// <summary>
        /// 初始化控件
        /// </summary>
        protected virtual void Init_Control()
        {
            // 图片
            ImageSource = new Image();
            ImageSource.Source = IcoImage;
            ImageSource.Width = ImageWidth;
            ImageSource.Height = ImageHeight;

            // 图片的边框
            ImageBorder = new Border();
            ImageBorder.BorderBrush = new SolidColorBrush(Colors.Black);
            ImageBorder.BorderThickness = new Thickness(0);
            ImageBorder.CornerRadius = new CornerRadius(3);
            ImageBorder.Width = ImageSource.Width;
            ImageBorder.Height = ImageSource.Height;
            ImageBorder.Child = ImageSource;

            // 设备名
            TextDeviceName = new TextBlock();
            TextDeviceName.FontSize = 14;
            TextDeviceName.HorizontalAlignment = HorizontalAlignment.Center;
            TextDeviceName.VerticalAlignment = VerticalAlignment.Center;
            TextDeviceName.TextAlignment = TextAlignment.Center;

            // 设备当前状态
            ImageStatues = new Ellipse();
            ImageStatues.Fill = new SolidColorBrush(Colors.Green);
            ImageStatues.Height = 12;
            ImageStatues.Width = 12;

            // 连接时显示的虚线
            LineVirtual = new Line();
            LineVirtual.Stroke = new SolidColorBrush(Colors.Black);
            LineVirtual.StrokeThickness = 2;
            DoubleCollection dc = new DoubleCollection();
            dc.Add(1);
            dc.Add(1);
            LineVirtual.StrokeDashArray = dc;

            // 设置ZIndex
            ImageBorder.SetValue(Canvas.ZIndexProperty, -64);
            TextDeviceName.SetValue(Canvas.ZIndexProperty, 64);

            this.Children.Add(ImageBorder);
            this.Children.Add(TextDeviceName);
            this.Children.Add(ImageStatues);
            this.Children.Add(LineVirtual);
        }
        /// <summary>
        /// Creates the dash array collection.
        /// </summary>
        /// <param name="dashArray">
        /// The dash array.
        /// </param>
        /// <returns>
        /// The dash collection.
        /// </returns>
        private static DoubleCollection CreateDashArrayCollection(IList<double> dashArray)
        {
            var dac = new DoubleCollection();
            foreach (double v in dashArray)
            {
                dac.Add(v);
            }

            return dac;
        }
Example #47
0
        public void CompendiumMapDepthMap_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _isLeftMouseButtonDown = true;
            _selectionStartPoint = translateTransform.Inverse.Transform(e.GetPosition(caller));
            _selectionStartPoint = scaleTransform.Inverse.Transform(_selectionStartPoint);
            if (_selectionRectangle != null)
            {
                caller.uxMapSurface.Children.Remove(_selectionRectangle);
                _selectionRectangle = null;
            }
            if (e.ClickCount != 2)
            {
                _selectionRectangle = new Rectangle();
                _selectionRectangle.Stroke = new SolidColorBrush(Colors.Black);
                _selectionRectangle.StrokeThickness = 1.0;
                _selectionRectangle.Opacity = 0.7;
                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(2);
                dashArray.Add(4);
                _selectionRectangle.StrokeDashArray = dashArray;
                _selectionRectangle.SetValue(Canvas.LeftProperty, _selectionStartPoint.X);
                _selectionRectangle.SetValue(Canvas.TopProperty, _selectionStartPoint.Y);
                caller.uxMapSurface.Children.Add(_selectionRectangle);
            }

            ViewManager.CommitNodeName();
        }
Example #48
0
        /// <summary>
        /// Reads a double array from the stream.
        /// </summary>
        public DoubleCollection ReadDoubleArray(string fieldName)
        {
            bool isNil = false;

            DoubleCollection values = new DoubleCollection();
                                    
            if (BeginField(fieldName, true, out isNil))
            {                                
                PushNamespace(Namespaces.OpcUaXsd);
                
                while (MoveToElement("Double"))
                {
                    values.Add(ReadDouble("Double"));
                }

                // check the length.
                if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < values.Count)
                {
                    throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded);
                }

                PopNamespace();

                EndField(fieldName);
                return values;
            }

            if (isNil)
            {
                return null;
            }

            return values;
        }
Example #49
0
        //------------------------------------------------------
        //
        //  Protected Methods
        //
        //------------------------------------------------------
 
        #region Protected Methods

        /// <summary>
        /// Render override to render the composition adorner here.
        /// </summary>
        protected override void OnRender(DrawingContext drawingContext)
        {
            // Get the matrix from AdornedElement to the visual parent to get the transformed
            // start/end point
            Visual parent2d = VisualTreeHelper.GetParent(this.AdornedElement) as Visual;
            if (parent2d == null)
            {
                return;
            }

            GeneralTransform transform = AdornedElement.TransformToAncestor(parent2d);
            if (transform == null)
            {
                return;
            }

            // Please note that we do the highlight adornment for the CONVERTED text only 
            // for Simplified Chinese IMEs. Doing this uniformly across all IMEs wasnt possible 
            // because it was noted that some of them (viz. Japanese) werent being consistent 
            // about this attribute.

            bool isChinesePinyin = chinesePinyin.Equals(InputLanguageManager.Current.CurrentInputLanguage.IetfLanguageTag);

            // Render the each of the composition string attribute from the attribute ranges.
            for (int i = 0; i < _attributeRanges.Count; i++)
            {
                DoubleCollection dashArray;

                // Get the composition attribute range from the attribute range lists
                AttributeRange attributeRange = (AttributeRange)_attributeRanges[i];

                // Skip the rendering composition lines if the composition line doesn't exist.
                if (attributeRange.CompositionLines.Count == 0)
                {
                    continue;
                }

                // Set the line bold and squiggle
                bool lineBold = attributeRange.TextServicesDisplayAttribute.IsBoldLine ? true : false;
                bool squiggle = false;
                bool hasVirtualSelection = (attributeRange.TextServicesDisplayAttribute.AttrInfo & UnsafeNativeMethods.TF_DA_ATTR_INFO.TF_ATTR_TARGET_CONVERTED) != 0;

                Brush selectionBrush = null;
                double selectionOpacity = -1;
                Pen selectionPen = null;

                if (isChinesePinyin && hasVirtualSelection)
                {
                    DependencyObject owner = _textView.TextContainer.Parent;
                    selectionBrush = (Brush)owner.GetValue(TextBoxBase.SelectionBrushProperty);
                    selectionOpacity = (double)owner.GetValue(TextBoxBase.SelectionOpacityProperty);
                }

                // Set the line height and cluse gap value that base on the ratio of text height
                double height = attributeRange.Height;
                double lineHeight = height * (lineBold ? BoldLineHeightRatio : NormalLineHeightRatio);
                double clauseGap = height * ClauseGapRatio;

                // Create Pen for drawing the composition lines with the specified line color
                Pen pen = new Pen(new SolidColorBrush(Colors.Black), lineHeight);

                // Set the pen style that based on IME's composition line style
                switch (attributeRange.TextServicesDisplayAttribute.LineStyle)
                {
                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_DOT:
                        // Add the dot length and specify the start/end line cap as the round
                        dashArray = new DoubleCollection();
                        dashArray.Add(DotLength);
                        dashArray.Add(DotLength);

                        pen.DashStyle = new DashStyle(dashArray, 0);
                        pen.DashCap = System.Windows.Media.PenLineCap.Round;
                        pen.StartLineCap = System.Windows.Media.PenLineCap.Round;
                        pen.EndLineCap = System.Windows.Media.PenLineCap.Round;

                        // Update the line height for the dot line. Dot line will be more thickness than
                        // other line to show it clearly.
                        lineHeight = height * (lineBold ? BoldDotLineHeightRatio : NormalDotLineHeightRatio);

                        break;

                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_DASH:
                        double dashLength = height * (lineBold ? BoldDashRatio : NormalDashRatio);
                        double dashGapLength = height * (lineBold ? BoldDashGapRatio : NormalDashGapRatio);

                        // Add the dash and dash gap legth
                        dashArray = new DoubleCollection();
                        dashArray.Add(dashLength);
                        dashArray.Add(dashGapLength);

                        pen.DashStyle = new DashStyle(dashArray, 0);
                        pen.DashCap = System.Windows.Media.PenLineCap.Round;
                        pen.StartLineCap = System.Windows.Media.PenLineCap.Round;
                        pen.EndLineCap = System.Windows.Media.PenLineCap.Round;

                        break;

                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SOLID:
                        pen.StartLineCap = System.Windows.Media.PenLineCap.Round;
                        pen.EndLineCap = System.Windows.Media.PenLineCap.Round;

                        break;

                    case UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_SQUIGGLE:
                        squiggle = true;
                        break;
                }

                double halfLineHeight = lineHeight / 2;

                // Draw the each of the composition line
                for (int j = 0; j < attributeRange.CompositionLines.Count; j++)
                {
                    CompositionLine compositionLine = (CompositionLine)attributeRange.CompositionLines[j];

                    // Get the start/end point for composition adorner.
                    // Currently Text doesn't aware of the spaceroom for the drawing of the composition 
                    // adorner(like as normal/bold dot/line/squggle), so we should draw the composition adorners
                    // to the closest area of the bottom text.
                    Point startPoint = new Point(compositionLine.StartPoint.X + clauseGap, compositionLine.StartPoint.Y - halfLineHeight);
                    Point endPoint = new Point(compositionLine.EndPoint.X - clauseGap, compositionLine.EndPoint.Y - halfLineHeight);
                    
                    // Apply composition line color which is actually the foreground of text as well
                    pen.Brush = new SolidColorBrush(compositionLine.LineColor);

                    // Apply matrix to start/end point
                    // 
                    transform.TryTransform(startPoint, out startPoint);
                    transform.TryTransform(endPoint, out endPoint);

                    if (isChinesePinyin && hasVirtualSelection)
                    {
                        Rect rect = Rect.Union(compositionLine.StartRect, compositionLine.EndRect);
                        rect = transform.TransformBounds(rect);
                        
                        drawingContext.PushOpacity(selectionOpacity);
                    
                        drawingContext.DrawRectangle(selectionBrush, selectionPen, rect);
                    
                        drawingContext.Pop();
                    }
                    
                    if (squiggle)
                    {
                        // Draw the squiggle line with using of the PathFigure and DrawGemetry.
                        // We may revisit this logic to render the smooth squiggle line.
                        Point pathPoint = new Point(startPoint.X, startPoint.Y - halfLineHeight);

                        double squiggleGap = halfLineHeight;

                        PathFigure pathFigure = new PathFigure();
                        pathFigure.StartPoint = pathPoint;

                        int indexPoint = 0;

                        while (indexPoint < ((endPoint.X - startPoint.X) / (squiggleGap)))
                        {
                            if (indexPoint % 4 == 0 || indexPoint % 4 == 3)
                            {
                                pathPoint = new Point(pathPoint.X + squiggleGap, pathPoint.Y + halfLineHeight);
                                pathFigure.Segments.Add(new LineSegment(pathPoint, true));
                            }
                            else if (indexPoint % 4 == 1 || indexPoint % 4 == 2)
                            {
                                pathPoint = new Point(pathPoint.X + squiggleGap, pathPoint.Y - halfLineHeight);
                                pathFigure.Segments.Add(new LineSegment(pathPoint, true));
                            }

                            indexPoint++;
                        }

                        PathGeometry pathGeometry = new PathGeometry();
                        pathGeometry.Figures.Add(pathFigure);

                        // Draw the composition line with the squiggle
                        drawingContext.DrawGeometry(null, pen, pathGeometry);
                    }
                    else
                    {
                        drawingContext.DrawLine(pen, startPoint, endPoint);
                    }
                }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="adornedElement">The adorned InkCanvas</param>
        internal InkCanvasSelectionAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            Debug.Assert(adornedElement is InkCanvasInnerCanvas, 
                "InkCanvasSelectionAdorner only should be used by InkCanvas internally");

            // Initialize the internal data.
            _adornerBorderPen = new Pen(Brushes.Black, 1.0);
            DoubleCollection dashes = new DoubleCollection( );
            dashes.Add(4.5);
            dashes.Add(4.5);
            _adornerBorderPen.DashStyle = new DashStyle(dashes, 2.25);
            _adornerBorderPen.DashCap = PenLineCap.Flat;
            _adornerBorderPen.Freeze();

            _adornerPenBrush = new Pen(new SolidColorBrush(Color.FromRgb(132, 146, 222)), 1);
            _adornerPenBrush.Freeze();

            _adornerFillBrush = new LinearGradientBrush(  Color.FromRgb(240, 242, 255), //start color
                                            Color.FromRgb(180, 207, 248),               //end color
                                            45f                                         //angle
                                            );
            _adornerFillBrush.Freeze();

            // Create a hatch pen
            DrawingGroup hatchDG = new DrawingGroup( );
            DrawingContext dc = null;

            try
            {
                dc = hatchDG.Open( );

                dc.DrawRectangle(
                    Brushes.Transparent,
                    null,
                    new Rect(0.0, 0.0, 1f, 1f));

                Pen squareCapPen = new Pen(Brushes.Black, LineThickness);
                squareCapPen.StartLineCap = PenLineCap.Square;
                squareCapPen.EndLineCap = PenLineCap.Square;

                dc.DrawLine(squareCapPen,
                    new Point(1f, 0f), new Point(0f, 1f));
            }
            finally
            {
                if ( dc != null )
                {
                    dc.Close( );
                }
            }
            hatchDG.Freeze();

            DrawingBrush tileBrush = new DrawingBrush(hatchDG);
            tileBrush.TileMode = TileMode.Tile;
            tileBrush.Viewport = new Rect(0, 0, HatchBorderMargin, HatchBorderMargin);
            tileBrush.ViewportUnits = BrushMappingMode.Absolute;
            tileBrush.Freeze();

            _hatchPen = new Pen(tileBrush, HatchBorderMargin);
            _hatchPen.Freeze();

            _elementsBounds = new List<Rect>();
            _strokesBounds = Rect.Empty;
        }
Example #51
0
 private DoubleCollection SetTickFrq(double octave)
 {
     DoubleCollection ticks = new DoubleCollection();
     double tick = fMin;
     while (tick < fMax)
     {
         ticks.Add(tick);
         tick *= octave;
     }
     return ticks;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        public PollIntervalSlider(TextBlock sliderLabel, int defaultValue = 7)
        {
            this.sliderLabel = sliderLabel;

            this.IsSnapToTickEnabled = true;
            this.Minimum = LogScaleConverter.Convert(1000 * 5);
            this.Maximum = LogScaleConverter.Convert(1000 * 60 * 60 * 24);
            this.TickPlacement = TickPlacement.BottomRight;

            // Add ticks to the slider.
            DoubleCollection tickMarks = new DoubleCollection();
            tickMarks.Add(LogScaleConverter.Convert(1000 * 5)); // 5 seconds.
            tickMarks.Add(LogScaleConverter.Convert(1000 * 15));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 30));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 3)); // 3 minutes.
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 10));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 30));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 3)); // 3 hours.
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 8));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 12));
            tickMarks.Add(LogScaleConverter.Convert(1000 * 60 * 60 * 24));
            this.Ticks = tickMarks;

            // Show current value in UI.
            ShowCurrentValue();
        }
Example #53
0
        public dynConnector(dynNodeUI start, dynNodeUI end, int startIndex, int endIndex, int portType, bool visible)
        {
            //don't try to create a connector with a bad start,
            //end, or if we're trying to connector the same
            //port to itself.
            if (start == null || end == null || start == end)
            {
                throw new Exception("Attempting to create connector with invalid start or end nodes.");
            }

            pStart = start.OutPorts[startIndex];

            dynPort endPort = null;

            if (portType == 0)
                endPort = end.InPorts[endIndex];

            //connect the two ports
            //get start point

            pStart.Connect(this);

            BrushConverter bc = new BrushConverter();
            strokeBrush = (Brush)bc.ConvertFrom("#313131");

            #region bezier creation
            connector = new Path();
            connector.Stroke = strokeBrush;
            connector.StrokeThickness = STROKE_THICKNESS;
            connector.Opacity = STROKE_OPACITY;

            connector.DataContext = this;
            Binding strokeBinding = new Binding("StrokeBrush");
            connector.SetBinding(Path.StrokeProperty, strokeBinding);

            DoubleCollection dashArray = new DoubleCollection();
            dashArray.Add(5); dashArray.Add(2);
            connector.StrokeDashArray = dashArray;

            PathGeometry connectorGeometry = new PathGeometry();
            connectorPoints = new PathFigure();
            connectorCurve = new BezierSegment();

            connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            connectorCurve.Point1 = connectorPoints.StartPoint;
            connectorCurve.Point2 = connectorPoints.StartPoint;
            connectorCurve.Point3 = connectorPoints.StartPoint;

            connectorPoints.Segments.Add(connectorCurve);
            connectorGeometry.Figures.Add(connectorPoints);
            connector.Data = connectorGeometry;
            dynSettings.Workbench.Children.Add(connector);
            #endregion

            #region polyline creation
            plineConnector = new Path();
            plineConnector.Stroke = strokeBrush;
            plineConnector.StrokeThickness = STROKE_THICKNESS;
            plineConnector.Opacity = STROKE_OPACITY;
            plineConnector.StrokeDashArray = dashArray;

            PathGeometry plineGeometry = new PathGeometry();
            //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
            plineFigure = new PathFigure();
            plineFigure.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
            pline = new PolyLineSegment(polyLinePointArray, true);
            pline.Points = new PointCollection(polyLinePointArray);
            plineFigure.Segments.Add(pline);
            plineGeometry.Figures.Add(plineFigure);
            plineConnector.Data = plineGeometry;
            dynSettings.Workbench.Children.Add(plineConnector);
            #endregion

            endDot = new Ellipse();
            endDot.Height = 6;
            endDot.Width = 6;
            endDot.Fill = Brushes.Black;
            endDot.StrokeThickness = 2;
            endDot.Stroke = Brushes.Black;
            endDot.IsHitTestVisible = false;
            endDot.MouseDown +=new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);
            Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE / 2);
            Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE / 2);
            dynSettings.Workbench.Children.Add(endDot);
            endDot.Opacity = STROKE_OPACITY;
            endDot.IsHitTestVisible = false;
            endDot.MouseDown += new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);

            this.Visible = visible;

            connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            connector.MouseLeave += delegate { Unhighlight(); };
            plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            plineConnector.MouseLeave += delegate { Unhighlight(); };

            isDrawing = true;

            //set this to not draggable
            Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
            Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

            //set the z order to the front
            //Canvas.SetZIndex(this, 300);
            Canvas.SetZIndex(this, 1);

            this.Connect(endPort);

            ConnectorType = dynSettings.Bench.ConnectorType;
        }
Example #54
0
        private void _MouseDownEvent(Object sender, MouseButtonEventArgs e)
        {
            try
            {
                Canvas _plotarea = (Canvas)sender;
                Canvas _graph = (Canvas)_plotarea.Parent;
                plotData _plotData = getPlotData((string)_graph.Tag);

                posDown = e.GetPosition(_plotarea);
                if (e.ClickCount == 1)
                {
                    if (e.LeftButton == MouseButtonState.Pressed)
                    {
                        mouseDown = true;
                        _plotData.scaleArea = new Rectangle();
                        _plotData.scaleArea.Stroke = getBrush(linesColour);
                        DoubleCollection style = new DoubleCollection();
                        style.Add(2);
                        style.Add(2);
                        _plotData.scaleArea.StrokeDashArray = style;
                        _plotData.scaleArea.StrokeThickness = 1.0;
                        _plotarea.Children.Add(_plotData.scaleArea);
                    }
                    else if (e.RightButton == MouseButtonState.Pressed)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
        }
Example #55
0
 /// <summary>
 /// Set shape Pen style (dash, dot etc).
 /// </summary>
 /// <param name="shapeName">
 /// The shape name.
 /// </param>
 /// <param name="dash">
 /// The dash length.
 /// </param>
 /// <param name="space">
 /// The space length.
 /// </param>
 /// <returns>
 /// None.
 /// </returns>
 public static void PenStyle(Primitive shapeName, Primitive dash, Primitive space)
 {
     try
     {
         if (_objectsMap.TryGetValue((string)shapeName, out obj))
         {
             InvokeHelper ret = new InvokeHelper(delegate
             {
                 try
                 {
                     if (obj.GetType() == typeof(Ellipse))
                     {
                         Ellipse shape = (Ellipse)obj;
                         DoubleCollection style = new DoubleCollection();
                         style.Add(dash);
                         style.Add(space);
                         shape.StrokeDashArray = style;
                     }
                     else if (obj.GetType() == typeof(Rectangle))
                     {
                         Rectangle shape = (Rectangle)obj;
                         DoubleCollection style = new DoubleCollection();
                         style.Add(dash);
                         style.Add(space);
                         shape.StrokeDashArray = style;
                     }
                     else if (obj.GetType() == typeof(Polygon))
                     {
                         Polygon shape = (Polygon)obj;
                         DoubleCollection style = new DoubleCollection();
                         style.Add(dash);
                         style.Add(space);
                         shape.StrokeDashArray = style;
                     }
                     else if (obj.GetType() == typeof(Line))
                     {
                         Line shape = (Line)obj;
                         DoubleCollection style = new DoubleCollection();
                         style.Add(dash);
                         style.Add(space);
                         shape.StrokeDashArray = style;
                     }
                 }
                 catch (Exception ex)
                 {
                     Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                 }
             });
             FastThread.Invoke(ret);
         }
         else
         {
             Utilities.OnShapeError(Utilities.GetCurrentMethod(), shapeName);
         }
     }
     catch (Exception ex)
     {
         Utilities.OnError(Utilities.GetCurrentMethod(), ex);
     }
 }
Example #56
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                BrushConverter bc = new BrushConverter();
                strokeBrush = (Brush)bc.ConvertFrom("#313131");

                #region bezier creation
                connector = new Path();
                connector.Stroke = strokeBrush;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity = STROKE_OPACITY;

                connector.DataContext = this;
                Binding strokeBinding = new Binding("StrokeBrush");
                connector.SetBinding(Path.StrokeProperty, strokeBinding);

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1 = connectorPoints.StartPoint;
                connectorCurve.Point2 = connectorPoints.StartPoint;
                connectorCurve.Point3 = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);
                #endregion

                #region polyline creation
                plineConnector = new Path();
                plineConnector.Stroke = strokeBrush;
                plineConnector.StrokeThickness = STROKE_THICKNESS;
                plineConnector.Opacity = STROKE_OPACITY;
                plineConnector.StrokeDashArray = dashArray;

                PathGeometry plineGeometry = new PathGeometry();
                //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
                plineFigure = new PathFigure();
                plineFigure.StartPoint = connectorPoints.StartPoint;
                Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
                pline = new PolyLineSegment(polyLinePointArray, true);
                pline.Points = new PointCollection(polyLinePointArray);
                plineFigure.Segments.Add(pline);
                plineGeometry.Figures.Add(plineFigure);
                plineConnector.Data = plineGeometry;
                dynSettings.Workbench.Children.Add(plineConnector);
                #endregion

                endDot = new Ellipse();
                endDot.Height = 6;
                endDot.Width = 6;
                endDot.Fill = Brushes.Black;
                endDot.StrokeThickness = 2;
                endDot.Stroke = Brushes.Black;
                endDot.IsHitTestVisible = false;
                endDot.MouseDown += new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);
                Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE / 2);
                Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE / 2);
                dynSettings.Workbench.Children.Add(endDot);
                endDot.Opacity = STROKE_OPACITY;

                connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
                connector.MouseLeave += delegate { Unhighlight(); };
                plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
                plineConnector.MouseLeave += delegate { Unhighlight(); };

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(connector, 0);
                Canvas.SetZIndex(endDot, 1);

                ConnectorType = dynSettings.Bench.ConnectorType;

            }
            else
            {
                throw new InvalidPortException();
            }
        }
Example #57
0
        private void initSliderTicks(bool useCache)
        {
            List<int> lengths = data.possibleLengths(useCache);
            DoubleCollection tickMarks = new DoubleCollection();

            foreach (int length in lengths)
            {
                double percent = ((double)length) / data.longestLength;
                tickMarks.Add(percent * 100);
            }
            lengthSlider.Ticks = tickMarks;

            lengthSlider.SelectionStart = tickMarks[0];
        }
        public void FirstCreate()
        {
            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 var view = ApplicationView.GetForCurrentView();
                 ApplicationViewTitleBar titleBar = view.TitleBar;
                 if (titleBar != null)
                 {
                     titleBar.BackgroundColor = Color.FromArgb(255, 0, 116, 206);
                     titleBar.ButtonBackgroundColor = Color.FromArgb(255, 0, 116, 206);
                 }
                 CreateRing.Visibility = Visibility.Visible;
                 var cole = new DoubleCollection();
                 cole.Add(0);
                 cole.Add(1470);
                 ProgressRoll.StrokeDashArray = cole;
                 CreateProgressText.Text = string.Format("{0}%", 0);
             });

        }
        internal void UpdateProgress(double v, double count)
        {
            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                var cole = new DoubleCollection();
                var progress = v + count;
                CreateProgressText.Text = string.Format("{0}%", (progress * 100).ToString("0"));
                progress *= 161.7924;
                cole.Add(progress);
                cole.Add(1470);
                ProgressRoll.StrokeDashArray = cole;

            });
        }
        public DifficultyMVVM(string uid, string name, double minValue, double avgValue, double maxValue)
        {
            Name = name;
            UID = uid;
            MinValue = Math.Min(maxValue, minValue);
            MaxValue = Math.Max(minValue, maxValue);
            SelectedValue = avgValue;
            Ticks = new DoubleCollection();

            double stepValue = (avgValue - Math.Min(maxValue, minValue)) / 3;

            for (double tick = Math.Min(maxValue, minValue); tick < avgValue; tick += stepValue)
            {
                Ticks.Add(tick);
            }

            stepValue = (Math.Max(maxValue, minValue) - avgValue) / 3;

            for (double tick = avgValue; tick <= Math.Max(maxValue, minValue); tick += stepValue)
            {
                Ticks.Add(tick);
            }

            Reversed = minValue > maxValue;
        }