Example #1
0
        private void ZoomToWindow_Activated(object sender, EventArgs e)
        {
            // The image is small enough to fit in the window
            if (PintaCore.Workspace.ImageFitsInWindow)
            {
                PintaCore.Actions.View.ActualSize.Activate();
            }
            else
            {
                int image_x = PintaCore.Workspace.ImageSize.Width;
                int image_y = PintaCore.Workspace.ImageSize.Height;

                var canvas_window = PintaCore.Workspace.ActiveWorkspace.Canvas.Parent;

                var window_x = canvas_window.Allocation.Width;
                var window_y = canvas_window.Allocation.Height;

                double ratio;

                // The image is more constrained by width than height
                if ((double)image_x / (double)window_x >= (double)image_y / (double)window_y)
                {
                    ratio = (double)(window_x - 20) / (double)image_x;
                }
                else
                {
                    ratio = (double)(window_y - 20) / (double)image_y;
                }

                PintaCore.Workspace.Scale = ratio;
                PintaCore.Actions.View.SuspendZoomUpdate();
                (PintaCore.Actions.View.ZoomComboBox.ComboBox as ComboBoxEntry).Entry.Text = ViewActions.ToPercent(PintaCore.Workspace.Scale);
                PintaCore.Actions.View.ResumeZoomUpdate();
            }

            PintaCore.Actions.View.ZoomToWindowActivated = true;
        }
Example #2
0
        private void ActiveDocumentChanged(object sender, EventArgs e)
        {
            if (PintaCore.Workspace.HasOpenDocuments)
            {
                PintaCore.Actions.View.SuspendZoomUpdate();
                (PintaCore.Actions.View.ZoomComboBox.ComboBox as Gtk.ComboBoxEntry).Entry.Text = ViewActions.ToPercent(PintaCore.Workspace.Scale);
                PintaCore.Actions.View.ResumeZoomUpdate();

                var doc = PintaCore.Workspace.ActiveDocument;
                var tab = FindTabWithCanvas((PintaCanvas)doc.Workspace.Canvas);

                if (tab != null)
                {
                    // We need to suppress because ActivateTab changes both the notebook
                    // and the tab, and we handle both events, so when it fires the notebook
                    // changed event, the tab has not been changed yet.
                    suppress_active_notebook_change = true;
                    dock_container.ActivateTab(tab);
                    suppress_active_notebook_change = false;
                }

                doc.Workspace.Canvas.GrabFocus();
            }
        }
Example #3
0
        private void ActiveDocumentChanged(object sender, EventArgs e)
        {
            if (PintaCore.Workspace.HasOpenDocuments)
            {
                PintaCore.Actions.View.SuspendZoomUpdate();
                (PintaCore.Actions.View.ZoomComboBox.ComboBox as Gtk.ComboBoxEntry).Entry.Text = ViewActions.ToPercent(PintaCore.Workspace.Scale);
                PintaCore.Actions.View.ResumeZoomUpdate();

                PintaCore.Workspace.OnCanvasSizeChanged();
            }

            PintaCore.Workspace.Invalidate();
        }