private void richTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Modifiers == Keys.Control) { if (e.KeyCode == Keys.Add) { Font selectionFont = this.richTextBox1.SelectionFont; if (selectionFont == null) { selectionFont = this.Font; } Font item = new Font(this.Font.FontFamily, selectionFont.Size + 0.75f); this.richTextBox1.SelectionFont = item; this.fontList.Add(item); } else if (e.KeyCode == Keys.Subtract) { Font font = this.richTextBox1.SelectionFont; if (font == null) { font = this.Font; } if (font.Size > 6f) { Font font4 = new Font(this.Font.FontFamily, font.Size - 0.75f); this.richTextBox1.SelectionFont = font4; this.fontList.Add(font4); } } else if (e.KeyCode == Keys.F) { if (this.richTextBox1.CanUndo) { this.FixCurrent(); } IntPtr hWnd = PInvoke.SendMessage(this.listView1.Handle, 0x104e, IntPtr.Zero, IntPtr.Zero); if (hWnd != IntPtr.Zero) { PInvoke.SetWindowPos(hWnd, new IntPtr(-1), 0, 0, 0, 0, 0x13); } this.CreateMemoList(); this.richTextBox1.Visible = false; this.Refresh(); this.textBox1.Focus(); } } }
public void ShowMemoForm(string path) { try { if (!fFirstLoadComplete) { LoadDB(); toolStripTrackBar.Value = (int)(Opacity * 255.0); toolStripTrackBar.BackColor = ProfessionalColors.MenuItemPressedGradientBegin; fFirstLoadComplete = true; } if (fNowShown && richTextBox1.CanUndo) { FixCurrent(); } currentPath = path; if (path.Length > 3) { Text = Path.GetFileName(path); } else { Text = path; } richTextBox1.SuspendLayout(); richTextBox1.Clear(); if (rtfDic.ContainsKey(currentPath)) { richTextBox1.Rtf = rtfDic[currentPath]; } richTextBox1.Visible = true; richTextBox1.ResumeLayout(); if (!fNowShown) { Show(); PInvoke.SetWindowPos(Handle, (IntPtr)(-1), 0, 0, 0, 0, 0x53); fNowShown = true; } } catch (Exception) { } }
public void ShowWindow(Point pnt, FOLDERVIEWMODE fvmCurrentMode) { const uint SWP_NOACTIVATE = 0x0010; const int SW_SHOWNOACTIVATE = 4; trackBar1.Value = ModeToInt(fvmCurrentMode); // set the slider of trackbar under mouse position RECT rct = GetThumbRect(); Point pntCenter = new Point(rct.left + rct.Width / 2, rct.top + rct.Height / 2); Rectangle rctScreen = Screen.FromPoint(pnt).Bounds; pnt.X = pnt.X - pntCenter.X; pnt.Y = pnt.Y - pntCenter.Y; // ensure visible in the screen if (pnt.X < rctScreen.Left) { pnt.X = rctScreen.Left; } else if (pnt.X + Width > rctScreen.Right) { pnt.X = rctScreen.Right - Width; } if (pnt.Y < rctScreen.Top) { pnt.Y = rctScreen.Top; } else if (pnt.Y + Height > rctScreen.Bottom) { pnt.Y = rctScreen.Bottom - Height; } PInvoke.SetWindowPos(Handle, (IntPtr)(-1), pnt.X, pnt.Y, Width, Height, SWP_NOACTIVATE); PInvoke.ShowWindow(Handle, SW_SHOWNOACTIVATE); trackBar1.Focus(); }