Пример #1
0
        static Gdk.Rectangle MacGetUsableMonitorGeometry(Gdk.Screen screen, int monitor)
        {
            IntPtr array = objc_msgSend_IntPtr(cls_NSScreen, sel_screens);
            IntPtr iter  = objc_msgSend_IntPtr(array, sel_objectEnumerator);

            Gdk.Rectangle geometry = screen.GetMonitorGeometry(0);
            RectangleF    visible, frame;
            IntPtr        scrn;
            int           i = 0;

            while ((scrn = objc_msgSend_IntPtr(iter, sel_nextObject)) != IntPtr.Zero && i < monitor)
            {
                i++;
            }

            if (scrn == IntPtr.Zero)
            {
                return(screen.GetMonitorGeometry(monitor));
            }

            objc_msgSend_RectangleF(out visible, scrn, sel_visibleFrame);
            objc_msgSend_RectangleF(out frame, scrn, sel_frame);

            // Note: Frame and VisibleFrame rectangles are relative to monitor 0, but we need absolute
            // coordinates.
            visible.X += geometry.X;
            visible.Y += geometry.Y;
            frame.X   += geometry.X;
            frame.Y   += geometry.Y;

            // VisibleFrame.Y is the height of the Dock if it is at the bottom of the screen, so in order
            // to get the menu height, we just figure out the difference between the visibleFrame height
            // and the actual frame height, then subtract the Dock height.
            //
            // We need to swap the Y offset with the menu height because our callers expect the Y offset
            // to be from the top of the screen, not from the bottom of the screen.
            float x, y, width, height;

            if (visible.Height < frame.Height)
            {
                float dockHeight    = visible.Y;
                float menubarHeight = (frame.Height - visible.Height) - dockHeight;

                height = frame.Height - menubarHeight - dockHeight;
                y      = menubarHeight;
            }
            else
            {
                height = frame.Height;
                y      = frame.Y;
            }

            // Takes care of the possibility of the Dock being positioned on the left or right edge of the screen.
            width = System.Math.Min(visible.Width, frame.Width);
            x     = System.Math.Max(visible.X, frame.X);

            return(new Gdk.Rectangle((int)x, (int)y, (int)width, (int)height));
        }
Пример #2
0
		public override Gdk.Rectangle GetUsableMonitorGeometry (Gdk.Screen screen, int monitor_id)
		{
			Gdk.Rectangle geometry = screen.GetMonitorGeometry (monitor_id);
			List<MonitorInfo> screens = new List<MonitorInfo> ();

			EnumDisplayMonitors (IntPtr.Zero, IntPtr.Zero, delegate (IntPtr hmonitor, IntPtr hdc, IntPtr prect, IntPtr user_data) {
				var info = new MonitorInfo ();

				info.Size = Marshal.SizeOf (info);

				GetMonitorInfoA (hmonitor, ref info);

				// In order to keep the order the same as Gtk, we need to put the primary monitor at the beginning.
				if ((info.Flags & MonitorInfoFlagsPrimary) != 0)
					screens.Insert (0, info);
				else
					screens.Add (info);

				return 1;
			}, IntPtr.Zero);

			MonitorInfo monitor = screens[monitor_id];
			Rect visible = monitor.VisibleFrame;
			Rect frame = monitor.Frame;

			// Rebase the VisibleFrame off of Gtk's idea of this monitor's geometry (since they use different coordinate systems)
			int x = geometry.X + (visible.Left - frame.Left);
			int width = visible.Width;

			int y = geometry.Y + (visible.Top - frame.Top);
			int height = visible.Height;

			return new Gdk.Rectangle (x, y, width, height);
		}
Пример #3
0
        public static Gdk.Rectangle GetUsableMonitorGeometry(this Gdk.Screen screen, int monitor)
        {
            if (Platform.IsMac)
            {
                return(MacGetUsableMonitorGeometry(screen, monitor));
            }

            return(screen.GetMonitorGeometry(monitor));
        }
Пример #4
0
        private void ConfigureWindow()
        {
            Gdk.Screen screen  = Screen;
            int        monitor = screen.GetMonitorAtWindow(parent.GdkWindow);

            Gdk.Rectangle bounds = screen.GetMonitorGeometry(monitor);
            Move(bounds.X, 0);
            SetDefaultSize(bounds.Width, bounds.Height);
        }
