Ejemplo n.º 1
0
        public static Keys ToEtoKey(this Gdk.ModifierType modifier)
        {
            Keys result = Keys.None;

            if (modifier.HasFlag(Gdk.ModifierType.Mod1Mask))
            {
                result |= Keys.Alt;
            }
            if (modifier.HasFlag(Gdk.ModifierType.ControlMask))
            {
                result |= Keys.Control;
            }
            if (modifier.HasFlag(Gdk.ModifierType.SuperMask))
            {
                result |= Keys.Application;
            }
            if (modifier.HasFlag(Gdk.ModifierType.ShiftMask))
            {
                result |= Keys.Shift;
            }

            // map CMD key to Control on macOS
            if (EtoEnvironment.Platform.IsMac && modifier.HasFlag(Gdk.ModifierType.Mod2Mask))
            {
                result |= Keys.Control;
            }
            return(result);
        }
Ejemplo n.º 2
0
        internal bool ProcessKey(Gdk.Key key, Gdk.ModifierType state)
        {
            switch (key)
            {
            case Gdk.Key.Up:
                if (state.HasFlag(Gdk.ModifierType.Mod2Mask))
                {
                    goto case Gdk.Key.Page_Up;
                }
                if (state.HasFlag(Gdk.ModifierType.ControlMask))
                {
                    goto case Gdk.Key.Home;
                }
                SelectItemUp();
                return(true);

            case Gdk.Key.Down:
                if (state.HasFlag(Gdk.ModifierType.Mod2Mask))
                {
                    goto case Gdk.Key.Page_Down;
                }
                if (state.HasFlag(Gdk.ModifierType.ControlMask))
                {
                    goto case Gdk.Key.End;
                }
                SelectItemDown();
                return(true);

            case Gdk.Key.KP_Page_Down:
            case Gdk.Key.Page_Down:
                SelectNextCategory();
                return(true);

            case Gdk.Key.KP_Page_Up:
            case Gdk.Key.Page_Up:
                SelectPrevCategory();
                return(true);

            case Gdk.Key.Home:
                SelectFirstCategory();
                return(true);

            case Gdk.Key.End:
                SelectLastCatgory();
                return(true);

            case Gdk.Key.Return:
                OnItemActivated(EventArgs.Empty);
                return(true);
            }
            return(true);
        }
Ejemplo n.º 3
0
        public RoomEditor()
        {
            TileWidth  = 16;
            TileHeight = 16;
            XOffset    = 8;
            YOffset    = 8;

            ViewObjectBoxes = true;

            this.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args)
            {
                if (client == null)
                {
                    return;
                }
                int x, y;
                args.Event.Window.GetPointer(out x, out y, out gdkState);
                UpdateMouse(x, y);
                if (gdkState.HasFlag(Gdk.ModifierType.Button1Mask))
                {
                    OnClicked(x, y);
                }
                if (IsInBounds(x, y))
                {
                    if (gdkState.HasFlag(Gdk.ModifierType.Button3Mask))
                    {
                        client.SelectedIndex = room.GetTile(HoveringX, HoveringY);
                    }
                }
            };
            this.ButtonReleaseEvent += delegate(object o, ButtonReleaseEventArgs args) {
                int x, y;
                args.Event.Window.GetPointer(out x, out y, out gdkState);
                if (!gdkState.HasFlag(Gdk.ModifierType.Button1Mask))
                {
                    draggingObject = false;
                }
            };
            this.MotionNotifyEvent += delegate(object o, MotionNotifyEventArgs args) {
                if (client == null)
                {
                    return;
                }
                int x, y;
                args.Event.Window.GetPointer(out x, out y, out gdkState);
                UpdateMouse(x, y);
                if (gdkState.HasFlag(Gdk.ModifierType.Button1Mask))
                {
                    OnDragged(x, y);
                }
            };
        }
Ejemplo n.º 4
0
        public static MouseButtons ToEtoMouseButtons(this Gdk.ModifierType modifiers)
        {
            MouseButtons buttons = MouseButtons.None;

            if (modifiers.HasFlag(Gdk.ModifierType.Button1Mask))
            {
                buttons |= MouseButtons.Primary;
            }
            if (modifiers.HasFlag(Gdk.ModifierType.Button2Mask))
            {
                buttons |= MouseButtons.Middle;
            }
            if (modifiers.HasFlag(Gdk.ModifierType.Button3Mask))
            {
                buttons |= MouseButtons.Alternate;
            }
            return(buttons);
        }
