private void VerRegistro_Deactivate(object sender, EventArgs e) { if (ParentForm != null) { ParentForm.Activate(); } }
/// <summary> /// Save, resize, and format dragged image with lblTitle filename. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void infoPane_DragDrop(object sender, DragEventArgs e) { if (lblTitle.Text.Length < 1) { BetterDialog.ShowDialog("Image Save", "Error : Title Required", "", "", "OK", null, BetterDialog.ImageStyle.Icon); } else { try { int x = this.PointToClient(new Point(e.X, e.Y)).X; int y = this.PointToClient(new Point(e.X, e.Y)).Y; //inside imgTitle boundaries if (x >= imgTitle.Location.X && x <= imgTitle.Location.X + imgTitle.Width && y >= imgTitle.Location.Y && y <= imgTitle.Location.Y + imgTitle.Height) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); FileStream fs = new FileStream(files[0], FileMode.Open); Image img = Image.FromStream(fs); fs.Close(); img = Image_IO.resize_Image(img, imgTitle.Width, imgTitle.Height); img.Save(string.Format("{0}\\{1}.jpg", Folder_IO.GetUserImagePath(), lblTitle.Text), System.Drawing.Imaging.ImageFormat.Jpeg); imgTitle.Image = img; } } catch (Exception ex) { BetterDialog.ShowDialog("Image Save", "Error : " + ex.Message, "", "", "OK", null, BetterDialog.ImageStyle.Icon); } } ParentForm.Activate(); }
private void OnDragDrop(object sender, DragEventArgs e) { try { var a = (Array)e.Data.GetData(DataFormats.FileDrop); if (a != null) { // Extract string from first array element // (ignore all files except first if number of files are dropped). string s = a.GetValue(0).ToString(); // Call OpenFile asynchronously. // Explorer instance from which file is dropped is not responding // all the time when DragDrop handler is active, so we need to return // immidiately (especially if OpenFile shows MessageBox). BeginInvoke(new Action <string>(OpenFileFromDrag), s); ParentForm.Activate(); // in the case Explorer overlaps this form } } catch (Exception) { #if DEBUG throw; #endif } }
/// <summary> /// Save dragged image with selected gridview row title. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void imgTitle_DragDrop(object sender, DragEventArgs e) { if (gvContents.Rows.Count > 0) { try { int x = this.PointToClient(new Point(e.X, e.Y)).X; int y = this.PointToClient(new Point(e.X, e.Y)).Y; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); FileStream fs = new FileStream(files[0], FileMode.Open); Image img = Image.FromStream(fs); fs.Close(); img = Image_IO.resize_Image(img, IMG_SIZE.Width, IMG_SIZE.Height); img.Save( string.Format("{0}\\{1}.jpg", Folder_IO.GetUserImagePath(), gvContents.SelectedRows[0].Cells[0].Value), System.Drawing.Imaging.ImageFormat.Jpeg); imgTitle.Image = img; } catch (Exception ex) { toolTip.Show(ex.Message, imgTitle); } } Enable(); ParentForm.Activate(); DButton.SelBtn.DButton_Click(null, null); }
private void Button_Click(object sender, EventArgs e) { ActualizarBotonMapaProcesadorActivo(); visor.Owner = ParentForm; visor.StartPosition = FormStartPosition.Manual; visor.Location = new Point(MousePosition.X, MousePosition.Y); visor.Visible = true; ParentForm.Activate(); }
private void ImportModForm_FormClosing(object sender, FormClosingEventArgs e) { ParentForm?.Activate(); }
/// <summary> /// Overrides the message pump for the window so that we can respond to click events on the tabs themselves /// </summary> /// <param name="m">Message received by the pump</param> protected override void WndProc(ref Message m) { switch ((WM)m.Msg) { case WM.WM_NCLBUTTONDOWN: case WM.WM_LBUTTONDOWN: Point relativeCursorPosition = GetRelativeCursorPosition(Cursor.Position); // If we were over a tab, set the capture state for the window so that we'll actually receive a WM_LBUTTONUP message if (ParentForm.TabRenderer.IsOverTab(ParentForm.Tabs, relativeCursorPosition) == null && !ParentForm.TabRenderer.IsOverAddButton(relativeCursorPosition)) { ParentForm.ForwardMessage(ref m); } else { TitleBarTab clickedTab = ParentForm.TabRenderer.IsOverTab(ParentForm.Tabs, relativeCursorPosition); if (clickedTab != null) { // If the user clicked the close button, remove the tab from the list if (!ParentForm.TabRenderer.IsOverCloseButton(clickedTab, relativeCursorPosition)) { ParentForm.ResizeTabContents(clickedTab); ParentForm.SelectedTabIndex = ParentForm.Tabs.IndexOf(clickedTab); Render(); } OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0)); } ParentForm.Activate(); } break; case WM.WM_LBUTTONDBLCLK: ParentForm.ForwardMessage(ref m); break; // We always return HTCAPTION for the hit test message so that the underlying window doesn't have its focus removed case WM.WM_NCHITTEST: m.Result = new IntPtr((int)HT.HTCAPTION); break; case WM.WM_LBUTTONUP: case WM.WM_NCLBUTTONUP: case WM.WM_MBUTTONUP: case WM.WM_NCMBUTTONUP: Point relativeCursorPosition2 = GetRelativeCursorPosition(Cursor.Position); if (ParentForm.TabRenderer.IsOverTab(ParentForm.Tabs, relativeCursorPosition2) == null && !ParentForm.TabRenderer.IsOverAddButton(relativeCursorPosition2)) { ParentForm.ForwardMessage(ref m); } else { TitleBarTab clickedTab = ParentForm.TabRenderer.IsOverTab(ParentForm.Tabs, relativeCursorPosition2); if (clickedTab != null) { // If the user clicks the middle button/scroll wheel over a tab, close it if ((WM)m.Msg == WM.WM_MBUTTONUP || (WM)m.Msg == WM.WM_NCMBUTTONUP) { clickedTab.Content.Close(); Render(); } else { // If the user clicked the close button, remove the tab from the list if (ParentForm.TabRenderer.IsOverCloseButton(clickedTab, relativeCursorPosition2)) { clickedTab.Content.Close(); Render(); } else { ParentForm.OnTabClicked(new TitleBarTabEventArgs(TabControlAction.Selected, clickedTab, ParentForm.SelectedTabIndex, s_wasDragging)); } } } // Otherwise, if the user clicked the add button, call CreateTab to add a new tab to the list and select it else if (ParentForm.TabRenderer.IsOverAddButton(relativeCursorPosition2)) { ParentForm.AddNewTab(); } if ((WM)m.Msg == WM.WM_LBUTTONUP || (WM)m.Msg == WM.WM_NCLBUTTONUP) { OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0)); } } break; default: base.WndProc(ref m); break; } }