Пример #5
0
        public override Gdk.Rectangle GetUsableMonitorGeometry(Gdk.Screen screen, int monitor_id)
        {
            Gdk.Rectangle ygeometry = screen.GetMonitorGeometry(monitor_id);
            Gdk.Rectangle xgeometry = screen.GetMonitorGeometry(0);
            NSScreen      monitor   = NSScreen.Screens[monitor_id];
            RectangleF    visible   = monitor.VisibleFrame;
            RectangleF    frame     = monitor.Frame;

            // Note: Frame and VisibleFrame rectangles are relative to monitor 0, but we need absolute
            // coordinates.
            visible.X += xgeometry.X;
            frame.X   += xgeometry.X;

            // VisibleFrame.Y is the height of the Dock if it is at the bottom of the screen, so in order
            // to get the menu height, we just figure out the difference between the visibleFrame height
            // and the actual frame height, then subtract the Dock height.
            //
            // We need to swap the Y offset with the menu height because our callers expect the Y offset
            // to be from the top of the screen, not from the bottom of the screen.
            float x, y, width, height;

            if (visible.Height <= frame.Height)
            {
                float dockHeight    = visible.Y - frame.Y;
                float menubarHeight = (frame.Height - visible.Height) - dockHeight;

                height = frame.Height - menubarHeight - dockHeight;
                y      = ygeometry.Y + menubarHeight;
            }
            else
            {
                height = frame.Height;
                y      = ygeometry.Y;
            }

            // Takes care of the possibility of the Dock being positioned on the left or right edge of the screen.
            width = Math.Min(visible.Width, frame.Width);
            x     = Math.Max(visible.X, frame.X);

            return(new Gdk.Rectangle((int)x, (int)y, (int)width, (int)height));
        }
Пример #6
0
 protected void CheckMonitorGeometry(int pWidth, int pHeight)
 {
     try
     {
         Gdk.Screen    screen          = this.Screen;
         Gdk.Rectangle monitorGeometry = screen.GetMonitorGeometry(0);
         if (monitorGeometry.Width < pWidth || monitorGeometry.Height < pHeight)
         {
             Utils.ShowMessageTouch(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, string.Format(Resx.dialog_message_low_resolution_detected, pWidth, pHeight));
             Environment.Exit(0);
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.Message, ex);
     }
 }
Пример #7
0
        private void ConfigureWindow()
        {
            Gdk.Screen screen  = Screen;
            int        monitor = screen.GetMonitorAtWindow(parent.GdkWindow);

            Gdk.Rectangle bounds = screen.GetMonitorGeometry(monitor);
            Move(bounds.X, bounds.Y);
            Resize(bounds.Width, bounds.Height);

            if (controls != null)
            {
                int width, height;
                controls.GetSize(out width, out height);
                if (width > bounds.Width)
                {
                    controls.Resize(bounds.Width, height);
                }
            }
        }
