Exemplo n.º 1
0
		/// <summary>
		/// Undoes the last step.
		/// </summary>
		/// <param name="buffer">Buffer to use</param>
		/// <remarks>Used internally, don't use!</remarks>
		internal UndoStep Undo(ref BufferManager buffer)
		{
			if (UndoStack.Count > 0) {
				UndoStep step = (UndoStep)UndoStack.Peek();
				RedoStack.Push(step);
				UndoStack.Pop();
				switch (step.Action) {
					case UndoAction.Insert :
						buffer.SetBytes(step.Start, step.GetBytes(), false);
						break;
					case UndoAction.Remove :
						buffer.RemoveBytes(step.Start, step.GetBytes().Length);
						break;
					case UndoAction.Overwrite :
						buffer.SetBytes(step.Start, step.GetOldBytes(), true);
						break;
				}
				EventHandler<UndoEventArgs> temp = ActionUndone;
				if (temp != null)
					temp(this, new UndoEventArgs(step, true));
				
				return step;
			}
			return null;
		}
Exemplo n.º 2
0
		public SelectionManager(ref BufferManager buffer)
		{
			this.buffer = buffer;
		}
Exemplo n.º 3
0
		/// <summary>
		/// Creates a new HexEditor Control with basic settings and initialises all components.
		/// </summary>
		public Editor()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			buffer = new BufferManager(this);
			selection = new SelectionManager(ref buffer);
			undoStack = new UndoManager();
			insertmode = true;
			underscorewidth = MeasureStringWidth(this.CreateGraphics(), "_", Settings.DataFont);
			underscorewidth3 = underscorewidth * 3;
			fontheight = GetFontHeight(Settings.DataFont);
			selregion = new Rectangle[] {};
			selpoints = new Point[] {};
			headertext = GetHeaderText();
			
			this.ActiveView = this.hexView;
			
			UpdatePainters();
			
			caret = new Caret(this.gbHex, 1, fontheight, 0);
			
			HexEditSizeChanged(null, EventArgs.Empty);
			AdjustScrollBar();
			
			this.Invalidate();
		}
Exemplo n.º 4
0
 public SelectionManager(ref BufferManager buffer)
 {
     this.buffer = buffer;
 }