private void Workspace_DocumentCreated(object sender, DocumentEventArgs e) { var doc = e.Document; // Find the currently active container for our new tab var container = DockNotebookManager.ActiveNotebookContainer ?? dock_container; var selected_index = container.TabControl.CurrentTabIndex; var canvas = new CanvasWindow(doc) { RulersVisible = PintaCore.Actions.View.Rulers.Active, RulerMetric = GetCurrentRulerMetric() }; var my_content = new DocumentViewContent(doc, canvas); // Insert our tab to the right of the currently selected tab container.TabControl.InsertTab(my_content, selected_index + 1); doc.Workspace.Canvas = canvas.Canvas; // Zoom to window only on first show (if we do it always, it will be called on every resize) canvas.SizeAllocated += (o, e2) => { if (!canvas.HasBeenShown) { ZoomToWindow_Activated(o, e); } canvas.HasBeenShown = true; }; PintaCore.Actions.View.Rulers.Toggled += (o, e2) => { canvas.RulersVisible = ((ToggleAction)o).Active; }; PintaCore.Actions.View.Pixels.Activated += (o, e2) => { canvas.RulerMetric = MetricType.Pixels; }; PintaCore.Actions.View.Inches.Activated += (o, e2) => { canvas.RulerMetric = MetricType.Inches; }; PintaCore.Actions.View.Centimeters.Activated += (o, e2) => { canvas.RulerMetric = MetricType.Centimeters; }; }
public DocumentViewContent(Document document, CanvasWindow canvasWindow) { this.Document = document; this.canvas_window = canvasWindow; document.IsDirtyChanged += (o, e) => LabelChanged?.Invoke(this, EventArgs.Empty); document.Renamed += (o, e) => { LabelChanged?.Invoke(this, EventArgs.Empty); }; }
public DocumentViewContent(Document document, CanvasWindow canvasWindow) { this.Document = document; this.canvas_window = canvasWindow; document.IsDirtyChanged += (o, e) => IsDirty = document.IsDirty; document.Renamed += (o, e) => { if (ContentNameChanged != null) { ContentNameChanged(this, EventArgs.Empty); } }; }
private void Workspace_DocumentCreated (object sender, DocumentEventArgs e) { var doc = e.Document; // Find the currently active container for our new tab var container = DockNotebookManager.ActiveNotebookContainer ?? dock_container; var selected_index = container.TabControl.CurrentTabIndex; var canvas = new CanvasWindow (doc) { RulersVisible = PintaCore.Actions.View.Rulers.Active, RulerMetric = GetCurrentRulerMetric () }; var my_content = new DocumentViewContent (doc, canvas); // Insert our tab to the right of the currently selected tab container.TabControl.InsertTab (my_content, selected_index + 1); doc.Workspace.Canvas = canvas.Canvas; // Zoom to window only on first show (if we do it always, it will be called on every resize) canvas.SizeAllocated += (o, e2) => { if (!canvas.HasBeenShown) ZoomToWindow_Activated (o, e); canvas.HasBeenShown = true; }; PintaCore.Actions.View.Rulers.Toggled += (o, e2) => { canvas.RulersVisible = ((ToggleAction)o).Active; }; PintaCore.Actions.View.Pixels.Activated += (o, e2) => { canvas.RulerMetric = MetricType.Pixels; }; PintaCore.Actions.View.Inches.Activated += (o, e2) => { canvas.RulerMetric = MetricType.Inches; }; PintaCore.Actions.View.Centimeters.Activated += (o, e2) => { canvas.RulerMetric = MetricType.Centimeters; }; }