示例#1
0
        /// <summary>
        /// Undo the last operation perform on the {@link NiceArtEditor}
        /// </summary>
        /// <returns>true if there nothing more to undo</returns>
        public bool Undo(ViewType viewType)
        {
            try
            {
                if (AddedViews.Count > 0)
                {
                    var view = AddedViews.LastOrDefault();
                    if (view != null)
                    {
                        if (view.GetType() == typeof(BrushDrawingView))
                        {
                            return(BrushDrawingView != null && BrushDrawingView.Undo());
                        }
                        else
                        {
                            AddedViews.Remove(view);
                            ParentView.RemoveView(view);
                            RedoViews.Add(view);
                        }
                    }

                    if (MOnNiceArtEditorListener != null)
                    {
                        MOnNiceArtEditorListener?.OnRemoveViewListener(AddedViews.Count);
                        MOnNiceArtEditorListener.OnRemoveViewListener(viewType, AddedViews.Count);
                    }
                }
                return(AddedViews.Count != 0);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(false);
            }
        }
        public void OnViewRemoved(BrushDrawingView brushDrawingView)
        {
            try
            {
                if (AddedViews.Count > 0)
                {
                    var item = AddedViews.LastOrDefault();
                    if (item != null)
                    {
                        AddedViews.Remove(item);
                        if (!(item.GetType() == typeof(BrushDrawingView)))
                        {
                            ParentView.RemoveView(item);
                        }
                        RedoViews.Add(item);
                    }
                }

                if (MOnNiceArtEditorListener != null)
                {
                    MOnNiceArtEditorListener?.OnRemoveViewListener(ViewType.BrushDrawing, AddedViews.Count);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
 public void ViewUndo(View removedView, ViewType viewType)
 {
     try
     {
         if (AddedViews.Count > 0)
         {
             if (AddedViews.Contains(removedView))
             {
                 ParentView.RemoveView(removedView);
                 AddedViews.Remove(removedView);
                 RedoViews.Add(removedView);
                 if (MOnNiceArtEditorListener != null)
                 {
                     MOnNiceArtEditorListener.OnRemoveViewListener(viewType, AddedViews.Count);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 public void ViewUndo(View removedView, ViewType viewType)
 {
     try
     {
         if (AddedViews.Count > 0)
         {
             if (AddedViews.Contains(removedView))
             {
                 ParentView.RemoveView(removedView);
                 AddedViews.Remove(removedView);
                 RedoViews.Add(removedView);
                 if (MOnNiceArtEditorListener != null)
                 {
                     MOnNiceArtEditorListener.OnRemoveViewListener(AddedViews.Count);
                     MOnNiceArtEditorListener.OnRemoveViewListener(viewType, AddedViews.Count);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }