Example #1
0
        private void PointerPressed(InkPoint point, PointerPoint pointer)
        {
            TmpRectGra = (GraphicsRectSizeBase)GraphicsInstCreateManager.CreateGraphics(Drawer.PenType, Drawer.LocPenModel, Drawer, InkCanvasSharp);
            Drawer.GraphicsRects.Add(TmpRectGra);
            TmpRectGra.BeginDraw(point, pointer);
            //TmpRectGra.PenAttribute.SetLinerPoints(TmpRectGra.Bounds);
            TmpRectGra.IsFill = Drawer.IsFill;
            Drawer.HistoriesManager.PushHistory(new CreateGraphicsHistory(Drawer, TmpRectGra));
            Drawer.LocPenModel = Drawer.LocPenModel.Copy();

            /*
             * if (TmpRectGra is GraphicsTextModel)
             * {
             *  var tm = (TmpRectGra as GraphicsTextModel);
             *  tm.Text = Drawer.Text;
             *  tm.TextFormat = Drawer.TextFormat;
             *
             *  var ctf = new CanvasTextFormat();
             *  var propdic = new Dictionary<string, PropertyInfo>();
             *  foreach (var item in ctf.GetType().GetProperties())
             *  {
             *      propdic.Add(item.Name, item);
             *  }
             *  Drawer.TextFormat.GetType().GetProperties().ToList().ForEach(prop =>propdic[prop.Name].SetValue(ctf, prop.GetValue(Drawer.TextFormat)));
             *
             *  //??????
             *  Drawer.TextFormat = new CanvasTextFormat() { FontSize=Drawer.TextFormat.FontSize};
             * }
             */
        }
 private void PointerPressed(InkPoint point, PointerPoint p)
 {
     Drawer.LocPenModel.SetSolidColorBrush(Colors.White);//可以为背景颜色
     TmpRectGra        = (GraphicsRectSizeBase)GraphicsInstCreateManager.CreateGraphics(GraphicsTypes.CurveLine, Drawer.LocPenModel, Drawer, InkCanvasSharp);
     TmpRectGra.IsLock = true;
     Drawer.GraphicsRects.Add(TmpRectGra);
     TmpRectGra.BeginDraw(point, p);
     Drawer.HistoriesManager.PushHistory(new CreateGraphicsHistory(Drawer, TmpRectGra));
     Drawer.LocPenModel = Drawer.LocPenModel.Copy();
 }
Example #3
0
        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);
        }
Example #4
0
        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);
        }