Ejemplo n.º 5
0
            public bool ModifierMatchesState(Gdk.ModifierType state)
            {
                if (mod.HasFlag(MouseModifier.Any))
                {
                    return(true);
                }
                MouseModifier flags = MouseModifier.None;

                if (state.HasFlag(Gdk.ModifierType.ControlMask))
                {
                    flags |= MouseModifier.Ctrl;
                }
                if (state.HasFlag(Gdk.ModifierType.ShiftMask))
                {
                    flags |= MouseModifier.Shift;
                }

                return(mod == flags);
            }
Ejemplo n.º 6
0
            public bool ButtonMatchesState(Gdk.ModifierType state)
            {
                bool left  = state.HasFlag(Gdk.ModifierType.Button1Mask);
                bool right = state.HasFlag(Gdk.ModifierType.Button3Mask);

                if (button == MouseButton.Any && (left || right))
                {
                    return(true);
                }
                if (button == MouseButton.LeftClick && left)
                {
                    return(true);
                }
                if (button == MouseButton.RightClick && right)
                {
                    return(true);
                }
                return(false);
            }
Ejemplo n.º 7
0
Archivo: KeyMap.cs Proyecto: yaram/Eto
        public static Keys ToEtoKey(this Gdk.ModifierType modifier)
        {
            Keys result = Keys.None;

            if (modifier.HasFlag(Gdk.ModifierType.Mod1Mask))
            {
                result |= Keys.Alt;
            }
            if (modifier.HasFlag(Gdk.ModifierType.ControlMask))
            {
                result |= Keys.Control;
            }
            if (modifier.HasFlag(Gdk.ModifierType.SuperMask))
            {
                result |= Keys.Application;
            }
            if (modifier.HasFlag(Gdk.ModifierType.ShiftMask))
            {
                result |= Keys.Shift;
            }
            return(result);
        }
        protected override bool ProcessViewModelClicked(IViewModel viewModel, int x, int y, int cellWidth, Gdk.ModifierType state)
        {
            if (viewModel is EventTypeTimelineVM && state.HasFlag(Gdk.ModifierType.None))
            {
                var vm = (EventTypeTimelineVM)viewModel;
                if (vm.Model is SubstitutionEventType)
                {
                    return(false);
                }

                if (PlaysCellRenderer.ClickedPlayButton(x, y, cellWidth))
                {
                    vm.LoadEventType();
                    pathClicked = null;
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
        // Workaround for bug "Bug 688247 - Ctrl+Alt key not work on windows7 with bootcamp on a Mac Book Pro"
        // Ctrl+Alt should behave like right alt key - unfortunately TranslateKeyboardState doesn't handle it.
        static void TranslateKeyboardState(uint hardware_keycode, Gdk.ModifierType state, int group, out uint keyval,
                                           out int effective_group, out int level, out Gdk.ModifierType consumed_modifiers)
        {
            if (Platform.IsWindows)
            {
                const Gdk.ModifierType ctrlAlt = Gdk.ModifierType.ControlMask | Gdk.ModifierType.Mod1Mask;
                if ((state & ctrlAlt) == ctrlAlt)
                {
                    state = (state & ~ctrlAlt) | Gdk.ModifierType.Mod2Mask;
                    group = 1;
                }
                // Case: Caps lock on + shift + key
                // See: Bug 8069 - [UI Refresh] If caps lock is on, holding the shift key prevents typed characters from appearing
                if (state.HasFlag(Gdk.ModifierType.ShiftMask))
                {
                    state &= ~Gdk.ModifierType.ShiftMask;
                }
            }

            keymap.TranslateKeyboardState(hardware_keycode, state, group, out keyval, out effective_group,
                                          out level, out consumed_modifiers);
        }
Ejemplo n.º 10
0
        //this method is MIT/X11, 2009, Michael Hutchinson / (c) Novell
        internal static async void OpenFiles(IEnumerable <FileOpenInformation> files, IDictionary <string, string> metadata)
        {
            if (!files.Any())
            {
                return;
            }

            if (!IsInitialized)
            {
                EventHandler onInit = null;
                onInit = delegate {
                    Initialized -= onInit;
                    OpenFiles(files, metadata);
                };
                Initialized += onInit;
                return;
            }

            var filteredFiles = new List <FileOpenInformation> ();

            Gdk.ModifierType mtype        = Components.GtkWorkarounds.GetCurrentKeyModifiers();
            bool             closeCurrent = !mtype.HasFlag(Gdk.ModifierType.ControlMask);

            if (Platform.IsMac && closeCurrent)
            {
                closeCurrent = !mtype.HasFlag(Gdk.ModifierType.Mod2Mask);
            }

            foreach (var file in files)
            {
                if (Services.ProjectService.IsWorkspaceItemFile(file.FileName) ||
                    Services.ProjectService.IsSolutionItemFile(file.FileName))
                {
                    try {
                        // Close the current solution, but only for the first solution we open.
                        // If more than one solution is specified in the list we want to open all them together.
                        await Workspace.OpenWorkspaceItem(file.FileName, closeCurrent, true, metadata);

                        closeCurrent = false;
                    } catch (Exception ex) {
                        MessageService.ShowError(GettextCatalog.GetString("Could not load solution: {0}", file.FileName), ex);
                    }
                }
                else if (file.FileName.HasExtension("mpack"))
                {
                    var service = new SetupService(AddinManager.Registry);
                    AddinManagerWindow.RunToInstallFile(Workbench.RootWindow,
                                                        service,
                                                        file.FileName.FullPath);
                }
                else
                {
                    filteredFiles.Add(file);
                }
            }

            // Wait for active load operations to be finished (there might be a solution already being loaded
            // when OpenFiles was called). This will ensure that files opened as part of the solution status
            // restoration won't steal the focus from the files we are explicitly loading here.
            await Workspace.CurrentWorkspaceLoadTask;

            foreach (var file in filteredFiles)
            {
                Workbench.OpenDocument(file.FileName, null, file.Line, file.Column, file.Options).ContinueWith(t => {
                    if (t.IsFaulted)
                    {
                        MessageService.ShowError(GettextCatalog.GetString("Could not open file: {0}", file.FileName), t.Exception);
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext()).Ignore();
            }

            Workbench.Present();
        }
Ejemplo n.º 11
0
        //this method is MIT/X11, 2009, Michael Hutchinson / (c) Novell
        internal static async Task <bool> OpenFilesAsync(IEnumerable <FileOpenInformation> files, OpenWorkspaceItemMetadata metadata)
        {
            if (!files.Any())
            {
                return(false);
            }

            await initializationTask.Task;

            Workbench.Present();

            var filteredFiles = new List <FileOpenInformation> ();

            Gdk.ModifierType mtype        = Components.GtkWorkarounds.GetCurrentKeyModifiers();
            bool             closeCurrent = !mtype.HasFlag(Gdk.ModifierType.ControlMask);

            if (Platform.IsMac && closeCurrent)
            {
                closeCurrent = !mtype.HasFlag(Gdk.ModifierType.Mod2Mask);
            }

            foreach (var file in files)
            {
                if (Services.ProjectService.IsWorkspaceItemFile(file.FileName) ||
                    Services.ProjectService.IsSolutionItemFile(file.FileName))
                {
                    try {
                        // Close the current solution, but only for the first solution we open.
                        // If more than one solution is specified in the list we want to open all them together.
                        await Workspace.OpenWorkspaceItem(file.FileName, closeCurrent, true, metadata);

                        closeCurrent = false;
                    } catch (Exception ex) {
                        MessageService.ShowError(GettextCatalog.GetString("Could not load solution: {0}", file.FileName), ex);
                    }
                }
                else if (file.FileName.HasExtension("mpack"))
                {
                    var service = new SetupService(AddinManager.Registry);
                    AddinManagerWindow.RunToInstallFile(Workbench.RootWindow.Visible ? Workbench.RootWindow : null,
                                                        service,
                                                        file.FileName.FullPath);
                }
                else
                {
                    filteredFiles.Add(file);
                }
            }

            // Wait for active load operations to be finished (there might be a solution already being loaded
            // when OpenFiles was called). This will ensure that files opened as part of the solution status
            // restoration won't steal the focus from the files we are explicitly loading here.
            await Workspace.CurrentWorkspaceLoadTask;

            for (int n = 0; n < filteredFiles.Count; n++)
            {
                var file = filteredFiles [n];
                if (n == 0)
                {
                    file.Options |= OpenDocumentOptions.BringToFront;
                }
                else
                {
                    file.Options &= ~OpenDocumentOptions.BringToFront;
                }
                IdeServices.DocumentManager.OpenDocument(file).Ignore();
            }
            return(true);
        }