public bool UpdateForm() { try { if (formX != null) { formX.Refresh(); } } catch (Exception exn) { return(false); } return(true); }
public static string ShowDialog(string text, string caption, List<string> comboitems) { prompt = new Form(); prompt.SizeChanged += new System.EventHandler(SimpleCombo_SizeChanged); prompt.AutoSizeMode = AutoSizeMode.GrowOnly; prompt.Padding = new Padding(50); prompt.Text = caption; textLabel = new Label() { Text = text, AutoSize = true}; textLabel.Left = (int)Math.Ceiling((double)(prompt.Width - textLabel.Width) * 0.5); textLabel.Top = (int)Math.Ceiling((double)(prompt.Height - textLabel.Height) * 0.25); comboBox = new ComboBox() { DataSource = comboitems, MinimumSize = new System.Drawing.Size(500,20)}; comboBox.Left = (int)Math.Ceiling((double)(prompt.Width - comboBox.Width) * 0.5); comboBox.Top = (int)Math.Ceiling((double)(prompt.Height - comboBox.Height) * 0.5); confirmation = new Button() {Text = "OK" }; confirmation.Left = (int)Math.Ceiling((double)(prompt.Width - confirmation.Width) * 0.5); confirmation.Top = (int)Math.Ceiling((double)(prompt.Height - confirmation.Height) * 0.75); confirmation.Click += (sender, e) => { prompt.Close(); }; prompt.Controls.Add(confirmation); prompt.Controls.Add(textLabel); prompt.Controls.Add(comboBox); prompt.AcceptButton = confirmation; prompt.AutoSize = true; prompt.Refresh(); prompt.ShowDialog(); return comboBox.SelectedItem.ToString(); }
public static void FadeForm(System.Windows.Forms.Form f) { DateTime myDateTime = DateTime.Now; int NumberOfSteps = 100; int StepVal = (int)(100f / NumberOfSteps); float fOpacity = 100f; for (int b = 0; b < NumberOfSteps; b++) { f.Opacity = fOpacity / 100; f.Refresh(); fOpacity -= StepVal; myDateTime = DateTime.Now.AddMilliseconds(25); while (DateTime.Now < myDateTime) { Application.DoEvents(); } } }
private void _form_Layout(object sender, LayoutEventArgs e) { if (_lastState == Form.WindowState) { return; } // in case the RibbonForm is started in WindowState.Maximized and the WindowState changes to normal // the size of the RibbonForm is set to the values of _storeSize - which has not been set yet! if (_storeSize.IsEmpty) { _storeSize = Form.Size; } if (WinApi.IsGlassEnabled) { Form.Invalidate(); } else // on XP systems Invalidate is not sufficient in case the Form contains a control with DockStyle.Fill { Form.Refresh(); } _lastState = Form.WindowState; }
/// <summary> /// /// </summary> /// <param name="mainForm"></param> /// <param name="clientInfo"></param> public static void setPermission(Form mainForm,ClientInfo clientInfo) { MenuStrip mainMenu = mainForm.MainMenuStrip; setPermission(clientInfo.LoggedUser, ref mainMenu, clientInfo.MenuPermissions); mainForm.Invalidate(); mainForm.Refresh(); mainMenu.Refresh(); }
public override void OnClick(EventArgs e) { base.OnClick(e); Form f = Owner.FindForm(); if (f == null) { return; } switch (CaptionButtonType) { case CaptionButton.Minimize: f.WindowState = FormWindowState.Minimized; break; case CaptionButton.Maximize: if (f.WindowState == FormWindowState.Normal) { f.WindowState = FormWindowState.Maximized; SetCaptionButtonType(CaptionButton.Restore); f.Refresh(); } else { f.WindowState = FormWindowState.Normal; SetCaptionButtonType(CaptionButton.Maximize); f.Refresh(); } break; case CaptionButton.Restore: f.WindowState = FormWindowState.Normal; SetCaptionButtonType(CaptionButton.Maximize); f.Refresh(); break; case CaptionButton.Close: f.Close(); break; default: break; } }
// Colorize edges and vertices to mark path: public static void updateGraph() { Console.WriteLine(Path.Count); for (int i = 0; i < Path.Count; i++) { // COLOR THE NODES TRAVERSED IN RED Node n = defaultG.FindNode(Path[i].ToString()); n.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.DarkRed; // Bind the graph to the viewer viewer.Graph = defaultG; viewer.Dock = DockStyle.Fill; graphForm.Refresh(); System.Threading.Thread.Sleep(500); // COLOR THE EDGES TOO: // Edge e = graph.fi // e.Attr.ArrowHeadAtTarget = ArrowStyle.None; } }
public static void FadeOut(Form frm) { float FadeOut; for (FadeOut = 90; FadeOut >= 10; FadeOut += -10) { frm.Opacity = FadeOut / 100; frm.Refresh(); System.Threading.Thread.Sleep(100); } }
public static void FadeIn(Form frm) { float FadeIn; for (FadeIn = 0.0f; FadeIn <= 1.1; FadeIn += 0.1f) { frm.Opacity = FadeIn; frm.Refresh(); System.Threading.Thread.Sleep(100); } }
private void setLayoutFormCategories() { formCategories.SuspendLayout(); createTLPCatMain(); formCategories.Controls.Add(tLPCatMain); formCategories.ResumeLayout(); formCategories.Refresh(); }
public static void AttachForm(Form form) { Action<string> handler = msg => form.BeginInvoke((Action)(() => { form.Text = msg; form.Refresh(); })); MessageSanded += handler; form.Closed += (s, e) => MessageSanded -= handler; }
public void Completed(object sender, AsyncCompletedEventArgs e) { lblStatus.Text = "Completed"; frmProgress.Refresh(); System.Threading.Thread.Sleep(2000); string FamilyPath = Path.GetFullPath(@"c:\Temp\" + properities.filename + ".rfa"); frmProgress.Close(); properities.minwindow = true; this.Hide(); }
public void FadeOut(Form TargetForm, double FadeStep) { if (TargetForm.Visible == false) { return; } for (_i = 1; _i >= _MinOpacity; _i -= FadeStep) { TargetForm.Opacity = _i; TargetForm.Refresh(); } }
/// <summary> /// Captures the specified area of the control or whats underneath /// </summary> /// <param name="ctl">Control to capture</param> /// <param name="client">If true capture only client area else entire control.</param> /// <param name="under">If true capture specified area underneath the control else whats on the control.</param> /// <returns>bitmap image of the control or whats underneath the control</returns> public static void Control(System.Windows.Forms.Form ctl) { Bitmap bmp; // capture bitmap Rectangle ctlR; // capture area rectangle in control coordinates Rectangle scrR; // capture area rectangle in screen coordinates int m_hDelay = 0; scrR = ctl.Bounds; // get rectangle in parent coordinates if (ctl.Parent != null) // if parent exists { scrR = ctl.Parent.RectangleToScreen(scrR); // map to screen coordinates } ctlR = ctl.RectangleToClient(scrR); // get rectangle in control coordinates // capture an area under the control ctl.Opacity = 0; System.Threading.Thread.Sleep(m_hDelay); Single oprvV = (float)ctl.Opacity; // save control visibility if (oprvV > 0) // if control visible { ctl.Opacity = 0; ctl.Refresh(); } IntPtr desktopHWND = USER32.GetDesktopWindow(); // get window handle for desktop bmp = Window(desktopHWND, scrR); // get bitmap for capture area under control if (ctl.Opacity < 1) { ctl.BackgroundImage = bmp; ctl.Refresh(); System.Threading.Thread.Sleep(m_hDelay); ctl.Opacity = 1; } System.GC.Collect(); }
public void FadeIn(Form TargetForm, double FadeStep) { if (TargetForm.Visible == false) { TargetForm.Opacity = 0; TargetForm.Visible = true; } for (_i = 0; _i <= _MaxOpacity; _i += FadeStep) { TargetForm.Opacity = _i; TargetForm.Refresh(); } }
private void SetVisible(System.Windows.Forms.Form form, Boolean value) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (form.InvokeRequired) { SetVisibleFormCallback d = new SetVisibleFormCallback(SetVisible); this.Invoke(d, new object[] { form, value }); } else { form.Visible = value; form.Refresh(); } }
/// <summary> /// Function used to fade out a form using a user defined number /// of steps /// </summary> /// <param name="f">The Windows form to fade out</param> /// <param name="NumberOfSteps">The number of steps used to fade the /// form</param> public static void FadeForm(System.Windows.Forms.Form f, byte NumberOfSteps) { DateTime start = DateTime.Now; float StepVal = (float)(100f / NumberOfSteps); float fOpacity = 100f; for (byte b = 0; b < NumberOfSteps; b++) { f.Opacity = fOpacity / 100; f.Refresh(); fOpacity -= StepVal; if ((DateTime.Now - start) > TimeSpan.FromMilliseconds(800)) { f.Opacity = 0; b = NumberOfSteps; } } }
void _form_Layout(object sender, LayoutEventArgs e) { if (_lastState == _form.WindowState) { return; } if (WinApi.IsGlassEnabled) { Form.Invalidate(); } else // on XP systems Invalidate is not sufficient in case the Form contains a control with DockStyle.Fill { Form.Refresh(); } _lastState = _form.WindowState; }
public static void setStyle(System.Windows.Forms.Form frm) { uint oldStyle = getStyle(frm); uint newStyle = (uint)( WINSTYLES.WS_OVERLAPPED | WINSTYLES.WS_POPUP | WINSTYLES.WS_VISIBLE | //WINSTYLES.WS_SYSMENU | // add if you need a X to close WINSTYLES.WS_CAPTION | WINSTYLES.WS_BORDER | //WINSTYLES.WS_DLGFRAME | WINSTYLES.WS_MAXIMIZEBOX | WINSTYLES.WS_POPUPWINDOW); int iRet = SetWindowLong(frm.Handle, (int)GWL.GWL_STYLE, (int)newStyle); //if returned iRet is zero we got an error int newExStyle = GetWindowLong(frm.Handle, (int)GWL.GWL_EXSTYLE); newExStyle = (int)((uint)newExStyle - (uint)WINEXSTYLES.WS_EX_CAPTIONOKBTN); //remove OK button iRet = SetWindowLong(frm.Handle, (int)GWL.GWL_EXSTYLE, (int)newExStyle); moveWindow(frm); frm.Refresh(); }
public static void SpawnAnimationThread(LayoutEngine layoutEngine, Form form, int interFrameSleepTimeMillis) { BackgroundWorker animationThread = new BackgroundWorker(); animationThread.WorkerReportsProgress = true; animationThread.WorkerSupportsCancellation = true; animationThread.DoWork += new DoWorkEventHandler(delegate(object sender, DoWorkEventArgs e) { while (true) { layoutEngine.incrementLayout(); Thread.Sleep(interFrameSleepTimeMillis); //Console.Out.WriteLine("Animating " + i); animationThread.ReportProgress(0); } }); animationThread.ProgressChanged += new ProgressChangedEventHandler(delegate(object sender, ProgressChangedEventArgs e) { form.Refresh(); }); animationThread.RunWorkerAsync(); }
//https://stackoverflow.com/questions/5427020/prompt-dialog-in-windows-forms public static void CardQuizzer(string caption, string text) { Form prompt = new Form(); prompt.Width = 500; prompt.Height = 500; prompt.FormBorderStyle = FormBorderStyle.FixedDialog; prompt.Text = caption; prompt.StartPosition = FormStartPosition.CenterScreen; Label textLabel = new Label() { Left = 50, Top = 20, Text = text }; TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 }; Button confirmation = new Button() { Text = "Confirm", Left = 300, Width = 100, Top = 70, DialogResult = DialogResult.OK }; Button denial = new Button() { Text = "Update", Left = 200, Width = 100, Top = 70}; confirmation.Click += (sender, e) => { prompt.Close(); }; denial.Click += (sender, e) => { prompt.Refresh(); }; //maybe refreshes form, build method to [.Refresh() or .Update()] //prompt.Controls.Add(textBox); prompt.Controls.Add(confirmation); prompt.Controls.Add(denial); prompt.Controls.Add(textLabel); //prompt.AcceptButton = confirmation; prompt.ShowDialog(); }
/// <summary> /// Function used to fade out a form using a user defined number /// of steps. /// </summary> /// <param name="f">The Windows form to fade out</param> /// <param name="NumberOfSteps">The number of steps used to fade the form</param> public static void FadeForm(Form form, byte NumberOfSteps, bool fadeIn) { float StepVal = (float)(100f / NumberOfSteps); float fOpacity = 0; if (!fadeIn) { fOpacity = 100f; } for (byte b = 0; b < NumberOfSteps; b++) { form.Opacity = fOpacity / 100; form.Refresh(); if (fadeIn) { fOpacity += StepVal; } else { fOpacity -= StepVal; } } }
/// <summary> /// Gets an image snapshot of the specified control, which does not have to be /// mapped to a <see cref="System.Windows.Forms.Form"/> and does not have to be /// fully visible. /// </summary> /// <param name="control">The control to get an image snapshot of.</param> /// <returns>An image snapshot of the control.</returns> public static Image OffscreenGrab(Control control) { // Save the old parent and location. Control oldParent = control.Parent; Point oldLocation = control.Location; // Create a form offscreen Form transpForm = new Form(); transpForm.StartPosition = FormStartPosition.Manual; transpForm.Location = new Point(Screen.PrimaryScreen.Bounds.Right + 10, 0); transpForm.ClientSize = new Size(control.Width + 10, control.Height + 10); // Make the form semi-transparent so windows turns on layering. transpForm.Opacity = .8; // Add the control. transpForm.Controls.Add(control); control.Location = new Point(0, 0); // Show the form (offscreen). transpForm.Show(); transpForm.Visible = true; transpForm.Refresh(); transpForm.Update(); // Grab the control. Image img = GrabControl(control); // Put the control back on its original form. control.Parent = oldParent; control.Location = oldLocation; // Get rid of our temporary form. transpForm.Close(); // Return the image. return img; }
void _form_ResizeEnd(object sender, EventArgs e) { UpdateRibbonConditions(); Form.Refresh(); }
public static void OpenForm(Form form) { Cursor.Current = Cursors.AppStarting; form.Refresh(); if (Program.FormPrincipal != null && form.MdiParent == null) form.MdiParent = Program.FormPrincipal; form.Show(); }
private void DoFormResizeEnd(object sender, EventArgs e) { UpdateRibbonConditions(); Form.Refresh(); Form.Update(); }
public void ParentTest() { _eventSink.ExpectedPaintCount = 1; _eventSink.ExpectedParentChangedCount = 2; Form parentForm = new Form(); _ctrl.Parent = parentForm; parentForm.Show(); Assert.AreEqual(parentForm, _ctrl.Parent); parentForm.Refresh(); _ctrl.Parent = null; parentForm.Refresh(); }
[Test] // bug #82040 public void ShowNoChildren () { Form form = new Form (); form.ShowInTaskbar = false; TableLayoutPanel tableLayoutPanel = new TableLayoutPanel (); tableLayoutPanel.ColumnCount = 3; tableLayoutPanel.Dock = DockStyle.Fill; tableLayoutPanel.RowCount = 11; form.Controls.Add (tableLayoutPanel); form.Show (); form.Refresh (); form.Dispose (); }
/// <summary> /// Tạo một thể hiện mới với các tham số được truyền vào /// </summary> /// <param name="frm">Form chứa Border này</param> /// <param name="backcolor">Màu nền của Border</param> /// <param name="textcolor">Màu chữ tiêu đề của Border</param> /// <param name="textsize">Kích thước chữ tiêu đề của Border</param> /// <param name="backgroundMoveable">Chỉ định khả năng di chuyển form bằng background</param> /// <param name="resizeable">Chỉ định khả năng thay đổi kích thước của form</param> public Border(Form frm, Color backcolor, Color textcolor, bool backgroundMoveable, bool resizeable) { _frm = frm; _frm.FormBorderStyle = FormBorderStyle.None; BackgroundMoveable = backgroundMoveable; Resizeable = resizeable; AddFormMoveableControls(this, Title); InitializeComponent(backcolor, textcolor); // add event to control frm.MouseMove += delegate(object sender, MouseEventArgs e) { if (e.Y < Height / 2) { Timer1.Start(); Timer2.Stop(); } else { Timer2.Start(); Timer1.Stop(); } }; frm.SizeChanged += delegate(object sender, EventArgs e) { this.Width = frm.Width; CloseBox.Location = new Point(Width - CloseBox.Width, 0); NormnalBox.Location = new Point(Width - NormnalBox.Width * 2, 0); MiniBox.Location = new Point(Width - MiniBox.Width * 3, 0); OpacityTrackbar.Location = new Point(MiniBox.Left - OpacityTrackbar.Width - 5, 2); Title.Width = OpacityTrackbar.Left; frm.Refresh(); }; frm.Paint += delegate(object sender, PaintEventArgs e) { e.Graphics.DrawRectangle(new Pen(Title.BackColor), new Rectangle(0, 0, frm.Width - 1, frm.Height - 1)); }; Controls.Add(Title); Controls.Add(OpacityTrackbar); Controls.Add(MiniBox); Controls.Add(NormnalBox); Controls.Add(CloseBox); frm.Controls.Add(this); this.BringToFront(); }
[Test] // Xamarin bug #24372 public void Bug24372_first_row_index () { Form form = new Form (); DataGridView24372 dgv = new DataGridView24372 (); dgv.Parent = form; dgv.ColumnCount = 1; dgv.RowCount = 100; dgv.CurrentCell = dgv[0,50]; dgv.Focus (); form.Show (); dgv.Rows.Clear (); form.Refresh (); Application.DoEvents (); if (dgv.HasException) Assert.Fail("#A1"); form.Dispose (); }
private static void SavePlayLists(iTunesApp ituneApp, string newPath) { var form = new Form { StartPosition = FormStartPosition.CenterScreen, Width = 250, Height = 60, Text = "Do not close me" }; form.Show(); var text = new Label { TextAlign = ContentAlignment.MiddleCenter, Width = 250 }; var count = 0; form.Controls.Add(text); if (newPath.LastIndexOf(@"\", StringComparison.Ordinal) == newPath.Length-1) { newPath = newPath.Substring(0, newPath.LastIndexOf(@"\", StringComparison.Ordinal)); } var songDict = GetLocationAndNewPath(ituneApp, newPath, text); foreach(var keyVal in songDict) { var location = keyVal.Key; var newLocation = keyVal.Value; Directory.CreateDirectory(newLocation.Substring(0, newLocation.LastIndexOf(@"\", StringComparison.Ordinal))); try { File.Copy(location, newLocation, true); } catch (UnauthorizedAccessException) { throw new UnauthorizedAccessException($"The file {newLocation} already exists. Its highly suggested to do a backup in an empty/unexisting directory"); } ++count; text.Text = $"Creating a backup... {count}/{songDict.Count} completed."; form.Refresh(); } }
private static ProgressBar InitFormAndProgressBar() { Form updateForm = new Form(); ProgressBar bar = new ProgressBar(); Label label = new Label(); updateForm.Controls.Add(bar); updateForm.Controls.Add(label); //init the form updateForm.Text = @"Updating..."; updateForm.Width = 300; updateForm.Height = 200; updateForm.BackColor = System.Drawing.Color.Lavender; updateForm.StartPosition = FormStartPosition.CenterScreen; ////init the icon //System.Resources.ResourceManager resource = // new System.Resources.ResourceManager("Nail.Properties.Resources", // System.Reflection.Assembly.GetExecutingAssembly()); //updateForm.Icon = (System.Drawing.Icon)resource.GetObject("AutoUpdaterIcon"); //init the label label.Text = @"Updating..."; label.AutoSize = true; label.Location = new System.Drawing.Point(100, 30); //init the progressBar bar.Location = new System.Drawing.Point(100, 70); bar.Value = 0; bar.Step = 1; updateForm.Show(); updateForm.Refresh(); return bar; }
//for pagar column void repositoryItemCheckEdit2_CheckedChanged(object sender, EventArgs e) { DataRow r = gridViewReservas.GetDataRow(gridViewReservas.FocusedRowHandle); DevExpress.XtraEditors.CheckEdit chBtn = (sender as DevExpress.XtraEditors.CheckEdit); if (chBtn.Checked) { formReservasPagar = new Form(); PnlVentas ventas = new PnlVentas(); // ventas.InitializeDataTable(); CommonUtils.Cliente cliente = new CommonUtils.Cliente(int.Parse(r[10].ToString()), r[6].ToString(), r[8].ToString(), r[9].ToString(), r[7].ToString(), int.Parse(r[12].ToString())); ventas.Cliente = cliente; ventas.StartButtonsReserva(new string[] { r[8].ToString(), r[7].ToString(), r[3].ToString(), r[5].ToString() }); chBtn.Checked = false; ventas.PedidoId = r[0].ToString(); ventas.ReservasPanel = this; ventas.Chbtn = chBtn; ventas.LlamadoDePnlReservas = true; formReservasPagar.Size=new Size(1046, 738); getPedidosDescripcion(r[0].ToString(),ventas); ventas.Dock = DockStyle.Fill; formReservasPagar.Controls.Add(ventas); formReservasPagar.MaximizeBox = false; formReservasPagar.Text = "Pagar reserva"; formReservasPagar.ShowDialog(); formReservasPagar.Refresh(); } // chBtn.Checked = false; }
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 (); }
/// <summary> /// reads info from the current open map file and /// stores in it this map object /// </summary> /// <remarks></remarks> private void LoadMap() { switch (HaloVersion) { case HaloVersionEnum.Halo2: { MapHeader = new MapHeaderInfo(ref BR, HaloVersion); IndexHeader = new IndexHeaderInfo(ref BR, this); MetaInfo = new ObjectIndexInfo(ref BR, this); #region Added for loading of obfuscated maps System.Collections.Generic.List<int> offsets = new System.Collections.Generic.List<int>(); System.Collections.Generic.List<int> indexes = new System.Collections.Generic.List<int>(); // Obfuscated maps set filename offset to 0 and change all listings to spaces. // This point is back to the correct place for starters. if (MapHeader.offsetTofileNames == 0) { MapHeader.offsetTofileNames = MapHeader.offsetTofileIndex - MapHeader.fileNamesSize; MapHeader.offsetTofileNames = MapHeader.offsetTofileNames - (MapHeader.offsetTofileNames % 64); // All sizes get set to maximum length if (MetaInfo.Size[0] == Int32.MaxValue) { // Sort our meta by offset to start for (int x = 0; x < MapHeader.fileCount; x++) if (x == 0 || MetaInfo.Offset[x] >= offsets[x - 1]) { offsets.Add(MetaInfo.Offset[x]); indexes.Add(x); } else { for (int y = 0; y < x; y++) if (MetaInfo.Offset[x] < offsets[y]) { offsets.Insert(y, MetaInfo.Offset[x]); indexes.Insert(y, x); break; } } for (int x = 0; x < MapHeader.fileCount; x++) { if (offsets[x] < 0) continue; if (indexes[x] < MapHeader.fileCount - 1) MetaInfo.Size[indexes[x]] = offsets[x + 1] - offsets[x]; else MetaInfo.Size[indexes[x]] = this.MapHeader.fileSize - offsets[x]; } } } #endregion FileNames = new FileNamesInfo(ref BR, this); Strings = new StringsInfo(ref BR, this); CloseMap(); Unicode = new UnicodeTableReader(this.filePath, this.MetaInfo.Offset[0]); #region Attempt to detect and recover meta tag names from a known good base map // If the first two entries both start with our default # sign and offsets has a count, map is probably obfuscated if (FileNames.Name[0].StartsWith("#") && FileNames.Name[1].StartsWith("#") && offsets.Count > 0) { if (MessageBox.Show("This map may have been obfuscated. Would you like to try to recover names from a map(s)?", "Decode from map(s)?", MessageBoxButtons.YesNo) == DialogResult.Yes) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Map Files|*.map"; ofd.Multiselect = true; ofd.Title = "Select the Clean Base Map for this Map (" + MapHeader.mapName.TrimEnd((char)0) + ")"; do { if (ofd.ShowDialog() == DialogResult.OK) { #region Information Form (f) Creation Form f = new Form(); f.ControlBox = false; f.MinimizeBox = false; f.MaximizeBox = false; f.FormBorderStyle = FormBorderStyle.FixedSingle; f.Size = new System.Drawing.Size(700, 60); f.StartPosition = FormStartPosition.CenterScreen; Label lbl = new Label(); lbl.Dock = DockStyle.Fill; lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; #endregion f.Show(); f.Controls.Add(lbl); foreach (string filename in ofd.FileNames) { f.Text = filename; lbl.Text = "Unknowns remaining: " + indexes.Count.ToString(); f.Focus(); f.Refresh(); // Load clean base map Map tempMap = Map.LoadFromFile(filename); if (tempMap == null) continue; /* // Match all Idents and use original name for (int z = 0; z < tempMap.MetaInfo.Ident.Length; z++) for (int y = 0; y < indexes.Count; y++) if (tempMap.MetaInfo.Ident[z] == MetaInfo.Ident[indexes[y]]) { FileNames.Name[indexes[y]] = tempMap.FileNames.Name[z]; // No longer need these, so remove to speed up future searches. indexes.RemoveAt(y); offsets.RemoveAt(y); break; } */ // Match all tags with same length, tag type & name lengths for (int z = 0; z < tempMap.MetaInfo.Size.Length; z++) for (int y = 0; y < indexes.Count; y++) if (tempMap.MetaInfo.Size[z] == MetaInfo.Size[indexes[y]] && tempMap.MetaInfo.TagType[z] == MetaInfo.TagType[indexes[y]] && tempMap.FileNames.Name[z].Length == FileNames.Name[indexes[y]].Length) { FileNames.Name[indexes[y]] = tempMap.FileNames.Name[z]; // No longer need these, so remove to speed up future searches. indexes.RemoveAt(y); offsets.RemoveAt(y); break; } tempMap.CloseMap(); } f.Hide(); f.Dispose(); } if (indexes.Count > 0) if (MessageBox.Show("There are still " + indexes.Count.ToString() + " unknowns.\n Would you like to try retrieving data from another map?", "Check another base map?", MessageBoxButtons.YesNo) == DialogResult.No) break; } while (indexes.Count > 0); // For left-over tags, try something else for (int y = 0; y < indexes.Count; y++) { // Models store the name inside the tag, so at least show that much if (MetaInfo.TagType[indexes[y]] == "mode") { Meta m = Map.GetMetaFromTagIndex(indexes[y], this, false, false); BinaryReader br = new BinaryReader(m.MS); br.BaseStream.Position = 0; int SID = br.ReadInt16(); br.BaseStream.Position += 1; byte SIDLen = br.ReadByte(); if (this.Strings.Length[SID] == SIDLen) { string name = this.Strings.Name[SID] + "__"; FileNames.Name[indexes[y]] = FileNames.Name[indexes[y]].Substring(0, 6) + name + FileNames.Name[indexes[y]].Remove(0, 6 + name.Length); } m.Dispose(); indexes.RemoveAt(y); offsets.RemoveAt(y); } } if (MessageBox.Show("Do you wish to save changes into map now?", "Save changes?", MessageBoxButtons.YesNo) == DialogResult.Yes) { this.OpenMap(MapTypes.Internal); // Write the proper offset location to the header this.BW.BaseStream.Position = 708; BW.Write(this.MapHeader.offsetTofileNames); // Write the meta tag sizes for (int x = 0; x < this.IndexHeader.metaCount; x++) { BW.BaseStream.Position = this.IndexHeader.tagsOffset + x * 16 + 12; BW.Write(this.MetaInfo.Size[x]); } // Write the names into the file for (int x = 0; x < this.IndexHeader.metaCount; x++) { BW.BaseStream.Position = this.MapHeader.offsetTofileNames + this.FileNames.Offset[x]; BW.Write(this.FileNames.Name[x].PadRight(this.FileNames.Length[x],'\0').ToCharArray(), 0, this.FileNames.Length[x]); } this.CloseMap(); } } } #endregion break; } case HaloVersionEnum.Halo2Vista: { MapHeader = new MapHeaderInfo(ref BR, HaloVersion); IndexHeader = new IndexHeaderInfo(ref BR, this); MetaInfo = new ObjectIndexInfo(ref BR, this); FileNames = new FileNamesInfo(ref BR, this); Strings = new StringsInfo(ref BR, this); CloseMap(); Unicode = new UnicodeTableReader(this.filePath, this.MetaInfo.Offset[0]); break; } case HaloVersionEnum.HaloCE: { BitmapLibary = new BitmapLibraryLayout(this); MapHeader = new MapHeaderInfo(ref BR, HaloVersion); IndexHeader = new IndexHeaderInfo(ref BR, this); MetaInfo = new ObjectIndexInfo(ref BR, this); FileNames = new FileNamesInfo(ref BR, this); this.MapHeader.fileNamesSize = FileNames.FileNameStringsSize; this.MapHeader.offsetTofileNames = FileNames.FileNameStringsOffset; break; } case HaloVersionEnum.Halo1: { // BitmapLibary = new BitmapLibraryLayout(this); MapHeader = new MapHeaderInfo(ref BR, HaloVersion); IndexHeader = new IndexHeaderInfo(ref BR, this); MetaInfo = new ObjectIndexInfo(ref BR, this); FileNames = new FileNamesInfo(ref BR, this); this.MapHeader.fileNamesSize = FileNames.FileNameStringsSize; this.MapHeader.offsetTofileNames = FileNames.FileNameStringsOffset; break; } } switch (HaloVersion) { case HaloVersionEnum.Halo2: case HaloVersionEnum.Halo2Vista: ugh_.GetUghContainerInfo(this); this.BSP = new BSPContainer(this); break; case HaloVersionEnum.Halo1: case HaloVersionEnum.HaloCE: this.BSP = new BSPContainer(this); break; } DisplayType = Meta.ItemType.Reflexive; }
/// <summary> /// Processes the WndProc for a form with a Ribbbon. Returns true if message has been handled /// </summary> /// <param name="m">Message to process</param> /// <returns><c>true</c> if message has been handled. <c>false</c> otherwise</returns> public virtual bool WndProc(ref Message m) { if (DesignMode) { return(false); } bool handled = false; if (WinApi.IsVista) { #region Checks if DWM processes the message IntPtr result; int dwmHandled = WinApi.DwmDefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam, out result); if (dwmHandled == 1) { m.Result = result; handled = true; } #endregion } //if (m.Msg == WinApi.WM_NCLBUTTONUP) //{ // UpdateRibbonConditions(); //} if (!handled) { if (m.Msg == WinApi.WM_NCCALCSIZE && (int)m.WParam == 1) { #region Catch the margins of what the client area would be WinApi.NCCALCSIZE_PARAMS nccsp = (WinApi.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(WinApi.NCCALCSIZE_PARAMS)); if (!MarginsChecked) { //Set what client area would be for passing to DwmExtendIntoClientArea SetMargins(new Padding( nccsp.rect2.Left - nccsp.rect1.Left, nccsp.rect2.Top - nccsp.rect1.Top, nccsp.rect1.Right - nccsp.rect2.Right, nccsp.rect1.Bottom - nccsp.rect2.Bottom)); MarginsChecked = true; } Marshal.StructureToPtr(nccsp, m.LParam, false); m.Result = IntPtr.Zero; handled = true; #endregion } else if (m.Msg == WinApi.WM_NCHITTEST && (int)m.Result == 0) { #region Check the Non-client area hit test m.Result = new IntPtr(Convert.ToInt32(NonClientHitTest(new Point(WinApi.LoWord((int)m.LParam), WinApi.HiWord((int)m.LParam))))); handled = true; if (Ribbon != null && Ribbon.ActualBorderMode == RibbonWindowMode.NonClientAreaCustomDrawn) { Form.Refresh(); } #endregion } //else if ((m.Msg == WinApi.WM_SIZE) && Ribbon != null && Ribbon.ActualBorderMode == RibbonWindowMode.NonClientAreaGlass) //{ // //UpdateRibbonConditions(); //} else if ( (Ribbon != null && Ribbon.ActualBorderMode != RibbonWindowMode.NonClientAreaCustomDrawn) && (m.Msg == 0x112 || m.Msg == 0x47 || m.Msg == 0x46 || m.Msg == 0x2a2)) //WM_SYSCOMMAND { //InvalidateCaption(); //using (Graphics g = Form.CreateGraphics()) //{ // g.DrawRectangle(Pens.Red, new Rectangle(Form.Width - 200, 0, 200, 50)); //} }/* * else if ( * (Ribbon != null && Ribbon.ActualBorderMode == RibbonWindowMode.NonClientAreaCustomDrawn) && * (m.Msg == 0x86 || m.Msg == 0x85 || m.Msg == 0xc3c2 || m.Msg == 0xc358) * ) * { * m.Result = new IntPtr(-1); * handled = true; * }*/ } return(handled); }
public static void LoadWindowInfo(Form win, string settings) { if (settings.Length != 0) { WindowInfo = settings; string[] wi = settings.Split(','); win.Location = new Point(int.Parse(wi[0]), int.Parse(wi[1])); win.Size = new Size(int.Parse(wi[2]), int.Parse(wi[3])); win.WindowState = (FormWindowState)int.Parse(wi[4]); win.Refresh(); } else { win.WindowState = FormWindowState.Normal; win.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - win.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - win.Height) / 2); } }
/// <summary> /// Make a full-size thumbnail of the captured window on a new topmost form, and capture /// this new form with a black and then white background. Then compute the transparency by /// difference between the black and white versions. /// This method has these advantages: /// - the full form is captured even if it is obscured on the Windows desktop /// - there is no problem with unpredictable Z-order anymore (the background and /// the window to capture are drawn on the same window) /// Note: now that GDI capture is more robust, DWM capture is not that useful anymore. /// </summary> /// <param name="handle">handle of the window to capture</param> /// <param name="windowRect">the bounds of the window</param> /// <param name="redBGImage">the window captured with a red background</param> /// <param name="captureRedBGImage">whether to do the capture of the window with a red background</param> /// <returns>the captured window image</returns> private static Image CaptureWindowWithTransparencyDWM(IntPtr handle, Rectangle windowRect, out Bitmap redBGImage, bool captureRedBGImage) { Image windowImage = null; redBGImage = null; using (Form form = new Form()) { form.FormBorderStyle = FormBorderStyle.None; form.ShowInTaskbar = false; form.BackColor = Color.White; form.TopMost = true; form.Bounds = windowRect; IntPtr thumb; NativeMethods.DwmRegisterThumbnail(form.Handle, handle, out thumb); SIZE size; NativeMethods.DwmQueryThumbnailSourceSize(thumb, out size); if (size.x <= 0 || size.y <= 0) { return null; } form.Location = new Point(windowRect.X, windowRect.Y); form.Size = new Size(size.x, size.y); form.Show(); NativeMethods.DWM_THUMBNAIL_PROPERTIES props = new NativeMethods.DWM_THUMBNAIL_PROPERTIES(); props.dwFlags = NativeMethods.DWM_TNP_VISIBLE | NativeMethods.DWM_TNP_RECTDESTINATION | NativeMethods.DWM_TNP_OPACITY; props.fVisible = true; props.opacity = (byte)255; props.rcDestination = new RECT(0, 0, size.x, size.y); NativeMethods.DwmUpdateThumbnailProperties(thumb, ref props); NativeMethods.ActivateWindowRepeat(handle, 250); Bitmap whiteBGImage = CaptureRectangle(windowRect) as Bitmap; form.BackColor = Color.Black; form.Refresh(); NativeMethods.ActivateWindowRepeat(handle, 250); Bitmap blackBGImage = CaptureRectangle(windowRect) as Bitmap; if (captureRedBGImage) { form.BackColor = Color.Red; form.Refresh(); NativeMethods.ActivateWindowRepeat(handle, 250); redBGImage = CaptureRectangle(windowRect) as Bitmap; } form.BackColor = Color.White; form.Refresh(); NativeMethods.ActivateWindowRepeat(handle, 250); Bitmap whiteBGImage2 = CaptureRectangle(windowRect) as Bitmap; // Don't do transparency calculation if an animated picture is detected if (whiteBGImage.AreBitmapsEqual(whiteBGImage2)) { windowImage = GraphicsMgr.ComputeOriginal(whiteBGImage, blackBGImage); } else { FileSystem.AppendDebug("Detected animated image => cannot compute transparency"); form.Close(); Application.DoEvents(); Image result = new Bitmap(whiteBGImage.Width, whiteBGImage.Height, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(result)) { // Redraw the image on a black background to avoid transparent pixels artifacts g.Clear(Color.Black); g.DrawImage(whiteBGImage, 0, 0); } windowImage = result; } NativeMethods.DwmUnregisterThumbnail(thumb); blackBGImage.Dispose(); whiteBGImage.Dispose(); whiteBGImage2.Dispose(); } return windowImage; }
public static void UpdateFonts(Form form) { foreach (Control c in form.Controls) { if (c is TextBox || c is DataGridView || c is ListBox) { c.Font = new Font(Properties.Settings.Default.Fonts[0], c.Font.Size); c.ForeColor = Color.Black; } else { c.Font = new Font(Main.GetFont(), c.Font.Size); if (c.Name != "bt_Exit" && c.Name != "bt_Back" && c.Name != "bt_Logout") c.ForeColor = Main.GetColor(); } } form.Update(); form.Refresh(); }
public static void fade(Form myForm, int fadeSpeed) { int num1 = Math.Abs(fadeSpeed); int num2 = 0; while (num2 < 100 + num1) { myForm.Opacity = fadeSpeed <= 0 ? (double) (100 - num2) / 100.0 : (double) num2 / 100.0; myForm.Refresh(); Thread.Sleep(50); num2 += num1; } }
[Test] // bug #82041 public void DontCallResumeLayout () { Form form = new Form (); form.ShowInTaskbar = false; TableLayoutPanel tableLayoutPanel = new TableLayoutPanel (); form.Controls.Add (tableLayoutPanel); tableLayoutPanel.SuspendLayout (); tableLayoutPanel.ColumnCount = 3; tableLayoutPanel.Dock = DockStyle.Fill; tableLayoutPanel.RowCount = 11; tableLayoutPanel.Controls.Add (new Button ()); form.Show (); form.Refresh (); form.Dispose (); }
/// <summary> /// Make a full-size thumbnail of the captured window on a new topmost form, and capture /// this new form with a black and then white background. Then compute the transparency by /// difference between the black and white versions. /// This method has these advantages: /// - the full form is captured even if it is obscured on the Windows desktop /// - there is no problem with unpredictable Z-order anymore (the background and /// the window to capture are drawn on the same window) /// </summary> /// <param name="handle">handle of the window to capture</param> /// <param name="windowRect">the bounds of the window</param> /// <param name="redBGImage">the window captured with a red background</param> /// <param name="captureRedBGImage">whether to do the capture of the window with a red background</param> /// <returns>the captured window image</returns> private static Image CaptureWindowWithDWM(IntPtr handle, Rectangle windowRect, out Bitmap redBGImage, Color backColor) { Image windowImage = null; redBGImage = null; if (backColor != Color.White) { backColor = Color.FromArgb(255, backColor.R, backColor.G, backColor.B); } using (Form form = new Form()) { form.StartPosition = FormStartPosition.Manual; form.FormBorderStyle = FormBorderStyle.None; form.ShowInTaskbar = false; form.BackColor = backColor; form.TopMost = true; form.Bounds = CaptureHelpers.GetWindowRectangle(handle, false); IntPtr thumb; NativeMethods.DwmRegisterThumbnail(form.Handle, handle, out thumb); SIZE size; NativeMethods.DwmQueryThumbnailSourceSize(thumb, out size); #if DEBUG DebugHelper.WriteLine("Rectangle Size: " + windowRect.ToString()); DebugHelper.WriteLine("Window Size: " + size.ToString()); #endif if (size.Width <= 0 || size.Height <= 0) { return null; } DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES(); props.dwFlags = NativeMethods.DWM_TNP_VISIBLE | NativeMethods.DWM_TNP_RECTDESTINATION | NativeMethods.DWM_TNP_OPACITY; props.fVisible = true; props.opacity = (byte)255; props.rcDestination = new RECT(0, 0, size.Width, size.Height); NativeMethods.DwmUpdateThumbnailProperties(thumb, ref props); form.Show(); System.Threading.Thread.Sleep(250); if (form.BackColor != Color.White) { // no need for transparency; user has requested custom background color NativeMethods.ActivateWindowRepeat(form.Handle, 250); windowImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap; } else if (form.BackColor == Color.White) { // transparent capture NativeMethods.ActivateWindowRepeat(handle, 250); Bitmap whiteBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap; form.BackColor = Color.Black; form.Refresh(); NativeMethods.ActivateWindowRepeat(handle, 250); Bitmap blackBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap; // Capture rounded corners with except for Windows 8 if (ZAppHelper.IsWindows8()) { form.BackColor = Color.Red; form.Refresh(); NativeMethods.ActivateWindowRepeat(handle, 250); redBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap; } form.BackColor = Color.White; form.Refresh(); NativeMethods.ActivateWindowRepeat(handle, 250); Bitmap whiteBGImage2 = Screenshot.CaptureRectangleNative(windowRect) as Bitmap; // Don't do transparency calculation if an animated picture is detected if (whiteBGImage.AreBitmapsEqual(whiteBGImage2)) { windowImage = HelpersLib.GraphicsHelper.Core.ComputeOriginal(whiteBGImage, blackBGImage); } else { DebugHelper.WriteLine("Detected animated image => cannot compute transparency"); form.Close(); Application.DoEvents(); Image result = new Bitmap(whiteBGImage.Width, whiteBGImage.Height, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(result)) { // Redraw the image on a black background to avoid transparent pixels artifacts g.Clear(Color.Black); g.DrawImage(whiteBGImage, 0, 0); } windowImage = result; } blackBGImage.Dispose(); whiteBGImage.Dispose(); whiteBGImage2.Dispose(); } NativeMethods.DwmUnregisterThumbnail(thumb); } return windowImage; }
public static Form LoadingBox(string title, string promptText) { Form form = new Form(); System.Windows.Forms.Label label = new System.Windows.Forms.Label(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2)); form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); form.Text = title; label.Text = promptText; label.SetBounds(9, 50, 372, 13); label.AutoSize = true; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label }); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; ThemeManager.ApplyThemeTo(form); form.Show(); form.Refresh(); label.Refresh(); Application.DoEvents(); return form; }
private void ThreadFunction() { try { // show window Form window = new Form(); window.FormClosing += FormOnClose; window.Text = "Map"; //window.Size = new System.Drawing.Size(800, 600); window.AutoSize = true; while (true) { lock (this) { if (bitmap != null) { if (window.Visible != visible) { if (visible) { if (first) { PictureBox picture = new PictureBox(); picture.Image = bitmap; picture.SizeMode = PictureBoxSizeMode.AutoSize; window.Controls.Add(picture); first = false; } window.Show(); } else { window.Hide(); } } } if (updated) { if (window.Visible) { window.Refresh(); } updated = false; } if (window.Visible) { Application.DoEvents(); } } Thread.Sleep(100); } } catch (ThreadInterruptedException e) { // do nothing } }
private void DoFormTextChanged(object sender, EventArgs e) { UpdateRibbonConditions(); Form.Refresh(); Form.Update(); }
public static void OpenForm(Form form, Form mdiForm) { Cursor.Current = Cursors.AppStarting; mdiForm.Refresh(); form.MdiParent = mdiForm; form.Show(); }