Пример #1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            bool handle = false;

            Shortcuts.ProcessCmdKey(ref msg, keyData, ref handle);
            if (handle)
            {
                return(true);
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Пример #2
0
        public static void Update()
        {
            if (isFontSizeDirtied)
            {
                NativeManager.InvalidateFont();
                var appDirectory = Manager.GetEntryDirectory();
                var type         = Core.Option.Font.Value;

                NativeManager.ClearAllFonts();

                var characterTable = System.IO.Path.Combine(appDirectory, "resources/languages/characterTable.txt");

                if (type == Data.FontType.Normal)
                {
                    NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, MultiLanguageTextProvider.GetText("Font_Normal")), characterTable, MultiLanguageTextProvider.GetText("CharacterTable"), Core.Option.FontSize.Value);
                }
                else if (type == Data.FontType.Bold)
                {
                    NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, MultiLanguageTextProvider.GetText("Font_Bold")), characterTable, MultiLanguageTextProvider.GetText("CharacterTable"), Core.Option.FontSize.Value);
                }

                NativeManager.AddFontFromAtlasImage(System.IO.Path.Combine(appDirectory, "resources/icons/MenuIcons.png"), 0xec00, 24, 24, 16, 16);

                isFontSizeDirtied = false;
            }

            // Reset

            IO.Update();
            Shortcuts.Update();
            Network.Update();

            var handle = false;

            if (!handle)
            {
                if (!NativeManager.IsAnyItemActive())
                {
                    Shortcuts.ProcessCmdKey(ref handle);
                }
            }

            var mousePos = NativeManager.GetMousePosition();

            if (isFirstUpdate)
            {
                mousePos_pre = mousePos;
            }

            if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered))
            {
                var result = ControllViewport();

                if (result.Slide)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._3D)
                    {
                        Viewer.Slide(dx / 30.0f, dy / 30.0f);
                    }
                    else if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._2D)
                    {
                        Viewer.Slide(dx / 16.0f, dy / 16.0f);
                    }
                }
                else if (NativeManager.GetMouseWheel() != 0)
                {
                    Viewer.Zoom(NativeManager.GetMouseWheel());
                }
                else if (result.Zoom)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;
                    Viewer.Zoom(-dy * 0.25f);
                }
                else if (result.Rotate)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._3D)
                    {
                        Viewer.Rotate(dx, dy);
                    }
                    else if (Core.Option.ViewerMode.Value == Data.OptionValues.ViewMode._2D)
                    {
                        Viewer.Slide(dx / 16.0f, dy / 16.0f);
                    }
                }
            }

            mousePos_pre = mousePos;

            Viewer.UpdateViewer();

            Native.UpdateWindow();

            Native.ClearWindow(50, 50, 50, 0);

            //if(effectViewer == null)
            //{
            //	Native.RenderWindow();
            //}

            NativeManager.ResetGUI();

            if (resetCount < 0)
            {
                resetCount++;
                if (resetCount == 0)
                {
                    Application.Current.OnResetWindowActually();
                }
            }

            if (resizedCount > 0)
            {
                resizedCount--;
            }

            Controls.Lock();

            foreach (var c in Controls.Internal)
            {
                c.Update();
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }

                var dp = _ as Dock.DockPanel;
                if (dp != null)
                {
                    dp.DispatchDisposed();
                }
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }
                Controls.Remove(_);
            }

            Controls.Unlock();

            for (int i = 0; i < dockTypes.Length; i++)
            {
                if (panels[i] != null && panels[i].ShouldBeRemoved)
                {
                    panels[i] = null;
                }
            }

            NativeManager.RenderGUI(resizedCount == 0);

            Native.Present();
            NativeManager.Present();

            isFirstUpdate = false;

            // TODO more smart
            // When minimized, suppress CPU activity
            if (actualWidth == 0)
            {
                System.Threading.Thread.Sleep(16);
            }
        }
Пример #3
0
        public static void Update()
        {
            Shortcuts.Update();

            var handle = false;

            if (!handle)
            {
                Shortcuts.ProcessCmdKey(ref handle);
            }

            var mousePos = NativeManager.GetMousePosition();

            if (isFirstUpdate)
            {
                mousePos_pre = mousePos;
            }

            if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered))
            {
                if (NativeManager.GetMouseButton(2) > 0)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    Viewer.Slide(dx / 30.0f, dy / 30.0f);
                }

                if (NativeManager.GetMouseButton(1) > 0)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    Viewer.Rotate(dx, dy);
                }

                if (NativeManager.GetMouseWheel() != 0)
                {
                    Viewer.Zoom(NativeManager.GetMouseWheel());
                }
            }

            mousePos_pre = mousePos;

            Viewer.UpdateViewer();

            Native.UpdateWindow();

            Native.ClearWindow(50, 50, 50, 0);

            if (effectViewer == null)
            {
                Native.RenderWindow();
            }

            NativeManager.ResetGUI();

            if (resetCount < 0)
            {
                resetCount++;
                if (resetCount == 0)
                {
                    ResetWindowActually();
                }
            }

            Controls.Lock();

            foreach (var c in Controls.Internal)
            {
                c.Update();
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }

                var dp = _ as Dock.DockPanel;
                if (dp != null)
                {
                    dp.DispatchDisposed();
                }
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }
                Controls.Remove(_);
            }

            Controls.Unlock();

            for (int i = 0; i < dockTypes.Length; i++)
            {
                if (panels[i] != null && panels[i].ShouldBeRemoved)
                {
                    panels[i] = null;
                }
            }

            NativeManager.RenderGUI();

            Native.Present();
            NativeManager.Present();

            isFirstUpdate = false;
        }
