示例#1
0
 public UndoItem(string text, MyEditor editor, TextPoint position, UndoType type)
 {
     this.text     = text;
     this.editor   = editor;
     this.position = position;
     this.type     = type;
 }
示例#2
0
        /// <summary>
        /// Create undo point
        /// </summary>
        /// <param name="saveMsg"></param>
        public void CreateRestorePoint(UndoType type, string saveMsg = default(string))
        {
            // Get
            TerrainData td = TP.Instance.TerrainData;
            if (td.splatPrototypes.Length < 2) { return; }
            while (m_currentIndex != history.Count) { history.RemoveAt(m_currentIndex); }

            // Add and clean
            HistoryContainer c = new HistoryContainer(type, saveMsg);
            switch (type)
            {
                case UndoType.Splatmap:
                    c.splatData = td.GetAlphamaps(0, 0, td.alphamapWidth, td.alphamapHeight);
                    break;
                case UndoType.DetailMap:
                    c.detailData = new int[td.detailPrototypes.Length][,];
                    for (int i = 0; i < td.detailPrototypes.Length; i++) { c.detailData[i] = td.GetDetailLayer(0, 0, td.detailWidth, td.detailHeight, i); }
                    break;
                //default: return;
            }

            history.Add(c);
            while (history.Count > m_capacity + 1) { history.RemoveAt(0); }
            m_currentIndex = history.Count;
            m_hasCreatedCurrentRestore = false;
        }
示例#3
0
 public bool CanUndo(UndoType undoType)
 {
     lock (thisLock)
     {
         return(Record.CanUndo((int)undoType));
     }
 }
示例#4
0
 public Undo(WP6Document doc, int index, int size)
     : base(doc, index, size)
 {
     undoType = (UndoType)Enum.Parse(typeof(UndoType), functionData[0].ToString());
     // bytes 1 and 2 are not useful for external applications
     name = FixedLengthGroup.undo;
 }
示例#5
0
        public static IUndoItem CreateUndoItem(UndoType undoType)
        {
            Type type;

            if (types.TryGetValue(undoType, out type))
            {
                return(Activator.CreateInstance(type) as IUndoItem);
            }
            return(null);
        }
示例#6
0
        public void Show(IList <Chat> chats, UndoType type, Action <IList <Chat> > undo, Action <IList <Chat> > action = null)
        {
            _timeout.Stop();
            _storyboard?.Stop();

            _remaining = 5;
            _queue.Enqueue(new UndoOp(chats, undo, action));

            _timeout.Start();

            if (type == UndoType.Archive)
            {
                Text.Text = chats.Count > 1 ? Strings.Resources.ChatsArchived : Strings.Resources.ChatArchived;

                Remaining.Visibility = Visibility.Collapsed;
                Slice.Visibility     = Visibility.Collapsed;
                Player.Source        = new Assets.Animations.ChatArchivedAnimation();

                _ = Player.PlayAsync(0, 1, false);
            }
            else
            {
                if (type == UndoType.Clear)
                {
                    Text.Text = Strings.Resources.HistoryClearedUndo;
                }
                else if (chats.Count == 1 && chats[0] is Chat chat)
                {
                    if (chat.Type is ChatTypeSupergroup super)
                    {
                        Text.Text = super.IsChannel ? Strings.Resources.ChannelDeletedUndo : Strings.Resources.GroupDeletedUndo;
                    }
                    else
                    {
                        Text.Text = chat.Type is ChatTypeBasicGroup ? Strings.Resources.GroupDeletedUndo : Strings.Resources.ChatDeletedUndo;
                    }
                }
                else
                {
                    Text.Text = Strings.Resources.ChatDeletedUndo;
                }

                Remaining.Visibility = Visibility.Visible;
                Slice.Visibility     = Visibility.Visible;
                Player.Source        = null;
            }

            IsEnabled = true;

            Slice.StartAngle  = 0;
            Remaining.Content = 5;

            StartAnimation();
            Grid.SetRow(LayoutRoot, 0);
        }
示例#7
0
        public void Undo(UndoType undoType)
        {
            lock (thisLock)
            {
                if (!CanUndo(undoType))
                {
                    throw new InvalidOperationException("Undoできません.");
                }

                State = Record.Undo((int)undoType).Clone();
            }
        }
示例#8
0
		public UndoPoint(Element element, UndoAction action)
		{
			if (! (element is Shape || element is Line)) throw new UndoPointException("Element must be of type Shape or type Line.");
			
			mKey = element.Key;
			mBytes = SerializeElement(element);
			mAction = action;
			mObjectType = element.GetType();
			if (element is Shape) mUndoType = UndoType.Shape;
			if (element is Line) mUndoType = UndoType.Line;

			mContainer = element.Container;
			mLayer = element.Layer;
		}
示例#9
0
        /// <summary>
        /// Create undo point
        /// </summary>
        /// <param name="saveMsg"></param>
        public void CreateRestorePoint(UndoType type, string saveMsg = default(string))
        {
            // Get
            TerrainData td = TP.Instance.TerrainData;

            if (td.splatPrototypes.Length < 2)
            {
                return;
            }
            while (m_currentIndex != history.Count)
            {
                history.RemoveAt(m_currentIndex);
            }

            // Add and clean
            HistoryContainer c = new HistoryContainer(type, saveMsg);

            switch (type)
            {
            case UndoType.Splatmap:
                c.splatData = td.GetAlphamaps(0, 0, td.alphamapWidth, td.alphamapHeight);
                break;

            case UndoType.DetailMap:
                c.detailData = new int[td.detailPrototypes.Length][, ];
                for (int i = 0; i < td.detailPrototypes.Length; i++)
                {
                    c.detailData[i] = td.GetDetailLayer(0, 0, td.detailWidth, td.detailHeight, i);
                }
                break;
                //default: return;
            }

            history.Add(c);
            while (history.Count > m_capacity + 1)
            {
                history.RemoveAt(0);
            }
            m_currentIndex             = history.Count;
            m_hasCreatedCurrentRestore = false;
        }
示例#10
0
        public UndoPoint(Element element, UndoAction action)
        {
            if (!(element is Shape || element is Line))
            {
                throw new UndoPointException("Element must be of type Shape or type Line.");
            }

            mKey        = element.Key;
            mBytes      = SerializeElement(element);
            mAction     = action;
            mObjectType = element.GetType();
            if (element is Shape)
            {
                mUndoType = UndoType.Shape;
            }
            if (element is Line)
            {
                mUndoType = UndoType.Line;
            }

            mContainer = element.Container;
            mLayer     = element.Layer;
        }
 public UndoData(UndoType tipe, string config)
 {
     undoType = tipe;
     configuration = config;
 }
 public UndoItem(string text, MyEditor editor, TextPoint position, UndoType type)
 {
     this.text = text;
     this.editor = editor;
     this.position = position;
     this.type = type;
 }
示例#13
0
 public HistoryContainer(UndoType type, string msg = default(string))
 {
     undoType = type;
     message  = msg;
 }
示例#14
0
 public HistoryContainer(UndoType type, string msg = default(string))
 {
     undoType = type;
     message = msg;
 }