当前位置: 首页>>代码示例>>C#>>正文


C# Control.Dispose方法代码示例

本文整理汇总了C#中System.Windows.Forms.Control.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Control.Dispose方法的具体用法?C# Control.Dispose怎么用?C# Control.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Control的用法示例。


在下文中一共展示了Control.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DestroyControlPane

    public override void DestroyControlPane(Control pane)
    {
      //TODO: uncommet
      //ns.mainPan.onClosing(null);
      pane.Dispose();

    }
开发者ID:chantsunman,项目名称:BCFier,代码行数:7,代码来源:AppMain.cs

示例2: UnregisterControl

 private void UnregisterControl(DiagramDocument circuitNode, Control control)
 {
     //it's OK if the CircuitEditingContext was already removed or wasn't added to IContextRegistry.
     _contextRegistry.RemoveContext(circuitNode.As<DiagramEditingContext>());
     _hostService.UnregisterControl(control);
     control.Visible = false;
     control.Dispose();
     _controls.Remove(circuitNode);
 }
开发者ID:coreafive,项目名称:XLE,代码行数:9,代码来源:DiagramControlRegistry.cs

示例3: CalculatePreferedSizes

 //TODO: Seems to fail on the build machine - commented out temporarily
 //[Test, TestCaseSource("PathNameTestData")]
 public void CalculatePreferedSizes(TestData tc)
 {
     FolderListItem item = new FolderListItem(tc.Path, FolderListItem.AllowSearch.None, false){MaxWidth = 50};
     Control parent = new Control {Font = new Font(FontFamily.GenericMonospace, 10)};
     item.Parent = parent;
     Assert.That(item.PreferredSize.Width, Is.EqualTo(tc.ExpectedWidth), "Width");
     Assert.That(item.Path, Is.EqualTo(tc.Path), "Path");
     parent.Dispose();
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:11,代码来源:FolderListItemTests.cs

示例4: DisposedTest

		public void DisposedTest ()
		{
			Control c = new Control ();
			// Test Disposed Event
			c.Disposed += new EventHandler (Event_Handler1);
			eventhandled = false;
			c.Dispose ();
			Assert.AreEqual (true, eventhandled, "#A7");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:ControlEventTest.cs

示例5: FreeControl

 public void FreeControl(Control control)
 {
     try
     {
         control.Dispose();
         while (control.Controls.Count > 0) control.Controls[0].Dispose();
         control = null;
     }
     catch (Exception ex) { CaughtException(ex); }
 }
开发者ID:Byt3-Hub,项目名称:PAWNEdit,代码行数:10,代码来源:Form1.cs

示例6: FromHandleTest

		public void FromHandleTest ()
		{
			Control c1 = null;
			Control c2 = null;

			try {
				c1 = new Control ();
				c2 = new Control ();

				c1.Name = "parent";
				c2.Name = "child";
				c1.Controls.Add(c2);

				// Handle
				Assert.AreEqual (c1.Name, Control.FromHandle (c1.Handle).Name, "Handle1");
				Assert.IsNull (Control.FromHandle (IntPtr.Zero), "Handle2");

				// ChildHandle
				Assert.AreEqual (c1.Name, Control.FromChildHandle (c1.Handle).Name, "Handle3");
				Assert.IsNull (Control.FromChildHandle (IntPtr.Zero), "Handle4");


			} finally {
				if (c1 != null)
					c1.Dispose ();

				if (c2 != null)
					c2.Dispose ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:30,代码来源:ControlTest.cs

示例7: FindFormTest

		public void FindFormTest () {
			Form f = new Form ();

			f.ShowInTaskbar = false;
			f.Name = "form";
			Control c = null;

			try {
				f.Controls.Add (c = new Control ());
				Assert.AreEqual (f.Name, c.FindForm ().Name, "Find1");

				f.Controls.Remove (c);

				GroupBox g = new GroupBox ();
				g.Name = "box";
				f.Controls.Add (g);
				g.Controls.Add (c);

				Assert.AreEqual (f.Name, f.FindForm ().Name, "Find2");

				g.Controls.Remove (c);
				Assert.IsNull(c.FindForm (), "Find3");

			} finally {
				if (c != null)
					c.Dispose ();
				if (f != null)
					f.Dispose ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:30,代码来源:ControlTest.cs

示例8: ShowTopLevel

        private void ShowTopLevel(Control control, object[] propertyObjects, bool modal, Action<Form> shownAction)
        {
            //if (TestContext.CurrentContext.Test.Properties["_CATEGORIES"])

            ThrowIfPropertyObjectsContainsActionDueToLikelyMisuse(propertyObjects);

            GuiTestHelper.Initialize();

            formShown = shownAction;

            if (control.TopLevelControl == control)
            {
                ShowTopLevelControl(control, modal);
            }
            else
            {
                ShowControlInTestForm(control, modal, propertyObjects);
            }

            // clear all controls shown as non-modal after modal control closes 
            if (!modal)
            {
                var testName = TestContext.CurrentContext.Test.FullName;

                if (string.IsNullOrEmpty(nonModalControlsTestName))
                {
                    nonModalControlsTestName = testName;
                }
                else
                {
                    if (nonModalControlsTestName != testName)
                    {
                        var errorMessage = string.Format("Did you forget to call WindowsFormsTestHelper.CloseAll() at the end of the following test: {0}?", nonModalControlsTestName);
                        nonModalControlsTestName = testName; // reset for the next test
                        throw new InvalidOperationException(errorMessage);
                    }
                }

                nonModalControls.Add(this);
            }
            else
            {
                CloseAll();

                Close();
                Dispose();

                control.Dispose();
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:50,代码来源:WindowsFormsTestHelper.cs

示例9: SessionThreadStart

        void SessionThreadStart()
        {
            Monitor.Enter(sessionThread);
            {
                try
                {
                    sessionThreadControl = new Control();
                    sessionThreadControl.CreateControl();

                    session = TtlLiveSingleton.Get();

                    dataTimer = new Timer();
                    dataTimer.Interval = 100;
                    dataTimer.Tick += new EventHandler(dataTimer_Tick);

                    notificationTimer = new Timer();
                    notificationTimer.Interval = 100;
                    notificationTimer.Tick += new EventHandler(notificationTimer_Tick);
                    notificationTimer.Start();
                }
                catch (Exception ex)
                {
                    sessionThreadInitException = ex;
                    TtlLiveSingleton.Dispose();
                }
                Monitor.Pulse(sessionThread);
            }
            Monitor.Exit(sessionThread);

            //Create a message pump for this thread
            Application.Run(applicationContext);

            //Dispose of all stuff on this thread
            dataTimer.Stop();
            dataTimer.Dispose();

            notificationTimer.Stop();
            notificationTimer.Dispose();

            TtlLiveSingleton.Dispose();
            sessionThreadControl.Dispose();

            return;
        }
开发者ID:Faham,项目名称:emophiz,代码行数:44,代码来源:LiveSessionTtl.cs

示例10: PerformInductionMethod

        public void PerformInductionMethod(Control control)
        {
            try
            {
                //if (control == null) return;
                if (!UserHasAccess(control.Name))
                {
                    control.Dispose();
                    return;

                }

                var arrControlHasType = (from dr in dtFormControl.AsEnumerable()
                          where dr.Field<string>(LFormControl.Columns.FormName).Equals(FormName) &
                                dr.Field<string>(LFormControl.Columns.ControlName).Equals(control.Name) &
                                !string.IsNullOrEmpty(Utility.sDbnull(dr.Field<object>(LFormControl.Columns.ControlTypeName)))
                          select dr).ToList();

                string[] arrItem_Name = new string[] { };
                if (control.Name == "tabTestInfo")
                {
                    Console.WriteLine(control.Name);
                }
                if (arrControlHasType.Count <= 0)
                {
                    //arrItem_Name = (from ctrl in control.Controls.Cast<Control>() select ctrl.Name).ToArray();
                    var arrControl = (from ctrl in control.Controls.Cast<Control>() select ctrl).ToList();
                    //List<Control> listControlName = new List<string>();
                    //foreach (Control ctrl in control.Controls)
                    //{
                    //    listControlName.Add(ctrl.Name);
                    //}
                    foreach (Control ctrl in arrControl)
                    {

                        PerformInductionMethod(ctrl);
                    }
                    return;
                }

                switch (Utility.sDbnull(arrControlHasType[0][LFormControl.Columns.ControlTypeName]).ToUpper())
                {
                    case "WIN.TOOLSTRIP":
                        ToolStrip toolStrip = (ToolStrip)control;
                        arrItem_Name = (from item in toolStrip.Items.Cast<ToolStripItem>()
                                            where !UserHasAccess(item.Name)
                                            select item.Name).ToArray();
                        foreach (string item_Name in arrItem_Name)
                        {
                            toolStrip.Items[item_Name].Dispose();
                        }
                        break;
                    case "WIN.CONTEXTMENUSTRIP":
                        if (!arrAllowed_Control_Name.Contains(control.Name))
                            arrItem_Name = (from item in control.ContextMenuStrip.Items.Cast<ToolStripItem>()
                                            where item !=null
                                            select item.Name).ToArray();

                        //else arrItem_Name = (from item in control.ContextMenuStrip.Items.Cast<ToolStripItem>()

                        //                     where arrControl_Name.Contains(item.Name) & !arrAllowed_Control_Name.Contains(item.Name)
                        //                     select item.Name).ToArray();
                        foreach (string item_Name in arrItem_Name)
                        {
                            control.ContextMenuStrip.Items[item_Name].Enabled = false;
                        }
                        break;
                }

            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
开发者ID:khaha2210,项目名称:CodeNewTeam,代码行数:75,代码来源:ControlUtilities.cs

示例11: DisposeControl

 static void DisposeControl(ref Control control)
 {
     if (control != null)
     {
         control.Dispose();
         control = null;
     }
 }
开发者ID:renyh1013,项目名称:dp2,代码行数:8,代码来源:EasyMarcControl.cs

示例12: WM_PARENTNOTIFY_Test

		public void WM_PARENTNOTIFY_Test ()
		{
			WMTester tester;
			Control child;
			int child_handle;
			
			tester = new WMTester ();
			child = new Control ();
			tester.Controls.Add (child);
			
			tester.Visible = true;
			child.Visible = true;

			child_handle = child.Handle.ToInt32 ();

			ArrayList msgs;
			Message m1;
				
			msgs = tester.Find (WndMsg.WM_PARENTNOTIFY);
			
			Assert.AreEqual (1, msgs.Count, "#1");
			
			m1 = (Message) msgs [0];
			Assert.AreEqual (WndMsg.WM_CREATE, ((WndMsg) LowOrder (m1.WParam)),  "#2");
			//Assert.AreEqual (child.Identifier??, HighOrder (m1.WParam),  "#3");
			Assert.AreEqual (child_handle, m1.LParam.ToInt32 (),  "#4");

			child.Dispose ();

			msgs = tester.Find (WndMsg.WM_PARENTNOTIFY);
			Assert.AreEqual (2, msgs.Count, "#5");
			m1 = (Message) msgs [1];

			Assert.AreEqual (WndMsg.WM_DESTROY, ((WndMsg) LowOrder (m1.WParam)),  "#6");
			//Assert.AreEqual (child.Identifier??, HighOrder (m1.WParam),  "#7");
			Assert.AreEqual (child_handle, m1.LParam.ToInt32 (),  "#8");

			tester.Dispose ();
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:39,代码来源:ControlTest.cs

示例13: WriteTo

        private void WriteTo(IndentedTextWriter writer, Layout selectedLayout)
        {
            if (selectedLayout == null || !selectedLayout.hasLayout())
                return;

            var xscale = specs.desiredWidth/selectedLayout.Dimensions.Width;
            var yscale = specs.desiredHeight/selectedLayout.Dimensions.Height;
            var scale = Math.Min(xscale, yscale);
            var papersize = Enum.GetName(typeof (papersize), specs.size);
            var orientation = specs.desiredWidth > specs.desiredHeight ? "landscape" : "portrait";
            writer.WriteLine("% This TeX file was generated by SBML2TikZ Version: {0}",
                             Assembly.GetExecutingAssembly().GetName().Version);
            writer.WriteLine("\\documentclass{article}");
            writer.WriteLine("\\usepackage{tikz}");
            writer.WriteLine("\\usepackage{pgf}");
            writer.WriteLine("\\usepackage[total={{{0}pt,{1}pt}}, centering, {2}, {3}]{{geometry}}", specs.desiredWidth,
                             specs.desiredHeight, papersize, orientation);
            writer.WriteLine("\\pagestyle{empty}");
            writer.WriteLine("\\begin{document}");
            writer.WriteLine("\\begin{center}");
            writer.WriteLine("\\begin{{tikzpicture}}[xscale = {0}, yscale = -{1}]", xscale, yscale);
            writer.WriteLine("{");

            // _layout._EmlRenderInformation is a list of LocalRenderInformation
            // Each LocalRenderInformation has lists of GradientDefinitions, ColorDefinitions & LineEndings
            // It also contains a list of Styles
            // Each Style can be applied to items that share a role with its rolelist or a type with its typelist
            // Presently we do not need to worry about GlobalRenderInformation as it is dealt with by the
            // RenderInformation.GetStyleForObject, although this may be revised

            // if there are more than one renderinformation objects, we need to ask the user to pick one

            // in order to use some of the classes in the EmlRenderExtension we need a Graphics object
            var dummyControl = new Control();
            try
            {
                var g = dummyControl.CreateGraphics();

                DefineColorsAndGradients(selectedLayout._EmlRenderInformation[0].ColorDefinitions,
                                         selectedLayout._EmlRenderInformation[0].GradientDefinitions,
                                         selectedLayout._EmlRenderInformation[0], writer);

                foreach (var glyph in selectedLayout.CompartmentGlyphs)
                {
                    glyphToTex(glyph, selectedLayout, writer, g, scale);
                }

                foreach (var glyph in selectedLayout.ReactionGlyphs)
                {
                    glyphToTex(glyph, selectedLayout, writer, g, scale);
                }

                foreach (var glyph in selectedLayout.SpeciesGlyphs)
                {
                    glyphToTex(glyph, selectedLayout, writer, g, scale);
                }

                foreach (var glyph in selectedLayout.TextGlyphs)
                {
                    glyphToTex(glyph, selectedLayout, writer, g, scale);
                }

                foreach (var glyph in selectedLayout.AdditionalGraphicalObjects)
                {
                    glyphToTex(glyph, selectedLayout, writer, g, scale);
                }

                writer.WriteLine("}");
                writer.WriteLine("\\end{tikzpicture}");
                writer.WriteLine("\\end{center}");
                writer.WriteLine("\\end{document}");
            }
            finally
            {
                //TODO: you are creating a control, to obtain a graphics handle, but then dispose the control,
                //      so this handle is invalid!
                dummyControl.Dispose();
            }
        }
开发者ID:yarden,项目名称:sbml2tikz,代码行数:79,代码来源:Converter.cs

示例14: DisposeControl

 private void DisposeControl(Control Control)
 {
     if (Control.InvokeRequired)
     {
         var d = new DisposeControlDelegate(DisposeControl);
         this.Invoke(d, Control);
     }
     else
     {
         Control.Dispose();
     }
 }
开发者ID:ApexWeed,项目名称:backdrops,代码行数:12,代码来源:MainForm.cs

示例15: Remove

 protected void Remove(Control palent, Control self)
 {
     if (self != null){
         _controlCounter--;
         if (palent != null){
             // ownerがnullの場合は、非表示(デバッグモード)
             palent.Controls.Remove(self);
             self.Dispose();
         }
     }
     //RemoveListener(); // リスナーも削除する
 }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:12,代码来源:OneCtrl.cs


注:本文中的System.Windows.Forms.Control.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。