2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
2009-02-21 22:58:37 +00:00
|
|
|
using System.Threading;
|
2007-11-12 22:43:01 +00:00
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.IO;
|
|
|
|
using System.Reflection;
|
2008-05-29 11:54:45 +00:00
|
|
|
using CodeImp.DoomBuilder.Windows;
|
2007-11-12 22:43:01 +00:00
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using System.Diagnostics;
|
2008-05-29 11:34:01 +00:00
|
|
|
using CodeImp.DoomBuilder.Actions;
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Editing
|
|
|
|
{
|
2008-01-02 21:49:43 +00:00
|
|
|
public class UndoManager
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Undo and redo stacks
|
2007-12-08 15:18:14 +00:00
|
|
|
private List<UndoSnapshot> undos;
|
|
|
|
private List<UndoSnapshot> redos;
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
// Grouping
|
|
|
|
private UndoGroup lastgroup;
|
|
|
|
private int lastgrouptag;
|
|
|
|
|
|
|
|
// Unique tickets
|
|
|
|
private int ticketid;
|
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
// Background thread
|
|
|
|
private volatile bool dobackgroundwork;
|
|
|
|
private Thread backgroundthread;
|
|
|
|
|
2007-11-12 22:43:01 +00:00
|
|
|
// Disposing
|
|
|
|
private bool isdisposed = false;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
2008-12-24 18:27:13 +00:00
|
|
|
public UndoSnapshot NextUndo { get { if(undos.Count > 0) return undos[0]; else return null; } }
|
|
|
|
public UndoSnapshot NextRedo { get { if(redos.Count > 0) return redos[0]; else return null; } }
|
2007-11-12 22:43:01 +00:00
|
|
|
public bool IsDisposed { get { return isdisposed; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2008-01-02 21:49:43 +00:00
|
|
|
internal UndoManager()
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
ticketid = 1;
|
2007-12-08 15:18:14 +00:00
|
|
|
undos = new List<UndoSnapshot>(General.Settings.UndoLevels + 1);
|
|
|
|
redos = new List<UndoSnapshot>(General.Settings.UndoLevels + 1);
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
// Bind any methods
|
2008-04-27 12:07:26 +00:00
|
|
|
General.Actions.BindMethods(this);
|
2007-11-12 22:43:01 +00:00
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
// Start background thread
|
|
|
|
backgroundthread = new Thread(new ThreadStart(BackgroundThread));
|
2009-02-22 10:13:09 +00:00
|
|
|
backgroundthread.Name = "Snapshot Compressor";
|
2009-02-21 22:58:37 +00:00
|
|
|
backgroundthread.Priority = ThreadPriority.Lowest;
|
|
|
|
backgroundthread.IsBackground = true;
|
|
|
|
backgroundthread.Start();
|
|
|
|
|
2007-11-12 22:43:01 +00:00
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
2008-01-02 21:49:43 +00:00
|
|
|
// Disposer
|
|
|
|
internal void Dispose()
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
|
|
|
// Not already disposed?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
|
|
|
// Unbind any methods
|
2008-04-27 12:07:26 +00:00
|
|
|
General.Actions.UnbindMethods(this);
|
2009-02-21 22:58:37 +00:00
|
|
|
|
|
|
|
// Stop the thread and wait for it to end
|
|
|
|
backgroundthread.Interrupt();
|
|
|
|
backgroundthread.Join();
|
|
|
|
backgroundthread = null;
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
// Clean up
|
|
|
|
ClearUndos();
|
|
|
|
ClearRedos();
|
2008-05-26 13:11:25 +00:00
|
|
|
General.WriteLogLine("All undo and redo levels cleared.");
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
// Done
|
|
|
|
isdisposed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Private Methods
|
|
|
|
|
|
|
|
// This clears the redos
|
|
|
|
private void ClearRedos()
|
|
|
|
{
|
2009-02-21 22:58:37 +00:00
|
|
|
lock(redos)
|
|
|
|
{
|
|
|
|
// Dispose all redos
|
|
|
|
foreach(UndoSnapshot u in redos) u.Dispose();
|
|
|
|
redos.Clear();
|
|
|
|
}
|
2007-11-12 22:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This clears the undos
|
|
|
|
private void ClearUndos()
|
|
|
|
{
|
2009-02-21 22:58:37 +00:00
|
|
|
lock(undos)
|
|
|
|
{
|
|
|
|
// Dispose all undos
|
|
|
|
foreach(UndoSnapshot u in undos) u.Dispose();
|
|
|
|
undos.Clear();
|
|
|
|
}
|
2007-11-12 22:43:01 +00:00
|
|
|
}
|
|
|
|
|
2007-12-08 15:18:14 +00:00
|
|
|
// This checks and removes a level when the limit is reached
|
|
|
|
private void LimitUndoRedoLevel(List<UndoSnapshot> list)
|
|
|
|
{
|
|
|
|
UndoSnapshot u;
|
|
|
|
|
|
|
|
// Too many?
|
|
|
|
if(list.Count > General.Settings.UndoLevels)
|
|
|
|
{
|
|
|
|
// Remove one and dispose map
|
|
|
|
u = list[list.Count - 1];
|
2008-12-24 18:27:13 +00:00
|
|
|
u.Dispose();
|
2007-12-08 15:18:14 +00:00
|
|
|
list.RemoveAt(list.Count - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
// Background thread
|
|
|
|
private void BackgroundThread()
|
|
|
|
{
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
if(dobackgroundwork)
|
|
|
|
{
|
|
|
|
// First set dobackgroundwork to false before performing the work so
|
|
|
|
// that it can be set to true again when another pass is needed
|
|
|
|
dobackgroundwork = false;
|
|
|
|
|
|
|
|
int undolevel = 0;
|
|
|
|
UndoSnapshot snapshot;
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
// Get the next snapshot or leave
|
|
|
|
lock(undos)
|
|
|
|
{
|
|
|
|
if(undolevel < undos.Count)
|
|
|
|
snapshot = undos[undolevel];
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write to file or load from file, if needed
|
|
|
|
if(snapshot.StoreOnDisk && !snapshot.IsOnDisk)
|
|
|
|
snapshot.WriteToFile();
|
|
|
|
else if(!snapshot.StoreOnDisk && snapshot.IsOnDisk)
|
|
|
|
snapshot.RestoreFromFile();
|
|
|
|
|
|
|
|
// Next
|
|
|
|
undolevel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int redolevel = 0;
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
// Get the next snapshot or leave
|
|
|
|
lock(redos)
|
|
|
|
{
|
|
|
|
if(redolevel < redos.Count)
|
|
|
|
snapshot = redos[redolevel];
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write to file or load from file, if needed
|
|
|
|
if(snapshot.StoreOnDisk && !snapshot.IsOnDisk)
|
|
|
|
snapshot.WriteToFile();
|
|
|
|
else if(!snapshot.StoreOnDisk && snapshot.IsOnDisk)
|
|
|
|
snapshot.RestoreFromFile();
|
|
|
|
|
|
|
|
// Next
|
|
|
|
redolevel++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try { Thread.Sleep(30); }
|
|
|
|
catch(ThreadInterruptedException) { break; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-12 22:43:01 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Public Methods
|
|
|
|
|
2008-06-11 05:02:48 +00:00
|
|
|
// This clears all redos
|
|
|
|
public void ClearAllRedos()
|
|
|
|
{
|
|
|
|
ClearRedos();
|
|
|
|
General.MainWindow.UpdateInterface();
|
|
|
|
}
|
|
|
|
|
2008-12-24 18:27:13 +00:00
|
|
|
// This makes an undo and returns the unique ticket id
|
2008-12-31 00:44:04 +00:00
|
|
|
// Also automatically indicates that the map is changed
|
2008-12-24 18:27:13 +00:00
|
|
|
public int CreateUndo(string description)
|
|
|
|
{
|
|
|
|
return CreateUndo(description, UndoGroup.None, 0);
|
|
|
|
}
|
|
|
|
|
2007-11-12 22:43:01 +00:00
|
|
|
// This makes an undo and returns the unique ticket id
|
2008-12-31 00:44:04 +00:00
|
|
|
// Also automatically indicates that the map is changed
|
2008-04-07 14:33:41 +00:00
|
|
|
public int CreateUndo(string description, UndoGroup group, int grouptag)
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
|
|
|
UndoSnapshot u;
|
2008-12-31 00:44:04 +00:00
|
|
|
|
2007-11-12 22:43:01 +00:00
|
|
|
// Not the same as previous group?
|
|
|
|
if((group == UndoGroup.None) ||
|
|
|
|
(group != lastgroup) ||
|
|
|
|
(grouptag != lastgrouptag))
|
|
|
|
{
|
|
|
|
// Next ticket id
|
|
|
|
if(++ticketid == int.MaxValue) ticketid = 1;
|
|
|
|
|
2008-05-26 13:11:25 +00:00
|
|
|
General.WriteLogLine("Creating undo snapshot \"" + description + "\", Group " + group + ", Tag " + grouptag + ", Ticket ID " + ticketid + "...");
|
2007-11-12 22:43:01 +00:00
|
|
|
|
2008-12-06 13:20:47 +00:00
|
|
|
// Make a snapshot
|
|
|
|
u = new UndoSnapshot(description, General.Map.Map.Serialize(), ticketid);
|
2009-02-21 22:58:37 +00:00
|
|
|
|
|
|
|
lock(undos)
|
|
|
|
{
|
|
|
|
// The current top of the stack can now be written to disk
|
|
|
|
// because it is no longer the next immediate undo level
|
|
|
|
if(undos.Count > 0) undos[0].StoreOnDisk = true;
|
|
|
|
|
|
|
|
// Put it on the stack
|
|
|
|
undos.Insert(0, u);
|
|
|
|
LimitUndoRedoLevel(undos);
|
|
|
|
}
|
2007-12-08 15:18:14 +00:00
|
|
|
|
2007-11-12 22:43:01 +00:00
|
|
|
// Clear all redos
|
2008-04-20 23:47:39 +00:00
|
|
|
ClearRedos();
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
// Keep grouping info
|
|
|
|
lastgroup = group;
|
|
|
|
lastgrouptag = grouptag;
|
2008-12-31 00:44:04 +00:00
|
|
|
|
|
|
|
// Map changes!
|
|
|
|
General.Map.IsChanged = true;
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
// Update
|
2009-02-21 22:58:37 +00:00
|
|
|
dobackgroundwork = true;
|
2007-11-12 22:43:01 +00:00
|
|
|
General.MainWindow.UpdateInterface();
|
|
|
|
|
|
|
|
// Done
|
|
|
|
return ticketid;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This removes a previously made undo
|
|
|
|
public void WithdrawUndo(int ticket)
|
|
|
|
{
|
|
|
|
// Anything to undo?
|
|
|
|
if(undos.Count > 0)
|
|
|
|
{
|
|
|
|
// Check if the ticket id matches
|
2008-12-24 18:27:13 +00:00
|
|
|
if(ticket == undos[0].TicketID)
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
2008-12-24 18:27:13 +00:00
|
|
|
General.WriteLogLine("Withdrawing undo snapshot \"" + undos[0].Description + "\", Ticket ID " + ticket + "...");
|
2008-05-26 13:11:25 +00:00
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
lock(undos)
|
|
|
|
{
|
|
|
|
// Remove the last made undo
|
|
|
|
undos[0].Dispose();
|
|
|
|
undos.RemoveAt(0);
|
|
|
|
|
|
|
|
// Make the current top of the stack load into memory
|
|
|
|
// because it just became the next immediate undo level
|
|
|
|
if(undos.Count > 0) undos[0].StoreOnDisk = false;
|
|
|
|
}
|
2007-11-12 22:43:01 +00:00
|
|
|
|
|
|
|
// Update
|
2009-02-21 22:58:37 +00:00
|
|
|
dobackgroundwork = true;
|
2007-11-12 22:43:01 +00:00
|
|
|
General.MainWindow.UpdateInterface();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This performs an undo
|
2008-04-27 12:07:26 +00:00
|
|
|
[BeginAction("undo")]
|
2008-06-11 05:02:48 +00:00
|
|
|
public void PerformUndo()
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
|
|
|
UndoSnapshot u, r;
|
2008-01-13 21:23:59 +00:00
|
|
|
Cursor oldcursor = Cursor.Current;
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
|
|
|
2008-12-06 13:20:47 +00:00
|
|
|
// Anything to undo?
|
|
|
|
if(undos.Count > 0)
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
2008-12-06 13:20:47 +00:00
|
|
|
// Let the plugins know
|
|
|
|
if(General.Plugins.OnUndoBegin())
|
2008-09-13 13:24:06 +00:00
|
|
|
{
|
2008-12-06 13:20:47 +00:00
|
|
|
// Call UndoBegin event
|
|
|
|
if(General.Editing.Mode.OnUndoBegin())
|
2008-09-22 18:27:50 +00:00
|
|
|
{
|
2008-12-06 13:20:47 +00:00
|
|
|
// Cancel volatile mode, if any
|
|
|
|
// This returns false when mode was not volatile
|
|
|
|
if(!General.CancelVolatileMode())
|
2008-09-22 20:57:50 +00:00
|
|
|
{
|
2009-02-21 22:58:37 +00:00
|
|
|
lock(undos)
|
|
|
|
{
|
|
|
|
// Get undo snapshot
|
|
|
|
u = undos[0];
|
|
|
|
undos.RemoveAt(0);
|
|
|
|
|
|
|
|
// Make the current top of the stack load into memory
|
|
|
|
// because it just became the next immediate undo level
|
|
|
|
if(undos.Count > 0) undos[0].StoreOnDisk = false;
|
|
|
|
}
|
2008-05-08 16:39:14 +00:00
|
|
|
|
2008-12-24 18:27:13 +00:00
|
|
|
General.WriteLogLine("Performing undo \"" + u.Description + "\", Ticket ID " + u.TicketID + "...");
|
2009-02-27 15:38:13 +00:00
|
|
|
General.Interface.DisplayStatus(StatusType.Action, u.Description + " undone.");
|
2007-11-12 22:43:01 +00:00
|
|
|
|
2008-09-22 20:57:50 +00:00
|
|
|
// Make a snapshot for redo
|
2008-12-06 13:20:47 +00:00
|
|
|
r = new UndoSnapshot(u, General.Map.Map.Serialize());
|
2008-05-26 13:11:25 +00:00
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
lock(redos)
|
|
|
|
{
|
|
|
|
// The current top of the stack can now be written to disk
|
|
|
|
// because it is no longer the next immediate undo level
|
|
|
|
if(redos.Count > 0) redos[0].StoreOnDisk = true;
|
|
|
|
|
|
|
|
// Put it on the stack
|
|
|
|
redos.Insert(0, r);
|
|
|
|
LimitUndoRedoLevel(redos);
|
|
|
|
}
|
|
|
|
|
2008-09-22 20:57:50 +00:00
|
|
|
// Reset grouping
|
|
|
|
lastgroup = UndoGroup.None;
|
2007-11-12 22:43:01 +00:00
|
|
|
|
2009-02-22 10:13:09 +00:00
|
|
|
// Change map set
|
|
|
|
MemoryStream data = u.GetMapData();
|
|
|
|
General.Map.ChangeMapSet(new MapSet(data));
|
|
|
|
data.Dispose();
|
2009-02-22 09:45:35 +00:00
|
|
|
|
2008-09-22 20:57:50 +00:00
|
|
|
// Remove selection
|
2008-12-06 13:20:47 +00:00
|
|
|
General.Map.Map.ClearAllMarks(false);
|
|
|
|
General.Map.Map.ClearAllSelected();
|
2008-09-13 13:24:06 +00:00
|
|
|
|
2008-10-08 13:57:43 +00:00
|
|
|
// Done
|
2008-11-27 11:59:17 +00:00
|
|
|
General.Editing.Mode.OnUndoEnd();
|
2008-10-08 13:57:43 +00:00
|
|
|
General.Plugins.OnUndoEnd();
|
2008-09-13 13:24:06 +00:00
|
|
|
|
2008-09-22 20:57:50 +00:00
|
|
|
// Update
|
2009-02-21 22:58:37 +00:00
|
|
|
dobackgroundwork = true;
|
2008-09-22 20:57:50 +00:00
|
|
|
General.MainWindow.RedrawDisplay();
|
|
|
|
General.MainWindow.UpdateInterface();
|
|
|
|
}
|
2008-09-22 18:27:50 +00:00
|
|
|
}
|
2008-09-13 13:24:06 +00:00
|
|
|
}
|
2007-11-12 22:43:01 +00:00
|
|
|
}
|
2008-09-22 18:27:50 +00:00
|
|
|
|
2008-01-13 21:23:59 +00:00
|
|
|
Cursor.Current = oldcursor;
|
2007-11-12 22:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This performs a redo
|
2008-04-27 12:07:26 +00:00
|
|
|
[BeginAction("redo")]
|
2009-02-22 10:13:09 +00:00
|
|
|
public void PerformRedo()
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
|
|
|
UndoSnapshot u, r;
|
2008-01-13 21:23:59 +00:00
|
|
|
Cursor oldcursor = Cursor.Current;
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
|
|
|
2008-12-06 13:20:47 +00:00
|
|
|
// Anything to redo?
|
|
|
|
if(redos.Count > 0)
|
2007-11-12 22:43:01 +00:00
|
|
|
{
|
2008-12-06 13:20:47 +00:00
|
|
|
// Let the plugins know
|
|
|
|
if(General.Plugins.OnRedoBegin())
|
2008-09-22 18:27:50 +00:00
|
|
|
{
|
2008-12-06 13:20:47 +00:00
|
|
|
// Call RedoBegin event
|
|
|
|
if(General.Editing.Mode.OnRedoBegin())
|
2008-09-22 20:57:50 +00:00
|
|
|
{
|
2008-12-06 13:20:47 +00:00
|
|
|
// Cancel volatile mode, if any
|
|
|
|
General.CancelVolatileMode();
|
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
lock(redos)
|
|
|
|
{
|
|
|
|
// Get redo snapshot
|
|
|
|
r = redos[0];
|
|
|
|
redos.RemoveAt(0);
|
|
|
|
|
|
|
|
// Make the current top of the stack load into memory
|
|
|
|
// because it just became the next immediate undo level
|
|
|
|
if(redos.Count > 0) redos[0].StoreOnDisk = false;
|
|
|
|
}
|
2008-05-26 13:11:25 +00:00
|
|
|
|
2008-12-24 18:27:13 +00:00
|
|
|
General.WriteLogLine("Performing redo \"" + r.Description + "\", Ticket ID " + r.TicketID + "...");
|
2009-02-27 15:38:13 +00:00
|
|
|
General.Interface.DisplayStatus(StatusType.Action, r.Description + " redone.");
|
2007-11-12 22:43:01 +00:00
|
|
|
|
2008-09-22 20:57:50 +00:00
|
|
|
// Make a snapshot for undo
|
2008-12-06 13:20:47 +00:00
|
|
|
u = new UndoSnapshot(r, General.Map.Map.Serialize());
|
2007-11-13 06:49:13 +00:00
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
lock(undos)
|
|
|
|
{
|
|
|
|
// The current top of the stack can now be written to disk
|
|
|
|
// because it is no longer the next immediate undo level
|
|
|
|
if(undos.Count > 0) undos[0].StoreOnDisk = true;
|
2008-05-16 20:00:49 +00:00
|
|
|
|
2009-02-21 22:58:37 +00:00
|
|
|
// Put it on the stack
|
|
|
|
undos.Insert(0, u);
|
|
|
|
LimitUndoRedoLevel(undos);
|
|
|
|
}
|
|
|
|
|
2008-09-22 20:57:50 +00:00
|
|
|
// Reset grouping
|
|
|
|
lastgroup = UndoGroup.None;
|
2007-11-12 22:43:01 +00:00
|
|
|
|
2009-02-22 10:13:09 +00:00
|
|
|
// Change map set
|
|
|
|
MemoryStream data = r.GetMapData();
|
|
|
|
General.Map.ChangeMapSet(new MapSet(data));
|
|
|
|
data.Dispose();
|
2009-02-22 09:45:35 +00:00
|
|
|
|
2008-12-06 13:20:47 +00:00
|
|
|
// Remove selection
|
|
|
|
General.Map.Map.ClearAllMarks(false);
|
|
|
|
General.Map.Map.ClearAllSelected();
|
2008-09-22 18:27:50 +00:00
|
|
|
|
2008-10-08 13:57:43 +00:00
|
|
|
// Done
|
2008-11-27 11:59:17 +00:00
|
|
|
General.Editing.Mode.OnRedoEnd();
|
2008-10-08 13:57:43 +00:00
|
|
|
General.Plugins.OnRedoEnd();
|
|
|
|
|
2008-09-22 20:57:50 +00:00
|
|
|
// Update
|
|
|
|
General.MainWindow.RedrawDisplay();
|
|
|
|
General.MainWindow.UpdateInterface();
|
|
|
|
}
|
2008-09-22 18:27:50 +00:00
|
|
|
}
|
2007-11-12 22:43:01 +00:00
|
|
|
}
|
2008-01-13 21:23:59 +00:00
|
|
|
|
|
|
|
Cursor.Current = oldcursor;
|
2007-11-12 22:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|