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(); } }
/// <summary> /// Constructor. /// </summary> public PollIntervalSlider() { this.IsSnapToTickEnabled = true; this.Minimum = 5; this.Maximum = 60 * 60 * 24; this.TickPlacement = TickPlacement.BottomRight; this.AutoToolTipPlacement = AutoToolTipPlacement.BottomRight; // Add ticks to the slider. DoubleCollection tickMarks = new DoubleCollection(); tickMarks.Add(5); // 5 seconds tickMarks.Add(60); tickMarks.Add(60 * 2); // 2 minutes tickMarks.Add(60 * 3); tickMarks.Add(60 * 5); tickMarks.Add(60 * 10); tickMarks.Add(60 * 15); tickMarks.Add(60 * 30); tickMarks.Add(60 * 60); tickMarks.Add(60 * 60 * 2); // 2 hours tickMarks.Add(60 * 60 * 4); tickMarks.Add(60 * 60 * 8); tickMarks.Add(60 * 60 * 12); tickMarks.Add(60 * 60 * 24); this.Ticks = tickMarks; }
/// <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(); }
/// <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 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> /// Constructor from an array and offset /// <param name="dashes"> /// The array of lengths of dashes and gaps, measured in Thickness units. /// If the value of dashes is null then the style will be solid /// </param> /// <param name="offset"> /// Determines where in the dash sequence the stroke will start /// </param> /// </summary> public DashStyle(IEnumerable<double> dashes, Double offset) { Offset = offset; if (dashes != null) { Dashes = new DoubleCollection(dashes); } }
public OverlayedSlider(string overlayText, DoubleCollection ticks) { InitializeComponent(); tbOverlay.Text = overlayText; slValue.Minimum = ticks.First(); slValue.Maximum = ticks.Last(); slValue.Ticks = ticks; }
public SingleBand(float value, float maxValue, float minValue, DoubleCollection ticks, string label) { MaxValue = maxValue; MinValue = minValue; TickFrequency = 0; Ticks = ticks; Value = value; Label = label; }
public Pen() { Thickness = 1; DashArray = new DoubleCollection(); StartLineCap = PenLineCap.Flat; EndLineCap = PenLineCap.Flat; DashCap = PenLineCap.Flat; LineJoin = PenLineJoin.Miter; // TODO: check default values MiterLimit = 10; // TODO: check default values }
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(); } }
public static Hatch CreateHatch(this List<Point2d> pts) { pts = pts.DistinctPoints(); var ptCol = new Point2dCollection(pts.ToArray()); ptCol.Add(pts[0]); var dCol = new DoubleCollection(new double[pts.Count]); var h = new Hatch(); h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); h.AppendLoop(HatchLoopTypes.Default, ptCol, dCol); h.EvaluateHatch(false); return h; }
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; }
/// <summary> /// Constructs a new GuidelineSet object. /// </summary> /// <param name="guidelinesX">Array of X coordinates that defines a set of vertical guidelines.</param> /// <param name="guidelinesY">Array of Y coordinates that defines a set of horizontal guidelines.</param> public GuidelineSet(double[] guidelinesX, double[] guidelinesY) { if (guidelinesX != null) { GuidelinesX = new DoubleCollection(guidelinesX); } if (guidelinesY != null) { GuidelinesY = new DoubleCollection(guidelinesY); } }
private void AddLine(Brush brush, double x1, double y1, double x2, double y2, double strokeThickness = 2, DoubleCollection doubleCollection = null) { LayoutRoot.Children.Add(new Line { X1 = x1, X2 = x2, Y1 = y1, Y2 = y2, Stroke = brush, StrokeThickness = strokeThickness, StrokeDashArray = doubleCollection }); }
internal static void DrawRectangle(PdfRenderContext context, Brush fill, Brush stroke, double strokeThickness, double actualWidth, double actualHeight, DoubleCollection dashArray) { using (context.drawingSurface.SaveGraphicProperties()) { SetFill(context, fill, actualWidth, actualHeight); SetStroke(context, strokeThickness, stroke, actualWidth, actualHeight, dashArray); if (context.drawingSurface.GraphicProperties.IsFilled || context.drawingSurface.GraphicProperties.IsStroked) { // account for the difference in the notion of stroke in wpf's Rectangle/Border and pdf's Rectangle double thickness = context.drawingSurface.GraphicProperties.IsStroked ? strokeThickness : 0; context.drawingSurface.DrawRectangle(new Rect(thickness / 2, thickness / 2, actualWidth - thickness, actualHeight - thickness)); } } }
internal static void SetStroke(PdfRenderContext context, double thickness, Brush brush, double width, double height, DoubleCollection dashArray) { var stroke = PdfColorHelper.ConvertBrush(brush, context.opacity, context.drawingSurface.Position, width, height); context.drawingSurface.GraphicProperties.IsStroked = thickness != 0 && stroke != null; if (context.drawingSurface.GraphicProperties.IsStroked) { context.drawingSurface.GraphicProperties.StrokeThickness = thickness; context.drawingSurface.GraphicProperties.StrokeColor = stroke; if (dashArray != null) { context.drawingSurface.GraphicProperties.StrokeDashArray = dashArray; } } }
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 }
/// <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; }
private void DrawLine(double x1, double y1, double x2, double y2, bool dotted) { var line = new Line { X1 = x1, Y1 = y1, X2 = x2, Y2 = y2, Stroke = Brushes.Red, StrokeThickness = 1.0 }; if (dotted) { var collection = new DoubleCollection {3, 3}; line.StrokeDashArray = collection; } _screen.Children.Add(line); }
/// <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; }
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 ); }
/// <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; }
/// <summary> /// Apply Opacity animation to an object /// </summary> /// <param name="objectToAnimate">Object to animate</param> /// <param name="parentObj">Storyboard parent Object</param> /// <param name="storyboard">Storyboard reference</param> /// <param name="beginTime">Begin time</param> /// <param name="duration">Animation duration</param> /// <param name="targetValue">Target opacity value</param> /// <returns>Storyboard</returns> internal static Storyboard ApplyPointAnimation(DependencyObject objectToAnimate, String property, FrameworkElement parentObj, Storyboard storyboard, Double beginTime, Double[] timeCollection, Point[] valueCollection, List <KeySpline> splain, Double speedRatio) { if (objectToAnimate != null && parentObj != null) { PointCollection values = Graphics.GeneratePointCollection(valueCollection); DoubleCollection frameTimes = Graphics.GenerateDoubleCollection(timeCollection); PointAnimationUsingKeyFrames animation = AnimationHelper.CreatePointAnimation(parentObj, objectToAnimate, property, beginTime, frameTimes, values, splain); if (!Double.IsNaN(speedRatio)) { animation.SpeedRatio = speedRatio; } storyboard.Children.Add(animation); } return(storyboard); }
public void UpdateVisuals() { if (this.dashArray == null) { this.dashArray = new DoubleCollection() { 4, 2 }; } int arrangedVisuals = this.ArrangeLines(true); // hide not used lines while (arrangedVisuals < this.ContainerVisualLines.Count) { this.ContainerVisualLines[arrangedVisuals].IsVisible = false; arrangedVisuals++; } }
public static void AddHorizontalLine(decimal price, DateTime start, DateTime end, IDataSeries dataSeries, AnnotationCollection annotations, Trade trade, Color colour, bool extendLeftAndRight = false, bool extendRightIfZeroLength = false, DoubleCollection strokeDashArray = null) { var dateStartIndex = dataSeries.FindIndex(start, SearchMode.RoundDown); var dateEndIndex = dataSeries.FindIndex(end, SearchMode.RoundUp); if (extendLeftAndRight) { dateStartIndex -= 4; } if (dateStartIndex < 0) { dateStartIndex = 0; } if (extendLeftAndRight) { dateEndIndex += 4; } if (extendRightIfZeroLength && dateStartIndex == dateEndIndex) { dateEndIndex++; } var lineAnnotation = new LineAnnotation { DataContext = trade, X1 = dateStartIndex, Y1 = price, X2 = dateEndIndex, Y2 = price, StrokeThickness = 3, Opacity = 0.8, Stroke = new SolidColorBrush(colour) }; if (strokeDashArray != null) { lineAnnotation.StrokeDashArray = strokeDashArray; } annotations.Add(lineAnnotation); }
public override object ConvertFromInvariantString(string value) { string[] doubles = value.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); var doubleCollection = new DoubleCollection(); foreach (string d in doubles) { if (double.TryParse(d, NumberStyles.Number, CultureInfo.InvariantCulture, out double number)) { doubleCollection.Add(number); } else { throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", d, typeof(double))); } } return(doubleCollection); }
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); }
private Rectangle getNewRectangle(Point pointOne, Point pointTwo, Color color) { Rectangle rectan = new Rectangle(); rectan.Stroke = new SolidColorBrush(getAllColor()); rectan.Height = 0; rectan.Width = 0; rectan.Margin = new Thickness(pointOne.X, pointOne.Y - 25, pointTwo.X, pointTwo.Y - 25); rectan.StrokeThickness = getStroke(); if (dash) { DoubleCollection dashes = new DoubleCollection(); dashes.Add(2); dashes.Add(2); rectan.StrokeDashArray = dashes; } return(rectan); }
//StrokeDashArray applied only for the first line element when it is applied through style. //It is bug in the framework. //And hence manually setting stroke dash array for each and every line. public static void SetStrokeDashArray(UIElementsRecycler <Line> lineRecycler) { if (lineRecycler.Count > 0) { DoubleCollection collection = lineRecycler[0].StrokeDashArray; if (collection != null && collection.Count > 0) { foreach (Line line in lineRecycler) { DoubleCollection doubleCollection = new DoubleCollection(); foreach (double value in collection) { doubleCollection.Add(value); } line.StrokeDashArray = doubleCollection; } } } }
private void CreteRectangle() { currentRect = new Rectangle(); currentRect.Stroke = new SolidColorBrush(Colors.DarkGreen); currentRect.StrokeThickness = 2; currentRect.Opacity = 0.7; DoubleCollection dashSize = new DoubleCollection(); dashSize.Add(1); dashSize.Add(1); currentRect.StrokeDashArray = dashSize; currentRect.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; currentRect.VerticalAlignment = System.Windows.VerticalAlignment.Top; drawcanvas.Children.Add(currentRect); Rectlist.Add(currentRect); }
//--------------------------------------------------------------------------- /** * @fn void InitUI(object sender, EventArgs e) * @brief Align Control의 UI 초기화. * @return void * @param object sender * @param EventArgs e * @remark * - * @author 선경규(Kyeong Kyu - Seon) * @date 2020/3/9 16:36 */ void InitUI(object sender, EventArgs e) { ComponentDispatcher.ThreadIdle -= InitUI; m_manualRect.Fill = new SolidColorBrush(Color.FromArgb(55, 255, 0, 0)); m_manualRect.StrokeThickness = 3; m_manualRect.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)); DoubleCollection dc1 = new DoubleCollection(); dc1.Add(3 / m_dScale); dc1.Add(3 / m_dScale); m_manualRect.StrokeDashArray = dc1; m_manualRect.Visibility = Visibility.Visible; lib_Canvas.Children.Add(m_manualRect); lib_Canvas.Children.Add(line_X); lib_Canvas.Children.Add(line_Y); lib_Canvas.Children.Add(tb_Count); }
public static DBObject Create(this Grevit.Types.Spline s, Transaction tr) { LayerTable lt = (LayerTable)tr.GetObject(Command.Database.LayerTableId, OpenMode.ForRead); try { Point3dCollection points = new Point3dCollection(); foreach (Grevit.Types.Point p in s.controlPoints) { points.Add(p.ToPoint3d()); } DoubleCollection dc = new DoubleCollection(); foreach (double dbl in s.weights) { dc.Add(dbl); } DoubleCollection dcc = new DoubleCollection(); foreach (double dbl in s.knots) { dcc.Add(dbl); } Spline sp = new Spline(s.degree, s.isRational, s.isClosed, s.isPeriodic, points, dcc, dc, 0, 0); sp.SetDatabaseDefaults(Command.Database); BlockTable bt = (BlockTable)tr.GetObject(Command.Database.BlockTableId, OpenMode.ForRead); BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); if (lt.Has(s.TypeOrLayer)) { sp.LayerId = lt[s.TypeOrLayer]; } ms.AppendEntity(sp); tr.AddNewlyCreatedDBObject(sp, true); ms.Dispose(); return(sp); } catch (Autodesk.AutoCAD.Runtime.Exception e) { } return(null); }
void TransferFromStyle(Path path, Style style) { var sdap = style.Find(Shape.StrokeDashArrayProperty, default(DoubleCollection)); if (sdap != null && sdap != path.StrokeDashArray) { var ndc = new DoubleCollection(); //path.StrokeDashArray.Clear(); foreach (var dx in sdap) { ndc.Add(dx); } path.SetValue(Shape.StrokeDashArrayProperty, ndc); } else { //path.ClearValue(Shape.StrokeDashArrayProperty); } }
public TestCase( TickBarPlacement placement, bool isDirectionReversed, double value, double tickWidth, double strokeThickness, double tickFrequency, DoubleCollection ticks, Thickness padding) { this.Placement = placement; this.IsDirectionReversed = isDirectionReversed; this.Value = value; this.TickWidth = tickWidth; this.StrokeThickness = strokeThickness; this.TickFrequency = tickFrequency; this.Ticks = ticks; this.Padding = padding; }
protected override void SetVisualBindings(Shape element) { base.SetVisualBindings(element); var polarSeries = Series as PolarRadarSeriesBase; if (polarSeries != null) { DoubleCollection seriesStrokeDashArray = polarSeries.StrokeDashArray; DoubleCollection seriesArrayCollection = new DoubleCollection(); if (seriesStrokeDashArray != null && seriesStrokeDashArray.Count > 0) { foreach (double value in seriesStrokeDashArray) { seriesArrayCollection.Add(value); } element.StrokeDashArray = seriesArrayCollection; } } }
private static void OnProgressNumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { CircularProgressBar cpb = d as CircularProgressBar; //两位小数cpb.ProgressNumText = (cpb.ProgressNum * 100).ToString("0.00") + "%"; cpb.ProgressNumText = (cpb.ProgressNum * 100).ToString("0") + "%"; //圆形直径 double diameter = cpb.Width - cpb.RingWidth; //环形长度 double cirLength = diameter * 3.14 * cpb.ProgressNum / cpb.RingWidth; DoubleCollection dc = new DoubleCollection(); dc.Add(cirLength); //填充间隔长度 远大于周长 dc.Add(cpb.Width * 3.14 * 3); cpb.RingLength = dc; }
public SelectionRegion(Canvas canvas) { DoubleCollection dashes = new DoubleCollection(); dashes.Add(10); dashes.Add(10); _line1 = new Line() { Stroke = System.Windows.Media.Brushes.Black, StrokeDashArray = dashes, StrokeDashCap = PenLineCap.Round }; _line2 = new Line() { Stroke = System.Windows.Media.Brushes.Black, StrokeDashArray = dashes, StrokeDashCap = PenLineCap.Round }; _line3 = new Line() { Stroke = System.Windows.Media.Brushes.Black, StrokeDashArray = dashes, StrokeDashCap = PenLineCap.Round }; _line4 = new Line() { Stroke = System.Windows.Media.Brushes.Black, StrokeDashArray = dashes, StrokeDashCap = PenLineCap.Round }; Reset(); canvas.Children.Add(_line1); canvas.Children.Add(_line2); canvas.Children.Add(_line3); canvas.Children.Add(_line4); }
/// <summary> /// Apply Opacity animation to an object /// </summary> /// <param name="objectToAnimate">Object to animate</param> /// <param name="parentObj">Storyboard parent Object</param> /// <param name="storyboard">Storyboard reference</param> /// <param name="beginTime">Begin time</param> /// <param name="duration">Animation duration</param> /// <param name="targetValue">Target opacity value</param> /// <returns>Storyboard</returns> internal static Storyboard ApplyOpacityAnimation(FrameworkElement objectToAnimate, FrameworkElement parentObj, Storyboard storyboard, Double beginTime, Double duration, Double fromValue, Double targetValue) { if (objectToAnimate != null && parentObj != null) { DoubleCollection values = Graphics.GenerateDoubleCollection(fromValue, targetValue); DoubleCollection frameTimes = Graphics.GenerateDoubleCollection(0, duration); List <KeySpline> splines = GenerateKeySplineList ( new Point(0, 0), new Point(1, 1), new Point(0, 0), new Point(0.5, 1) ); objectToAnimate.Opacity = fromValue; DoubleAnimationUsingKeyFrames opacityAnimation = AnimationHelper.CreateDoubleAnimation(parentObj, objectToAnimate, "(UIElement.Opacity)", beginTime + 0.5, frameTimes, values, splines); storyboard.Children.Add(opacityAnimation); } return(storyboard); }
public static void StringToDashArray(string str, DoubleCollection array) { var nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; array.Clear(); str = str.Trim(); if (!String.IsNullOrEmpty(str)) { var split = str.Split(',', ' '); foreach (var s in split) { double dbl; if (Double.TryParse(s.Trim(), NumberStyles.Any, nfi, out dbl)) { array.Add(dbl); } } } }
private Line CreateCanvasLine() { Line = new Line(); Line.X1 = 0; Line.Y1 = 0; Line.X2 = 0; Line.Y2 = 0; Line.StrokeThickness = 1; DoubleCollection dashes = new DoubleCollection(); dashes.Add(2); dashes.Add(2); Line.StrokeDashArray = dashes; SolidColorBrush redBrush = new SolidColorBrush(); redBrush.Color = Colors.Transparent; Line.Stroke = redBrush; return(Line); }
public static DoubleCollection Parse(string source) { var db = new DoubleCollection(); if (source != null) { IFormatProvider formatProvider = CultureInfo.InvariantCulture; char[] separator = new char[2] { TokenizerHelper.GetNumericListSeparator(formatProvider), ' ' }; string[] split = source.Split(separator, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < split.Length; i++) { db.Add(Convert.ToDouble(split[i], formatProvider)); } } return(db); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Visibility visibility = Visibility.Collapsed; try { DoubleCollection dashArray = (DoubleCollection)System.Convert.ChangeType( value, typeof(DoubleCollection), culture); visibility = (dashArray != null && dashArray.Count == 1 && dashArray[0] == 0) ? Visibility.Collapsed : Visibility.Visible; } catch { } return(visibility); }
public static Hatch?CreateHatch([CanBeNull] this List <PolylineVertex> pts) { if (pts?.Any() != true) { return(null); } if (!pts[0].Pt.IsEqualTo(pts[pts.Count - 1].Pt)) { pts.Add(pts[0]); } var ptCol = new Point2dCollection(pts.Select(s => s.Pt).ToArray()); var dCol = new DoubleCollection(pts.Select(s => s.Bulge).ToArray()); var h = new Hatch(); h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID"); h.AppendLoop(HatchLoopTypes.Default, ptCol, dCol); h.EvaluateHatch(false); return(h); }
public override void OnApplied(IFigure figure, FrameworkElement element) { var line = element as Line; if (StrokeDashArray.IsEmpty()) { if (line != null) { line.StrokeDashArray = null; } return; } if (line != null) { var collection = new DoubleCollection(); collection.AddRange(this.StrokeDashArray); line.StrokeDashArray = collection; } }
public static Line SetLine(Brush brush, Point p1, Point p2, bool isDashed, Canvas canvas) { Line line = new Line(); line.X1 = p1.X; line.Y1 = p1.Y; line.X2 = p2.X; line.Y2 = p2.Y; line.StrokeThickness = OptionDrawLine.strokeThickness; if (isDashed) { DoubleCollection dashes = new DoubleCollection(); dashes.Add(3); dashes.Add(3); line.StrokeDashArray = dashes; } line.Stroke = brush; canvas.Children.Add(line); return(line); }
public Line(Circle start, Circle end, Brush stroke, Brush labelColor, double opacity, double thickness = 1, double strokeDashLength = 0) { _line = new System.Windows.Shapes.Line(); Canvas.SetZIndex(_line, int.MinValue); _label = new LineLabel(labelColor); Start = start; End = end; Stroke = stroke; LabelColor = labelColor; Opacity = opacity; Thickness = thickness; if (strokeDashLength > 0) { StrokeDash = new DoubleCollection() { strokeDashLength } } ; }
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); }
private void refreshGridStyle() { _penWidth = GridStyle == GridLineType.Ruler ? 1.0 : 0.8; _dashes = new DoubleCollection(2); switch (GridStyle) { case GridLineType.Dot: _dashes.Add(3); _dashes.Add(10); break; case GridLineType.Solid: default: break; } RefreshPositionsAndDraw(); drawElements(); }
internal static object INTERNAL_ConvertFromString(string doubleCollectionAsString) { char separator = ' '; if (doubleCollectionAsString.Trim().Contains(",")) { separator = ','; } string[] split = doubleCollectionAsString.Split(separator); DoubleCollection doubleCollection = new DoubleCollection(); foreach (string element in split) { if (!string.IsNullOrWhiteSpace(element)) { doubleCollection.Add(double.Parse(element)); } } return(doubleCollection); }
public Figures CreateLine(double X1, double X2, double Y1, double Y2, string letter, Thickness margin, DoubleCollection strokeDashArray, Brush brush, string name, int id) { Figures figure = new Figures { PointX1 = X1, PointX2 = X2, PointY1 = Y1, PointY2 = Y2, Letter = letter, LetterPosition = margin, StrokeDashArray = strokeDashArray, Color = brush, Name = name, Id = id }; return figure; }
public DDPenGuideLine() { Stroke = Brushes.Black; StrokeThickness = 2; StrokeDashArray = new DoubleCollection { 2, 2 }; StrokeEndLineCap = PenLineCap.Round; StoredGeometry = new LineGeometry(); BindingOperations.SetBinding(StoredGeometry, LineGeometry.StartPointProperty, new Binding("StartPoint") { Source = this }); BindingOperations.SetBinding(StoredGeometry, LineGeometry.EndPointProperty, new Binding("EndPoint") { Source = this }); }
public TestCase( bool isDirectionReversed, double thickness, double value, TickShape tickShape, double tickGap, double strokeThickness, double tickFrequency, DoubleCollection ticks, Thickness padding) { this.IsDirectionReversed = isDirectionReversed; this.Thickness = thickness; this.Value = value; this.TickShape = tickShape; this.TickGap = tickGap; this.StrokeThickness = strokeThickness; this.TickFrequency = tickFrequency; this.Ticks = ticks; this.Padding = padding; }
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; }
/// <summary> /// Constructs a new GuidelineSet object. /// This constructor is internal for now, till we'll find a solution /// for multi-path dynamic guideline implementation. If/when it'll happen, /// it should become "public" so that the next constructor (without "isDynamic' /// argument) may go away. /// </summary> /// <param name="guidelinesX">Array of X coordinates that defines a set of vertical guidelines.</param> /// <param name="guidelinesY">Array of Y coordinates that defines a set of horizontal guidelines.</param> /// <param name="isDynamic">Usage flag: when true then rendering machine will detect animation state and apply subpixel animation behavior.</param> internal GuidelineSet(double[] guidelinesX, double[] guidelinesY, bool isDynamic) { if (guidelinesX != null) { // Dynamic guideline is defined by a pair of numbers: (coordinate, shift), // so the legnth of array should be even. Debug.Assert(!isDynamic || guidelinesX.Length % 2 == 0); GuidelinesX = new DoubleCollection(guidelinesX); } if (guidelinesY != null) { // Dynamic guideline is defined by a pair of numbers: (coordinate, shift), // so the legnth of array should be even. Debug.Assert(!isDynamic || guidelinesY.Length % 2 == 0); GuidelinesY = new DoubleCollection(guidelinesY); } IsDynamic = isDynamic; }
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; }
/// <summary> /// Constructor. /// </summary> public PollIntervalSlider() { this.IsSnapToTickEnabled = true; this.Minimum = LogScaleConverter.Convert(1000 * 5); this.Maximum = LogScaleConverter.Convert(1000 * 60 * 60 * 24); this.TickPlacement = TickPlacement.BottomRight; this.AutoToolTipPlacement = AutoToolTipPlacement.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; }
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; }
internal static void DrawLine(PdfRenderContext context, double x1, double y1, double x2, double y2, double strokeThickness, Brush stroke, DoubleCollection dashArray) { using (context.drawingSurface.SaveGraphicProperties()) { if (x1 == x2 && System.Math.Abs(y1 - y2) > 10) { if (y2 < y1) { double max = y1; y1 = y2; y2 = max; } // offset the start position of the line to resolve a visual bug in Adobe Reader, where the axis line seems to continue after the last tick y1 += 0.5; } SetStroke(context, strokeThickness, stroke, Math.Abs(x2 - x1), Math.Abs(y2 - y1)); if (context.drawingSurface.GraphicProperties.IsStroked) { context.drawingSurface.GraphicProperties.StrokeDashArray = dashArray; context.drawingSurface.DrawLine(new Point(x1, y1), new Point(x2, y2)); } } }
public void SetAnimDash(PointCollection pc, ShapeLayer layer) { MapPolyline animDashLine = new MapPolyline() { MapStrokeThickness = 20, Points = pc, ScaleFactor = 0.2 }; animDashLine.Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128, 255, 255, 255)); animDashLine.StrokeLineJoin = PenLineJoin.Round; animDashLine.StrokeStartLineCap = PenLineCap.Flat; animDashLine.StrokeEndLineCap = PenLineCap.Triangle; animDashLine.StrokeDashCap = PenLineCap.Triangle; var dc = new DoubleCollection { 2, 2 }; animDashLine.IsHitTestVisible = false; animDashLine.StrokeDashArray = dc; DoubleAnimation animation = new DoubleAnimation { From = 4, To = 0, FillBehavior = System.Windows.Media.Animation.FillBehavior.HoldEnd, RepeatBehavior = RepeatBehavior.Forever }; var strokeStoryboard = new Storyboard(); strokeStoryboard.Children.Add(animation); Storyboard.SetTargetProperty(animation, new PropertyPath("(Line.StrokeDashOffset)")); Storyboard.SetTarget(animation, animDashLine); strokeStoryboard.Begin(); layer.Shapes.Add(animDashLine); }