private void Initializer(SettingObject setting)
        {
            Name = setting.Name;
            InitializeComponent();

            OverlayName.Text = setting.Name;
            overlayGlobalHotkeyType.Items.Add(ShortcutModeNone);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeHide);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeClickthru);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeToggleLock);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeTakeScreenshot);

            OverlayWidth.ValueChanged       += SaveSetting;
            OverlayHeight.ValueChanged      += SaveSetting;
            OverlayX.ValueChanged           += SaveSetting;
            OverlayY.ValueChanged           += SaveSetting;
            OverlayNameChangeButton.Click   += SaveSetting;
            OverlayLock.CheckedChanged      += SaveSetting;
            OverlayClickthru.CheckedChanged += SaveSetting;
            OverlayShow.CheckedChanged      += SaveSetting;
            OverlayFramerate.ValueChanged   += SaveSetting;
            SiteURL.TextChanged             += SaveSetting;
            overlayGlobalHotkeyType.SelectedIndexChanged += SaveSetting;

            SiteURL.Text = setting.Url;

            Overlay = new OverlayForm(setting.Url)
            {
                Framerate     = setting.Framerate,
                Name          = setting.Name,
                Text          = setting.Name,
                ShowInTaskbar = false
            };

            if (!DesignMode)
            {
                LanguageLoader.LanguagePatch(this);
            }

            Overlay.LocationChanged += Overlay_LocationChanged;
            Overlay.SizeChanged     += Overlay_SizeChanged;
            Overlay.Show();
            Overlay.Location                       = new Point(setting.Left, setting.Top);
            Overlay.Size                           = new Size(setting.Width, setting.Height);
            OverlayClickthru.Checked               = setting.Clickthru;
            OverlayGlobalHotkey.Checked            = setting.UseGlobalHotkey;
            OverlayLock.Checked                    = setting.Locked;
            OverlayEnableBeforeLogLineRead.Checked = setting.BeforeLogLineRead;

            GlobalHotkey                  = (Keys)setting.GlobalHotkey;
            GlobalHotkeyModifiers         = (Keys)setting.GlobalHotkeyModifiers;
            OverlayGlobalHotkeyInput.Text = GetHotkeyString((Keys)setting.GlobalHotkeyModifiers, (Keys)setting.GlobalHotkey, "");

            OverlayFramerate.Value              = setting.Framerate;
            OverlayUpdaterate.Value             = setting.Updaterate;
            Overlay.OverlayTicTimer.Interval    = setting.Updaterate;
            Overlay.Browser.BrowserInitialized += Browser_BrowserInitialized;
            IsInitialized = true;
        }
        public SettingObject SettingExport()
        {
            var s = new SettingObject()
            {
                Url                   = SiteURL.Text,
                Name                  = OverlayName.Text,
                Show                  = OverlayShow.Checked,
                Clickthru             = OverlayClickthru.Checked,
                Locked                = OverlayLock.Checked,
                UseGlobalHotkey       = OverlayGlobalHotkey.Checked,
                BeforeLogLineRead     = OverlayEnableBeforeLogLineRead.Checked,
                Framerate             = (int)OverlayFramerate.Value,
                Updaterate            = (int)OverlayUpdaterate.Value,
                Width                 = (int)OverlayWidth.Value,
                Height                = (int)OverlayHeight.Value,
                Left                  = (int)OverlayX.Value,
                Top                   = (int)OverlayY.Value,
                GlobalHotkey          = (int)GlobalHotkey,
                GlobalHotkeyModifiers = (int)GlobalHotkeyModifiers,
                GlobalHotkeyType      = overlayGlobalHotkeyType.SelectedIndex,
            };

            return(s);
        }
 public OverlayConfig(SettingObject s)
 {
     Initializer(s);
 }
Example #4
0
        private void Initializer(SettingObject setting)
        {
            Name = setting.Name;
            InitializeComponent();

            OverlayName.Text = setting.Name;
            overlayGlobalHotkeyType.Items.Add(ShortcutModeNone);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeHide);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeClickthru);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeToggleLock);
            overlayGlobalHotkeyType.Items.Add(ShortcutModeTakeScreenshot);

            OverlayWidth.ValueChanged       += SaveSetting;
            OverlayHeight.ValueChanged      += SaveSetting;
            OverlayX.ValueChanged           += SaveSetting;
            OverlayY.ValueChanged           += SaveSetting;
            OverlayNameChangeButton.Click   += SaveSetting;
            OverlayLock.CheckedChanged      += SaveSetting;
            OverlayClickthru.CheckedChanged += SaveSetting;
            OverlayShow.CheckedChanged      += SaveSetting;
            OverlayFramerate.ValueChanged   += SaveSetting;
            SiteURL.TextChanged             += SaveSetting;
            overlayGlobalHotkeyType.SelectedIndexChanged += SaveSetting;

            OverlayEnableBeforeLogLineRead.CheckedChanged += SaveSetting;
            OverlayGlobalHotkey.CheckedChanged            += SaveSetting;

            SiteURL.Text = setting.Url;

            Overlay = new OverlayForm(setting.Url)
            {
                Framerate     = setting.Framerate,
                Name          = setting.Name,
                Text          = setting.Name,
                ShowInTaskbar = false
            };

            if (!DesignMode)
            {
                LanguageLoader.LanguagePatch(this);
            }

            Overlay.LocationChanged += Overlay_LocationChanged;
            Overlay.SizeChanged     += Overlay_SizeChanged;
            Overlay.Show();
            Overlay.Location                       = new Point(setting.Left, setting.Top);
            Overlay.Size                           = new Size(setting.Width, setting.Height);
            OverlayClickthru.Checked               = setting.Clickthru;
            OverlayGlobalHotkey.Checked            = setting.UseGlobalHotkey;
            OverlayLock.Checked                    = setting.Locked;
            OverlayEnableBeforeLogLineRead.Checked = setting.BeforeLogLineRead;

            new Thread((ThreadStart) delegate
            {
                try
                {
                    while (!Process.GetCurrentProcess().HasExited)
                    {
                        if (SettingManager.GlobalSetting.AutoHide)
                        {
                            var l = SettingManager.GlobalSetting.DetectProcessName.Split(',');
                            for (var i = 0; i < l.Length; i++)
                            {
                                l[i] = l[i].ToLower().Trim();
                            }

                            try
                            {
                                var hnd = NativeMethods.GetForegroundWindow();
                                NativeMethods.GetWindowThreadProcessId(hnd, out uint pid);
                                Overlay.Visible = l.Contains(System.IO.Path.GetFileName(Process.GetProcessById((int)pid).MainModule.FileName).ToLower());
                            }
                            catch
                            {
                                // caution: if you running STEAM GAME with VAC, comming here
                            }
                        }
                        else
                        {
                            Overlay.Visible = true;
                        }
                        Thread.Sleep(1000);
                    }
                }
                catch { }
            }).Start();