void SketchPageImpl(bool createDefaultLayer) { Layers = new ObservableCollection <PageLayer>(); if (createDefaultLayer) { var defaultLayer = new PageLayer(); Layers.Add(defaultLayer); //SelectedLayer = defaultLayer; } }
private async void LoadSketch(int sketchId) { var foundS = StorageService.Instance.Storage.RetrieveById<SketchDataModel>(sketchId); if (foundS != null && foundS.Count() > 0) { var fs = foundS.First(); var foundSP = StorageService.Instance.Storage.RetrieveByField<SketchPageDataModel>("SketchId", fs.Id.ToString()); if (foundSP != null && foundSP.Count() > 0) { foreach (var fsp in foundSP) { var pg = new SketchPage() { Title = fsp.Title, Width = (int)fsp.Width, Height = (int)fsp.Height, Top = (int)fsp.Top, Left = (int)fsp.Left }; var foundSPL = StorageService.Instance.Storage.RetrieveByField<SketchPageLayerDataModel>("SketchPageId", fsp.Id.ToString()); if (foundSPL != null && foundSPL.Count() > 0) { foreach (var fspl in foundSPL) { var pl = new PageLayer() { PersistedId = fspl.Id, HasChildContainerCanvas = fspl.HasChildContainerCanvas }; //add xamlfrags var foundSPLXF = StorageService.Instance.Storage.RetrieveByField<SketchPageLayerXamlFragmentDataModel>("SketchPageLayerId", fspl.Id.ToString()); if (foundSPLXF != null && foundSPLXF.Count() > 0) { foreach (var fsplxf in foundSPLXF) { var dt = string.IsNullOrEmpty(fsplxf.DataType) ? null : Type.GetType(fsplxf.DataType); var xf = new XamlFragment() { Uid = fsplxf.Uid, Xaml = fsplxf.Xaml, Data = fsplxf.Data, Type = dt }; pl.XamlFragments.Add(xf); } } pg.Layers.Add(pl); } } var nc = new Controls.PageLayout() { DataContext = pg, Width = pg.Width, Height = pg.Height }; nc.SetValue(Windows.UI.Xaml.Controls.Canvas.LeftProperty, pg.Left); nc.SetValue(Windows.UI.Xaml.Controls.Canvas.TopProperty, pg.Top); nc.PerformAction += PageLayout_PerformAction; cvMain.Children.Add(nc); vm.Pages.Add(pg); //// add xaml frags //foreach (var pl in pg.Layers) //{ // var foundSPLXF = StorageService.Instance.Storage.RetrieveByField<SketchPageLayerXamlFragmentDataModel>("SketchPageLayerId", pl.PersistedId.ToString()); // if (foundSPLXF != null && foundSPLXF.Count() > 0) // { // foreach (var fsplxf in foundSPLXF) // { // var dt = string.IsNullOrEmpty(fsplxf.DataType) ? null: Type.GetType(fsplxf.DataType); // var xf = new XamlFragment() { Uid = fsplxf.Uid, Xaml = fsplxf.Xaml, Data = fsplxf.Data, Type = dt }; // pl.XamlFragments.Add(xf); // } // } // pl.ExternalPC("Layers"); //} } } // foreach (var pgg in vm.Pages) // { // pgg.ExternalPC("Layers"); // } } }
private void Stamp_PerformAction(object sender, EventArgs e) { _currentStamp = (UIElement)sender; _stampStartX = (double)_currentStamp.GetValue(Windows.UI.Xaml.Controls.Canvas.LeftProperty); _stampStartY = (double)_currentStamp.GetValue(Windows.UI.Xaml.Controls.Canvas.TopProperty); if (e is Controls.Stamps.ResizeMoveEdgesEventArgs) { var te = e as Controls.Stamps.ResizeMoveEdgesEventArgs; _stampStartWidth = ((FrameworkElement)_currentStamp).Width; _stampStartHeight = ((FrameworkElement)_currentStamp).Height; _stampEA = e; IsResizingStamp = true; } else if (e is IStampEventArgs) { var te = e as IStampEventArgs; var stamp = ((IStamp)_currentStamp); if (te.ActionType == eActionTypes.CloseStamp) { stamp.PerformAction -= Stamp_PerformAction; cvMainAdorner.Children.Remove((UIElement)stamp); return; } else if (te.ActionType == eActionTypes.RotateBottomLeft) { _stampStartRotation = ((CompositeTransform)((UIElement)stamp).RenderTransform).Rotation; } if (te.ActionType == eActionTypes.CreateFromStamp) { if (_currentPageLayoutForStamps != null) { var plvm = _currentPageLayoutForStamps.DataContext as SketchPage; var npl = new PageLayer(); var gt = ((FrameworkElement)stamp).TransformToVisual(_currentPageLayoutForStamps); npl.HasChildContainerCanvas = true; var ptCenter = gt.TransformPoint(new Windows.Foundation.Point(0, 0)); var uid = RandomString(15); var str = stamp.GenerateXAML(uid, cvMainContainer.Scale, cvMainContainer.Scale, ptCenter.X, ptCenter.Y); npl.XamlFragments.Add(new XamlFragment() { Uid = uid, Xaml = str, Type = stamp.GetType(), Data = stamp.GetData() }); plvm.Layers.Add(npl); plvm.ExternalPC("Layers"); } } } }
private async void LoadSketch(int sketchId) { var foundS = StorageService.Instance.Storage.RetrieveById <SketchDataModel>(sketchId); if (foundS != null && foundS.Count() > 0) { var fs = foundS.First(); var foundSP = StorageService.Instance.Storage.RetrieveByField <SketchPageDataModel>("SketchId", fs.Id.ToString()); if (foundSP != null && foundSP.Count() > 0) { foreach (var fsp in foundSP) { var pg = new SketchPage(false) { Title = fsp.Title, Width = (int)fsp.Width, Height = (int)fsp.Height, Top = (int)fsp.Top, Left = (int)fsp.Left }; var foundSPL = StorageService.Instance.Storage.RetrieveByField <SketchPageLayerDataModel>("SketchPageId", fsp.Id.ToString()); if (foundSPL != null && foundSPL.Count() > 0) { foreach (var fspl in foundSPL) { var pl = new PageLayer() { PersistedId = fspl.Id, HasChildContainerCanvas = fspl.HasChildContainerCanvas }; //add xamlfrags var foundSPLXF = StorageService.Instance.Storage.RetrieveByField <SketchPageLayerXamlFragmentDataModel>("SketchPageLayerId", fspl.Id.ToString()); if (foundSPLXF != null && foundSPLXF.Count() > 0) { foreach (var fsplxf in foundSPLXF) { var dt = string.IsNullOrEmpty(fsplxf.DataType) ? null : Type.GetType(fsplxf.DataType); var xf = new XamlFragment() { Uid = fsplxf.Uid, Xaml = fsplxf.Xaml, Data = fsplxf.Data, Type = dt }; pl.XamlFragments.Add(xf); } } pg.Layers.Add(pl); } } var nc = new Controls.PageLayout() { DataContext = pg, Width = pg.Width, Height = pg.Height }; nc.SetValue(Windows.UI.Xaml.Controls.Canvas.LeftProperty, pg.Left); nc.SetValue(Windows.UI.Xaml.Controls.Canvas.TopProperty, pg.Top); nc.PerformAction += PageLayout_PerformAction; cvMain.Children.Add(nc); vm.Pages.Add(pg); //// add xaml frags //foreach (var pl in pg.Layers) //{ // var foundSPLXF = StorageService.Instance.Storage.RetrieveByField<SketchPageLayerXamlFragmentDataModel>("SketchPageLayerId", pl.PersistedId.ToString()); // if (foundSPLXF != null && foundSPLXF.Count() > 0) // { // foreach (var fsplxf in foundSPLXF) // { // var dt = string.IsNullOrEmpty(fsplxf.DataType) ? null: Type.GetType(fsplxf.DataType); // var xf = new XamlFragment() { Uid = fsplxf.Uid, Xaml = fsplxf.Xaml, Data = fsplxf.Data, Type = dt }; // pl.XamlFragments.Add(xf); // } // } // pl.ExternalPC("Layers"); //} } } // foreach (var pgg in vm.Pages) // { // pgg.ExternalPC("Layers"); // } } }