Пример #8
0
 protected void CheckMonitorGeometry(int pWidth, int pHeight)
 {
     try
     {
         Gdk.Screen    screen          = this.Screen;
         Gdk.Rectangle monitorGeometry = screen.GetMonitorGeometry(string.IsNullOrEmpty(GlobalFramework.Settings["appScreen"])
             ? 0
             : Convert.ToInt32(GlobalFramework.Settings["appScreen"]));
         if (monitorGeometry.Width < pWidth || monitorGeometry.Height < pHeight)
         {
             Utils.ShowMessageTouch(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_low_resolution_detected"), pWidth, pHeight));
             Environment.Exit(0);
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.Message, ex);
     }
 }
Пример #9
0
 public virtual Gdk.Rectangle GetUsableMonitorGeometry(Gdk.Screen screen, int monitor)
 {
     return(screen.GetMonitorGeometry(monitor));
 }
Пример #10
0
        public FullScreenView(IBrowsableCollection collection, Window parent) : base("Full Screen Mode")
        {
            //going fullscreen on the same screen the parent window
            Gdk.Screen screen  = Screen;
            int        monitor = screen.GetMonitorAtWindow(parent.GdkWindow);

            Gdk.Rectangle bounds = screen.GetMonitorGeometry(monitor);
            Move(bounds.X, bounds.Y);

            string style = "style \"test\" {\n" +
                           "GtkToolbar::shadow_type = GTK_SHADOW_NONE\n" +
                           "}\n" +
                           "class \"GtkToolbar\" style \"test\"";

            Gtk.Rc.ParseString(style);

            Name = "FullscreenContainer";
            try {
                //scroll = new Gtk.ScrolledWindow (null, null);
                actions = new ActionGroup("joe");

                actions.Add(new[] {
                    new ActionEntry(HideToolbar, Stock.Close,
                                    Catalog.GetString("Hide"),
                                    null,
                                    Catalog.GetString("Hide toolbar"),
                                    HideToolbarAction)
                });

                actions.Add(new[] {
                    new ToggleActionEntry(Info,
                                          Stock.Info,
                                          Catalog.GetString("Info"),
                                          null,
                                          Catalog.GetString("Image information"),
                                          InfoAction,
                                          false)
                });

                Gtk.Action exit_full_screen = new Gtk.Action(ExitFullScreen,
                                                             Catalog.GetString("Exit fullscreen"),
                                                             null,
                                                             null);
                exit_full_screen.IconName   = "view-restore";
                exit_full_screen.Activated += ExitAction;
                actions.Add(exit_full_screen);

                Gtk.Action slide_show = new Gtk.Action(SlideShow,
                                                       Catalog.GetString("Slideshow"),
                                                       Catalog.GetString("Start slideshow"),
                                                       null);
                slide_show.IconName   = "media-playback-start";
                slide_show.Activated += SlideShowAction;
                actions.Add(slide_show);

                new WindowOpacityFader(this, 1.0, 600);
                notebook            = new Notebook();
                notebook.ShowBorder = false;
                notebook.ShowTabs   = false;
                notebook.Show();

                scroll = new ScrolledView();
                scroll.ScrolledWindow.SetPolicy(PolicyType.Never, PolicyType.Never);
                view = new PhotoImageView(collection);
                // FIXME this should be handled by the new style setting code
                view.ModifyBg(Gtk.StateType.Normal, this.Style.Black);
                Add(notebook);
                view.Show();
                view.MotionNotifyEvent += HandleViewMotion;
                view.PointerMode        = PointerMode.Scroll;

                scroll.ScrolledWindow.Add(view);

                Toolbar tbar = new Toolbar();
                tbar.ToolbarStyle = Gtk.ToolbarStyle.BothHoriz;

                tbar.ShowArrow   = false;
                tbar.BorderWidth = 15;

                ToolItem t_item = (actions [ExitFullScreen]).CreateToolItem() as ToolItem;
                t_item.IsImportant = true;
                tbar.Insert(t_item, -1);

                Gtk.Action action = new PreviousPictureAction(view.Item);
                actions.Add(action);
                tbar.Insert(action.CreateToolItem() as ToolItem, -1);

                play_pause_button = (actions [SlideShow]).CreateToolItem() as ToolButton;
                tbar.Insert(play_pause_button, -1);

                action = new NextPictureAction(view.Item);
                actions.Add(action);
                tbar.Insert(action.CreateToolItem() as ToolItem, -1);

                t_item       = new ToolItem();
                t_item.Child = new Label(Catalog.GetString("Slide transition:"));
                tbar.Insert(t_item, -1);

                display = new SlideShow(view.Item);
                display.AddEvents((int)(Gdk.EventMask.PointerMotionMask));
                display.ModifyBg(Gtk.StateType.Normal, Style.Black);
                display.MotionNotifyEvent += HandleViewMotion;
                display.Show();

                t_item = new ToolItem();
                ComboBox combo = ComboBox.NewText();
                foreach (var transition in display.Transitions)
                {
                    combo.AppendText(transition.Name);
                }
                combo.Active   = 0;
                combo.Changed += HandleTransitionChanged;
                t_item.Child   = combo;
                tbar.Insert(t_item, -1);

                action = new RotateLeftAction(view.Item);
                actions.Add(action);
                tbar.Insert(action.CreateToolItem() as ToolItem, -1);

                action = new RotateRightAction(view.Item);
                actions.Add(action);
                tbar.Insert(action.CreateToolItem() as ToolItem, -1);

                info_button = (ToggleToolButton)((actions [Info]).CreateToolItem() as ToolItem);
                tbar.Insert(info_button, -1);

                tbar.Insert((actions [HideToolbar]).CreateToolItem() as ToolItem, -1);

                notebook.AppendPage(scroll, null);
                notebook.AppendPage(display, null);

                tbar.ShowAll();

                scroll.Show();
                Decorated = false;
                Fullscreen();
                ButtonPressEvent += HandleButtonPressEvent;

                view.Item.Changed += HandleItemChanged;
                view.GrabFocus();

                hide_cursor_delay = new DelayedOperation(3000, new GLib.IdleHandler(HideCursor));
                hide_cursor_delay.Start();

                controls = new ControlOverlay(this);
                controls.Add(tbar);
                controls.Dismiss();

                notebook.CurrentPage = 0;
            } catch (Exception e) {
                Log.Exception(e);
            }
        }