public Toggler(string[] args) { _args = args; // Always on top if (Settings.Instance.AlwaysOnTop) { TopMostWindow.SetTopMost(_process); } // Hide from taskbar var windLong = User32.GetWindowLong(_process.MainWindowHandle, User32.GWL_EX_STYLE); User32.ThrowIfError(); User32.SetWindowLong(_process.MainWindowHandle, User32.GWL_EX_STYLE, (windLong | User32.WS_EX_TOOLWINDOW) & ~User32.WS_EX_APPWINDOW); User32.Rect rect = default; User32.ShowWindow(_process.MainWindowHandle, NCmdShow.MAXIMIZE); var isOpen = true; // Register hotkeys Settings.Get(s => { if (s.Hotkeys == null) { return; // Hotkeys not loaded yet } _registeredHotKeys.ForEach(hk => HotKeyManager.UnregisterHotKey(hk)); _registeredHotKeys.Clear(); s.Hotkeys.ForEach(hk => { Log.Information($"Registering hot key {hk.Modifiers} + {hk.Key}"); var reg = HotKeyManager.RegisterHotKey(hk.Key, hk.Modifiers); _registeredHotKeys.Add(reg); }); }); // Hide on focus lost FocusTracker.OnFocusLost += (s, a) => { if (Settings.Instance.HideOnFocusLost && isOpen) { isOpen = false; Toggle(false, 0); } }; // Toggle on hotkey(s) HotKeyManager.HotKeyPressed += (s, a) => { Toggle(!isOpen, Settings.Instance.ToggleDurationMs); isOpen = !isOpen; }; // Start hidden? if (Settings.Instance.StartHidden) { Toggle(isOpen = false, 0); } }
private void Form_RunText_Load(object sender, EventArgs e) { { label_text.Font = f; label_text.ForeColor = c; //Console.WriteLine("===" + c); //this.BackColor = bc; label_text.Text = text; if (text.Equals("")) { label_text.Visible = false; //contextMenuStrip1.Enabled = false; subTextToolStripMenuItem.Enabled = false; AutotoolStripMenuItem1.Enabled = false; } timer1.Interval = Interval; Lable_Resize(); label_text.BackColor = Color.Transparent; if (tans_Flag) { this.TopMost = true; timer2.Enabled = true; } else { if (image_Flag) { string s = settingFile.ReadString("SETTING", "PictureLogo", ""); //Console.WriteLine("s ====" + s); if (!s.Equals("")) { s = s.Substring(s.Length - 4, 4); s = Application.StartupPath + @"\pic\logoshow" + s; if (this.BackgroundImage != null) { this.BackgroundImage.Dispose(); } Image im = Image.FromFile(s); this.BackgroundImage = new Bitmap(im); this.BackgroundImageLayout = ImageLayout.Stretch; } else { if (this.BackgroundImage != null) { this.BackgroundImage.Dispose(); } //this.BackgroundImage = global::WallControl.Properties.Resources.上位机_英文版_MTC_New_Logo; this.BackgroundImageLayout = ImageLayout.Stretch; } timer1.Enabled = false; //AutoAdjustShow(); label_text.TextAlign = ContentAlignment.MiddleCenter; subStopToolStripMenuItem.Checked = true; AutotoolStripMenuItem1.Enabled = true; subStartToolStripMenuItem.CheckState = CheckState.Unchecked; subStartToolStripMenuItem.Enabled = false; subColorToolStripMenuItem.Enabled = false; //int h = label_text.Size.Height; this.Height = (this.Size.Width * 9) / 16; //label_text.Location = new Point(w, (this.Size.Height - h) / 2); } } //if (tans_Flag) { if (Interval > 0 && !text.Equals("")) { /* * Thread t = new Thread(new ThreadStart(StartRunText)); * t.IsBackground = true; * t.Start(); */ if (direction) { label_text.Left = this.Width; } else { label_text.Left = -label_text.Width; } if (!image_Flag) { timer1.Enabled = true; timer1.Start(); } } else { timer1.Enabled = false; //AutoAdjustShow(); label_text.TextAlign = ContentAlignment.MiddleCenter; subStartToolStripMenuItem.CheckState = CheckState.Unchecked; subStopToolStripMenuItem.CheckState = CheckState.Checked; AutotoolStripMenuItem1.Enabled = true; subStartToolStripMenuItem.Enabled = false; //int h = label_text.Size.Height; //int w = (this.Size.Width - label_text.Size.Width) / 2; //label_text.Location = new Point(w, (this.Size.Height - h) / 2); } this.Activate(); } } Lable_Resize(); //IntPtr hDeskTop = FindWindow(null, "Form_RunText"); //SetParent(this.Handle, hDeskTop); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); TopMostWindow.SetTopomost(this.Handle); }