예제 #1
0
        /// <inheritdoc />
        public async Task ExecuteUserActionAsync()
        {
            var openPicker = new FileOpenPicker();

            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".json");
            openPicker.ViewMode = PickerViewMode.List;

            StorageFile file = await openPicker.PickSingleFileAsync();

            if (file != null)
            {
                string jsonString = await FileIO.ReadTextAsync(file);

                List <PaintBase> newShapeList = DeserializeJsonSave(jsonString);

                // Clear undo, redo and master list
                UndoStack.Clear();
                RedoStack.Clear();
                ShapeList.Clear();
                // Add deserialized master list to main page
                ShapeList.AddRange(newShapeList);

                // Send draw and update list commands to main page
                _page.Draw();
                _page.UpdateList();
            }
        }
예제 #2
0
 internal void PastSelected()
 {
     try
     {
         List <Shape> copyShapes = (List <Shape>)MyDeSerialize();
         ShapeList.AddRange(copyShapes);
     }catch (Exception e)
     {
     }
 }
예제 #3
0
 /// <summary>
 /// Разгрупиране формите.
 /// </summary>
 public void UnGroup()
 {
     for (int i = 0; i < Selection.Count; i++)
     {
         if (Selection[i] is GroupShape)
         {
             var ungroupedShapes = (Selection[i] as GroupShape).SubItems;
             ShapeList.AddRange(ungroupedShapes);
             ShapeList.RemoveAt(ShapeList.IndexOf(Selection[i]));
             Selection.AddRange(ungroupedShapes);
             Selection.RemoveAt(i);
             i -= 1;
         }
     }
 }
예제 #4
0
        /// <inheritdoc />
        public Task ExecuteUserActionAsync()
        {
            if (UndoStack.Count > 0)
            {
                List <PaintBase> newState = UndoStack.Pop();
                RedoStack.Push(ShapeList.DeepCopy());

                ShapeList.Clear();
                ShapeList.AddRange(newState);

                _page.Draw();
                _page.UpdateList();
            }

            return(Task.CompletedTask);
        }
예제 #5
0
 public void PasteShape()
 {
     if (_copiedShape != null)
     {
         if (_copiedShape is GroupShape gs)
         {
             var shapes = gs.CopyShapes();
             ShapeList.AddRange(shapes);
         }
         else
         {
             var newShape = _copiedShape.Copy();
             ShapeList.Add(newShape);
             Select(newShape);
         }
     }
 }
예제 #6
0
        public void ReGroup()
        {
            for (int i = 0; i < Selection.Count; i++)
            {
                if (Selection[i].GetType().Equals(typeof(GroupShapeImpl)))
                {
                    GroupShapeImpl group = (GroupShapeImpl)Selection[i];

                    ShapeList.AddRange(group.SubItem);
                    group.SubItem.Clear();
                    Selection[i] = null;
                    group        = null;
                    ShapeList.Remove(Selection[i]);
                    Selection.Remove(Selection[i]);
                }
            }
            GC.Collect();
        }
예제 #7
0
 public void UnGroup()
 {
     for (int i = 0; i < Selection.Count; i++)
     {
         if (Selection[i].GetType().Equals(typeof(GroupShape)))
         {
             GroupShape group = (GroupShape)Selection[i];
             ShapeList.AddRange(group.SubItems);
             group.SubItems.Clear();
             ShapeList.Remove(group);
             Selection[i] = null;
             group        = null;
             ShapeList.Remove(Selection[i]);
             Selection.Remove(Selection[i]);
         }
     }
     Selection = new List <Shape>();
 }
예제 #8
0
        /// <inheritdoc />
        public Task ExecuteUserActionAsync()
        {
            if (RedoStack.Count > 0)
            {
                // Pop prior state from stack
                List <PaintBase> newState = RedoStack.Pop();
                // Push current state onto the undo stack
                UndoStack.Push(ShapeList.DeepCopy());

                // Add prior state as current state
                ShapeList.Clear();
                ShapeList.AddRange(newState);

                _page.Draw();
                _page.UpdateList();
            }

            return(Task.CompletedTask);
        }
        internal void UnGroupSelectedShapes()
        {
            for (int i = 0; i < Selection.Count; i++)
            {
                if (Selection[i].GetType().Equals(typeof(GroupShape)))
                {
                    GroupShape gs = (GroupShape)Selection[i];

                    ShapeList.AddRange(gs.Shapes);
                    Selection.AddRange(gs.Shapes);
                    gs.Shapes.Clear();
                    gs.Rectangle = new RectangleF();
                    Selection[i] = null;
                    gs           = null;
                    ShapeList.Remove(Selection[i]);
                    Selection.Remove(Selection[i]);
                }
            }
        }
예제 #10
0
        internal void PasteSelected()
        {
            List <Shape> copy = (List <Shape>)MyDeSerialize();

            ShapeList.AddRange(copy);
        }