private void InitializeAdditionalComponents() { // The panel for moving the form by any point. this.panel1 = new TransparentDraggablePanel(this) { Name = "panel1", Location = new System.Drawing.Point(0, 0), Size = this.Size, TabIndex = 1, Locked = m_Locked }; var title = User32Windows.GetWindowText(m_Handle, 255); this.Text = "Transparent - " + title; var icon = User32Windows.GetIcon(m_Handle); if (icon != null) { this.pictureBox1.Image = icon.ToBitmap(); } this.Controls.Add(this.panel1); panel1.BringToFront(); if (IsWindows10()) { this.panel1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.TransparentWindowToolForm_MouseWheel); } else { this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.TransparentWindowToolForm_MouseWheel); } this.panel1.DoubleClick += new System.EventHandler(this.TransparentWindowToolForm_DoubleClick); this.panel1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.TransparentWindowToolForm_MouseClick); this.LocationChanged += (sender, e) => { m_ClicksCount = ClicksToShow - 2; }; }
private void propertiesToolStripMenuItem_Click(object sender, EventArgs e) { var settingsForm = new SendCommandToolPropertiesForm() { HostHwnd = this.m_HostWindowHwnd, ToolWidht = this.Size.Width, ToolHeight = this.Size.Height, AnchorH = m_AnchorH, AnchorV = m_AnchorV, Commands = m_Commands, CommandType = m_SendCommandType, Sleep = m_Sleep, SleepTimeout = m_SleepTimeout, RunOnAllWindowsWithSameTitle = m_RunOnAllWindowsWithSameTitle, ToolLeft = this.Location.X, ToolTop = this.Location.Y, BorderColor = this.m_PenNormal.Color, BorderHoverColor = this.m_PenHover.Color, TitlePattern = this.m_TitlePattern, ActivateOnHover = this.ActivateOnHover }; var result = settingsForm.ShowDialog(); if (result == DialogResult.OK) { this.m_HostWindowHwnd = settingsForm.HostHwnd; this.Size = new Size(settingsForm.ToolWidht, settingsForm.ToolHeight); this.m_AnchorH = settingsForm.AnchorH; this.m_AnchorV = settingsForm.AnchorV; this.m_DrawRectangle = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1); this.m_Commands = settingsForm.Commands; this.m_SendCommandType = settingsForm.CommandType; if (this.m_SendCommandType == SendCommandType.ActivateWindow) { int handle; if (int.TryParse(m_Commands, out handle)) { if (User32Windows.IsWindow((IntPtr)handle)) { if (this.BackgroundImagePath != string.Empty) { var q = MessageBox.Show("The tool already has an background icon,\novervrite?", "Background icon", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (q == DialogResult.No) { return; } } var icon = User32Windows.GetIcon((IntPtr)handle); if (icon != null) { this.BackgroundImage = icon.ToBitmap(); } } } } this.m_Sleep = settingsForm.Sleep; this.m_SleepTimeout = settingsForm.SleepTimeout; this.m_RunOnAllWindowsWithSameTitle = settingsForm.RunOnAllWindowsWithSameTitle; this.m_TitlePattern = settingsForm.TitlePattern; this.Location = new Point(settingsForm.ToolLeft, settingsForm.ToolTop); this.m_PenNormal.Color = settingsForm.BorderColor; this.m_PenHover.Color = settingsForm.BorderHoverColor; if (m_TitlePattern != String.Empty) { m_TitleRegex = new Regex(m_TitlePattern); } else { m_TitleRegex = null; } this.ActivateOnHover = settingsForm.ActivateOnHover; } }