Example #1
0
        public GDIZone(RenderedLayout Layout)
        {
            var instanceHandle = System.Diagnostics.Process.GetCurrentProcess().Handle;

            TransWind = new Window("ZoneMove", TransparencyPaintFunc, instanceHandle, hidden: true, delayShow: true)
            {
                Left         = -5,
                Top          = 0 - GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) - 7,
                Width        = ScreenInfo.GetDisplays().MaxWidth + 10,
                Height       = ScreenInfo.GetDisplays().MaxHeight + GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) + 15,
                ZPos         = GDIWindow.Win32Enums.HWNDPosStates.TopMost,
                Style        = GDIWindow.Win32Enums.WindowStylesEx.WS_EX_VisualStudioEmulation | GDIWindow.Win32Enums.WindowStylesEx.WS_EX_TOPMOST,
                Transparency = BackgroundColor.A,
            };

            LabelWind = new Window("ZoneMove1", LabelPaintFunc, TransWind.Handle, hidden: true, delayShow: true)
            {
                Left         = -5,
                Top          = 0 - GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) - 7,
                Width        = ScreenInfo.GetDisplays().MaxWidth + 10,
                Height       = ScreenInfo.GetDisplays().MaxHeight + GDIWindow.WinApi.WinAPI.GetSystemMetrics(GDIWindow.Win32Enums.SystemMetric.SM_CYCAPTION) + 15,
                ZPos         = GDIWindow.Win32Enums.HWNDPosStates.TopMost,
                Style        = GDIWindow.Win32Enums.WindowStylesEx.WS_EX_VisualStudioEmulation | GDIWindow.Win32Enums.WindowStylesEx.WS_EX_TOPMOST,
                Transparency = 255,
            };

            TransWind.DelayedShow();
            LabelWind.DelayedShow();

            UpdateZones(Layout);
        }
Example #2
0
        private static void MouseButtonDown(MSLLHOOKSTRUCT m)
        {
            if (HotkeyState.HasFlag(TriggerHotkeys) || TriggerHotkeys == default(state))
            {
                candidateWindow = GetWindowDetailsFromPoint(m.pt);
                if (candidateWindow.IsPartOfWindowsUI)
                {
                    Console.WriteLine("Candidate Window is shell window -- NO!");
                    candidateWindow = null;
                    return;
                }
                if (DropZone.Settings.OnlyTriggerOnTitleBarClick && m.pt.y > candidateWindow.rect.Top + candidateWindow.TitleBarHeight)
                {
                    Console.WriteLine("Click detected, but not in title bar constraints");
                    candidateWindow = null;
                    return;
                }

                HotkeyState.Add(state.active);
                new System.Threading.Tasks.Task(() =>
                {
                    mhook.MouseMove += Mhook_MouseMove;
                    renderer.ActivateSector(LayoutCollection.ActiveLayout.GetActiveZoneFromPoint(m.pt.x, m.pt.y));

                    renderer.RenderZone(ScreenInfo.GetDisplays().MaxWidth, ScreenInfo.GetDisplays().MaxHeight);
                }).Start();
#if DEBUG
                printState(m);
#endif
            }
        }
Example #3
0
        public static int StartCore()
        {
            IZoneRenderer.ActiveZoneColor = Color.FromArgb(Int32.Parse(DropZone.Settings.ActiveColor.TrimStart('#'), System.Globalization.NumberStyles.HexNumber));
//            IZoneRenderer.BackgroundOpacity = DropZone.Settings.BackgroundOpacity;
            IZoneRenderer.LabelColor = Color.FromArgb(Int32.Parse(DropZone.Settings.LabelColor.TrimStart('#'), System.Globalization.NumberStyles.HexNumber));

            var dic = ScreenInfo.GetDisplays();

            LayoutCollection = DropZone.Settings.Zones;
            renderer         = new ZoneRenderer.GDI.GDIZone(LayoutCollection.ActiveLayout);

            var t = new SystemTray.TrayIcon(Process.GetCurrentProcess().Handle, "Exit Drop Zone", GetDropZoneIcon().GetHicon());

            t.Events[SystemTray.TrayIcon.MouseMessages.WM_LBUTTONDOWN] += (s, e) => {
                System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location, "management");
            };
            t.Events[SystemTray.TrayIcon.MouseMessages.WM_LBUTTONDBLCLK] += (s, e) =>
            {
                System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location, "management");
            };

            if (!Environment.GetCommandLineArgs().Any(x => x == "Silent"))
            {
                t.PostInfo("DropZone Running", "DropZone will run in the background, click the system try icon to close the process");
            }
#if DEBUG
            ShowConsole();
#else
            HideConsole();
#endif
            RegisterInputHooks();
            return(MessagePump.Pump.Start((str, ex) => {
                t.PostInfo("DropZone Error", str);
            }));
        }