Пример #4
0
        public static void Update()
        {
            // Reset
            NativeManager.SetNextDockRate(0.5f);
            NativeManager.SetNextDock(swig.DockSlot.Tab);
            NativeManager.ResetNextParentDock();

            Shortcuts.Update();

            var handle = false;

            if (!handle)
            {
                var cursor = Manager.NativeManager.GetMouseCursor();
                if (cursor == swig.MouseCursor.None || cursor == swig.MouseCursor.Arrow)
                {
                    Shortcuts.ProcessCmdKey(ref handle);
                }
            }

            var mousePos = NativeManager.GetMousePosition();

            if (isFirstUpdate)
            {
                mousePos_pre = mousePos;
            }

            if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered))
            {
                if (NativeManager.GetMouseButton(2) > 0)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    Viewer.Slide(dx / 30.0f, dy / 30.0f);
                }

                if (NativeManager.GetMouseButton(1) > 0)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    Viewer.Rotate(dx, dy);
                }

                if (NativeManager.GetMouseWheel() != 0)
                {
                    Viewer.Zoom(NativeManager.GetMouseWheel());
                }
            }

            mousePos_pre = mousePos;

            Viewer.UpdateViewer();

            Native.UpdateWindow();

            Native.ClearWindow(50, 50, 50, 0);

            if (effectViewer == null)
            {
                Native.RenderWindow();
            }

            NativeManager.ResetGUI();

            if (resetCount < 0)
            {
                resetCount++;
                if (resetCount == 0)
                {
                    ResetWindowActually();
                }
            }

            if (resizedCount > 0)
            {
                resizedCount--;
            }

            Controls.Lock();

            foreach (var c in Controls.Internal)
            {
                c.Update();
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }

                var dp = _ as Dock.DockPanel;
                if (dp != null)
                {
                    dp.DispatchDisposed();
                }
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }
                Controls.Remove(_);
            }

            Controls.Unlock();

            for (int i = 0; i < dockTypes.Length; i++)
            {
                if (panels[i] != null && panels[i].ShouldBeRemoved)
                {
                    panels[i] = null;
                }
            }

            NativeManager.RenderGUI(resizedCount == 0);

            Native.Present();
            NativeManager.Present();

            isFirstUpdate = false;

            // TODO more smart
            // When minimized, suppress CPU activity
            if (actualWidth == 0)
            {
                System.Threading.Thread.Sleep(16);
            }
        }
Пример #5
0
        public static void Update()
        {
            if (isFontSizeDirtied)
            {
                NativeManager.InvalidateFont();
                var appDirectory = Manager.GetEntryDirectory();
                var type         = Core.Option.Font.Value;

                if (type == Data.FontType.Normal)
                {
                    NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, "resources/GenShinGothic-Monospace-Normal.ttf"), Core.Option.FontSize.Value);
                }
                else if (type == Data.FontType.Bold)
                {
                    NativeManager.AddFontFromFileTTF(System.IO.Path.Combine(appDirectory, "resources/fonts/GenShinGothic-Monospace-Bold.ttf"), Core.Option.FontSize.Value);
                }
                isFontSizeDirtied = false;
            }

            // Reset
            NativeManager.SetNextDockRate(0.5f);
            NativeManager.SetNextDock(swig.DockSlot.Tab);
            NativeManager.ResetNextParentDock();

            IO.Update();
            Shortcuts.Update();
            Network.Update();

            var handle = false;

            if (!handle)
            {
                if (!NativeManager.IsAnyItemActive())
                {
                    Shortcuts.ProcessCmdKey(ref handle);
                }
            }

            var mousePos = NativeManager.GetMousePosition();

            if (isFirstUpdate)
            {
                mousePos_pre = mousePos;
            }

            if ((effectViewer == null && !NativeManager.IsAnyWindowHovered()) || (effectViewer != null && effectViewer.IsHovered))
            {
                if (NativeManager.GetMouseButton(2) > 0)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    Viewer.Slide(dx / 30.0f, dy / 30.0f);
                }

                if (NativeManager.GetMouseButton(1) > 0)
                {
                    var dx = mousePos.X - mousePos_pre.X;
                    var dy = mousePos.Y - mousePos_pre.Y;

                    Viewer.Rotate(dx, dy);
                }

                if (NativeManager.GetMouseWheel() != 0)
                {
                    Viewer.Zoom(NativeManager.GetMouseWheel());
                }
            }

            mousePos_pre = mousePos;

            Viewer.UpdateViewer();

            Native.UpdateWindow();

            Native.ClearWindow(50, 50, 50, 0);

            if (effectViewer == null)
            {
                Native.RenderWindow();
            }

            NativeManager.ResetGUI();

            if (resetCount < 0)
            {
                resetCount++;
                if (resetCount == 0)
                {
                    ResetWindowActually();
                }
            }

            if (resizedCount > 0)
            {
                resizedCount--;
            }

            Controls.Lock();

            foreach (var c in Controls.Internal)
            {
                c.Update();
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }

                var dp = _ as Dock.DockPanel;
                if (dp != null)
                {
                    dp.DispatchDisposed();
                }
            }

            foreach (var _ in Controls.Internal)
            {
                if (!_.ShouldBeRemoved)
                {
                    continue;
                }
                Controls.Remove(_);
            }

            Controls.Unlock();

            for (int i = 0; i < dockTypes.Length; i++)
            {
                if (panels[i] != null && panels[i].ShouldBeRemoved)
                {
                    panels[i] = null;
                }
            }

            NativeManager.RenderGUI(resizedCount == 0);

            Native.Present();
            NativeManager.Present();

            isFirstUpdate = false;

            // TODO more smart
            // When minimized, suppress CPU activity
            if (actualWidth == 0)
            {
                System.Threading.Thread.Sleep(16);
            }
        }