Exemplo n.º 1
0
        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; };
        }
Exemplo n.º 2
0
        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); };
        }
Exemplo n.º 3
0
        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);
                                                   }
            };
        }
Exemplo n.º 4
0
        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; };
        }