void CustomComboBox_MouseClick(object sender, MouseEventArgs e) { if (e.Button != Forms.MouseButtons.Left) { return; } //if (DropDownButtonHitTest(e.Location)) { Form parentForm = FormManager.GetTopForm(this.Parent); Point screenLocation = Point.Empty; if (this.Parent as Form != null) { screenLocation = parentForm.PointToScreen(this.Location); frmDropDownList.Location = new Point( screenLocation.X, screenLocation.Y + this.Height - 1); } else { screenLocation = this.PointToScreen(this.Location); frmDropDownList.Location = new Point( screenLocation.X - this.Location.X, screenLocation.Y + this.Height - this.Location.Y - 2); } //frmDropDownList.TopMost = true; frmDropDownList.Show(); frmDropDownList.Activate(); } }
public static Point[] Draw(Pen pen, Form parent) { sPen = pen; // Record the start point mPos = parent.PointToClient(Control.MousePosition); // Create a transparent form on top of the parent form mMask = new Form(); mMask.FormBorderStyle = FormBorderStyle.None; mMask.BackColor = Color.Magenta; mMask.TransparencyKey = mMask.BackColor; mMask.ShowInTaskbar = false; mMask.StartPosition = FormStartPosition.Manual; mMask.Size = parent.ClientSize; mMask.Location = parent.PointToScreen(Point.Empty); mMask.MouseMove += MouseMove; mMask.MouseUp += MouseUp; mMask.Paint += PaintRectangle; mMask.Load += DoCapture; // Display the overlay mMask.ShowDialog(parent); // Clean-up and calculate return value mMask.Dispose(); mMask = null; var pos = parent.PointToClient(Control.MousePosition); return new[] {mPos, pos}; }
void ParentForm_LocationChanged(object sender, EventArgs e) { Form parentForm = sender as Form; Point p = parentForm.PointToScreen(this.Location); frmDropDownList.Location = new Point(p.X, p.Y + this.Height); }
public YamuiSmokeScreen(Form owner, Rectangle pageRectangle) { SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true); _pageRectangle = pageRectangle; FormBorderStyle = FormBorderStyle.None; ControlBox = false; ShowInTaskbar = false; StartPosition = FormStartPosition.Manual; Location = owner.PointToScreen(_pageRectangle.Location); _sizeDifference = new Point(owner.Width - _pageRectangle.Width, owner.Height - _pageRectangle.Height); ClientSize = new Size(owner.Width - _sizeDifference.X, owner.Height - _sizeDifference.Y); owner.LocationChanged += Cover_LocationChanged; owner.ClientSizeChanged += Cover_ClientSizeChanged; owner.VisibleChanged += Cover_OnVisibleChanged; // Disable Aero transitions, the plexiglass gets too visible if (Environment.OSVersion.Version.Major >= 6) { int value = 1; DwmApi.DwmSetWindowAttribute(owner.Handle, DwmApi.DwmwaTransitionsForcedisabled, ref value, 4); } base.Opacity = 0d; Show(owner); owner.Focus(); }
//posicion en pantalla public static void Position(bool mover, System.Windows.Forms.Form form, int px, int py) { //px coordenada en X //py coordenada en Y //Mover deshabilitar y habilitar el movimiento del objeto //posiciones capturados en 'objeto'_Down if (mover == true) { form.Location = form.PointToScreen(new System.Drawing.Point(System.Windows.Forms.Control.MousePosition.X - px - form.Location.X, System.Windows.Forms.Control.MousePosition.Y - py - form.Location.Y)); } }
private MaskedDialog(Form parent, UserControl ucDialog) { this.ucDialog = ucDialog; this.FormBorderStyle = FormBorderStyle.None; this.BackColor = System.Drawing.Color.Black; this.Opacity = 0.50; this.ShowInTaskbar = false; this.StartPosition = FormStartPosition.Manual; this.Size = parent.ClientSize; this.Location = parent.PointToScreen(System.Drawing.Point.Empty); parent.Move += AdjustPosition; parent.SizeChanged += AdjustPosition; }
public DimmerMask(Form parent) { //InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.BackColor = Color.Black; this.Opacity = 0.70; this.ShowInTaskbar = false; this.StartPosition = FormStartPosition.Manual; this.Size = parent.ClientSize; this.Location = parent.PointToScreen(Point.Empty); parent.Move += AdjustPosition; parent.SizeChanged += AdjustPosition; }
public Plexiglass(Form tocover) { this.BackColor = Color.Black; this.Opacity = 0.5; // Tweak as desired this.FormBorderStyle = FormBorderStyle.None; this.ControlBox = false; this.ShowInTaskbar = false; this.StartPosition = FormStartPosition.Manual; this.AutoScaleMode = AutoScaleMode.None; this.Location = tocover.PointToScreen(Point.Empty); this.ClientSize = tocover.ClientSize; tocover.LocationChanged += Cover_LocationChanged; tocover.ClientSizeChanged += Cover_ClientSizeChanged; this.Show(tocover); tocover.Focus(); }
public BackgroundDialogView(Form parent, Form dialog) : this() { this.Opacity = 0.70; this.StartPosition = FormStartPosition.Manual; this.Location = parent.PointToScreen(System.Drawing.Point.Empty); this.ClientSize = parent.ClientSize; this.Main = parent; parent.Move += AdjustPosition; parent.SizeChanged += AdjustPosition; dialog.FormClosed += Dialog_FormClosed; dialog.StartPosition = FormStartPosition.CenterParent; this.Show(); dialog.ShowDialog(); }
/// <summary> /// Gets the form borderless snapshot. /// </summary> /// <param name="window">The window.</param> /// <returns>Bitmap.</returns> public static Bitmap GetFormBorderlessSnapshot(this System.Windows.Forms.Form window) { using (var bmp = new Bitmap(window.Width, window.Height)) { window.DrawToBitmap(bmp, new Rectangle(0, 0, window.Width, window.Height)); System.Drawing.Point point = window.PointToScreen(System.Drawing.Point.Empty); Bitmap target = new Bitmap(window.ClientSize.Width, window.ClientSize.Height); using (Graphics g = Graphics.FromImage(target)) { var srcRect = new Rectangle(point.X - window.Location.X, point.Y - window.Location.Y, target.Width, target.Height); g.DrawImage(bmp, 0, 0, srcRect, GraphicsUnit.Pixel); } return(target); } }
/// <summary> /// Shows the balloon tooltip on the electric bulb icon (pictureBox1) /// </summary> /// <param name="newText">The new text.</param> /// <param name="time">The time in milliseconds</param> /// <param name="parent">The generating form (since we redirect the controls)</param> /// <param name="permanent">if set to <c>true</c> the tooltip will come again</param> public void ShowPictureBoxBalloon(string newText, int time, Form parent, bool permanent) { balloonToolTipInfo.SetBalloonText( this.pbxIcon, newText ); // ??? Point point = parent.PointToScreen(pbxIcon.PointToScreen(pbxIcon.Location)); point.X += 5; balloonToolTipInfo.Show(this.pbxIcon, point); timerToolTip.Interval = time; timerToolTip.Enabled = true; if (permanent) { _showPermanentText = newText; _showPermanentEntered = false; pbxIcon.MouseEnter += new EventHandler(pictureBox1_MouseEnter); pbxIcon.MouseLeave += new EventHandler(pictureBox1_MouseLeave); } }
private void CreateToolbar() { menuForm = new Form() { AutoScaleDimensions = new SizeF(6F, 13F), AutoScaleMode = AutoScaleMode.Font, AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, ClientSize = new Size(759, 509), FormBorderStyle = FormBorderStyle.None, Location = new Point(200, 200), ShowInTaskbar = false, StartPosition = FormStartPosition.Manual, Text = "ShareX - Region capture menu", TopMost = true }; menuForm.KeyUp += MenuForm_KeyUp; menuForm.LocationChanged += MenuForm_LocationChanged; menuForm.SuspendLayout(); tsMain = new ToolStripEx() { AutoSize = true, CanOverflow = false, ClickThrough = true, Dock = DockStyle.None, GripStyle = ToolStripGripStyle.Hidden, Location = new Point(0, 0), MinimumSize = new Size(10, 30), Padding = new Padding(0, 0, 0, 0), Renderer = new CustomToolStripProfessionalRenderer(), TabIndex = 0, ShowItemToolTips = false }; tsMain.MouseLeave += TsMain_MouseLeave; tsMain.SuspendLayout(); // https://www.medo64.com/2014/01/scaling-toolstrip-with-dpi/ using (Graphics g = menuForm.CreateGraphics()) { double scale = Math.Max(g.DpiX, g.DpiY) / 96.0; double newScale = ((int)Math.Floor(scale * 100) / 25 * 25) / 100.0; if (newScale > 1) { int newWidth = (int)(tsMain.ImageScalingSize.Width * newScale); int newHeight = (int)(tsMain.ImageScalingSize.Height * newScale); tsMain.ImageScalingSize = new Size(newWidth, newHeight); } } menuForm.Controls.Add(tsMain); tslDragLeft = new ToolStripLabel() { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.ui_radio_button_uncheck, Margin = new Padding(2, 0, 2, 0), Padding = new Padding(2) }; tsMain.Items.Add(tslDragLeft); if (form.Mode == RegionCaptureMode.Editor) { #region Editor mode ToolStripButton tsbCompleteEdit = new ToolStripButton("Run after capture tasks"); tsbCompleteEdit.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbCompleteEdit.Image = Resources.tick; tsbCompleteEdit.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateRunAfterCaptureTasks); tsMain.Items.Add(tsbCompleteEdit); ToolStripButton tsbSaveImage = new ToolStripButton("Save image"); tsbSaveImage.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbSaveImage.Enabled = !string.IsNullOrEmpty(form.ImageFilePath); tsbSaveImage.Image = Resources.disk_black; tsbSaveImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateSaveImage); tsMain.Items.Add(tsbSaveImage); ToolStripButton tsbSaveImageAs = new ToolStripButton("Save image as..."); tsbSaveImageAs.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbSaveImageAs.Image = Resources.disks_black; tsbSaveImageAs.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateSaveImageAs); tsMain.Items.Add(tsbSaveImageAs); ToolStripButton tsbCopyImage = new ToolStripButton("Copy image to clipboard"); tsbCopyImage.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbCopyImage.Image = Resources.clipboard; tsbCopyImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateCopyImage); tsMain.Items.Add(tsbCopyImage); ToolStripButton tsbUploadImage = new ToolStripButton("Upload image"); tsbUploadImage.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbUploadImage.Image = Resources.drive_globe; tsbUploadImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateUploadImage); tsMain.Items.Add(tsbUploadImage); ToolStripButton tsbPrintImage = new ToolStripButton("Print image..."); tsbPrintImage.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbPrintImage.Image = Resources.printer; tsbPrintImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotatePrintImage); tsMain.Items.Add(tsbPrintImage); tsMain.Items.Add(new ToolStripSeparator()); #endregion Editor mode } #region Tools foreach (ShapeType shapeType in Helpers.GetEnums<ShapeType>()) { if (form.Mode == RegionCaptureMode.Editor) { if (IsShapeTypeRegion(shapeType)) { continue; } } else if (shapeType == ShapeType.DrawingRectangle) { tsMain.Items.Add(new ToolStripSeparator()); } ToolStripButton tsbShapeType = new ToolStripButton(shapeType.GetLocalizedDescription()); tsbShapeType.DisplayStyle = ToolStripItemDisplayStyle.Image; Image img = null; switch (shapeType) { case ShapeType.RegionRectangle: img = Resources.layer_shape_region; break; case ShapeType.RegionEllipse: img = Resources.layer_shape_ellipse_region; break; case ShapeType.RegionFreehand: img = Resources.layer_shape_polygon; break; case ShapeType.DrawingRectangle: img = Resources.layer_shape; break; case ShapeType.DrawingEllipse: img = Resources.layer_shape_ellipse; break; case ShapeType.DrawingFreehand: img = Resources.layer_shape_curve; break; case ShapeType.DrawingLine: img = Resources.layer_shape_line; break; case ShapeType.DrawingArrow: img = Resources.layer_shape_arrow; break; case ShapeType.DrawingText: img = Resources.layer_shape_text; break; case ShapeType.DrawingSpeechBalloon: img = Resources.balloon_box_left; break; case ShapeType.DrawingStep: img = Resources.counter_reset; break; case ShapeType.DrawingImage: img = Resources.image; break; case ShapeType.EffectBlur: img = Resources.layer_shade; break; case ShapeType.EffectPixelate: img = Resources.grid; break; case ShapeType.EffectHighlight: img = Resources.highlighter_text; break; } tsbShapeType.Image = img; tsbShapeType.Checked = shapeType == CurrentShapeType; tsbShapeType.Tag = shapeType; tsbShapeType.MouseDown += (sender, e) => { tsbShapeType.RadioCheck(); CurrentShapeType = shapeType; }; tsMain.Items.Add(tsbShapeType); } #endregion Tools #region Shape options tsMain.Items.Add(new ToolStripSeparator()); tsbBorderColor = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Border_color___); tsbBorderColor.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbBorderColor.Click += (sender, e) => { PauseForm(); ShapeType shapeType = CurrentShapeType; Color borderColor; if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon) { borderColor = AnnotationOptions.TextBorderColor; } else if (shapeType == ShapeType.DrawingStep) { borderColor = AnnotationOptions.StepBorderColor; } else { borderColor = AnnotationOptions.BorderColor; } using (ColorPickerForm dialogColor = new ColorPickerForm(borderColor)) { if (dialogColor.ShowDialog() == DialogResult.OK) { if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon) { AnnotationOptions.TextBorderColor = dialogColor.NewColor; } else if (shapeType == ShapeType.DrawingStep) { AnnotationOptions.StepBorderColor = dialogColor.NewColor; } else { AnnotationOptions.BorderColor = dialogColor.NewColor; } UpdateMenu(); UpdateCurrentShape(); } } ResumeForm(); }; tsMain.Items.Add(tsbBorderColor); tsbFillColor = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Fill_color___); tsbFillColor.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbFillColor.Click += (sender, e) => { PauseForm(); ShapeType shapeType = CurrentShapeType; Color fillColor; if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon) { fillColor = AnnotationOptions.TextFillColor; } else if (shapeType == ShapeType.DrawingStep) { fillColor = AnnotationOptions.StepFillColor; } else { fillColor = AnnotationOptions.FillColor; } using (ColorPickerForm dialogColor = new ColorPickerForm(fillColor)) { if (dialogColor.ShowDialog() == DialogResult.OK) { if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon) { AnnotationOptions.TextFillColor = dialogColor.NewColor; } else if (shapeType == ShapeType.DrawingStep) { AnnotationOptions.StepFillColor = dialogColor.NewColor; } else { AnnotationOptions.FillColor = dialogColor.NewColor; } UpdateMenu(); UpdateCurrentShape(); } } ResumeForm(); }; tsMain.Items.Add(tsbFillColor); tsbHighlightColor = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Highlight_color___); tsbHighlightColor.DisplayStyle = ToolStripItemDisplayStyle.Image; tsbHighlightColor.Click += (sender, e) => { PauseForm(); using (ColorPickerForm dialogColor = new ColorPickerForm(AnnotationOptions.HighlightColor)) { if (dialogColor.ShowDialog() == DialogResult.OK) { AnnotationOptions.HighlightColor = dialogColor.NewColor; UpdateMenu(); UpdateCurrentShape(); } } ResumeForm(); }; tsMain.Items.Add(tsbHighlightColor); tsddbShapeOptions = new ToolStripDropDownButton("Shape options"); tsddbShapeOptions.DisplayStyle = ToolStripItemDisplayStyle.Image; tsddbShapeOptions.Image = Resources.layer__pencil; tsMain.Items.Add(tsddbShapeOptions); tslnudBorderSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Border_size_); tslnudBorderSize.Content.Minimum = 0; tslnudBorderSize.Content.Maximum = 20; tslnudBorderSize.Content.ValueChanged = (sender, e) => { ShapeType shapeType = CurrentShapeType; int borderSize = (int)tslnudBorderSize.Content.Value; if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon) { AnnotationOptions.TextBorderSize = borderSize; } else if (shapeType == ShapeType.DrawingStep) { AnnotationOptions.StepBorderSize = borderSize; } else { AnnotationOptions.BorderSize = borderSize; } UpdateCurrentShape(); }; tsddbShapeOptions.DropDownItems.Add(tslnudBorderSize); tslnudCornerRadius = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Corner_radius_); tslnudCornerRadius.Content.Minimum = 0; tslnudCornerRadius.Content.Maximum = 150; tslnudCornerRadius.Content.ValueChanged = (sender, e) => { ShapeType shapeType = CurrentShapeType; if (shapeType == ShapeType.RegionRectangle) { AnnotationOptions.RegionCornerRadius = (int)tslnudCornerRadius.Content.Value; } else if (shapeType == ShapeType.DrawingRectangle || shapeType == ShapeType.DrawingText) { AnnotationOptions.DrawingCornerRadius = (int)tslnudCornerRadius.Content.Value; } UpdateCurrentShape(); }; tsddbShapeOptions.DropDownItems.Add(tslnudCornerRadius); tslnudBlurRadius = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Blur_radius_); tslnudBlurRadius.Content.Minimum = 3; tslnudBlurRadius.Content.Maximum = 199; tslnudBlurRadius.Content.Increment = 2; tslnudBlurRadius.Content.ValueChanged = (sender, e) => { AnnotationOptions.BlurRadius = (int)tslnudBlurRadius.Content.Value; UpdateCurrentShape(); }; tsddbShapeOptions.DropDownItems.Add(tslnudBlurRadius); tslnudPixelateSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Pixel_size_); tslnudPixelateSize.Content.Minimum = 2; tslnudPixelateSize.Content.Maximum = 10000; tslnudPixelateSize.Content.ValueChanged = (sender, e) => { AnnotationOptions.PixelateSize = (int)tslnudPixelateSize.Content.Value; UpdateCurrentShape(); }; tsddbShapeOptions.DropDownItems.Add(tslnudPixelateSize); tsmiShadow = new ToolStripMenuItem("Drop shadow"); tsmiShadow.Checked = true; tsmiShadow.CheckOnClick = true; tsmiShadow.Click += (sender, e) => { AnnotationOptions.Shadow = tsmiShadow.Checked; UpdateCurrentShape(); }; tsddbShapeOptions.DropDownItems.Add(tsmiShadow); // In dropdown menu if only last item is visible then menu opens at 0, 0 position on first open, so need to add dummy item to solve this weird bug... tsddbShapeOptions.DropDownItems.Add(new ToolStripSeparator() { Visible = false }); #endregion Shape options #region Edit ToolStripDropDownButton tsddbEdit = new ToolStripDropDownButton("Edit"); tsddbEdit.DisplayStyle = ToolStripItemDisplayStyle.Image; tsddbEdit.Image = Resources.wrench_screwdriver; tsMain.Items.Add(tsddbEdit); tsmiUndo = new ToolStripMenuItem("Undo"); tsmiUndo.Image = Resources.arrow_circle_225_left; tsmiUndo.ShortcutKeyDisplayString = "Ctrl+Z"; tsmiUndo.MouseDown += (sender, e) => UndoShape(); tsddbEdit.DropDownItems.Add(tsmiUndo); tsddbEdit.DropDownItems.Add(new ToolStripSeparator()); tsmiDelete = new ToolStripMenuItem("Delete"); tsmiDelete.Image = Resources.layer__minus; tsmiDelete.ShortcutKeyDisplayString = "Del"; tsmiDelete.MouseDown += (sender, e) => DeleteCurrentShape(); tsddbEdit.DropDownItems.Add(tsmiDelete); tsmiDeleteAll = new ToolStripMenuItem("Delete all"); tsmiDeleteAll.Image = Resources.eraser; tsmiDeleteAll.ShortcutKeyDisplayString = "Shift+Del"; tsmiDeleteAll.MouseDown += (sender, e) => DeleteAllShapes(); tsddbEdit.DropDownItems.Add(tsmiDeleteAll); tsddbEdit.DropDownItems.Add(new ToolStripSeparator()); tsmiMoveTop = new ToolStripMenuItem("Bring to front"); tsmiMoveTop.Image = Resources.layers_stack_arrange; tsmiMoveTop.ShortcutKeyDisplayString = "Home"; tsmiMoveTop.MouseDown += (sender, e) => MoveCurrentShapeTop(); tsddbEdit.DropDownItems.Add(tsmiMoveTop); tsmiMoveUp = new ToolStripMenuItem("Bring forward"); tsmiMoveUp.Image = Resources.layers_arrange; tsmiMoveUp.ShortcutKeyDisplayString = "Page up"; tsmiMoveUp.MouseDown += (sender, e) => MoveCurrentShapeUp(); tsddbEdit.DropDownItems.Add(tsmiMoveUp); tsmiMoveDown = new ToolStripMenuItem("Send backward"); tsmiMoveDown.Image = Resources.layers_arrange_back; tsmiMoveDown.ShortcutKeyDisplayString = "Page down"; tsmiMoveDown.MouseDown += (sender, e) => MoveCurrentShapeDown(); tsddbEdit.DropDownItems.Add(tsmiMoveDown); tsmiMoveBottom = new ToolStripMenuItem("Send to back"); tsmiMoveBottom.Image = Resources.layers_stack_arrange_back; tsmiMoveBottom.ShortcutKeyDisplayString = "End"; tsmiMoveBottom.MouseDown += (sender, e) => MoveCurrentShapeBottom(); tsddbEdit.DropDownItems.Add(tsmiMoveBottom); #endregion Edit if (form.Mode != RegionCaptureMode.Editor) { tsMain.Items.Add(new ToolStripSeparator()); #region Capture ToolStripDropDownButton tsddbCapture = new ToolStripDropDownButton("Capture"); tsddbCapture.DisplayStyle = ToolStripItemDisplayStyle.Image; tsddbCapture.Image = Resources.camera; tsMain.Items.Add(tsddbCapture); tsmiRegionCapture = new ToolStripMenuItem("Capture regions"); tsmiRegionCapture.Image = Resources.layer; tsmiRegionCapture.ShortcutKeyDisplayString = "Enter"; tsmiRegionCapture.MouseDown += (sender, e) => { form.UpdateRegionPath(); form.Close(RegionResult.Region); }; tsddbCapture.DropDownItems.Add(tsmiRegionCapture); if (RegionCaptureForm.LastRegionFillPath != null) { ToolStripMenuItem tsmiLastRegionCapture = new ToolStripMenuItem("Capture last region"); tsmiLastRegionCapture.Image = Resources.layers; tsmiLastRegionCapture.MouseDown += (sender, e) => form.Close(RegionResult.LastRegion); tsddbCapture.DropDownItems.Add(tsmiLastRegionCapture); } ToolStripMenuItem tsmiFullscreenCapture = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Capture_fullscreen); tsmiFullscreenCapture.Image = Resources.layer_fullscreen; tsmiFullscreenCapture.ShortcutKeyDisplayString = "Space"; tsmiFullscreenCapture.MouseDown += (sender, e) => form.Close(RegionResult.Fullscreen); tsddbCapture.DropDownItems.Add(tsmiFullscreenCapture); ToolStripMenuItem tsmiActiveMonitorCapture = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Capture_active_monitor); tsmiActiveMonitorCapture.Image = Resources.monitor; tsmiActiveMonitorCapture.ShortcutKeyDisplayString = "~"; tsmiActiveMonitorCapture.MouseDown += (sender, e) => form.Close(RegionResult.ActiveMonitor); tsddbCapture.DropDownItems.Add(tsmiActiveMonitorCapture); ToolStripMenuItem tsmiMonitorCapture = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Capture_monitor); tsmiMonitorCapture.HideImageMargin(); tsmiMonitorCapture.Image = Resources.monitor_window; tsddbCapture.DropDownItems.Add(tsmiMonitorCapture); Screen[] screens = Screen.AllScreens; for (int i = 0; i < screens.Length; i++) { Screen screen = screens[i]; ToolStripMenuItem tsmi = new ToolStripMenuItem($"{screen.Bounds.Width}x{screen.Bounds.Height}"); tsmi.ShortcutKeyDisplayString = (i + 1).ToString(); int index = i; tsmi.MouseDown += (sender, e) => { form.MonitorIndex = index; form.Close(RegionResult.Monitor); }; tsmiMonitorCapture.DropDownItems.Add(tsmi); } #endregion Capture #region Options ToolStripDropDownButton tsddbOptions = new ToolStripDropDownButton(Resources.ShapeManager_CreateContextMenu_Options); tsddbOptions.DisplayStyle = ToolStripItemDisplayStyle.Image; tsddbOptions.Image = Resources.gear; tsMain.Items.Add(tsddbOptions); tsmiQuickCrop = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Multi_region_mode); tsmiQuickCrop.Checked = !Config.QuickCrop; tsmiQuickCrop.CheckOnClick = true; tsmiQuickCrop.ShortcutKeyDisplayString = "Q"; tsmiQuickCrop.Click += (sender, e) => Config.QuickCrop = !tsmiQuickCrop.Checked; tsddbOptions.DropDownItems.Add(tsmiQuickCrop); tsmiTips = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_tips); tsmiTips.Checked = Config.ShowHotkeys; tsmiTips.CheckOnClick = true; tsmiTips.ShortcutKeyDisplayString = "F1"; tsmiTips.Click += (sender, e) => Config.ShowHotkeys = tsmiTips.Checked; tsddbOptions.DropDownItems.Add(tsmiTips); ToolStripMenuItem tsmiShowInfo = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_position_and_size_info); tsmiShowInfo.Checked = Config.ShowInfo; tsmiShowInfo.CheckOnClick = true; tsmiShowInfo.Click += (sender, e) => Config.ShowInfo = tsmiShowInfo.Checked; tsddbOptions.DropDownItems.Add(tsmiShowInfo); ToolStripMenuItem tsmiShowMagnifier = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_magnifier); tsmiShowMagnifier.Checked = Config.ShowMagnifier; tsmiShowMagnifier.CheckOnClick = true; tsmiShowMagnifier.Click += (sender, e) => Config.ShowMagnifier = tsmiShowMagnifier.Checked; tsddbOptions.DropDownItems.Add(tsmiShowMagnifier); ToolStripMenuItem tsmiUseSquareMagnifier = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Square_shape_magnifier); tsmiUseSquareMagnifier.Checked = Config.UseSquareMagnifier; tsmiUseSquareMagnifier.CheckOnClick = true; tsmiUseSquareMagnifier.Click += (sender, e) => Config.UseSquareMagnifier = tsmiUseSquareMagnifier.Checked; tsddbOptions.DropDownItems.Add(tsmiUseSquareMagnifier); ToolStripLabeledNumericUpDown tslnudMagnifierPixelCount = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Magnifier_pixel_count_); tslnudMagnifierPixelCount.Content.Minimum = RegionCaptureOptions.MagnifierPixelCountMinimum; tslnudMagnifierPixelCount.Content.Maximum = RegionCaptureOptions.MagnifierPixelCountMaximum; tslnudMagnifierPixelCount.Content.Increment = 2; tslnudMagnifierPixelCount.Content.Value = Config.MagnifierPixelCount; tslnudMagnifierPixelCount.Content.ValueChanged = (sender, e) => Config.MagnifierPixelCount = (int)tslnudMagnifierPixelCount.Content.Value; tsddbOptions.DropDownItems.Add(tslnudMagnifierPixelCount); ToolStripLabeledNumericUpDown tslnudMagnifierPixelSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Magnifier_pixel_size_); tslnudMagnifierPixelSize.Content.Minimum = RegionCaptureOptions.MagnifierPixelSizeMinimum; tslnudMagnifierPixelSize.Content.Maximum = RegionCaptureOptions.MagnifierPixelSizeMaximum; tslnudMagnifierPixelSize.Content.Value = Config.MagnifierPixelSize; tslnudMagnifierPixelSize.Content.ValueChanged = (sender, e) => Config.MagnifierPixelSize = (int)tslnudMagnifierPixelSize.Content.Value; tsddbOptions.DropDownItems.Add(tslnudMagnifierPixelSize); ToolStripMenuItem tsmiShowCrosshair = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_screen_wide_crosshair); tsmiShowCrosshair.Checked = Config.ShowCrosshair; tsmiShowCrosshair.CheckOnClick = true; tsmiShowCrosshair.Click += (sender, e) => Config.ShowCrosshair = tsmiShowCrosshair.Checked; tsddbOptions.DropDownItems.Add(tsmiShowCrosshair); ToolStripMenuItem tsmiFixedSize = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Fixed_size_region_mode); tsmiFixedSize.Checked = Config.IsFixedSize; tsmiFixedSize.CheckOnClick = true; tsmiFixedSize.Click += (sender, e) => Config.IsFixedSize = tsmiFixedSize.Checked; tsddbOptions.DropDownItems.Add(tsmiFixedSize); ToolStripDoubleLabeledNumericUpDown tslnudFixedSize = new ToolStripDoubleLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Width_, Resources.ShapeManager_CreateContextMenu_Height_); tslnudFixedSize.Content.Minimum = 10; tslnudFixedSize.Content.Maximum = 10000; tslnudFixedSize.Content.Increment = 10; tslnudFixedSize.Content.Value = Config.FixedSize.Width; tslnudFixedSize.Content.Value2 = Config.FixedSize.Height; tslnudFixedSize.Content.ValueChanged = (sender, e) => Config.FixedSize = new Size((int)tslnudFixedSize.Content.Value, (int)tslnudFixedSize.Content.Value2); tsddbOptions.DropDownItems.Add(tslnudFixedSize); ToolStripMenuItem tsmiShowFPS = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_FPS); tsmiShowFPS.Checked = Config.ShowFPS; tsmiShowFPS.CheckOnClick = true; tsmiShowFPS.Click += (sender, e) => Config.ShowFPS = tsmiShowFPS.Checked; tsddbOptions.DropDownItems.Add(tsmiShowFPS); ToolStripMenuItem tsmiRememberMenuState = new ToolStripMenuItem("Remember menu state"); tsmiRememberMenuState.Checked = Config.RememberMenuState; tsmiRememberMenuState.CheckOnClick = true; tsmiRememberMenuState.Click += (sender, e) => Config.RememberMenuState = tsmiRememberMenuState.Checked; tsddbOptions.DropDownItems.Add(tsmiRememberMenuState); #endregion Options } ToolStripLabel tslDragRight = new ToolStripLabel() { Alignment = ToolStripItemAlignment.Right, DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources.ui_radio_button_uncheck, Margin = new Padding(0, 0, 2, 0), Padding = new Padding(2) }; tsMain.Items.Add(tslDragRight); tslDragLeft.MouseDown += TslDrag_MouseDown; tslDragRight.MouseDown += TslDrag_MouseDown; tslDragLeft.MouseEnter += TslDrag_MouseEnter; tslDragRight.MouseEnter += TslDrag_MouseEnter; tslDragLeft.MouseLeave += TslDrag_MouseLeave; tslDragRight.MouseLeave += TslDrag_MouseLeave; tsMain.ResumeLayout(false); tsMain.PerformLayout(); menuForm.ResumeLayout(false); menuForm.Show(form); foreach (ToolStripItem tsi in tsMain.Items.OfType<ToolStripItem>()) { if (!string.IsNullOrEmpty(tsi.Text)) { tsi.MouseEnter += (sender, e) => { Point pos = CaptureHelpers.ScreenToClient(menuForm.PointToScreen(tsi.Bounds.Location)); pos.Y += tsi.Height + 8; MenuTextAnimation.Position = pos; MenuTextAnimation.Start(tsi.Text); }; tsi.MouseLeave += TsMain_MouseLeave; } } UpdateMenu(); CurrentShapeChanged += shape => UpdateMenu(); CurrentShapeTypeChanged += shapeType => UpdateMenu(); ShapeCreated += shape => UpdateMenu(); ConfigureMenuState(); form.Activate(); }
public GreyOutWindow openGreyOutWindow(bool showBorder, Form parent) { if (!this.isPopupWindowCreated(this.m_greyOutWindow)) { this.m_greyLogin = false; this.m_greyOutWindow = new GreyOutWindow(); Size clientSize = parent.ClientSize; Point point = parent.PointToScreen(new Point(0, 0)); this.m_greyOutWindow.Location = point; this.m_greyOutWindow.Size = clientSize; this.m_greyOutWindow.init(showBorder); this.m_greyOutWindow.Show(parent); } return this.m_greyOutWindow; }
public void TestPublicMethods () { // Public Methods that force Handle creation: // - CreateGraphics () // - GetChildAtPoint () // - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created // - PointToClient () // - PointToScreen () // - RectangleToClient () // - RectangleToScreen () // - Select () // - Show (IWin32Window) // Notes: // - CreateControl does NOT force Handle creation! Form c = new Form (); c.BringToFront (); Assert.IsFalse (c.IsHandleCreated, "A1"); c.Contains (new Form ()); Assert.IsFalse (c.IsHandleCreated, "A2"); c.CreateControl (); Assert.IsFalse (c.IsHandleCreated, "A3"); c = new Form (); Graphics g = c.CreateGraphics (); g.Dispose (); Assert.IsTrue (c.IsHandleCreated, "A4"); c.Dispose (); c = new Form (); c.Dispose (); Assert.IsFalse (c.IsHandleCreated, "A5"); c = new Form (); // This is weird, it causes a form to appear that won't go away until you move the mouse over it, // but it doesn't create a handle?? //DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None); //Assert.IsFalse (c.IsHandleCreated, "A6"); //Assert.AreEqual (DragDropEffects.None, d, "A6b"); //Bitmap b = new Bitmap (100, 100); //c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100)); //Assert.IsFalse (c.IsHandleCreated, "A7"); //b.Dispose (); c.FindForm (); Assert.IsFalse (c.IsHandleCreated, "A8"); c.Focus (); Assert.IsFalse (c.IsHandleCreated, "A9"); c.GetChildAtPoint (new Point (10, 10)); Assert.IsTrue (c.IsHandleCreated, "A10"); c.Dispose (); c = new Form (); c.GetContainerControl (); Assert.IsFalse (c.IsHandleCreated, "A11"); c.Dispose (); c = new Form (); c.GetNextControl (new Control (), true); Assert.IsFalse (c.IsHandleCreated, "A12"); c.GetPreferredSize (Size.Empty); Assert.IsFalse (c.IsHandleCreated, "A13"); c.Hide (); Assert.IsFalse (c.IsHandleCreated, "A14"); c.Invalidate (); Assert.IsFalse (c.IsHandleCreated, "A15"); //c.Invoke (new InvokeDelegate (InvokeMethod)); //Assert.IsFalse (c.IsHandleCreated, "A16"); c.PerformLayout (); Assert.IsFalse (c.IsHandleCreated, "A17"); c.PointToClient (new Point (100, 100)); Assert.IsTrue (c.IsHandleCreated, "A18"); c.Dispose (); c = new Form (); c.PointToScreen (new Point (100, 100)); Assert.IsTrue (c.IsHandleCreated, "A19"); c.Dispose (); c = new Form (); //c.PreProcessControlMessage ??? //c.PreProcessMessage ??? c.RectangleToClient (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A20"); c.Dispose (); c = new Form (); c.RectangleToScreen (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A21"); c.Dispose (); c = new Form (); c.Refresh (); Assert.IsFalse (c.IsHandleCreated, "A22"); c.ResetBackColor (); Assert.IsFalse (c.IsHandleCreated, "A23"); c.ResetBindings (); Assert.IsFalse (c.IsHandleCreated, "A24"); c.ResetCursor (); Assert.IsFalse (c.IsHandleCreated, "A25"); c.ResetFont (); Assert.IsFalse (c.IsHandleCreated, "A26"); c.ResetForeColor (); Assert.IsFalse (c.IsHandleCreated, "A27"); c.ResetImeMode (); Assert.IsFalse (c.IsHandleCreated, "A28"); c.ResetRightToLeft (); Assert.IsFalse (c.IsHandleCreated, "A29"); c.ResetText (); Assert.IsFalse (c.IsHandleCreated, "A30"); c.SuspendLayout (); Assert.IsFalse (c.IsHandleCreated, "A31"); c.ResumeLayout (); Assert.IsFalse (c.IsHandleCreated, "A32"); c.Scale (new SizeF (1.5f, 1.5f)); Assert.IsFalse (c.IsHandleCreated, "A33"); c.Select (); Assert.IsTrue (c.IsHandleCreated, "A34"); c.Dispose (); c = new Form (); c.SelectNextControl (new Control (), true, true, true, true); Assert.IsFalse (c.IsHandleCreated, "A35"); c.SetBounds (0, 0, 100, 100); Assert.IsFalse (c.IsHandleCreated, "A36"); c.Update (); Assert.IsFalse (c.IsHandleCreated, "A37"); // Form c.Activate (); Assert.IsFalse (c.IsHandleCreated, "F1"); c.AddOwnedForm (new Form ()); Assert.IsFalse (c.IsHandleCreated, "F2"); c.Close (); Assert.IsFalse (c.IsHandleCreated, "F3"); c.Hide (); Assert.IsFalse (c.IsHandleCreated, "F4"); c.LayoutMdi (MdiLayout.Cascade); Assert.IsFalse (c.IsHandleCreated, "F5"); #if !MONO c.PerformAutoScale (); Assert.IsFalse (c.IsHandleCreated, "F6"); #endif c.PerformLayout (); Assert.IsFalse (c.IsHandleCreated, "F7"); c.AddOwnedForm (new Form ()); c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]); Assert.IsFalse (c.IsHandleCreated, "F8"); c.ScrollControlIntoView (null); Assert.IsFalse (c.IsHandleCreated, "F9"); c.SetAutoScrollMargin (7, 13); Assert.IsFalse (c.IsHandleCreated, "F10"); c.SetDesktopBounds (-1, -1, 144, 169); Assert.IsFalse (c.IsHandleCreated, "F11"); c.SetDesktopLocation (7, 13); Assert.IsFalse (c.IsHandleCreated, "F12"); c = new Form (); c.Show (null); Assert.IsTrue (c.IsHandleCreated, "F13"); c.Close (); c = new Form (); //c.ShowDialog () c.ToString (); Assert.IsFalse (c.IsHandleCreated, "F14"); c.Validate (); Assert.IsFalse (c.IsHandleCreated, "F15"); #if !MONO c.ValidateChildren (); Assert.IsFalse (c.IsHandleCreated, "F16"); #endif c.Close (); }
public static void SetRoundedRegion(Form form, Size overrideSize) { int width, height; if (overrideSize == Size.Empty) { width = form.ClientSize.Width; height = form.ClientSize.Height; } else { width = overrideSize.Width; height = overrideSize.Height; } Region r = new Region(new Rectangle(3, 0, width - 6, height)); r.Union(new Rectangle(2, 1, width - 4, height - 2)); r.Union(new Rectangle(1, 2, width - 2, height - 4)); r.Union(new Rectangle(0, 3, width, height - 6)); RECT rect = new RECT(); User32.GetWindowRect(form.Handle, ref rect); Point windowScreenPos = RectangleHelper.Convert(rect).Location; Point clientScreenPos = form.PointToScreen(new Point(0, 0)); r.Translate(clientScreenPos.X - windowScreenPos.X, clientScreenPos.Y - windowScreenPos.Y); form.Region = r; }
public static void CreateShadows(ArrayList shadows, int shadowSize, bool canShow, Form form, Rectangle creatorRect1, Rectangle creatorRect2) { if (!canShow || !form.Visible || form.Bounds.IsEmpty || form.Disposing) { HideShadows(shadows); return; } Rectangle bounds = new Rectangle(form.PointToScreen(Point.Empty), form.ClientSize); Rectangle vertRect; Rectangle horzRect; FATopFormBase topForm = form as FATopFormBase; if (topForm == null) return; if (topForm.OwnerEdit.RightToLeft == RightToLeft.No) { vertRect = new Rectangle(bounds.Right, bounds.Top + shadowSize, shadowSize, bounds.Height); horzRect = new Rectangle(bounds.X + shadowSize, bounds.Bottom, bounds.Width - shadowSize, shadowSize); } else { vertRect = new Rectangle(bounds.Left - shadowSize, bounds.Top + shadowSize, shadowSize, bounds.Height); horzRect = new Rectangle(bounds.X, bounds.Bottom, bounds.Width - shadowSize, shadowSize); } if (shadows.Count == 0) { FAShadow vertShadow = new FAShadow(false, shadowSize, form); FAShadow horzShadow = new FAShadow(true, shadowSize, form); shadows.Add(vertShadow); shadows.Add(horzShadow); } //vertRect = CheckShadowRectangle(vertRect, creatorRect1, true); //vertRect = CheckShadowRectangle(vertRect, creatorRect2, true); //horzRect = CheckShadowRectangle(horzRect, creatorRect1, false); //horzRect = CheckShadowRectangle(horzRect, creatorRect2, false); (shadows[0] as FAShadow).RealBounds = vertRect; (shadows[1] as FAShadow).RealBounds = horzRect; UpdateShadows(shadows, creatorRect1, creatorRect2, shadowSize); ShowShadows(shadows); }