/// <summary> /// Constructs a new Network Properties page /// </summary> public PenPropertiesPage(PenStateModel psm, DrawingAttributes atts, bool isPen) { this.DrawingAttributes = atts; this.psm = psm; this.isPen = isPen; this.SuspendLayout(); this.Name = "PenPropertiesPage"; this.ClientSize = new Size(510, 238); this.FormBorderStyle = FormBorderStyle.FixedDialog; this.Font = ViewerStateModel.FormFont; this.Text = Strings.Pen; // Add the controls this.Controls.Add(new PenTypeGroupBox(this, new Point(5, 8), new Size(174, 64), 0)); this.Controls.Add(new PenShapeGroupBox(this, new Point(5, 72), new Size(174, 64), 1)); this.Controls.Add(new PenColorGroupBox(this, new Point(5, 136), new Size(174, 48), 2)); this.Controls.Add(new TipPropertiesGroupBox(this, new Point(184, 8), new Size(160, 176), 3)); this.Controls.Add(new ScribbleGroupBox(this, new Point(352, 8), new Size(144, 224), 4)); this.Controls.Add(new UndoChangesButton(this, new Point(185, 200), new Size(154, 23), 5)); this.Controls.Add(new OKButton(this, new Point(16, 200), new Size(96, 23), 6)); this.FireDrawingAttributesChanged(this); this.ResumeLayout(); }
public static NineInk.Stroke ToNineStroke(WindowsInk.Stroke windowsStroke) { var points = new List<NineInk.StrokePoint>(); foreach (var point in windowsStroke.StylusPoints) points.Add(new NineInk.StrokePoint(point.X, point.Y, point.PressureFactor)); var drwAttr = new DrawingAttributes(); drwAttr.Color.R = windowsStroke.DrawingAttributes.Color.R; drwAttr.Color.G = windowsStroke.DrawingAttributes.Color.G; drwAttr.Color.B = windowsStroke.DrawingAttributes.Color.B; drwAttr.Color.A = windowsStroke.DrawingAttributes.Color.A; switch (windowsStroke.DrawingAttributes.StylusTip.ToString()) { case "Rectangle": drwAttr.Brush = Brushes.Rectangle; break; case "Ellipse": default: drwAttr.Brush = Brushes.Ellipse; break; } drwAttr.Height = windowsStroke.DrawingAttributes.Height; drwAttr.Width = windowsStroke.DrawingAttributes.Width; drwAttr.IsHighlighter = windowsStroke.DrawingAttributes.IsHighlighter; return new NineInk.Stroke(points, drwAttr); }
public StylusEntry(DrawingAttributes atts, StylusModel stylus, string toolTipText, PenType pt) { if (atts == null) throw new ArgumentNullException("atts"); if (stylus == null) throw new ArgumentNullException("stylus"); this.DrawingAttributes = atts; this.Stylus = stylus; this.ToolTipText = toolTipText; this.PenType = pt; }
public PenStateModel() { DrawingAttributes atts = new DrawingAttributes(); this.m_PenRasterOperation = RasterOperation.CopyPen; this.m_PenTip = PenTip.Ball; this.m_PenColor = Color.Orange.ToArgb(); this.m_PenWidth = (int)atts.Width; this.m_PenHeight = (int)atts.Height; this.m_HLRasterOperation = RasterOperation.MaskPen; this.m_HLTip = PenTip.Ball; this.m_HLColor = Color.Pink.ToArgb(); this.m_HLWidth = (int)(6 * atts.Width); this.m_HLHeight = (int)(2 * atts.Width); }
public Canvas() { InitializeComponent(); graph = new Graph(); animations = new ArrayList(); animStarted = false; weight = -1; prevEdgeHit = null; // Declare repaint optimizations. base.SetStyle( ControlStyles.UserPaint| ControlStyles.AllPaintingInWmPaint| ControlStyles.DoubleBuffer, true); this.Paint += new PaintEventHandler(Canvas_Paint); inkOverlay = new InkOverlay(this.Handle, true); //attach to form, allow use of mouse for input inkOverlay.CollectionMode = CollectionMode.InkOnly; // allow ink only, no gestures inkOverlay.AutoRedraw = false; // Dynamic rendering only; we do all the painting. DrawingAttributes da = new DrawingAttributes(); da.AntiAliased = true; //Makes everything nice and smooth lookin' da.Transparency = 0; da.PenTip = Microsoft.Ink.PenTip.Ball; da.Width = 70.0f; inkOverlay.DefaultDrawingAttributes = da; //Triggered at each pen stroke inkOverlay.Stroke += new InkCollectorStrokeEventHandler(inkOverlay_Stroke); //Triggered at each eraser stroke inkOverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(inkOverlay_StrokesDeleting); //Triggered when a selection of strokes is moved inkOverlay.SelectionMoved += new InkOverlaySelectionMovedEventHandler(inkOverlay_SelectionMoved); //Triggered when a selection of strokes is resized inkOverlay.SelectionResized +=new InkOverlaySelectionResizedEventHandler(inkOverlay_SelectionResized); inkOverlay.Enabled = true; myRecognizer = new RecognizerContext(); myRecognizer.Strokes = inkOverlay.Ink.CreateStrokes(); edgeTimer = new System.Timers.Timer(TIME_INTERVAL); edgeTimer.AutoReset = true; edgeTimer.Elapsed +=new ElapsedEventHandler(edgeTimer_Elapsed); edgeTimer.Enabled = true; }
public MyBorder() { gotFirstStroke = false; // Set the default state if no button is clicked state = sMode.add; myInkPresenter = new InkPresenter(); Child = myInkPresenter; inkAttributes = new DrawingAttributes(); inkAttributes.Color = Colors.Green; inkAttributes.Width = 5; inkAttributes.Height = 5; renderer = new DynamicRenderer(); renderer.DrawingAttributes = inkAttributes; this.StylusPlugIns.Add(renderer); myInkPresenter.AttachVisuals(renderer.RootVisual, renderer.DrawingAttributes); StrokeConstructorSample(); }
public ImageProcWindow(System.Drawing.Bitmap bitmap) { bmp = bitmap; img = new Image(); da = new DrawingAttributes(); InitializeComponent(); tempList = new Stack <StrokeCollection>(); ink.Strokes.StrokesChanged += Strokes_StrokesChanged; img.Width = bitmap.Width; img.Height = bitmap.Height; ink.Children.Add(img); ink.Height = bitmap.Height; ink.Width = bitmap.Width; ink.EditingMode = InkCanvasEditingMode.None; da.Color = Color.FromRgb(255, 255, 255); da.Width = 10; da.Height = 10; da.StylusTip = StylusTip.Ellipse; }
protected override void DrawCore(DrawingContext DrawingContext, DrawingAttributes DrawingAttribs) { var start = StylusPoints.First().ToPoint(); var end = StylusPoints.Last().ToPoint(); if (end.X < start.X) { var t = start.X; start.X = end.X; end.X = t; } if (end.Y < start.Y) { var t = start.Y; start.Y = end.Y; end.Y = t; } var w = end.X - start.X; var h = end.Y - start.Y; if (w <= 0) { w = 1; } if (h <= 0) { h = 1; } var center = new Point(start.X + w / 2, start.Y + h / 2); DrawingContext.DrawEllipse(null, new Pen(new SolidColorBrush(DrawingAttribs.Color), DrawingAttribs.Width), center, w / 2, h / 2); }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { if (drawingContext == null) { throw new ArgumentNullException("drawingContext"); } if (null == drawingAttributes) { throw new ArgumentNullException("drawingAttributes"); } this.Center = this.GetCenter(); this.Radius = this.GetRadius(Center); if (this.Radius > 0) { double thickness = Math.Min(drawingAttributes.Width, drawingAttributes.Height); SolidColorBrush brush2 = new SolidColorBrush(drawingAttributes.Color); brush2.Freeze(); Pen newPen = new Pen(brush2, thickness); this.FixStylusPoint(this.Center, this.Radius); drawingContext.DrawEllipse(null, newPen, this.Center, this.Radius, this.Radius); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { testiadded = new List <StrokeCollection>(); testiremoved = new List <StrokeCollection>(); selectedcolor = buttonBlack.Background; inkCanvas1.Background = Brushes.White; inkCanvas1.DefaultDrawingAttributes.Color = Colors.Black; inkDA = new DrawingAttributes(); inkDA.Height = 5; inkDA.Width = 5; inkDA.FitToCurve = false; /*highlighterDA = new DrawingAttributes(); * highlighterDA.Color = Colors.Orchid; * highlighterDA.IsHighlighter = true; * highlighterDA.IgnorePressure = true; * highlighterDA.StylusTip = StylusTip.Rectangle; * highlighterDA.Height = 30; * highlighterDA.Width = 10;*/ inkCanvas1.DefaultDrawingAttributes = inkDA; }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { // Allocate memory to store the previous point to draw from. Point prevPoint = new Point(StylusPoints[0].X, StylusPoints[0].Y); Point pt0 = new Point(prevPoint.X, prevPoint.Y); // Draw linear gradient ellipses between // all the StylusPoints in the Stroke. for (int i = 0; i < this.StylusPoints.Count; i++) { Point pt = (Point)this.StylusPoints[i]; Vector v = Point.Subtract(prevPoint, pt); // Only draw if we are at least 4 units away // from the end of the last ellipse. Otherwise, // we're just redrawing and wasting cycles. if (v.Length > 4) { // Set the thickness of the stroke // based on how hard the user pressed. double radius = this.StylusPoints[i].PressureFactor * 20d; //画贝赛尔曲线 drawBezier(drawingContext, prevPoint, pt0, pt); //这一部分可以控制为绘图方式 prevPoint = pt0; pt0 = pt; } } }
public LanCanvas(InkCanvas canvas, IdGenerator generator, string owner, PermissionsData permissions) { eraserShape = new EllipseStylusShape(2, 2); PointerData = new SharedWindows.PointerData(); PointerData.Attributes = new DrawingAttributes(); PointerData.Attributes.Color = Colors.Red; PointerData.StayTime = 1500; PointerData.FadeTime = 500; OwnerName = owner; this.generator = generator; this.canvas = canvas; this.Permissions = permissions; DefaultDrawingAttributes = new DrawingAttributes(); cursorLibrary = new CursorLibrary(); modeChanger = new ModeChanger(); UpdatePermissions(); canvas.Dispatcher.Invoke(new Action(canvasInit)); drawer = new SignedStrokeDrawer(canvas.Strokes, generator, OwnerName); eraser = new SignedStrokeEraser(canvas.Strokes, permissions, OwnerName); cutter = new SignedStrokeCutter(canvas.Strokes); pointerDrawer = new SignedPointerStrokeDrawer(canvas.Strokes, OwnerName, generator, canvas.Dispatcher); ManualHandler = new ManualHandle(canvas); CanvasHandle = new CanvasEventsHandle(this, drawer, eraser, pointerDrawer); }
public MainWindow() { InitializeComponent(); DrawingAttributes drawingAttributes = new DrawingAttributes { Color = Colors.Red, Width = 2, Height = 2, StylusTip = StylusTip.Rectangle, FitToCurve = true, IsHighlighter = false, IgnorePressure = true, }; inkCanvasMeasure.DefaultDrawingAttributes = drawingAttributes; viewModel = new ViewModel { MeaInfo = "测试······", }; DataContext = viewModel; }
/// <summary> /// Initialization. /// </summary> public Window1() { InitializeComponent(); inkcanvas.PreferredPasteFormats = new InkCanvasClipboardFormat[] { InkCanvasClipboardFormat.InkSerializedFormat }; _markerDA = new DrawingAttributes(); _markerDA.Color = Color.FromRgb(200, 0, 200); _markerDA.StylusTip = StylusTip.Ellipse; _markerDA.Width = 3; _markerDA.Height = 3; inkcanvas.DefaultDrawingAttributes = _markerDA; _highlightDA = new DrawingAttributes(); _highlightDA.IsHighlighter = true; _highlightDA.Color = Color.FromRgb(255, 255, 0); _highlightDA.Width = 10; _highlightDA.Height = 25; _highlightDA.StylusTip = StylusTip.Rectangle; _colorPicker = new ColorPicker(); _colorPicker.SelectedDrawingAttributes = _markerDA; color_panel.Children.Add(_colorPicker); }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { Fill(drawingContext); SetSelection(drawingContext); OnDrawCore(drawingContext, drawingAttributes); updatePoints(); /*RotateTransform RT = new RotateTransform(); * RT.Angle = this.CurrentRotation; * drawingContext.PushTransform(RT);*/ if (this.Label != null) { DrawName(drawingContext); } DrawMethods(drawingContext); DrawAttributes(drawingContext); DrawEncrage(drawingContext); DrawRotator(drawingContext); //drawingContext.Pop(); }
public void saveStrokeSetting(DrawingAttributes d, bool isLine) { _strokeColor = d.Color.ToString(); _strokeradiusWidth = d.Width; if (d.IsHighlighter) { _isStrokeTransparent = 0; } else { _isStrokeTransparent = 1; } if (isLine) { _isStrokeLine = 0; } else { _isStrokeLine = 1; } string sqlCommand = "Update configuration Set strokeColor='" + _strokeColor + "' , strokeRadiusWidth=" + _strokeradiusWidth + ", strokeIsStraight=" + _isStrokeLine + ", strokeIsTransparent=" + _isStrokeTransparent; bookManager.sqlCommandNonQuery(sqlCommand); }
/// <Summary> /// Encodes a DrawingAttriubtesin the ISF stream. /// </Summary> #else /// <Summary> /// Encodes a DrawingAttriubtesin the ISF stream. /// </Summary> #endif internal static uint EncodeAsISF(DrawingAttributes da, Stream stream, GuidList guidList, byte compressionAlgorithm, bool fTag) { #if DEBUG System.Diagnostics.Debug.Assert(compressionAlgorithm == 0); System.Diagnostics.Debug.Assert(fTag == true); #endif Debug.Assert(stream != null); uint cbData = 0; BinaryWriter bw = new BinaryWriter(stream); PersistDrawingFlags(da, stream, guidList, ref cbData, ref bw); PersistColorAndTransparency(da, stream, guidList, ref cbData, ref bw); PersistRasterOperation(da, stream, guidList, ref cbData, ref bw); PersistWidthHeight(da, stream, guidList, ref cbData, ref bw); PersistStylusTip(da, stream, guidList, ref cbData, ref bw); PersistExtendedProperties(da, stream, guidList, ref cbData, ref bw, compressionAlgorithm, fTag); return(cbData); }
public MyStroke(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes) : base(stylusPoints, drawingAttributes) { //MoveStylusPoints(); }
/// <summary> /// Custom Pen Drawing /// </summary> private static Drawing CreatePenDrawing(DrawingAttributes drawingAttributes, bool isHollow, bool isRightToLeft, double dpiScaleX, double dpiScaleY) { // Create a single point stroke. StylusPointCollection stylusPoints = new StylusPointCollection(); stylusPoints.Add(new StylusPoint(0f, 0f)); DrawingAttributes da = new DrawingAttributes(); da.Color = drawingAttributes.Color; da.Width = drawingAttributes.Width; da.Height = drawingAttributes.Height; da.StylusTipTransform = drawingAttributes.StylusTipTransform; da.IsHighlighter = drawingAttributes.IsHighlighter; da.StylusTip = drawingAttributes.StylusTip; Stroke singleStroke = new Stroke(stylusPoints, da); // // We should draw our cursor in the device unit since it's device dependent object. singleStroke.DrawingAttributes.Width = ConvertToPixel(singleStroke.DrawingAttributes.Width, dpiScaleX); singleStroke.DrawingAttributes.Height = ConvertToPixel(singleStroke.DrawingAttributes.Height, dpiScaleY); double maxLength = Math.Min(SystemParameters.PrimaryScreenWidth / 2, SystemParameters.PrimaryScreenHeight / 2); // // NOTE: there are two ways to set the width / height of a stroke // 1) using .Width and .Height // 2) using StylusTipTransform and specifying a scale // these two can multiply and we need to prevent the size from ever going // over maxLength or under 1.0. The simplest way to check if we're too big // is by checking the bounds of the stroke, which takes both into account // Rect strokeBounds = singleStroke.GetBounds(); bool outOfBounds = false; // Make sure that the cursor won't exceed the minimum or the maximum boundary. if (DoubleUtil.LessThan(strokeBounds.Width, 1.0)) { singleStroke.DrawingAttributes.Width = 1.0; outOfBounds = true; } else if (DoubleUtil.GreaterThan(strokeBounds.Width, maxLength)) { singleStroke.DrawingAttributes.Width = maxLength; outOfBounds = true; } if (DoubleUtil.LessThan(strokeBounds.Height, 1.0)) { singleStroke.DrawingAttributes.Height = 1.0; outOfBounds = true; } else if (DoubleUtil.GreaterThan(strokeBounds.Height, maxLength)) { singleStroke.DrawingAttributes.Height = maxLength; outOfBounds = true; } //drop the StylusTipTransform if we're out of bounds. we might //consider trying to preserve any transform but this is such a rare //case (scaling over or under with a STT) that we don't care. if (outOfBounds) { singleStroke.DrawingAttributes.StylusTipTransform = Matrix.Identity; } if (isRightToLeft) { //reverse left to right to right to left Matrix xf = singleStroke.DrawingAttributes.StylusTipTransform; xf.Scale(-1, 1); //only set the xf if it has an inverse or the STT will throw if (xf.HasInverse) { singleStroke.DrawingAttributes.StylusTipTransform = xf; } } DrawingGroup penDrawing = new DrawingGroup(); DrawingContext dc = null; try { dc = penDrawing.Open(); // Call the internal drawing method on Stroke to draw as hollow if isHollow == true if (isHollow) { singleStroke.DrawInternal(dc, singleStroke.DrawingAttributes, isHollow); } else { // Invoke the public Draw method which will handle the Highlighter correctly. singleStroke.Draw(dc, singleStroke.DrawingAttributes); } } finally { if (dc != null) { dc.Close(); } } return(penDrawing); }
/// <summary> /// 创建显示笔迹的类 /// </summary> /// <param name="drawingAttributes"></param> public StrokeVisual(DrawingAttributes drawingAttributes) { _drawingAttributes = drawingAttributes; }
protected override void DrawCore(System.Windows.Media.DrawingContext context, DrawingAttributes overrides) { // create a drop shadow // if (this.Shadowed) { Geometry pathGeometry = this.GetGeometry(overrides).Clone(); pathGeometry.Transform = new TranslateTransform(5, 0); try { context.PushOpacity(0.5); context.DrawGeometry(Brushes.DarkGray, null, pathGeometry); } finally { context.Pop(); } } base.DrawCore(context, overrides); }
internal StylusData(StylusModel stylus, DrawingAttributes atts) { this.m_Stylus = stylus; this.m_DrawingAttributes = atts; }
public PenStylusModel(Guid id, DrawingAttributes atts) : base(id) { this.m_DrawingAttributes = atts; }
public virtual DrawingAttributes CreateDrawingAttributes() { DrawingAttributes atts = new DrawingAttributes(); this.UpdateDrawingAttributes(atts); return atts; }
public virtual void UpdateDrawingAttributes(DrawingAttributes atts) { atts.AntiAliased = this.AntiAliased; atts.Color = this.Color; foreach(ExtendedProperty prop in this.ExtendedProperties) atts.ExtendedProperties.Add(prop.Id, prop.Data); atts.FitToCurve = this.FitToCurve; atts.Height = this.Height; atts.IgnorePressure = this.IgnorePressure; atts.PenTip = this.PenTip; atts.RasterOperation = this.RasterOperation; atts.Transparency = this.Transparency; atts.Width = this.Width; }
protected StylusModel(Guid id) { this.m_Id = id; this.m_DrawingAttributes = new DrawingAttributes(); }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { Geometry geometry = this.GetGeometry(drawingAttributes); drawingContext.DrawGeometry(imageBrush, null, geometry); }
internal static void CalcGeometryAndBounds(StrokeNodeIterator iterator, DrawingAttributes drawingAttributes, bool calculateBounds, out Geometry geometry, out Rect bounds) { Matrix stylusTipTransform = drawingAttributes.StylusTipTransform; if (stylusTipTransform != Matrix.Identity) { CalcGeometryAndBoundsWithTransform(iterator, drawingAttributes, MatrixTypes.TRANSFORM_IS_TRANSLATION, calculateBounds, out geometry, out bounds); return; } StreamGeometry streamGeometry = new StreamGeometry(); streamGeometry.FillRule = FillRule.Nonzero; StreamGeometryContext streamGeometryContext = streamGeometry.Open(); geometry = streamGeometry; Rect rect = bounds = Rect.Empty; try { StrokeNode strokeNode = default(StrokeNode); StrokeNode strokeNodePrevious = default(StrokeNode); StrokeNode strokeNode2 = default(StrokeNode); StrokeNode strokeNode3 = default(StrokeNode); Rect rect2 = rect; Rect rect3 = rect; Rect rect4 = rect; double num = 95.0; double num2 = Math.Max(drawingAttributes.Height, drawingAttributes.Width); num += Math.Min(4.99999, num2 / 20.0 * 5.0); double lastAngle = double.MinValue; bool flag = true; bool isEllipse = drawingAttributes.StylusTip == StylusTip.Ellipse; bool ignorePressure = drawingAttributes.IgnorePressure; List <Point> list = new List <Point>(); List <Point> list2 = new List <Point>(); List <Point> list3 = new List <Point>(4); int count = iterator.Count; int num3 = 0; int previousIndex = -1; while (num3 < count) { if (!strokeNodePrevious.IsValid) { if (!strokeNode2.IsValid) { strokeNodePrevious = iterator[num3++, previousIndex++]; rect2 = strokeNodePrevious.GetBounds(); continue; } strokeNodePrevious = strokeNode2; rect2 = rect3; strokeNode2 = strokeNode; } if (!strokeNode2.IsValid) { if (!strokeNode3.IsValid) { strokeNode2 = iterator[num3++, previousIndex]; rect3 = strokeNode2.GetBounds(); switch (FuzzyContains(rect3, rect2, flag ? 99.99999 : num)) { case RectCompareResult.Rect1ContainsRect2: strokeNodePrevious = iterator[num3 - 1, strokeNodePrevious.Index - 1]; rect2 = Rect.Union(rect3, rect2); strokeNode2 = strokeNode; previousIndex = num3 - 1; break; case RectCompareResult.Rect2ContainsRect1: strokeNode2 = strokeNode; break; default: previousIndex = num3 - 1; break; } continue; } strokeNode2 = strokeNode3; rect3 = rect4; strokeNode3 = strokeNode; } if (!strokeNode3.IsValid) { strokeNode3 = iterator[num3++, previousIndex]; rect4 = strokeNode3.GetBounds(); RectCompareResult rectCompareResult = FuzzyContains(rect4, rect3, flag ? 99.99999 : num); RectCompareResult rectCompareResult2 = FuzzyContains(rect4, rect2, flag ? 99.99999 : num); if (flag && rectCompareResult == RectCompareResult.Rect1ContainsRect2 && rectCompareResult2 == RectCompareResult.Rect1ContainsRect2) { if (list.Count > 0) { strokeNode2.GetPointsAtEndOfSegment(list, list2); ReverseDCPointsRenderAndClear(streamGeometryContext, list, list2, list3, isEllipse, clear: true); } strokeNodePrevious = iterator[num3 - 1, strokeNodePrevious.Index - 1]; rect2 = strokeNodePrevious.GetBounds(); strokeNode2 = strokeNode; strokeNode3 = strokeNode; previousIndex = num3 - 1; continue; } switch (rectCompareResult) { case RectCompareResult.Rect1ContainsRect2: strokeNode3 = iterator[num3 - 1, strokeNode2.Index - 1]; if (!strokeNode3.GetConnectingQuad().IsEmpty) { strokeNode2 = strokeNode3; rect3 = Rect.Union(rect4, rect3); previousIndex = num3 - 1; } strokeNode3 = strokeNode; lastAngle = double.MinValue; continue; case RectCompareResult.Rect2ContainsRect1: strokeNode3 = strokeNode; continue; } previousIndex = num3 - 1; } bool flag2 = rect2.IntersectsWith(rect4); if (calculateBounds) { bounds.Union(rect3); } if (list.Count == 0) { if (calculateBounds) { bounds.Union(rect2); } if (flag && flag2) { strokeNodePrevious.GetContourPoints(list3); AddFigureToStreamGeometryContext(streamGeometryContext, list3, strokeNodePrevious.IsEllipse); list3.Clear(); } strokeNode2.GetPointsAtStartOfSegment(list, list2); flag = false; } if (lastAngle == double.MinValue) { lastAngle = GetAngleBetween(strokeNodePrevious.Position, strokeNode2.Position); } double angleDeltaFromLast = GetAngleDeltaFromLast(strokeNode2.Position, strokeNode3.Position, ref lastAngle); bool flag3 = Math.Abs(angleDeltaFromLast) > 90.0 && Math.Abs(angleDeltaFromLast) < 270.0; bool flag4 = flag2 && !ignorePressure && strokeNode3.PressureFactor != 1f && Math.Abs(angleDeltaFromLast) > 30.0 && Math.Abs(angleDeltaFromLast) < 330.0; double num4 = rect3.Height * rect3.Width; double num5 = rect4.Height * rect4.Width; bool flag5 = num4 != num5 || num4 != rect2.Height * rect2.Width; bool flag6 = false; if (flag2 && flag5 && Math.Min(num4, num5) / Math.Max(num4, num5) <= 0.9) { flag6 = true; } if (flag5 || angleDeltaFromLast != 0.0 || num3 >= count) { if ((flag2 && (flag4 | flag6)) | flag3) { strokeNode2.GetPointsAtEndOfSegment(list, list2); ReverseDCPointsRenderAndClear(streamGeometryContext, list, list2, list3, isEllipse, clear: true); if (flag6) { strokeNode2.GetContourPoints(list3); AddFigureToStreamGeometryContext(streamGeometryContext, list3, strokeNode2.IsEllipse); list3.Clear(); } } else { strokeNode3.GetPointsAtMiddleSegment(strokeNode2, angleDeltaFromLast, list, list2, out bool missingIntersection); if (missingIntersection) { strokeNode2.GetPointsAtEndOfSegment(list, list2); ReverseDCPointsRenderAndClear(streamGeometryContext, list, list2, list3, isEllipse, clear: true); } } } strokeNodePrevious = strokeNode; rect2 = rect; } if (strokeNodePrevious.IsValid) { if (strokeNode2.IsValid) { if (calculateBounds) { bounds.Union(rect2); bounds.Union(rect3); } if (list.Count > 0) { strokeNode2.GetPointsAtEndOfSegment(list, list2); ReverseDCPointsRenderAndClear(streamGeometryContext, list, list2, list3, isEllipse, clear: false); } else { RenderTwoStrokeNodes(streamGeometryContext, strokeNodePrevious, rect2, strokeNode2, rect3, list, list2, list3); } } else { if (calculateBounds) { bounds.Union(rect2); } strokeNodePrevious.GetContourPoints(list); AddFigureToStreamGeometryContext(streamGeometryContext, list, strokeNodePrevious.IsEllipse); } } else if (strokeNode2.IsValid && strokeNode3.IsValid) { if (calculateBounds) { bounds.Union(rect3); bounds.Union(rect4); } if (list.Count > 0) { strokeNode3.GetPointsAtEndOfSegment(list, list2); ReverseDCPointsRenderAndClear(streamGeometryContext, list, list2, list3, isEllipse, clear: false); if (FuzzyContains(rect4, rect3, 70.0) != RectCompareResult.NoItersection) { strokeNode3.GetContourPoints(list3); AddFigureToStreamGeometryContext(streamGeometryContext, list3, strokeNode3.IsEllipse); } } else { RenderTwoStrokeNodes(streamGeometryContext, strokeNode2, rect3, strokeNode3, rect4, list, list2, list3); } } } finally { streamGeometryContext.Close(); geometry.Freeze(); } }
// // Constructor // public MainWindow() { // Set the current directory as TabletDriverGUI.exe's directory. try { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); } catch (Exception) { } // // Prevent triggering input field events // isLoadingSettings = true; // Initialize WPF InitializeComponent(); // Version text textVersion.Text = this.Version; // Set culture to en-US to force decimal format and etc. CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); // Create notify icon notifyIcon = new System.Windows.Forms.NotifyIcon { // Icon Icon = Properties.Resources.AppIcon, // Menu items ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[] { new System.Windows.Forms.MenuItem("TabletDriverGUI " + Version), new System.Windows.Forms.MenuItem("Restart Driver", NotifyRestartDriver), new System.Windows.Forms.MenuItem("Show", NotifyShowWindow), new System.Windows.Forms.MenuItem("Exit", NotifyExit) }) }; notifyIcon.ContextMenu.MenuItems[0].Enabled = false; notifyIcon.Text = ""; notifyIcon.MouseClick += NotifyIcon_Click; notifyIcon.Visible = true; IsRealExit = false; // Create command history list commandHistory = new List <string> { "" }; commandHistoryIndex = 0; // Init setting commands list settingCommands = new List <string>(); // Init tablet driver driver = new TabletDriver("TabletDriverService.exe"); driverCommands = new Dictionary <string, string>(); driver.MessageReceived += OnDriverMessageReceived; driver.ErrorReceived += OnDriverErrorReceived; driver.StatusReceived += OnDriverStatusReceived; driver.Started += OnDriverStarted; driver.Stopped += OnDriverStopped; running = false; // Restart timer timerRestart = new DispatcherTimer { Interval = new TimeSpan(0, 0, 5) }; timerRestart.Tick += TimerRestart_Tick; // Statusbar timer timerStatusbar = new DispatcherTimer { Interval = new TimeSpan(0, 0, 5) }; timerStatusbar.Tick += TimerStatusbar_Tick; // Timer console update timerConsoleUpdate = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 200) }; timerConsoleUpdate.Tick += TimerConsoleUpdate_Tick; // Tooltip timeout ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(60000)); // // Hide tablet button mapping // groupBoxTabletButtons.Visibility = Visibility.Collapsed; // Ink canvas undo history inkCanvasUndoHistory = new StrokeCollection(); // Ink canvas drawing attributes inkCanvasDrawingAttributes = new DrawingAttributes { Width = 10, Height = 10, Color = Color.FromRgb(0x55, 0x55, 0x55), StylusTip = StylusTip.Ellipse, FitToCurve = false }; inkCanvas.DefaultDrawingAttributes = inkCanvasDrawingAttributes; // Process command line arguments ProcessCommandLineArguments(); // Events Closing += MainWindow_Closing; Loaded += MainWindow_Loaded; SizeChanged += MainWindow_SizeChanged; }
public DrawingWindow() { InitializeComponent(); drawingAttributes = surfaceDessin.DefaultDrawingAttributes; drawingAttributes.Color = (Color)ColorConverter.ConvertFromString("#000000"); drawingAttributes.Height = 10; drawingAttributes.Width = 10; drawingAttributes.StylusTip = StylusTip.Ellipse; socket.On(SocketEvents.STROKE_DRAWING, (points) => { Dispatcher.Invoke(() => { Stroke newStroke = new Stroke(JsonConvert.DeserializeObject <StylusPointCollection>(points.ToString())); newStroke.DrawingAttributes = drawingAttributes; newStroke.DrawingAttributes.Color = drawingAttributes.Color; newStroke.DrawingAttributes.Width = drawingAttributes.Width; newStroke.DrawingAttributes.Height = drawingAttributes.Height; newStroke.DrawingAttributes.StylusTip = drawingAttributes.StylusTip; surfaceDessin.Strokes.Add(newStroke); ongoingStrokeIndex.Add(newStroke); }); }); socket.On(SocketEvents.STROKE_COLLECTED, (points) => { Dispatcher.Invoke(() => { Stroke newStroke = new Stroke(JsonConvert.DeserializeObject <StylusPointCollection>(points.ToString())); newStroke.DrawingAttributes.Color = drawingAttributes.Color; newStroke.DrawingAttributes.Width = drawingAttributes.Width; newStroke.DrawingAttributes.Height = drawingAttributes.Height; newStroke.DrawingAttributes.StylusTip = drawingAttributes.StylusTip; foreach (Stroke strokeToDelete in ongoingStrokeIndex) { surfaceDessin.Strokes.Remove(strokeToDelete); } surfaceDessin.Strokes.Add(newStroke); ongoingStrokeIndex.Clear(); }); }); socket.On(SocketEvents.STROKE_ERASING, (points) => { Dispatcher.Invoke(() => { List <StylusPoint> pointsToCheck = (JsonConvert.DeserializeObject <List <StylusPoint> >(points.ToString())); pointsToCheck.ForEach((point) => { StrokeCollection strokesToBeErased = surfaceDessin.Strokes.HitTest(new Point(point.X, point.Y)); surfaceDessin.Strokes.Remove(strokesToBeErased); }); }); }); socket.On(SocketEvents.STROKE_SEGMENT_ERASING, (points) => { Dispatcher.Invoke(() => { List <StylusPoint> pointsToCheck = (JsonConvert.DeserializeObject <List <StylusPoint> >(points.ToString())); Console.WriteLine(pointsToCheck.Count + " POINTS"); IncrementalStrokeHitTester eraserTester = surfaceDessin.Strokes.GetIncrementalStrokeHitTester(generateStylusShape()); eraserTester.StrokeHit += EraserTester_StrokeHit; pointsToCheck.ForEach((point) => eraserTester.AddPoint(new Point(point.X, point.Y))); eraserTester.StrokeHit -= EraserTester_StrokeHit; eraserTester.EndHitTesting(); }); }); socket.On(SocketEvents.STROKE_COLOR, (color) => { Dispatcher.Invoke(() => { string hex = "#" + ((Int64)color).ToString("X8"); drawingAttributes.Color = (Color)ColorConverter.ConvertFromString(hex); }); }); socket.On(SocketEvents.STROKE_SIZE, (size) => { Dispatcher.Invoke(() => { drawingAttributes.Height = Convert.ToInt32(size.ToString()); drawingAttributes.Width = Convert.ToInt32(size.ToString()); }); }); socket.On(SocketEvents.STROKE_TIP, (tip) => { Dispatcher.Invoke(() => { drawingAttributes.StylusTip = ((string)tip == Tool.PEN_ROUND_TIP) ? StylusTip.Ellipse : StylusTip.Rectangle; }); }); socket.On(SocketEvents.STROKE_TOOL, (tool) => { Dispatcher.Invoke(() => { OutilSelectionne = tool.ToString(); }); }); }
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes) { drawingContext.DrawRectangle(Pen.Brush, Pen, new Rect((Point)StylusPoints[0], (Point)StylusPoints[StylusPoints.Count - 1])); }
private void HandleDrawingAttributesChanged(object sender, PropertyEventArgs args) { using(Synchronizer.Lock(this)) { // Ensure that this.Stylus can't change. DrawingAttributes atts; if(this.Stylus != null) { using(Synchronizer.Lock(this.m_Stylus.SyncRoot)) { atts = (this.Stylus is PenStylusModel) ? ((PenStylusModel) this.Stylus).DrawingAttributes : null; } } else { atts = null; } this.m_DrawingAttributes = atts; // Enqueue a StylusData packet whether or not there are any DrawingAttributes. this.EnqueueStylusCustomData(); } }
internal static void CalcGeometryAndBoundsWithTransform(StrokeNodeIterator iterator, DrawingAttributes drawingAttributes, MatrixTypes stylusTipMatrixType, bool calculateBounds, out Geometry geometry, out Rect bounds) { StreamGeometry streamGeometry = new StreamGeometry(); streamGeometry.FillRule = FillRule.Nonzero; StreamGeometryContext streamGeometryContext = streamGeometry.Open(); geometry = streamGeometry; bounds = Rect.Empty; try { List <Point> list = new List <Point>(iterator.Count * 4); int num = iterator.Count * 2; int num2 = 0; for (int i = 0; i < num; i++) { list.Add(new Point(0.0, 0.0)); } List <Point> list2 = new List <Point>(); double lastAngle = 0.0; bool flag = false; Rect rect = new Rect(0.0, 0.0, 0.0, 0.0); for (int j = 0; j < iterator.Count; j++) { StrokeNode strokeNode = iterator[j]; Rect bounds2 = strokeNode.GetBounds(); if (calculateBounds) { bounds.Union(bounds2); } double num3 = Math.Abs(GetAngleDeltaFromLast(strokeNode.PreviousPosition, strokeNode.Position, ref lastAngle)); double num4 = 45.0; if (stylusTipMatrixType == MatrixTypes.TRANSFORM_IS_UNKNOWN) { num4 = 10.0; } else if (bounds2.Height > 40.0 || bounds2.Width > 40.0) { num4 = 20.0; } bool flag2 = num3 > num4 && num3 < 360.0 - num4; double val = rect.Height * rect.Width; double val2 = bounds2.Height * bounds2.Width; bool flag3 = false; if (Math.Min(val, val2) / Math.Max(val, val2) <= 0.7) { flag3 = true; } rect = bounds2; if ((j <= 1 || j >= iterator.Count - 2) | flag2 | flag3) { if (flag2 && !flag && j > 1 && j < iterator.Count - 1) { list2.Clear(); strokeNode.GetPreviousContourPoints(list2); AddFigureToStreamGeometryContext(streamGeometryContext, list2, strokeNode.IsEllipse); flag = true; } list2.Clear(); strokeNode.GetContourPoints(list2); AddFigureToStreamGeometryContext(streamGeometryContext, list2, strokeNode.IsEllipse); } if (!flag2) { flag = false; } Quad connectingQuad = strokeNode.GetConnectingQuad(); if (!connectingQuad.IsEmpty) { list[num2++] = connectingQuad.A; list[num2++] = connectingQuad.B; list.Add(connectingQuad.D); list.Add(connectingQuad.C); } if (strokeNode.IsLastNode && num2 > 0) { int num5 = iterator.Count * 2; int num6 = list.Count - 1; int num7 = num2; for (int k = num5; k <= num6; k++) { list[num7] = list[k]; num7++; } int num8 = num5 - num2; list.RemoveRange(num6 - num8 + 1, num8); int num9 = num2; int num10 = list.Count - 1; while (num9 < num10) { Point value = list[num9]; list[num9] = list[num10]; list[num10] = value; num9++; num10--; } AddFigureToStreamGeometryContext(streamGeometryContext, list, isBezierFigure: false); } } } finally { streamGeometryContext.Close(); geometry.Freeze(); } }
void IStylusAsyncPlugin.CustomStylusDataAdded(RealTimeStylus sender, CustomStylusData data) { if(data.CustomDataId == StylusInputSelector.StylusData.Id) { using(Synchronizer.Lock(this)) { // The new DrawingAttributes will take effect after the next StylusDown event. this.m_DrawingAttributes = ((StylusInputSelector.StylusData) data.Data).DrawingAttributes; if(this.RealTimeInkSheetModel != null) { using(Synchronizer.Lock(this.RealTimeInkSheetModel.SyncRoot)) { this.RealTimeInkSheetModel.CurrentDrawingAttributes = this.m_DrawingAttributes; } } } } }
// Be sure to pass in the DrawingAttributes when you create the stroke to // subscribe to the PropertyDataChaned event. public ShadowedStroke(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes) : base(stylusPoints, drawingAttributes) { this.DrawingAttributes.PropertyDataChanged += new PropertyDataChangedEventHandler(DrawingAttributes_PropertyDataChanged); }
/// <summary> /// Constructs a new <see cref="Core"/> instance, which will /// render ink to the graphics device returned by the <see cref="SlideDisplayModel"/>. /// </summary> /// <remarks> /// Furthermore, the ink will be transformed using the /// <see cref="SlideDisplayModel.InkTransform"/> /// and clipped by <see cref="SlideDisplayModel.Bounds"/>. /// </remarks> public Core(SlideDisplayModel display) { this.m_SlideDisplay = display; this.m_Renderer = new Renderer(); this.m_Ink = new Ink(); this.m_DrawingAttributes = new DrawingAttributes(); this.m_PacketsTable = new Dictionary<int,int[]>(); this.m_DrawingAttributesTable = new Dictionary<int,DrawingAttributes>(); this.m_TabletPropertiesTable = new Dictionary<int,TabletPropertyDescriptionCollection>(); this.m_CollectedPacketsTable = new Dictionary<int, List<int>>(); this.m_CurrentStrokeIdTable = new Dictionary<int, int>(); this.m_SlideDisplay.Changed["InkTransform"].Add(new PropertyEventHandler(this.HandleInkTransformChanged)); this.HandleInkTransformChanged(display, null); }
public void SetDefaultPens() { Pen1 = new DrawingAttributes(); Pen1.Color = Color.FromArgb(240, 60, 60); Pen1.Width = 80; Pen1.Transparency = 30; Pen2 = new DrawingAttributes(); Pen2.Color = Color.FromArgb(60, 60, 240); Pen2.Width = 80; Pen2.Transparency = 30; Pen3 = new DrawingAttributes(); Pen3.Color = Color.FromArgb(250, 210, 0); Pen3.Width = 80; Pen3.Transparency = 30; Pen4 = new DrawingAttributes(); Pen4.Color = Color.FromArgb(150, 200, 100); Pen4.Width = 800; Pen4.Transparency = 160; Pen5 = new DrawingAttributes(); Pen5.Color = Color.FromArgb(200, 150, 250); Pen5.Width = 800; Pen5.Transparency = 160; }
/// <summary> /// Notifies the <see cref="Core"/> that the <see cref="DrawingAttributes"/> which are to be /// used to render subsequent strokes have changed. /// </summary> /// <remarks> /// This property takes effect only at the next <see cref="StylusDown"/> event. /// If the <see cref="Core"/> is enabled while a stroke is in progress, /// then the stroke will continue to be rendered using the previous <see cref="DrawingAttributes"/>. /// </remarks> /// <param name="atts">The new <see cref="DrawingAttributes"/> to use to render ink.</param> public void DrawingAttributesChanged(DrawingAttributes atts) { // The new drawing attributes will take effect on the next StylusDown. this.DrawingAttributes = atts; }
public ComicTransMainWindow() { InitializeComponent(); TransResListView.ItemsSource = lstData; ComicImgList = new List <string>(); CurrentPos = 0; transRes1 = ""; transRes2 = ""; _translator1 = TranslateWindow.TranslatorAuto(Common.appSettings.FirstTranslator); _translator2 = TranslateWindow.TranslatorAuto(Common.appSettings.SecondTranslator); ocr = OCRCommon.OCRAuto(Common.appSettings.OCRsource); ocr.SetOCRSourceLang("jpn"); if (Common.appSettings.OCRsource == "BaiduOCR") { if (ocr.OCR_Init(Common.appSettings.BDOCR_APIKEY, Common.appSettings.BDOCR_SecretKey) == false) { HandyControl.Controls.Growl.ErrorGlobal($"百度OCR {Application.Current.Resources["APITest_Error_Hint"]}\n{ocr.GetLastError()}"); } } else if (Common.appSettings.OCRsource == "Tesseract5_vert") { if (ocr.OCR_Init("", "") == false) { HandyControl.Controls.Growl.ErrorGlobal($"Tesseract5_vert {Application.Current.Resources["APITest_Error_Hint"]}\n{ocr.GetLastError()}"); } } else if (Common.appSettings.OCRsource == "TesseractOCR") { if (ocr.OCR_Init("", "") == false) { HandyControl.Controls.Growl.ErrorGlobal($"TesseractOCR {Application.Current.Resources["APITest_Error_Hint"]}\n{ocr.GetLastError()}"); } } scale = Common.GetScale(); DrawingAttributes drawingAttributes = new DrawingAttributes { Color = Colors.Red, Width = 2, Height = 2, StylusTip = StylusTip.Rectangle, //FitToCurve = true, IsHighlighter = false, IgnorePressure = true, }; inkCanvasMeasure.DefaultDrawingAttributes = drawingAttributes; viewModel = new ViewModel { MeaInfo = "", InkStrokes = new StrokeCollection(), }; DataContext = viewModel; }
private void MainInkCanvas_MouseMove(object sender, MouseEventArgs e) { if (_drawerIsMove == false) { return; } DrawingAttributes drawingAttributes = MainInkCanvas.DefaultDrawingAttributes.Clone(); Stroke stroke = null; drawingAttributes.StylusTip = StylusTip.Ellipse; drawingAttributes.IgnorePressure = true; Point endP = e.GetPosition(MainInkCanvas); if (_mode == DrawMode.Text) { List <Point> pointList = new List <Point> { new Point(_drawerIntPos.X, _drawerIntPos.Y), new Point(_drawerIntPos.X, endP.Y), new Point(endP.X, endP.Y), new Point(endP.X, _drawerIntPos.Y), new Point(_drawerIntPos.X, _drawerIntPos.Y), }; drawingAttributes.Width = 2; drawingAttributes.Height = 2; drawingAttributes.FitToCurve = false;//must be false,other wise rectangle can not be drawed correct StylusPointCollection point = new StylusPointCollection(pointList); stroke = new Stroke(point) { DrawingAttributes = drawingAttributes, }; } else if (_mode == DrawMode.Ray) { //high lighter is ray line drawingAttributes.IsHighlighter = true; List <Point> pointList = new List <Point> { new Point(_drawerIntPos.X, _drawerIntPos.Y), new Point(endP.X, endP.Y), }; StylusPointCollection point = new StylusPointCollection(pointList); stroke = new Stroke(point) { DrawingAttributes = drawingAttributes, }; } else if (_mode == DrawMode.Line) { List <Point> pointList = new List <Point> { new Point(_drawerIntPos.X, _drawerIntPos.Y), new Point(endP.X, endP.Y), }; StylusPointCollection point = new StylusPointCollection(pointList); stroke = new Stroke(point) { DrawingAttributes = drawingAttributes, }; } else if (_mode == DrawMode.Arrow) { double w = 15, h = 15; double theta = Math.Atan2(_drawerIntPos.Y - endP.Y, _drawerIntPos.X - endP.X); double sint = Math.Sin(theta); double cost = Math.Cos(theta); List <Point> pointList = new List <Point> { new Point(_drawerIntPos.X, _drawerIntPos.Y), new Point(endP.X, endP.Y), new Point(endP.X + (w * cost - h * sint), endP.Y + (w * sint + h * cost)), new Point(endP.X, endP.Y), new Point(endP.X + (w * cost + h * sint), endP.Y - (h * cost - w * sint)), }; StylusPointCollection point = new StylusPointCollection(pointList); drawingAttributes.FitToCurve = false;//must be false,other wise rectangle can not be drawed correct stroke = new Stroke(point) { DrawingAttributes = drawingAttributes, }; } else if (_mode == DrawMode.Rectangle) { List <Point> pointList = new List <Point> { new Point(_drawerIntPos.X, _drawerIntPos.Y), new Point(_drawerIntPos.X, endP.Y), new Point(endP.X, endP.Y), new Point(endP.X, _drawerIntPos.Y), new Point(_drawerIntPos.X, _drawerIntPos.Y), }; drawingAttributes.FitToCurve = false;//must be false,other wise rectangle can not be drawed correct StylusPointCollection point = new StylusPointCollection(pointList); stroke = new Stroke(point) { DrawingAttributes = drawingAttributes, }; } else if (_mode == DrawMode.Circle) { List <Point> pointList = GenerateEclipseGeometry(_drawerIntPos, endP); StylusPointCollection point = new StylusPointCollection(pointList); stroke = new Stroke(point) { DrawingAttributes = drawingAttributes }; } if (_drawerLastStroke != null) { MainInkCanvas.Strokes.Remove(_drawerLastStroke); } if (stroke != null) { MainInkCanvas.Strokes.Add(stroke); } _drawerLastStroke = stroke; }
//</Snippet23> private void DrawSelectedStrokeAndPoints(DrawingContext context, DrawingAttributes overrides) { }
public DrawingAttributesSerializer(DrawingAttributes atts) { this.AntiAliased = atts.AntiAliased; this.Color = atts.Color; this.ExtendedProperties = new ArrayList(atts.ExtendedProperties); this.FitToCurve = atts.FitToCurve; this.Height = atts.Height; this.IgnorePressure = atts.IgnorePressure; this.PenTip = atts.PenTip; this.RasterOperation = atts.RasterOperation; this.Transparency = atts.Transparency; this.Width = atts.Width; }
public FormInput(string caption, string label, string txt, bool ML, gInk.Root rt = null, Microsoft.Ink.Stroke stk = null) { InitializeComponent(); // local this.btOK.Text = rt.Local.ButtonOkText; this.btCancel.Text = rt.Local.ButtonCancelText; this.FontBtn.Text = rt.Local.ButtonFontText; this.ColorBtn.Text = rt.Local.OptionsPensColor; boxingCb.Items.AddRange(rt.Local.TextFramingText.Split(';')); Text = caption; captionLbl.Text = label; if (ML) { InputML.Visible = true; txt = txt.Replace("\r\n", "\n").Replace("\n", "\r\n"); //in order to get multiline text to be correctly editable after restore InputML.Text = txt; ActiveControl = InputML; } else { InputSL.Visible = true; InputSL.Text = txt; ActiveControl = InputSL; } Root = rt; stroke = stk; if (stroke == null) { FontBtn.Visible = false; boxingCb.Visible = false; } else { FontBtn.Visible = true; ColorBtn.Visible = true; boxingCb.Visible = true;// !stk.ExtendedProperties.Contains(Root.ISTAG_GUID); FontDlg.Font = new Font((string)stk.ExtendedProperties[Root.TEXTFONT_GUID].Data, (float)(double)stk.ExtendedProperties[Root.TEXTFONTSIZE_GUID].Data, (System.Drawing.FontStyle)stk.ExtendedProperties[Root.TEXTFONTSTYLE_GUID].Data); InputML.TextChanged += new System.EventHandler(this.InputML_TextChanged); int i = (stk.ExtendedProperties.Contains(Root.ISSTROKE_GUID) ? 1 : 0) + (stk.ExtendedProperties.Contains(Root.ISFILLEDWHITE_GUID) ? 2 : 0) + (stk.ExtendedProperties.Contains(Root.ISFILLEDBLACK_GUID) ? 4 : 0); boxingCb.Text = boxingCb.Items[i].ToString(); Saved_Txt = InputML.Text; Saved_Da = stk.DrawingAttributes.Clone(); Saved_Font = (Font)FontDlg.Font.Clone(); Saved_Frame = stk.ExtendedProperties.Contains(Root.ISSTROKE_GUID); Saved_White = stk.ExtendedProperties.Contains(Root.ISFILLEDWHITE_GUID); Saved_Black = stk.ExtendedProperties.Contains(Root.ISFILLEDBLACK_GUID); if (ML) { InputML.SelectAll(); } else { InputSL.SelectAll(); } } }
public MainForm() { // Required for Windows Form Designer support. InitializeComponent(); // Load our icon. this.Icon = new Icon(typeof(MainForm),"PhysicsIllustrator.ico"); // Initialize the per-item smart tag. bodytag = new PhysicsIllustrator.SmartTag.SmartTag(); bodytag.Image = Global.LoadImage("Resources.PenMenu.ico"); bodytag.Visible = false; bodytag.ContextMenu = new ContextMenu(); bodytag.ContextMenu.MenuItems.Add("Clone", new EventHandler(hover_EditCloneClicked)); bodytag.ContextMenu.MenuItems.Add("Delete", new EventHandler(hover_EditDeleteClicked)); bodytag.ContextMenu.MenuItems.Add("-"); bodytag.ContextMenu.MenuItems.Add("Straighten", new EventHandler(hover_EditStraightenClicked)); bodytag.ContextMenu.MenuItems.Add("Properties...", new EventHandler(hover_EditPropertiesClicked)); this.Controls.Add(bodytag); // Go fullscreen. Note: this works even with the taskbar set // to "keep on top of other windows". this.WindowState = System.Windows.Forms.FormWindowState.Normal; // this.Bounds = Screen.PrimaryScreen.Bounds; // Declare repaint optimizations. base.SetStyle( ControlStyles.UserPaint| ControlStyles.AllPaintingInWmPaint| ControlStyles.DoubleBuffer, true); // Init inkoverlay. inkoverlay = new InkOverlay(this.Handle,true); inkoverlay.CollectionMode = CollectionMode.InkOnly; // no gestures inkoverlay.AutoRedraw = false; // Dynamic rendering only; we do all the painting. DrawingAttributes da = new DrawingAttributes(); da.AntiAliased = false; inkoverlay.DefaultDrawingAttributes = da; inkoverlay.Stroke += new InkCollectorStrokeEventHandler(inkoverlay_Stroke); inkoverlay.CursorInRange += new InkCollectorCursorInRangeEventHandler(inkoverlay_CursorInRange); inkoverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(inkoverlay_StrokesDeleting); inkoverlay.SelectionChanging += new InkOverlaySelectionChangingEventHandler(inkoverlay_SelectionChanging); inkoverlay.SelectionChanged += new InkOverlaySelectionChangedEventHandler(inkoverlay_SelectionChanged); inkoverlay.SelectionMoved += new InkOverlaySelectionMovedEventHandler(inkoverlay_SelectionMoved); inkoverlay.SelectionResized += new InkOverlaySelectionResizedEventHandler(inkoverlay_SelectionResized); // inkoverlay. declaredmode = inkoverlay.EditingMode; // Spin up SDI model (ink+doc). doc = new MagicDocument(); inkoverlay.Ink = doc.Ink; inkoverlay.Enabled = !DesignMode; inkoverlay.Ink.InkAdded += new StrokesEventHandler(inkoverlay_Ink_InkAdded); }
/// <summary> /// Initializes a new instance of the <see cref="Stroke" /> class. /// Require a List of Points and the DrawingAttributes. No other method are available. /// </summary> /// <param name="pts">The PTS.</param> /// <param name="drw">The DRW.</param> public Stroke(List <StrokePoint> pts, DrawingAttributes drw) { Points = pts; DrawingAttributes = drw; }
/// <summary> /// Constructor /// </summary> /// <param name="model">The presenter model</param> public StylusToolBarButtons(PresenterModel model) { this.m_Model = model; // Initialize the stylus models. this.m_PenModel = new PenStylusModel(Guid.NewGuid()); this.m_HighlighterModel = new PenStylusModel(Guid.NewGuid()); this.m_EraserModel = new EraserStylusModel(Guid.NewGuid()); // Comment out as it is not being used currently //this.m_LassoModel = new LassoStylusModel(Guid.NewGuid()); this.m_ImageModel = new ImageStylusModel(Guid.NewGuid()); this.m_TextModel = TextStylusModel.GetInstance(); this.m_PenAtts = new DrawingAttributes(Color.Black); this.m_HighLighterAtts = new HighlighterDrawingAttributes(Color.Orange); this.m_StylusEntrys = new StylusEntry[][] { new StylusEntry[] { new StylusEntry(new DrawingAttributes(Color.Orange), this.m_PenModel, Strings.SelectCustomColorPen, PenType.Pen), new StylusEntry(new HighlighterDrawingAttributes(Color.Pink), this.m_HighlighterModel, Strings.SelectCustomColorHighlighter, PenType.Hightlighter), new StylusEntry(new DrawingAttributes(Color.Orange), this.m_TextModel, Strings.CustomColorText, PenType.Text), }, new StylusEntry[] { new StylusEntry(new DrawingAttributes(Color.Blue), this.m_PenModel, Strings.SelectBluePen, PenType.Pen), new StylusEntry(new HighlighterDrawingAttributes(Color.Cyan), this.m_HighlighterModel, Strings.SelectCyanHighlighter, PenType.Hightlighter), new StylusEntry(new DrawingAttributes(Color.Blue), this.m_TextModel, Strings.BlueText, PenType.Text), }, new StylusEntry[] { new StylusEntry(new DrawingAttributes(Color.Green), this.m_PenModel, Strings.SelectGreenPen, PenType.Pen), new StylusEntry(new HighlighterDrawingAttributes(Color.LawnGreen), this.m_HighlighterModel, Strings.SelectGreenHighlighter, PenType.Hightlighter), new StylusEntry(new DrawingAttributes(Color.Green), this.m_TextModel, Strings.GreenText, PenType.Text), }, new StylusEntry[] { new StylusEntry(new DrawingAttributes(Color.Red), this.m_PenModel, Strings.SelectRedPen, PenType.Pen), new StylusEntry(new HighlighterDrawingAttributes(Color.Magenta), this.m_HighlighterModel, Strings.SelectMagentaHighlighter, PenType.Hightlighter), new StylusEntry(new DrawingAttributes(Color.Red), this.m_TextModel, Strings.RedText, PenType.Text), }, new StylusEntry[] { new StylusEntry(new DrawingAttributes(Color.Yellow), this.m_PenModel, Strings.SelectYellowPen, PenType.Pen), new StylusEntry(new HighlighterDrawingAttributes(Color.Yellow), this.m_HighlighterModel, Strings.SelectYellowHighlighter, PenType.Hightlighter), new StylusEntry(new DrawingAttributes(Color.Yellow), this.m_TextModel, Strings.YellowText, PenType.Text), }, new StylusEntry[] { new StylusEntry(this.m_PenAtts, this.m_PenModel, Strings.SelectBlackPen, PenType.Pen), new StylusEntry(this.m_HighLighterAtts, this.m_HighlighterModel, Strings.SelectOrangeHighlighter, PenType.Hightlighter), new StylusEntry(new DrawingAttributes(Color.Black), this.m_TextModel, Strings.BlackText, PenType.Text), }, }; }
internal bool NeedsUpdate(DrawingAttributes d) { if(d.AntiAliased != this.AntiAliased) return true; if(!d.Color.Equals(this.Color)) return true; foreach(ExtendedProperty prop in this.ExtendedProperties) if(!d.ExtendedProperties.DoesPropertyExist(prop.Id) || d.ExtendedProperties[prop.Id].Data.Equals(prop.Data)) return true; // FIXME: Verify that there are no extended properties in d that don't exist in this.ExtendedProperties (tough to do efficiently). if(d.FitToCurve != this.FitToCurve) return true; if(d.Height != this.Height) return true; if(d.IgnorePressure != this.IgnorePressure) return true; if(d.PenTip != this.PenTip) return true; if(d.RasterOperation != this.RasterOperation) return true; if(d.Transparency != this.Transparency) return true; if(d.Width != this.Width) return true; return false; }
public StrokeBase(StylusPointCollection pts, DrawingAttributes da) : base(pts, da) { this.StylusPoints = pts; this.DrawingAttributes = da; }
/// <summary> /// Compares two sets of drawing attributes to determine if they're equal /// </summary> /// <param name="left">The first set</param> /// <param name="right">The second set</param> /// <returns></returns> public static bool DrawingAttributesEquals(DrawingAttributes left, DrawingAttributes right) { if(left.AntiAliased != right.AntiAliased) return false; if(!left.Color.Equals(right.Color)) return false; if(left.ExtendedProperties.Count != right.ExtendedProperties.Count) return false; foreach(ExtendedProperty prop in left.ExtendedProperties) { if(!right.ExtendedProperties.DoesPropertyExist(prop.Id)) return false; object data = right.ExtendedProperties[prop.Id].Data; if(data == null && prop.Data != null || !data.Equals(prop.Data)) return false; } if(left.FitToCurve != right.FitToCurve) return false; if(left.Height != right.Height) return false; if(left.IgnorePressure != right.IgnorePressure) return false; if(left.PenTip != right.PenTip) return false; if(left.RasterOperation != right.RasterOperation) return false; if(left.Transparency != right.Transparency) return false; if(left.Width != right.Width) return false; return true; }