public void SelectRow_ShouldMaintain_ActivePosition() { // set up special conditions var grid = new Grid(); grid.Redim(1, 1); grid[0, 0] = new Cell(); var form = new Form(); form.Controls.Add(grid); form.Show(); grid.SelectionMode = GridSelectionMode.Row; grid.Selection.EnableMultiSelection = false; // just assert that we have correct conditions for test, // active position should not be empty grid.Selection.Focus(new Position(0, 0), true); Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition); // this method causes first row to be selected. Should not fail // it failed once in RowSelection.SelectRow method // As call to ResetSelection asked to maintain focus, a stack overflow was raised grid.Selection.SelectRow(0, true); Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition); // destroy form.Close(); form.Dispose(); }
/// <summary> /// Procesa el resultado de una operación. /// Si es un OperationResult, muestra el mensaje. /// Si es un formulario, muestra el formulario. /// </summary> public void ProcesarObjeto(object obj) { if (obj is Lfx.Types.OperationResult) { Lfx.Types.OperationResult ResOp = obj as Lfx.Types.OperationResult; if (ResOp.Success == false && ResOp.Message != null) { Lfx.Workspace.Master.RunTime.Toast(ResOp.Message, "Error"); } } else if (obj is System.Windows.Forms.Form) { System.Windows.Forms.Form ResForm = obj as System.Windows.Forms.Form; if (obj is Lui.Forms.ChildForm) { ResForm.MdiParent = Aplicacion.FormularioPrincipal; } else if (Aplicacion.Flotante) { ResForm.WindowState = Aplicacion.FormularioPrincipal.WindowState; ResForm.Owner = Aplicacion.FormularioPrincipal; } if (ResForm.DialogResult == System.Windows.Forms.DialogResult.Abort) { Lfx.Workspace.Master.RunTime.Toast("No se puede tener acceso al formulario.", "Error"); ResForm.Dispose(); } else { try { ResForm.Show(); ResForm.BringToFront(); } catch (ApplicationException ex) { Lfx.Workspace.Master.RunTime.Toast(ex.Message, "Error"); ResForm.Dispose(); } } } else if (obj != null) { Lfx.Workspace.Master.RunTime.Toast("La operación devolvió un objeto tipo " + obj.GetType().ToString(), "Aviso"); } }
public static void Initialize() { var window = new Form(); IntPtr direct3D = Direct3DAPI.Direct3DCreate9(Direct3DAPI.SDKVersion); if (direct3D == IntPtr.Zero) throw new Exception("Direct3DCreate9 failed (SDK Version: " + Direct3DAPI.SDKVersion + ")"); var pp = new Direct3DAPI.PresentParameters { Windowed = true, SwapEffect = 1, BackBufferFormat = 0 }; var createDevice = Helper.Magic.RegisterDelegate<Direct3DAPI.Direct3D9CreateDevice>(Helper.Magic.GetObjectVtableFunction(direct3D, 16)); IntPtr device; if (createDevice(direct3D, 0, 1, window.Handle, 0x20, ref pp, out device) < 0) throw new Exception("Failed to create device"); EndScenePointer = Helper.Magic.GetObjectVtableFunction(device, Direct3DAPI.EndSceneOffset); ResetPointer = Helper.Magic.GetObjectVtableFunction(device, Direct3DAPI.ResetOffset); ResetExPointer = Helper.Magic.GetObjectVtableFunction(device, Direct3DAPI.ResetExOffset); var deviceRelease = Helper.Magic.RegisterDelegate<Direct3DAPI.D3DRelease>(Helper.Magic.GetObjectVtableFunction(device, 2)); var release = Helper.Magic.RegisterDelegate<Direct3DAPI.D3DRelease>(Helper.Magic.GetObjectVtableFunction(direct3D, 2)); deviceRelease(device); release(direct3D); window.Dispose(); // TODO: replace this with a VTable hook _endSceneDelegate = Helper.Magic.RegisterDelegate<Direct3DAPI.Direct3D9EndScene>(EndScenePointer); _endSceneHook = Helper.Magic.Detours.CreateAndApply(_endSceneDelegate, new Direct3DAPI.Direct3D9EndScene(EndSceneHook), "EndScene"); }
public MaterialCheckBox() { // DPI Adjustments Form tmp = new Form(); int dpiY = Utilities.DPIMath.ratioY(tmp); int dpiX = Utilities.DPIMath.ratioX(tmp); tmp.Dispose(); CHECKBOX_SIZE = CHECKBOX_SIZE * dpiX; CHECKBOX_SIZE_HALF = CHECKBOX_SIZE_HALF * dpiX; CHECKBOX_INNER_BOX_SIZE = CHECKBOX_INNER_BOX_SIZE * dpiX; animationManager = new AnimationManager { AnimationType = AnimationType.EaseInOut, Increment = 0.05 }; rippleAnimationManager = new AnimationManager(false) { AnimationType = AnimationType.Linear, Increment = 0.10, SecondaryIncrement = 0.08 }; animationManager.OnAnimationProgress += sender => Invalidate(); rippleAnimationManager.OnAnimationProgress += sender => Invalidate(); CheckedChanged += (sender, args) => { animationManager.StartNewAnimation(Checked ? AnimationDirection.In : AnimationDirection.Out); }; Ripple = true; MouseLocation = new Point(-1, -1); }
/// <summary> /// Draws a MessageBox that always stays on top with a tile and selectable button /// </summary> static public DialogResult Show(string message, string title, MessageBoxButtons buttons) { // Create a host form that is a TopMost window which will be the // parent of the MessageBox. Form topmostForm = new Form(); // We do not want anyone to see this window so position it off the // visible screen and make it as small as possible topmostForm.Size = new System.Drawing.Size(1, 1); topmostForm.StartPosition = FormStartPosition.Manual; System.Drawing.Rectangle rect = SystemInformation.VirtualScreen; topmostForm.Location = new System.Drawing.Point(rect.Bottom + 10, rect.Right + 10); topmostForm.Show(); // Make this form the active form and make it TopMost topmostForm.Focus(); topmostForm.BringToFront(); topmostForm.TopMost = true; // Finally show the MessageBox with the form just created as its owner DialogResult result = MessageBox.Show(topmostForm, message, title, buttons); topmostForm.Dispose(); // clean it up all the way return result; }
public void CheckedTest () { RadioButton rb = new RadioButton (); Assert.AreEqual (false, rb.TabStop, "#A1"); Assert.AreEqual (false, rb.Checked, "#A2"); rb.Checked = true; Assert.AreEqual (true, rb.TabStop, "#B1"); Assert.AreEqual (true, rb.Checked, "#B2"); rb.Checked = false; Assert.AreEqual (false, rb.TabStop, "#C1"); Assert.AreEqual (false, rb.Checked, "#C2"); // RadioButton is NOT checked, but since it is the only // RadioButton instance in Form, when it gets selected (Form.Show) // it should acquire the focus Form f = new Form (); f.Controls.Add (rb); rb.CheckedChanged += new EventHandler (rb_checked_changed); event_received = false; f.ActiveControl = rb; Assert.AreEqual (true, event_received, "#D1"); Assert.AreEqual (true, rb.Checked, "#D2"); Assert.AreEqual (true, rb.TabStop, "#D3"); f.Dispose (); }
public void PreferredWidth () { Label l = new Label(); // preferred width is 0 by default Assert.AreEqual (0, l.PreferredWidth, "2"); // and after text is changed it's something else l.Text = "hi"; Assert.IsTrue (l.PreferredWidth > 0, "3"); // now add it to a form and see Form f = new Form (); f.ShowInTaskbar = false; l.Text = ""; f.Controls.Add (l); f.Show (); Assert.AreEqual (0, l.PreferredWidth, "4"); l.Text = "hi"; Assert.IsTrue (l.PreferredWidth > 0, "5"); f.Dispose (); }
public override void Initialize() { Form form = new Form(); IntPtr intPtr = Direct3DCreate9(32u); if (intPtr == IntPtr.Zero) { throw new Exception("Failed to create D3D."); } D3D9.Struct0 @struct = new D3D9.Struct0 { bool_0 = true, uint_6 = 1u, uint_2 = 0u }; D3D9.Delegate4 @delegate = (D3D9.Delegate4)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(intPtr), 64), typeof(D3D9.Delegate4)); IntPtr intPtr2; if (@delegate(intPtr, 0u, 1u, form.Handle, 32u, ref @struct, out intPtr2) < 0) { throw new Exception("Failed to create device."); } this.EndScenePointer = Marshal.ReadIntPtr(Marshal.ReadIntPtr(intPtr2), 168); D3D9.Delegate3 delegate2 = (D3D9.Delegate3)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(intPtr2), 8), typeof(D3D9.Delegate3)); D3D9.Delegate3 delegate3 = (D3D9.Delegate3)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(intPtr), 8), typeof(D3D9.Delegate3)); delegate2(intPtr2); delegate3(intPtr); form.Dispose(); this.delegate2_0 = (D3D9.Delegate2)Marshal.GetDelegateForFunctionPointer(this.EndScenePointer, typeof(D3D9.Delegate2)); this.localHook_0 = LocalHook.Create(this.EndScenePointer, new D3D9.Delegate2(this.method_0), this); int[] exclusiveACL = new int[1]; localHook_0.ThreadACL.SetExclusiveACL(exclusiveACL); }
public ConvertToBitmap() { Bitmap bitmap = null; // do cvThreshold using (IplImage src = new IplImage(FilePath.Image.Lenna, LoadMode.GrayScale)) using (IplImage dst = new IplImage(src.Size, BitDepth.U8, 1)) { src.Smooth(src, SmoothType.Gaussian, 5); src.Threshold(dst, 0, 255, ThresholdType.Otsu); // IplImage -> Bitmap bitmap = dst.ToBitmap(); //bitmap = BitmapConverter.ToBitmap(dst); } // visualize using WindowsForm Form form = new Form { Text = "from IplImage to Bitmap", ClientSize = bitmap.Size, }; PictureBox pictureBox = new PictureBox { Dock = DockStyle.Fill, SizeMode = PictureBoxSizeMode.StretchImage, Image = bitmap }; form.Controls.Add(pictureBox); form.ShowDialog(); form.Dispose(); bitmap.Dispose(); }
public void TestDataSet () { // Binding to a DataSet doesn't work unless you specify DataMember Form f = new Form (); f.ShowInTaskbar = false; DataSet ds = new DataSet (); DataTable dt = ds.Tables.Add ("Muppets"); dt.Columns.Add ("ID"); dt.Columns.Add ("Name"); dt.Columns.Add ("Sex"); dt.Rows.Add (1, "Kermit", "Male"); dt.Rows.Add (2, "Miss Piggy", "Female"); dt.Rows.Add (3, "Gonzo", "Male"); DataGridView dgv = new DataGridView (); dgv.DataSource = ds; f.Controls.Add (dgv); f.Show (); Assert.AreEqual (0, dgv.Columns.Count, "A1"); Assert.AreEqual (0, dgv.Rows.Count, "A2"); dgv.DataMember = "Muppets"; Assert.AreEqual (3, dgv.Columns.Count, "A3"); Assert.AreEqual (4, dgv.Rows.Count, "A4"); f.Dispose (); }
public static void AbrirNuevoForm(Form frmNueva) { Herramientas.frmAnterior = Herramientas.frmActual; Herramientas.frmActual = frmNueva; frmActual.Show(); frmAnterior.Dispose(); }
/// <summary> /// Devuelve o crea una instancia de un tipo de Formulario de la aplicación de forma genérica /// </summary> /// <param name="currentForm">Referencia del formulario origen de la llamada</param> /// <param name="newFormType">Tipo del formulario a crear</param> /// <param name="newForm">Referencia actual del formulario a crear (puede que ya exista)</param> /// <param name="forceCreate">Si es true, siempre se creará una instancia nueva, y si es false intentará devolver la instancia existente.</param> /// <returns></returns> private static Form getGenericFormInstance(Form currentForm, Type newFormType, Form newForm, Boolean forceCreate) { if (newForm == null || forceCreate) { // Hay que crear una instancia nueva if (newForm != null) { // Si ya existía, lo cerramos antes de crear otro, liberando los recursos utilizados por el mismo. newForm.Close(); newForm.Dispose(); } // Creamos el nuevo formulario newForm = (Form)Activator.CreateInstance(newFormType); } // Mostramos el nuevo formulario newForm.Show(); if (currentForm != null) { // Si nos llegó la referencia al formulario origen de la 'navegación', lo ocultamos (la referencia está guardada para recuperarla después) currentForm.Hide(); } return newForm; }
private static DialogResult DisplayForm(object[] parms) { MenuItem mnu = (MenuItem)parms[0]; System.Windows.Forms.Form frm = CTechCore.Tools.Forms.IsFormInstantiated(mnu.RuntimeFormType).FirstOrDefault(); if (frm != null) { frm.Close(); frm.Dispose(); frm = null; } if (mnu.RequiresParametersOnConstructer) { frm = (System.Windows.Forms.Form)Activator.CreateInstance(mnu.RuntimeFormType, parms); } else { frm = (System.Windows.Forms.Form)Activator.CreateInstance(mnu.RuntimeFormType, new object[] { }); } frm.WindowState = FormWindowState.Normal; frm.StartPosition = FormStartPosition.CenterScreen; if (!mnu.DisplayAllFormBeforeLoad) { frm.MdiParent = CTechCore.Tools.Forms.IsFormInstantiated("frmMain").FirstOrDefault(); frm.Show(); } else { frm.ShowDialog(); } return(DialogResult.OK); }
public static DialogResult Show(string text, string head) { form1.Dispose(); form1 = new Form(); InitializeComponent(); if (form1.ParentForm == null) form1.StartPosition = FormStartPosition.CenterScreen; label1.Location = new Point(12, label1.Location.Y); btnNames = AsignButtons(buttons); form1.Text = head; label1.Text = text; FormAutoHeigh(); CenterButtons(btnNames.Length); MakeButtons(btnNames, selNoBtn); AddSound(icon); DialogResult rez = form1.ShowDialog(); form1.Dispose(); return rez; }
public void set_window(Form frm) { foreach (Control control in panel_container.Controls) { if (control.Text == frm.Text) { control.BringToFront(); current_form = (Form)frm; frm.Dispose(); return; } } frm.TopLevel = false; frm.Dock = System.Windows.Forms.DockStyle.Fill; frm.FormBorderStyle = FormBorderStyle.None; frm.TopMost = true; this.panel_container.Controls.Add(frm); frm.Show(); frm.BringToFront(); current_form = (Form)frm; TreeNode node = new TreeNode(); node.Text = frm.Text; tree_menu.Nodes.Add(node); }
/// <summary>Displays Any String</summary> /// <param name="StringToDisplay">Object with Properties to edit</param> /// <param name="pDaddy">Parent Form Or Nothing (null)</param> /// <param name="strTitle">Window Title</param> public static void DisplayABigString(string StringToDisplay, System.Windows.Forms.Control pDaddy, string strTitle = "") { System.Windows.Forms.Form frmEO = new System.Windows.Forms.Form(); TextBox T = new TextBox() { Multiline = true, ScrollBars = ScrollBars.Both, Dock = DockStyle.Fill, WordWrap = false }; frmEO.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; frmEO.Text = strTitle; frmEO.Controls.Add(T); T.Text = StringToDisplay; T.Font = CourierNew(); T.SelectionStart = 0; T.SelectionLength = 0; T.KeyDown += TextBox_KeyDown; frmEO.Hide(); frmEO.Height = 640; frmEO.Width = 640; System.Windows.Forms.Application.DoEvents(); if (pDaddy == null) { frmEO.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; frmEO.ShowDialog(); } else { frmEO.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; frmEO.ShowDialog(pDaddy); } frmEO.Dispose(); }
public void AutoSize () { Form f = new Form (); f.ShowInTaskbar = false; Panel p = new Panel (); p.AutoSize = true; f.Controls.Add (p); Button b = new Button (); b.Size = new Size (200, 200); b.Location = new Point (200, 200); p.Controls.Add (b); f.Show (); Assert.AreEqual (new Size (403, 403), p.ClientSize, "A1"); p.Controls.Remove (b); Assert.AreEqual (new Size (200, 100), p.ClientSize, "A2"); p.AutoSizeMode = AutoSizeMode.GrowAndShrink; Assert.AreEqual (new Size (0, 0), p.ClientSize, "A3"); f.Dispose (); }
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}; }
public static void vCargaForma(Form Formulario, Form FormularioPadre, string strText) { Formulario.Text = strText; foreach (Form ctr in FormularioPadre.MdiChildren) { if (ctr.Text == Formulario.Text) { ctr.Focus(); Formulario.Dispose(); return; } } Formulario.WindowState = FormWindowState.Maximized; Formulario.MdiParent = FormularioPadre; Formulario.ControlBox = false; Formulario.BackgroundImage = ConsultasIkorMysql.Properties.Resources.fondo; Formulario.Icon = ConsultasIkorMysql.Properties.Resources.ToolboxWindow; Formulario.BackgroundImageLayout = ImageLayout.Stretch; Formulario.Show(); Formulario.WindowState = FormWindowState.Maximized; }
public void ActualizarTutor(Form vent, int Id, string nombre, string apellido, string dir, string tel) { try { cn = new SqlConnection(CadCon.Servidor()); cn.Open(); cmd = new SqlCommand("ActualizarTutor", cn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", Id); cmd.Parameters.AddWithValue("@nombre", nombre); cmd.Parameters.AddWithValue("@apellido", apellido); cmd.Parameters.AddWithValue("@dir", dir); cmd.Parameters.AddWithValue("@tel", tel); int f = cmd.ExecuteNonQuery(); if (f != 0) { MessageBox.Show("Tutor actualizado exitosamente", "", MessageBoxButtons.OK, MessageBoxIcon.Information); vent.Dispose(); cmd.Dispose(); cn.Close(); }//KMN } catch (SqlException ex) { MessageBox.Show(ex.Message); } }
public void Logout(Form currentForm) { currentForm.Hide(); _appGlobal.Logout(); Program.LoginForm.Show(); currentForm.Dispose(); }
public void TestCaptureWhileSettingSplitPosition () { Form f = new Form (); TextBox TextBox1 = new TextBox(); TextBox1.Dock = DockStyle.Left; Splitter Splitter = new Splitter(); Splitter.Dock = DockStyle.Left; TextBox TextBox2 = new TextBox(); TextBox2.Dock = DockStyle.Fill; f.Controls.AddRange(new Control[] { TextBox2, Splitter, TextBox1 }); Splitter.Capture = true; Splitter.SplitPosition = (f.ClientSize.Width - Splitter.Width) / 2; int position_with_capture = Splitter.SplitPosition; f.Dispose (); f = new Form (); TextBox1 = new TextBox(); TextBox1.Dock = DockStyle.Left; Splitter = new Splitter(); Splitter.Dock = DockStyle.Left; TextBox2 = new TextBox(); TextBox2.Dock = DockStyle.Fill; f.Controls.AddRange(new Control[] { TextBox2, Splitter, TextBox1 }); Splitter.Capture = true; Splitter.SplitPosition = (f.ClientSize.Width - Splitter.Width) / 2; Assert.AreEqual (Splitter.SplitPosition, position_with_capture, "1"); }
private static void GuiThread() { Form form1; form1 = new Form(); form1.Show(); form1.Dispose(); }
private void CmdSalir_Click(object sender, System.EventArgs e) { if (mSource != null) { mSource.Dispose(); } vDB.Compania = ""; Application.Exit(); }
public UserInterface() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form form = new Form(); form.Dispose(); synchronizationContext = SynchronizationContext.Current; }
//异常瓶贴按钮单击事件 private void btnQueryExpition_Click(object sender, EventArgs e) { CJia.PIVAS.App.UI.ExceptionLabel exceptionLabel = new UI.ExceptionLabel(this.ExceptionLabel); frmBase.Dispose(); frmBase = new System.Windows.Forms.Form(); frmBase.Text = "停止或未通过审核的医嘱对应的已打印的瓶贴"; //frmBase.MaximizeBox = false; //frmBase.MinimizeBox = false; frmBase.Size = new System.Drawing.Size(exceptionLabel.Width + 15, exceptionLabel.Height + 30); //frmBase.AutoSize = true; frmBase.StartPosition = FormStartPosition.CenterScreen; frmBase.KeyPreview = true; //UControl.Dock = DockStyle.Fill; frmBase.Controls.Add(exceptionLabel); //UControl.Parent = frmBase; exceptionLabel.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top); //frmBase.TopMost = true; frmBase.Show(); }
public static DialogResult ShowYesNoDialog(string message) { using (var form = new System.Windows.Forms.Form()) { form.TopMost = true; var result = MessageBox.Show(message, DefaultMessageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); form.Dispose(); return(result); } }
public void OpenDrugInfo() { var dr = this.dataGridView1.CurrentRow; if (dr == null) { return; } var druginfo = dr.DataBoundItem as Business.Models.PurchaseOrderImpt; Guid DrugId = druginfo.DrugInfoId; using (BaseFunctionForm bf = new Pharmacy.AppClient.UI.BaseFunctionForm()) { var di = bf.PharmacyDatabaseService.GetDrugInfo(out msg, DrugId); if (di == null) { return; } if (di.BusinessScopeCode.Contains("医疗器械")) { Forms.BaseDataManage.FormInstrument frm = new BaseDataManage.FormInstrument(); frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; frm.entity = di; Common.SetControls.SetControlReadonly(frm, true); frm.ShowDialog(); return; } if (di.BusinessScopeCode.Contains("保健食品")) { Forms.BaseDataManage.FormFood frm = new BaseDataManage.FormFood(); frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; frm.entity = di; Common.SetControls.SetControlReadonly(frm, true); frm.ShowDialog(); return; } UI.UserControls.ucGoodsInfo ucControl = new UserControls.ucGoodsInfo(di); System.Windows.Forms.Form f = new System.Windows.Forms.Form(); f.WindowState = System.Windows.Forms.FormWindowState.Normal; f.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; f.Text = di.ProductGeneralName; f.AutoSize = true; f.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; System.Windows.Forms.Panel p = new System.Windows.Forms.Panel(); p.AutoSize = true; p.Controls.Add(ucControl); f.Controls.Add(p); Forms.Common.SetControls.SetControlReadonly(f, true); f.ShowDialog(); f.Dispose(); } }
public void ArrangeIconsTest () { Form myform = new Form (); myform.ShowInTaskbar = false; ListView mylistview = new ListView (); myform.Controls.Add (mylistview); mylistview.Items.Add ("Item 1"); mylistview.Items.Add ("Item 2"); mylistview.View = View.LargeIcon; mylistview.ArrangeIcons (); myform.Dispose (); }
/// <summary> /// Recieves a form and an integer value representing the operation to perform when the closing /// event is fired. /// </summary> /// <param name="form">The form that fire the event.</param> /// <param name="operation">The operation to do while the form is closing.</param> public static void CloseOperation(System.Windows.Forms.Form form, int operation) { switch (operation) { case 0: break; case 1: form.Hide(); break; case 2: form.Dispose(); break; case 3: form.Dispose(); System.Windows.Forms.Application.Exit(); break; } }
public void CanExtendTest () { Control myControl = new Control (); Form myForm = new Form (); myForm.ShowInTaskbar = false; ToolBar myToolBar = new ToolBar (); ErrorProvider myErrorProvider = new ErrorProvider (); Assert.AreEqual (myErrorProvider.CanExtend (myControl), true, "#ext1"); Assert.AreEqual (myErrorProvider.CanExtend (myToolBar), false, "#ext2"); Assert.AreEqual (myErrorProvider.CanExtend (myForm), false, "#ext3"); myForm.Dispose (); }
public void GetContextMenuTest () { Form myform = new Form (); myform.ShowInTaskbar = false; ContextMenu mycontextmenu = new ContextMenu (); myform.ContextMenu= mycontextmenu; MenuItem menuItem1 = new MenuItem (); menuItem1.Text = "1"; mycontextmenu.MenuItems.Add (menuItem1); Assert.AreEqual (mycontextmenu, menuItem1.GetContextMenu (),"#1"); myform.Dispose (); }
public void ApperanceEventTest () { Form myform = new Form (); myform.ShowInTaskbar = false; myform.Visible = true; CheckBox chkbox = new CheckBox (); chkbox.Visible = true; myform.Controls.Add (chkbox); chkbox.AppearanceChanged += new EventHandler (CheckBox_EventHandler); chkbox.Appearance = Appearance.Button; Assert.AreEqual (true, eventhandled, "#A1"); myform.Dispose (); }
public static bool CheckPermit_WinForm(Form aForm) { try { return CheckPermit(aForm); } catch (Exception eee) { MessageBox.Show(eee.Message.ToString()); aForm.Dispose(); return false; } }
public static void ShowMessage(string _message) { var newForm = new System.Windows.Forms.Form();//ensure messagebox will be on top newForm.TopMost = true; MessageBox.Show(newForm, _message, DefaultMessageCaption, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); newForm.Dispose(); }
public void ContextMainFormTest () { Form f1 = new Form (); f1.ShowInTaskbar = false; ctx = new ApplicationContext (f1); f1.VisibleChanged += new EventHandler (form_visible_changed); Application.Run (ctx); Assert.IsNull (ctx.MainForm, "2"); f1.Dispose (); }
public void GetFormTest () { Form myform = new Form (); myform.ShowInTaskbar = false; myform.Name = "New Form"; MainMenu mymainmenu1 = new MainMenu (); MenuItem menuitem1 = new MenuItem (); menuitem1.Text = "item1"; mymainmenu1.MenuItems.Add (menuitem1); myform.Menu = mymainmenu1; Assert.AreEqual ("New Form", mymainmenu1.GetForm().Name, "#10"); myform.Dispose (); }
public void SimpleShowTest () { Form f = new Form (); f.ShowInTaskbar = false; TreeView tv = new TreeView (); //tv.BorderStyle = BorderStyle.FixedSingle; tv.Location = new Point (20, 20); //tv.Text = "adssssss"; f.Controls.Add (tv); f.Show (); f.Dispose (); }
/// <summary> /// hàm load form MDI /// </summary> private void AddWindows(Form f) { if (!ExistForm(f.Name)) { f.MdiParent = this; f.Show(); } else { f.Dispose(); Active_Form(f.Name); } }
private void groupControl2_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e) { if (e.Button.Properties.Caption == "Tạo Mới") { gridView1.OptionsSelection.MultiSelect = true; gridView1.SelectAll(); gridView1.DeleteSelectedRows(); } if (e.Button.Properties.Caption == "Đóng") { System.Windows.Forms.Form tmp = this.FindForm(); tmp.Close(); tmp.Dispose(); } if (e.Button.Properties.Caption == "Nạp Lại") { gridView1.OptionsSelection.MultiSelect = true; gridView1.SelectAll(); gridView1.DeleteSelectedRows(); } if (e.Button.Properties.Caption == "Lưu & Thêm") { string MaSP=""; string khoNhan = cbKhoNhan.EditValue.ToString(); for (int i = 0; i < gridView1.DataRowCount; i++) { MaSP = gridView1.GetRowCellValue(i, "MaSP").ToString(); } ChuyenKho ck = new ChuyenKho() { Phieu = txtPhieuCK.Text, Ngay = DateTime.Parse(cbNgay.Text), KhoXuat=cbKhoXuat.Text, KhoNhan=cbKhoNhan.Text, NguoiGui=cbNguoiChuyen.Text, NguoiNhan=cbNguoiNhan.Text, GhiChu=txtGhiChu.Text }; bus_ck.ThemDV(ck); bus_ck.Update(MaSP, khoNhan); gridView1.OptionsSelection.MultiSelect = true; gridView1.SelectAll(); gridView1.DeleteSelectedRows(); } }
/// <summary> /// 打開指定的窗體,如果已經實例化,則直接打開,否則先創建 /// </summary> /// <param name="frm"></param> private void ShowWindow(System.Windows.Forms.Form frm) { foreach (Form mdiForm in this.MdiChildren) { if (mdiForm.GetType().Equals(frm.GetType())) { mdiForm.Activate(); frm.Dispose(); return; } } frm.MdiParent = this; frm.WindowState = FormWindowState.Maximized; frm.Show(); }
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { DialogResult rs = MessageBox.Show(this, "Yakin ingin keluar dari aplikasi?", "Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (rs == System.Windows.Forms.DialogResult.Yes) { frm.Dispose(); //e.Cancel = false; //Application.Exit(); } else { e.Cancel = true; } }
// Close the splash window and show the main window private void Close_SplasScreen_And_Show_Main() { try { //SET ALL GLOBAL VARIABLES HERE AppDomain.CurrentDomain.SetData("UserNo", pvtint64UserNo); AppDomain.CurrentDomain.SetData("AccessInd", pvtstrAccessInd); AppDomain.CurrentDomain.SetData("CurrentForm", ""); AppDomain.CurrentDomain.SetData("DataSet", this.pvtDataSet); try { string strPath = ""; string strBasePath = ""; strPath = AppDomain.CurrentDomain.BaseDirectory + "TimeAttendanceMain.dll"; strBasePath = AppDomain.CurrentDomain.BaseDirectory; this.Hide(); AppDomainSetup myDomainInfo = new AppDomainSetup(); myDomainInfo.ApplicationBase = @strBasePath; // Creates the application domain. AppDomain mydomain = AppDomain.CreateDomain("TimeAttendanceMain", null, myDomainInfo); Assembly myAssembly = Assembly.LoadFile(@strPath); System.Windows.Forms.Form frm = (System.Windows.Forms.Form)myAssembly.CreateInstance("InteractPayrollClient.frmTimeAttendanceMain"); frm.ShowDialog(); frm.Dispose(); AppDomain.Unload(mydomain); this.Close(); } catch (System.Exception ex) { InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Late Binding Error " + ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); frmMessageBox.ShowDialog(); } } catch (Exception eException) { clsISClientUtilities.ErrorHandler(eException); this.Close(); } }
public void MdiShow(BaseForm frm, object FuncId, bool ReStart = false) { try { System.Windows.Forms.Form[] mdiChildren = base.MdiChildren; for (int i = 0; i < mdiChildren.Length; i++) { System.Windows.Forms.Form form = mdiChildren[i]; if (!ReStart) { if (form.GetType().Equals(frm.GetType())) { form.Activate(); form.Show(); frm.Dispose(); return; } } else if (form.GetType().Equals(frm.GetType())) { form.Close(); form.Dispose(); } } string objectString = clsPublic.GetObjectString(FuncId); if (!string.IsNullOrEmpty(objectString)) { frm.sFuncId = Guid.Parse(objectString); } frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; frm.MdiParent = this; frm.KeyPreview = true; frm.Mainform = this; frm.InitFeatureButton(); frm.Show(); } catch (System.Exception ex) { clsPublic.ShowException(ex, this.Text); } }
private void Show_Form(System.Windows.Forms.Form f, int sec) { // try { foreach (System.Windows.Forms.Form frm in this.MdiChildren) { if (frm.Name == f.Name) { frm.BringToFront(); f.Dispose(); return; } } f.Tag = sec; f.MdiParent = this; f.WindowState = FormWindowState.Maximized; f.Show(); } // catch(Exception ex) // { // MessageBox.Show ( ex.Message); // } }
/// <summary> /// Change the form to another form in the safe way /// </summary> /// <param name="form1">From form1</param> /// <param name="form2">To form2</param> public static void Form(System.Windows.Forms.Form form1, System.Windows.Forms.Form form2) { form1.Hide(); form2.ShowDialog(); form1.Dispose(); }
static private void btnOK_Click(object sender, System.EventArgs e) { OutputResponse.ReturnCode = DialogResult.OK; OutputResponse.Text = txtInput.Text; frmInputDialog.Dispose(); }
public void MapCtrl_Test() { string xmlString = System.IO.File.ReadAllText(@"Resources\Feature Display.mm"); MapTree tree = new MapTree(); new MindMapSerializer().Deserialize(xmlString, tree); tree.SelectedNodes.Add(tree.RootNode, false); var form = new System.Windows.Forms.Form(); MetaModel.MetaModel.Initialize(); MetaModel.MetaModel.Instance.MapEditorBackColor = Color.White; MetaModel.MetaModel.Instance.NoteEditorBackColor = Color.White; MapCtrl mapCtrl = new MapCtrl(new MapView(tree), new MainCtrlStub(form)); form.Controls.Add(mapCtrl.MapView.Canvas); tree.TurnOnChangeManager(); // folding test mapCtrl.AppendNodeAndEdit(); mapCtrl.MapView.NodeTextEditor.EndNodeEdit(true, true); mapCtrl.UpdateNodeText(tree.RootNode.LastChild, "Test Folding"); mapCtrl.AppendChildNode(tree.RootNode.LastChild); mapCtrl.AppendChildNode(tree.RootNode.LastChild); mapCtrl.AppendChildNode(tree.RootNode.LastChild); mapCtrl.SelectNodeRightOrUnfold(); mapCtrl.ToggleFolded(); // delete test mapCtrl.SelectNodeAbove(); mapCtrl.DeleteSelectedNodes(); // move up mapCtrl.MoveNodeUp(); // move right mapCtrl.SelectNodeBelow(); for (int i = 0; i < 20; i++) { mapCtrl.MoveNodeUp(); } //***** if (CONDUCT_INTERMEDIATE_TESTS) { ImageTest(mapCtrl.MapView, "MapCtrl1"); } // move down mapCtrl.SelectNodeRightOrUnfold(); for (int i = 0; i < 5; i++) { mapCtrl.SelectNodeAbove(); } for (int i = 0; i < 5; i++) { mapCtrl.MoveNodeDown(); } // move up mapCtrl.SelectNodeAbove(); for (int i = 0; i < 5; i++) { mapCtrl.MoveNodeUp(); } // move left mapCtrl.SelectNodeLeftOrUnfold(); for (int i = 0; i < 20; i++) { mapCtrl.MoveNodeDown(); } // select siblings above mapCtrl.SelectNodeLeftOrUnfold(); for (int i = 0; i < 3; i++) { mapCtrl.SelectNodeBelow(); } mapCtrl.SelectAllSiblingsAbove(); mapCtrl.ToggleBold(); // select siblings below mapCtrl.SelectNodeRightOrUnfold(); mapCtrl.SelectNodeLeftOrUnfold(); for (int i = 0; i < 3; i++) { mapCtrl.SelectNodeAbove(); } mapCtrl.SelectNodeBelow(); mapCtrl.SelectAllSiblingsBelow(); mapCtrl.ToggleItalic(); //***** if (CONDUCT_INTERMEDIATE_TESTS) { ImageTest(mapCtrl.MapView, "MapCtrl2"); } // add icon mapCtrl.AppendIcon("clock"); mapCtrl.AppendIcon("idea"); // remove last icon mapCtrl.RemoveLastIcon(); // remove all icon mapCtrl.SelectNodeRightOrUnfold(); mapCtrl.SelectNodeLeftOrUnfold(); for (int i = 0; i < 3; i++) { mapCtrl.SelectNodeBelow(); } mapCtrl.RemoveAllIcon(); //***** if (CONDUCT_INTERMEDIATE_TESTS) { ImageTest(mapCtrl.MapView, "MapCtrl3"); } mapCtrl.AppendNodeAndEdit(); mapCtrl.MapView.NodeTextEditor.EndNodeEdit(true, true); mapCtrl.UpdateNodeText(tree.SelectedNodes.First, "Format Test"); mapCtrl.ChangeLineColorUsingPicker(); mapCtrl.ChangeLinePattern(System.Drawing.Drawing2D.DashStyle.Dash); mapCtrl.ChangeLineWidth(2); mapCtrl.ChangeFont(); //***** if (CONDUCT_INTERMEDIATE_TESTS) { ImageTest(mapCtrl.MapView, "MapCtrl4"); } mapCtrl.SelectNodeRightOrUnfold(); mapCtrl.AppendSiblingNodeAndEdit(); mapCtrl.MapView.NodeTextEditor.EndNodeEdit(true, true); mapCtrl.UpdateNodeText(tree.SelectedNodes.First, "Node Color"); // change node color mapCtrl.AppendChildNode(tree.SelectedNodes.First); mapCtrl.UpdateNodeText(tree.SelectedNodes.First, "Node Color"); mapCtrl.ChangeTextColorByPicker(); // unfolding mapCtrl.SelectNodeRightOrUnfold(); mapCtrl.ToggleFolded(); mapCtrl.SelectNodeLeftOrUnfold(); // change background color mapCtrl.AppendChildNodeAndEdit(); mapCtrl.MapView.NodeTextEditor.EndNodeEdit(true, true); mapCtrl.UpdateNodeText(tree.SelectedNodes.First, "Background Color"); mapCtrl.ChangeBackColorByPicker(); mapCtrl.SelectNodeRightOrUnfold(); //***** if (CONDUCT_INTERMEDIATE_TESTS) { ImageTest(mapCtrl.MapView, "MapCtrl5"); } //select top/bottom sibling mapCtrl.SelectTopSibling(); mapCtrl.AppendSiblingAboveAndEdit(); mapCtrl.MapView.NodeTextEditor.EndNodeEdit(true, true); mapCtrl.UpdateNodeText(tree.SelectedNodes.First, "SelectTopSibling"); mapCtrl.ChangeNodeShapeBubble(); mapCtrl.SelectBottomSibling(); //insert parent mapCtrl.InsertParentAndEdit(); mapCtrl.EndNodeEdit(); mapCtrl.UpdateNodeText(tree.SelectedNodes.First, "Parent Inserted"); mapCtrl.ChangeNodeShapeBullet(); //move nodes var n = mapCtrl.MapView.SelectedNodes.First; tree.RootNode.GetLastChild(NodePosition.Right).Selected = true; mapCtrl.SelectNodeAbove(true); mapCtrl.MapView.SelectedNodes.Last.ForEach(a => tree.SelectedNodes.Add(a, true)); mapCtrl.MoveNodes(new DropLocation() { Parent = n, InsertAfterSibling = false }); mapCtrl.SelectNodeBelow(true); //change node shape mapCtrl.ChangeNodeShapeBox(); mapCtrl.MapView.SelectedNodes.Add(tree.SelectedNodes.First(a => a.Text == "Deep Hierarchy")); mapCtrl.ToggleFolded(); mapCtrl.SelectNodeLeftOrUnfold(); mapCtrl.SelectNodeLeftOrUnfold(); mapCtrl.SelectNodeBelow(true); mapCtrl.SelectNodeAbove(true); mapCtrl.ChangeNodeShapeFork(); ImageTest(mapCtrl.MapView, "MapCtrl6"); VerifyUndoRedo(mapCtrl, "Feature Display"); VerifySerializeDeserialize(mapCtrl); form.Dispose(); //form.Close(); }
public void AutosaveThrash() { // just spawna timer and see if I can make it fail _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); panelAutosave = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); form.Controls.Add(panelAutosave); // needed else DataGrid does not initialize form.Show(); //form.Visible = false; _w.output("boom"); // March 2013 -- notelist relies on having this YOM2013.DefaultLayouts.CreateASystemLayout(form, null); //NOTE: For now remember that htis ADDS 1 Extra notes string panelname = System.Guid.NewGuid().ToString(); panelAutosave.NewLayout(panelname, true, null); LayoutDetails.Instance.AddToList(typeof(FAKE_NoteDataXML_Panel), "testingpanel"); _w.output("herefirst"); Timer SaveTimer = new Timer(); SaveTimer.Interval = 300; SaveTimer.Tick += HandleSaveTimerTick; SaveTimer.Start(); // ADD 1 of each type foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 2; i++) { NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance(t); panelAutosave.AddNote(note); note.CreateParent(panelAutosave); note.UpdateAfterLoad(); } } panelAutosave.SaveLayout(); // // Second panel // string panelname2 = System.Guid.NewGuid().ToString(); FAKE_LayoutPanel PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.NewLayout(panelname2, true, null); PanelOtherGuy.SaveLayout(); Assert.AreEqual(2, PanelOtherGuy.CountNotes(), "count1"); // ADD 1 of each type //foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) { for (int i = 0; i < 10; i++) { NoteDataInterface note = new NoteDataXML_RichText(); PanelOtherGuy.AddNote(note); note.CreateParent(PanelOtherGuy); note.UpdateAfterLoad(); } } Assert.AreEqual(12, PanelOtherGuy.CountNotes(), "count2"); PanelOtherGuy.SaveLayout(); PanelOtherGuy = null; PanelOtherGuy = new FAKE_LayoutPanel(CoreUtilities.Constants.BLANK, false); PanelOtherGuy.LoadLayout(panelname2, false, null); Assert.AreEqual(12, PanelOtherGuy.CountNotes(), "count2"); // add another Layout and do something with it while autosave continues running SaveTimer.Stop(); form.Dispose(); }
protected override void Update(GameTime gameTime) { #region Keyboard Handling if (Properties.Settings.Default.LoginCheck) { // get keyboard press status KeyboardState keyboardstate = Keyboard.GetState(); // @ acive chatform try { if (keyboardstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) && Form_Chat != null) { Form_Chat.Activate(); } } catch { } // handling users moving if (keyboardstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down)) { ActorMoving(0); } else if (keyboardstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left)) { ActorMoving(1); } else if (keyboardstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right)) { ActorMoving(2); } else if (keyboardstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up)) { ActorMoving(3); } else if (keyboardVal) { keyboardVal = false; Send_Packet( Properties.Settings.Default.UserId + "," + Properties.Settings.Default.MapId + "," + "&%*^%8VdvteMWCqAqzDs7tXdtJA==&%*^%"); } // save the last keyboard status previousKayboardState = keyboardstate; } #endregion #region Handling Login // pressed login button if (Properties.Settings.Default.Login_click) { Send_Packet(Form_Login.textBox_id.Text + "," + Form_Login.textBox_pass.Text + ",&%*^%QX9y5TpZR6DOt7pLqpIbQw==&%*^%"); Properties.Settings.Default.Login_click = false; } #endregion #region [Networks] // drawing other players for (int i = 0; i < Users.Count; i++) { UserMoving(i); } #endregion #region [Conditional Systems] : Chat, Form Control, Exit // send a new chat if (!Program.Chatstring.Equals("")) { Send_Packet(Program.Chatstring + "&%*^%Q1SXiLEURCvizN+cfayrWsbtLahNidB/LQpJEauR26Q=&%*^%"); // # show up a ballon # // remove previous ballon if (Form_Ballon != null) { Form_Ballon.Dispose(); } // a new ballon Form_Ballon = new Forms.ChatBallon(Program.Chatstring); Form_Ballon.Show(); // initialize chat data Program.Chatstring = ""; } // minimize form size if (Properties.Settings.Default.FormMinimize) { Mainform.WindowState = FormWindowState.Minimized; Properties.Settings.Default.FormMinimize = false; } // exit game if (Properties.Settings.Default.gameclose) { Mainform.Dispose(); } #endregion #region [Auto Systems] // autosave mainform's position Properties.Settings.Default.Point_Mainform = new System.Drawing.Point(Mainform.Location.X, Mainform.Location.Y); // autosave cam's position Properties.Settings.Default.cam_po = new System.Drawing.Point((int)cam._pos.X, (int)cam._pos.Y); #endregion #region [Game Object] : Ballon, NameTag // ballon positioning if (Form_Ballon != null) { Form_Ballon.Location = new System.Drawing.Point((int)(Mainform.Location.X + Properties.Settings.Default.Actor_x - cam._pos.X + Mainform.Width / 2) - 50 - Form_Ballon.Width / 2, (int)(Mainform.Location.Y + Properties.Settings.Default.Actor_y - cam._pos.Y + Mainform.Height / 2) - 115); // 아래 : 35 } // nametag positionong if (nametag != null) { nametag.Location = new System.Drawing.Point((int)(Mainform.Location.X + Properties.Settings.Default.Actor_x - cam._pos.X + Mainform.Width / 2) - 100, (int)(Mainform.Location.Y + Properties.Settings.Default.Actor_y - cam._pos.Y + Mainform.Height / 2) - 95); // 아래 : 35 } #endregion base.Update(gameTime); }
private void btnDong_Click(object sender, EventArgs e) { System.Windows.Forms.Form tmp = this.FindForm(); tmp.Close(); tmp.Dispose(); }
public void GobackHome(System.Windows.Forms.Form form) { Program.Container.GetInstance <FormHome>().Show(); form.Dispose(); }
private void _initializeWgl() { // wglGetProcAddress does not work without an active OpenGL context, // but we need wglChoosePixelFormatARB's address before we can // create our main window. Thank you very much, Microsoft! // // The solution is to create a dummy OpenGL window first, and then // test for WGL_ARB_pixel_format support. If it is not supported, // we make sure to never call the ARB pixel format functions. // // If is is supported, we call the pixel format functions at least once // to initialize them (pointers are stored by glprocs.h). We can also // take this opportunity to enumerate the valid FSAA modes. SWF.Form frm = new SWF.Form(); IntPtr hwnd = frm.Handle; // if a simple CreateWindow fails, then boy are we in trouble... if (hwnd == IntPtr.Zero) { throw new Exception("Window creation failed"); } // no chance of failure and no need to release thanks to CS_OWNDC IntPtr hdc = User.GetDC(hwnd); // assign a simple OpenGL pixel format that everyone supports Gdi.PIXELFORMATDESCRIPTOR pfd = new Gdi.PIXELFORMATDESCRIPTOR(); ; pfd.nSize = (short)Marshal.SizeOf(pfd); pfd.nVersion = 1; pfd.cColorBits = 16; pfd.cDepthBits = 15; pfd.dwFlags = Gdi.PFD_DRAW_TO_WINDOW | Gdi.PFD_SUPPORT_OPENGL | Gdi.PFD_DOUBLEBUFFER; pfd.iPixelType = Gdi.PFD_TYPE_RGBA; // if these fail, wglCreateContext will also quietly fail int format; format = Gdi.ChoosePixelFormat(hdc, ref pfd); if (format != 0) { Gdi.SetPixelFormat(hdc, format, ref pfd); } IntPtr hrc = Wgl.wglCreateContext(hdc); if (hrc != IntPtr.Zero) { // if wglMakeCurrent fails, wglGetProcAddress will return null Wgl.wglMakeCurrent(hdc, hrc); Wgl.ReloadFunctions(); // Tao 2.0 // check for pixel format and multisampling support //IntPtr wglGetExtensionsStringARB = Wgl.wglGetProcAddress( "wglGetExtensionsStringARB" ); //if ( wglGetExtensionsStringARB != IntPtr.Zero ) //{ // string exts = Wgl.wglGetExtensionsStringARB( wglGetExtensionsStringARB, hdc ); // _hasPixelFormatARB = exts.Contains( "WGL_ARB_pixel_format" ); // _hasMultisample = exts.Contains( "WGL_ARB_multisample" ); //} _hasPixelFormatARB = Wgl.IsExtensionSupported("WGL_ARB_pixel_format"); _hasMultisample = Wgl.IsExtensionSupported("WGL_ARB_multisample"); if (_hasPixelFormatARB && _hasMultisample) { // enumerate all formats w/ multisampling int[] iattr = { Wgl.WGL_DRAW_TO_WINDOW_ARB, 1, Wgl.WGL_SUPPORT_OPENGL_ARB, 1, Wgl.WGL_DOUBLE_BUFFER_ARB, 1, Wgl.WGL_SAMPLE_BUFFERS_ARB, 1, Wgl.WGL_ACCELERATION_ARB, Wgl.WGL_FULL_ACCELERATION_ARB, // We are no matter about the colour, depth and stencil buffers here //WGL_COLOR_BITS_ARB, 24, //WGL_ALPHA_BITS_ARB, 8, //WGL_DEPTH_BITS_ARB, 24, //WGL_STENCIL_BITS_ARB, 8, // Wgl.WGL_SAMPLES_ARB, 2, 0 }; int[] formats = new int[256]; int[] count = new int[256]; // Tao 2.0 //int count; // cheating here. wglChoosePixelFormatARB proc address needed later on // when a valid GL context does not exist and glew is not initialized yet. _wglChoosePixelFormatARB = Wgl.wglGetProcAddress("wglChoosePixelFormatARB"); if (Wgl.wglChoosePixelFormatARB(hdc, iattr, null, 256, formats, count)) // Tao 2.0 //if ( Wgl.wglChoosePixelFormatARB( _wglChoosePixelFormatARB, hdc, iattr, null, 256, formats, out count ) != 0 ) { // determine what multisampling levels are offered int query = Wgl.WGL_SAMPLES_ARB, samples; for (int i = 0; i < count[0]; ++i) // Tao 2.0 //for ( int i = 0; i < count[ 0 ]; ++i ) { IntPtr wglGetPixelFormatAttribivARB = Wgl.wglGetProcAddress("wglGetPixelFormatAttribivARB"); if (Wgl.wglGetPixelFormatAttribivARB(hdc, formats[i], 0, 1, ref query, out samples)) // Tao 2.0 //if ( Wgl.wglGetPixelFormatAttribivARB( wglGetPixelFormatAttribivARB, hdc, formats[ i ], 0, 1, ref query, out samples ) != 0 ) { if (!_fsaaLevels.Contains(samples)) { _fsaaLevels.Add(samples); } } } } } Wgl.wglMakeCurrent(IntPtr.Zero, IntPtr.Zero); Wgl.wglDeleteContext(hrc); } // clean up our dummy window and class frm.Dispose(); frm = null; }