/// <summary> /// Asigna el lápiz a una figura /// </summary> internal static void AssignPen(Shape shape, PenModel pen) { if (pen != null) { // Asigna los datos del lápiz shape.Stroke = new SolidColorBrush(Color.FromArgb(pen.Color.Alpha, pen.Color.Red, pen.Color.Green, pen.Color.Blue)); shape.StrokeThickness = pen.Thickness; // Añade los puntos foreach (double dblDot in pen.Dots) { shape.StrokeDashArray.Add(dblDot); } shape.StrokeDashCap = Convert(pen.CapDots); if (pen.DashOffset != null) { shape.StrokeDashOffset = pen.DashOffset ?? 0; } if (pen.MiterLimit != null) { shape.StrokeMiterLimit = pen.MiterLimit ?? 1; } shape.StrokeStartLineCap = Convert(pen.StartLineCap); shape.StrokeEndLineCap = Convert(pen.EndLineCap); shape.StrokeLineJoin = Convert(pen.JoinMode); } }
public PenButton(PenModel model) { PenModel = model; PenModel.PropertyChanged += PenModel_PropertyChanged; this.Icon = new SymbolIcon(model.IsHighlighter ? Symbol.Highlight : Symbol.Edit); this.Foreground = new SolidColorBrush(model.Color); this.Label = model.LineStyle.ToString() + (model.EnableArrow ? " Arrow" : ""); }
public void Initialize(PenModel pen) { CurrentPen = pen; CurrentPen.PropertyChanged += PenChanged; //RefreshQuickPens(); PenChanged(this, null); }
public CanvasData LineConverter(InkStrokeConverterArgs args) { var sk = args.StrokeBuilder.CreateStrokeFromInkPoints(args.Graphics.Points, args.PenAttribute.PenTipTransform); sk.StrokeDuration = new TimeSpan((long)args.Graphics.Graphics); sk.DrawingAttributes = PenModel.ToInkDrawingAttributes(args.Graphics.PenAttribute); args.Canvas.InkPresenter.StrokeContainer.AddStroke(sk); return(null); }
public CustomInkCanvas() { CurrentPen = new PenModel() { IsFreehand = true, Color = Colors.Blue, LineStyle = PenModel.LineType.Solid, Size = 10 }; this.InitializeComponent(); _inkCanvas = this.InkCanvas; _canvas = this.LineCanvas; _actorCanvas = this.ActorCanvas; _savePoint = new Dictionary <object, int>(); _currentContent = new Dictionary <object, int>(); _redo = new Dictionary <object, int>(); _synch = _inkCanvas.InkPresenter.ActivateCustomDrying(); _inkCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Mouse | Windows.UI.Core.CoreInputDeviceTypes.Pen; _inkCanvas.InkPresenter.StrokesCollected += InkPresenter_StrokesCollected; //QuickPens = StorageIO.QuickPens; CreateSavePointCmd = new Command() { CanExecuteFunc = obj => true, ExecuteFunc = CreateSavePoint }; ClearQuickPensCmd = StorageIO.ClearQuickPensCmd; AddQuickPenCmd = StorageIO.AddQuickPenCmd; LoadQuickPenCmd = new Command <PenModel>() { CanExecuteFunc = obj => true, ExecuteFunc = LoadQuickPen }; ClearLinesCmd = new Command() { CanExecuteFunc = obj => true, ExecuteFunc = Clear }; SetLineStyleCmd = new Command <string>() { CanExecuteFunc = obj => true, ExecuteFunc = SetLineStyle }; UndoCmd = new Command() { CanExecuteFunc = obj => true, ExecuteFunc = Undo }; RedoCmd = new Command() { CanExecuteFunc = obj => true, ExecuteFunc = Redo }; this.DataContext = this; CurrentPen.PropertyChanged += CurrentPen_PropertyChanged; SmoothingFactor = 16; }
public GraphicsBase(GraphicsTypes graphics, PenModel penModel, IGraphicsDraw draw, IInkCanvasSharp canvasSharp) { Graphics = graphics; Drawer = draw; InkCanvasSharp = canvasSharp; PenAttribute = penModel; IsFill = false; IsLock = false; IsSelected = false; IsAppear = true; }
public void SetPen(PenModel currentPen) { if (currentPen == null) { return; } CurrentPen = currentPen; CurrentPen.PropertyChanged += CurrentPen_PropertyChanged; PenChanged(this, null); }
private void PenTypeChanged(GraphicsTypes obj) { if (obj == GraphicsTypes.Eraser) { OldPenModel = Drawer.LocPenModel.Copy(); } else if (obj != GraphicsTypes.EraserGraphics) { Drawer.LocPenModel = OldPenModel; } }
public GraphicsRectSizeBase(GraphicsTypes graphics, PenModel penModel, IGraphicsDraw draw)//AFTER:以后再改 : base(graphics, penModel, draw, draw as IInkCanvasSharp) { Points = new List <InkPoint>(); StrokeStyle = new CanvasStrokeStyle() { DashCap = CanvasCapStyle.Round, LineJoin = CanvasLineJoin.Round, StartCap = CanvasCapStyle.Round, EndCap = CanvasCapStyle.Round }; }
public async Task <bool> ReadInFolderAsync() { Debug.Assert(IsDeWrapper); var folders = (await TmpFolder.GetFoldersAsync()).Where(folder => folder.DisplayName == InkStrokesFolderName).ToList(); if (folders.Count != 0) { var folder = folders[0]; var files = (await folder.GetFilesAsync()).Where(f => f.FileType.ToLower() == ".isf"); foreach (var file in files) { var ic = new InkCanvas(); var filename = file.Name.Substring(0, file.Name.Length - 4); using (var fs = await file.OpenAsync(FileAccessMode.ReadWrite)) { await ic.InkPresenter.StrokeContainer.LoadAsync(fs); } var strokes = ic.InkPresenter.StrokeContainer.GetStrokes().ToList(); var gslength = Enum.GetValues(typeof(GraphicsTypes)).Length; var layer = new LayerModel(); foreach (var stroke in strokes) { var gi = stroke.StrokeDuration.Value.Ticks; if (gi > 0 && gi < gslength) { var gr = (GraphicsRectSizeBase)GraphicsInstCreateManager.CreateGraphics((GraphicsTypes)gi, layer.LocPenModel, layer, layer); Debug.Assert(gr != null); stroke.GetInkPoints().ToList().ForEach(p => gr.Points.Add(p)); gr.PenAttribute = PenModel.ToPenModel(stroke.DrawingAttributes); layer.GraphicsRects.Add(gr); } } layer.Name = filename; layer.CanvasSize = CanvasSize; Debug.Assert(XmlDoc != null); var xmlEle = XmlDoc.SelectSingleNode(filename); if (xmlEle != null) { var layerData = xmlEle.ChildNodes.Where(xmlNode => xmlNode.NodeName == "IsLock" || xmlNode.NodeName == "IsAppear").ToArray(); Debug.Assert(layerData.Count() == 2); layer.IsLock = Convert.ToBoolean(layerData[0].InnerText); layer.IsAppear = Convert.ToBoolean(layerData[1].InnerText); } //TODO:Init Others Reading?.Invoke(XmlDoc); Layers.Add(layer); } return(true); } return(false); }
/// <summary> /// Carga los datos de un lápiz /// </summary> private PenModel LoadPen(MLNode nodeML) { PenModel pen = new PenModel(); // Asigna los valores pen.Color = new ColorModel(nodeML.Attributes[ComicRepositoryConstants.TagColor].Value); pen.Thickness = nodeML.Attributes[ComicRepositoryConstants.TagWidth].Value.GetDouble(1); pen.Dots.AddRange(GetDots(nodeML.Attributes[ComicRepositoryConstants.TagDots].Value)); pen.CapDots = GetLineCap(nodeML.Attributes[ComicRepositoryConstants.TagCapDots].Value); pen.StartLineCap = GetLineCap(nodeML.Attributes[ComicRepositoryConstants.TagStartLineCap].Value); pen.EndLineCap = GetLineCap(nodeML.Attributes[ComicRepositoryConstants.TagEndLineCap].Value); pen.JoinMode = GetLineJoin(nodeML.Attributes[ComicRepositoryConstants.TagJoinMode].Value); pen.DashOffset = nodeML.Attributes[ComicRepositoryConstants.TagDashOffset].Value.GetDouble(); pen.MiterLimit = nodeML.Attributes[ComicRepositoryConstants.TagMiterLimit].Value.GetDouble(); // Devuelve el lápiz return(pen); }
public async Task <bool> ReadInFolderAsync() { Debug.Assert(IsDeWrapper && IsInitSucceed); var folders = (await TmpFolder.GetFoldersAsync()) .Where(folder => folder.DisplayName == InkStrokesFolderName) .ToList(); if (folders.Count != 0) { var folder = folders[0]; var files = (await folder.GetFilesAsync()).Where(f => f.FileType.ToLower() == ".isf"); foreach (var file in files) { var ic = new InkCanvas(); var filename = file.Name.Substring(0, file.Name.Length - 4); using (var fs = await file.OpenAsync(FileAccessMode.ReadWrite)) { await ic.InkPresenter.StrokeContainer.LoadAsync(fs); } var strokes = ic.InkPresenter.StrokeContainer.GetStrokes().ToList(); var gslength = Enum.GetValues(typeof(GraphicsTypes)).Length; var layer = new LayerModel(); foreach (var stroke in strokes) { var gi = stroke.StrokeDuration.Value.Ticks; if (gi > 0 && gi < gslength) { var gr = (GraphicsRectSizeBase)GraphicsInstCreateManager.CreateGraphics((GraphicsTypes)gi, layer.LocPenModel, layer, layer); Debug.Assert(gr != null); stroke.GetInkPoints().ToList().ForEach(p => gr.Points.Add(p)); gr.PenAttribute = PenModel.ToPenModel(stroke.DrawingAttributes); layer.GraphicsRects.Add(gr); } } layer.Name = filename; layer.CanvasSize = CanvasSize; FileRead?.Invoke(this); Layers.Add(layer); } return(true); } return(false); }
public MainPage() { this.InitializeComponent(); // Initialize View Models _penmodel = new PenModel(); this.DataContext = _penmodel; _penmodel.PropertyChanged += _penmodel_PropertyChanged; _renderingPanelAttributes = new ObservableCollection <DrawingAttributes>(); _renderingPanelAttributes.Add(new DrawingAttributes("Page 1")); _renderingPanelAttributes.Add(new DrawingAttributes("Page 2")); Current = this; // Set up Timer this.dispatcherTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(1000) }; this.dispatcherTimer.Tick += dispatcherTimer_Tick; }
public GaussianBlurModel(PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.GaussianBlur, penModel, draw) { }
private void LoadQuickPen(PenModel obj) { CurrentPen = obj; SetPen(CurrentPen); }
public GraphicsStraightLineModel(PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.StraightLine, penModel, draw) { }
public GraphicsLineModel(PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.CurveLine, penModel, draw) { IsFill = true; }
private static void AddQuickPen(PenModel newPen) { QuickPens.Add(new PenModel(newPen)); SaveQuickPens(); }
public GraphicsTextModel(PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.Text, penModel, draw) { }
public GraphicsRoundedRectangleModel(PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.RoundRectangle, penModel, draw) { }
public GraphicsEllipseModel(PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.Ellipse, penModel, draw) { }
/// <summary> /// 暂时不用 /// </summary> /// <param name="graphics"></param> /// <param name="penModel"></param> /// <param name="draw"></param> public GraphicsScanModel(GraphicsTypes graphics, PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.Scan, penModel, draw) { }
public GraphicsImage(GraphicsTypes graphics, PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.Image, penModel, draw) { }
public static object CreateGraphics(GraphicsTypes pen, PenModel penModel, IGraphicsDraw draw, IInkCanvasSharp canvasSharp) { return(Activator.CreateInstance(Pens[pen], penModel, draw)); }
public GraphicsCircleModel(PenModel penModel, IGraphicsDraw draw) : base(GraphicsTypes.Circle, penModel, draw) { }