コード例 #1
0
ファイル: Loader.cs プロジェクト: Scrxtchy/Aliapoh.Overlay
        public static bool InitializeMinimum()
        {
            string PDN = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", "").ToString();

            if (CultureInfo.CurrentCulture.Name.StartsWith("ko"))
            {
                DefaultFont = "맑은 고딕";
                if (PDN.StartsWith("Windows 10"))
                {
                    DefaultFont = "맑은 고딕 Semilight";
                }
            }
            else if (CultureInfo.CurrentCulture.Name.StartsWith("ja"))
            {
                DefaultFont = "Meiryo";
            }
            else
            {
                DefaultFont = "Microsoft Sans Serif";
            }

            LOG.Initialize();
            LOG.Logger.Log(LogLevel.Warning, "Aliapoh Overlay on " + (Environment.Is64BitProcess ? "x64" : "x86") + " Process");

            if (Environment.Is64BitProcess)
            {
                CEFDIR = GlobalVariables.DIRDICT["CEFX64"];
            }
            else
            {
                CEFDIR = GlobalVariables.DIRDICT["CEFX86"];
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            var Directories = new List <string>()
            {
                APPDIR,
                CEFDIR,
                GlobalVariables.DIRDICT["BINDIR"]
            };

            asmResolver = new AssemblyResolver(Directories);
            asmResolver.ExceptionOccured += (o, e) => LOG.Logger.Log(LogLevel.Error, "AssemblyResolver: Error: {0}", e.Exception);
            asmResolver.AssemblyLoaded   += (o, e) => LOG.Logger.Log(LogLevel.Debug, "AssemblyResolver: Loaded: {0}", e.LoadedAssembly.FullName);

            VersionManager.Initialize();
            Thread.Sleep(20);
            LOG.Logger.Log(LogLevel.Info, "Initialize CEF");

            CefLoader.Initialize();
            Thread.Sleep(20);
            LOG.Logger.Log(LogLevel.Info, "Initialize Localization");

            LanguageLoader.Initialize();
            Thread.Sleep(20);
            LOG.Logger.Log(LogLevel.Info, "Successfully loaded Aliapoh");

            return(true);
        }
コード例 #2
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);
                                if (!OverlayShow.Checked)
                                {
                                    Overlay.Hide();
                                }
                                else
                                {
                                    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 = OverlayShow.Checked;
                        }
                        Thread.Sleep(1000);
                    }
                }
                catch { }
            }).Start();