public BarrageWindow(ConfigurationsCollection confs) { // Initialize Form this.ShowInTaskbar = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Size = new Size(600, 400); this.MinimumSize = new Size(500, 300); this.StartPosition = FormStartPosition.WindowsDefaultLocation; IntPtr screenDc = ApiHelper.GetDC(IntPtr.Zero); hMemDc = ApiHelper.CreateCompatibleDC(screenDc); hBitmap = ApiHelper.CreateCompatibleBitmap(screenDc, ClientSize.Width, ClientSize.Height); ApiHelper.ReleaseDC(IntPtr.Zero, screenDc); ApiHelper.SelectObject(hMemDc, hBitmap); // Initialize Configurations this.confs = confs; hideKey = confs["General"].GetKeys("Hide-Key", Keys.Control | Keys.Alt | Keys.Q); GlobalKeyHook.Instance.SetProcessor(confs["General"].GetKeys("Exit-Key", Keys.Control | Keys.Alt | Keys.Shift | Keys.P), k => { this.BeginInvoke(new Action(() => this.Close())); return true; }); GlobalKeyHook.Instance.Start(); reverseColorKey = confs["General"].GetKeys("ReversColor-Key", Keys.Control | Keys.Alt | Keys.W); increaseAlphaKey = confs["General"].GetKeys("IncreaseAlpha-Key", Keys.Control | Keys.Alt | Keys.E); decreaseAlphaKey = confs["General"].GetKeys("DecreaseAlpha-Key", Keys.Control | Keys.Alt | Keys.R); infoBackColor = confs["General"].GetArgbColor("Info-BackColor", Color.FromArgb(128, Color.Gray)); infoBorderColor = confs["General"].GetArgbColor("Info-BorderColor", Color.Red); // Initialize NotifyIcon notifyIcon = new NotifyIcon(); notifyIcon.Text = "OriginalFire Barrager"; notifyIcon.Icon = Resource.OriginalFire_Barrager; MenuItem exitMenu = new MenuItem("退出", (sender, e) => this.Close()); ContextMenu contextMenu = new ContextMenu(); contextMenu.MenuItems.Add(exitMenu); notifyIcon.ContextMenu = contextMenu; notifyIcon.Visible = true; // Initialize Infomations infoBitmap = Infomations.CreateInfoBitmap(); copyrightBitmap = Infomations.CreateCopyrightBitmap(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool createdNew; using (Mutex mutex = new Mutex(true, "OriginalFire Barrager", out createdNew)) { if (!createdNew) { mutex.Close(); MessageBox.Show("OriginalFire Barrager已在运行中。", "OriginalFire Barrager"); return; } ConfigurationsCollection confs = new ConfigurationsCollection("config.ini"); Application.Run(new BarrageWindow(confs)); } }