static void Main() { if (!HostBridge.IsOnlyInstance()) { return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new HostForm()); }
private void HostForm_Load(object sender, EventArgs e) { this.Text = "GW2Clipboard"; this.notifyIcon.Icon = this.Icon; this.notifyIcon.Visible = true; this.Opacity = 0; hostBridge = new HostBridge(this); // If GW2 is available, emulate it being the last active window lastForiegnWindow = NativeMethods.FindWindow(IntPtr.Zero, "Guild Wars 2"); // Configure launch page (app.html for a release and app-debug.html when debugger is attached) string currentDirectory = Directory.GetCurrentDirectory(); if (hostBridge.IsDebugMode) { //#/CategoryType/0 currentDirectory = Directory.GetParent(currentDirectory).Parent.FullName; appFileName = String.Format("file:///{0}/ClientApp/app-debug.html#/CategoryType/0", currentDirectory.Replace("\\", "/")); } else { appFileName = String.Format("file:///{0}/ClientApp/app.html#/CategoryType/0", currentDirectory.Replace("\\", "/")); } // If MinimizeOnDrawerClosed is true, we never go to close drawer so default to open if (hostBridge.Settings.MinimizeOnStart || hostBridge.Settings.MinimizeOnDrawerClosed) { hostBridge.OpenDrawConfig(); } else { hostBridge.CloseDrawerConfig(); } ApplySettings(); // Registry HotKeys var hotKeySettings = hostBridge.Settings.HotKeys; var hotKeyDefs = new List <HotKeyDefinition>(); foreach (var key in hotKeySettings.Keys) { var hotkey = hotKeySettings[key]; hotKeyDefs.Add(new HotKeyDefinition { id = key, key = (Keys)hotkey[0], modifier = (KeyModifiers)hotkey[1] }); } try { hotKeys = new HotKey(hotKeyDefs, HotKeyDetected); } catch (Exception ex) { MessageBox.Show(ex.Message, "Hotkey configuration error"); Application.Exit(); } this.browser.ObjectForScripting = new ScriptInterface(hostBridge); this.browser.DocumentCompleted += DocumentCompleted; this.browser.Navigate(appFileName); timer.Enabled = true; }
public ScriptInterface(HostBridge hostBridge) { this.hostBridge = hostBridge; }