///<summary>Create a DataView</summary> public DataView() { dvControl = new DataViewControl(this); dvDisplay = new DataViewDisplay(this); dvDisplay.Control = dvControl; dvControl.Display = dvDisplay; // initialize clipdata buffer // and clipboard clipdata = new byte[0]; clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", true)); // initialize undo/redo cursor offset stacks cursorUndoDeque = new Deque <CursorState>(); cursorRedoDeque = new Deque <CursorState>(); prefID = "dv" + this.GetHashCode().ToString(); PreferencesChangedHandler handler = new PreferencesChangedHandler(OnPreferencesChanged); Preferences.Proxy.Subscribe("Undo.Limited", prefID, handler); Preferences.Proxy.Subscribe("Undo.Actions", prefID, handler); Preferences.Proxy.Subscribe("Highlight.PatternMatch", prefID, handler); Preferences.Proxy.Subscribe("ByteBuffer.TempDir", prefID, handler); }
public void CloseFile(DataView dv) { if (!dv.Buffer.FileOperationsAllowed) { return; } // if user decides not to close after all if (AskForSaveIfFileChanged(dv) == false) { return; } dataBook.RemoveView(dv); // promptly free resources memory (eg pixmaps) dv.Buffer.CloseFile(); dv.Cleanup(); // Make sure the new current DataView has the focus DataViewDisplay dvd = (DataViewDisplay)dataBook.CurrentPageWidget; if (dvd != null) { dvd.GrabKeyboardFocus(); } else { // there is no dataview left, // update title and statusbars mainWindow.Title = "Bless - Gtk# Hex Editor"; Services.UI.Info.ClearMessage(); } }
public void Cleanup() { this.Buffer = null; // all these to help the GC... dvDisplay.Cleanup(); dvDisplay = null; dvControl.Cleanup(); dvControl = null; Preferences.Proxy.Unsubscribe("Undo.Limited", prefID); Preferences.Proxy.Unsubscribe("Undo.Actions", prefID); Preferences.Proxy.Unsubscribe("Highlight.PatternMatch", prefID); Preferences.Proxy.Unsubscribe("ByteBuffer.TempDir", prefID); }
///<summary> /// Create and setup a DataView ///</summary> public DataView CreateDataView(ByteBuffer bb) { DataView dv = new DataView(); string layoutFile = string.Empty; // try to load default (from user preferences) layout file try { layoutFile = Preferences.Instance["Default.Layout.File"]; string useCurrent = Preferences.Instance["Default.Layout.UseCurrent"]; if (useCurrent == "True" && dataBook.NPages > 0) { DataViewDisplay dvd = (DataViewDisplay)dataBook.CurrentPageWidget; layoutFile = dvd.Layout.FilePath; } if (layoutFile != string.Empty) { dv.Display.Layout = new Bless.Gui.Layout(layoutFile); } } catch (Exception ex) { string msg = string.Format(Catalog.GetString("Error loading layout '{0}'. Loading default layout instead."), layoutFile); ErrorAlert ea = new ErrorAlert(msg, ex.Message, mainWindow); ea.Run(); ea.Destroy(); } if (Preferences.Instance["Default.EditMode"] == "Insert") { dv.Overwrite = false; } else if (Preferences.Instance["Default.EditMode"] == "Overwrite") { dv.Overwrite = true; } dv.Buffer = bb; return(dv); }
public void Cleanup() { okp_focusArea = null; dataView = null; dvDisplay = null; }