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


C# Form.Dispose方法代码示例

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


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

示例1: Draw

    public static Rectangle 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;
            Point pos = parent.PointToClient(Control.MousePosition);
            int x = Math.Min(mPos.X, pos.X);
            int y = Math.Min(mPos.Y, pos.Y);
            int w = Math.Abs(mPos.X - pos.X);
            int h = Math.Abs(mPos.Y - pos.Y);

            return new Rectangle(x, y, w, h);
    }
开发者ID:Khanchai,项目名称:Paint,代码行数:32,代码来源:EllipseTools.cs

示例2: Main

	static int Main ()
	{
		for (int i = 0; i < 50; i++) {
			Form form = new Form ();
			form.KeyDown += new KeyEventHandler (Form_KeyDown);
			form.Show ();
			SendKeys.SendWait ("a");

			if (_keyDown == null)
				return 1;
			if (_keyDown != "A")
				return 2;

			form.Dispose ();
		}
		return 0;
	}
开发者ID:mono,项目名称:gert,代码行数:17,代码来源:test.cs

示例3: Show

        public static DialogResult Show(string text)
        {
            Form form = new Form {Title = "Message", HasBorder = true, Width = 40, Height = 10};

            Label label = new Label {Text = text, Right = 0, Top = 0, Width = 38, Height = 6, Enabled = false};
            Button buttonOK = new Button("OK") {Right = 18, Top = 7};

            DialogResult result = DialogResult.None;

            buttonOK.ButtonClick += (sender, args) =>
            {
                result = DialogResult.OK;
                form.Dispose();
            };

            form.AddElement(label);
            form.AddElement(buttonOK);

            form.Init();
            form.Execute();

            return result;
        }
开发者ID:CAHbl4,项目名称:csharp,代码行数:23,代码来源:MessageBox.cs

示例4: Context_Form_Dispose

	static void Context_Form_Dispose ()
	{
		Console.WriteLine ("Context_Form_Dispose");
		Console.WriteLine ("*******************************");

		Application.ApplicationExit += application_applicationexit;
		Application.ThreadExit += application_threadexit;

		Form f = new Form ();
		f.HandleDestroyed += form_handle_destroyed;
		f.Closed += form_closed;

		ApplicationContext ctx = new ApplicationContext (f);
		ctx.ThreadExit += applicationcontext_threadexit;

		Timer t = new Timer ();

		t.Interval = 500;
		t.Tick += delegate (object sender, EventArgs e) { f.Dispose (); };

		t.Enabled = true;

		Application.Run (ctx);

		Application.ApplicationExit -= application_applicationexit;
		Application.ThreadExit -= application_threadexit;
	}
开发者ID:hitswa,项目名称:winforms,代码行数:27,代码来源:testexit.cs

示例5: Indexer

		public void Indexer ()
		{
			TabControl tab = new TabControl ();
			TabControl.TabPageCollection tabPages = new TabControl.TabPageCollection (tab);
			TabPage tabPageA = new TabPage ();
			TabPage tabPageB = new TabPage ();
			TabPage tabPageC = new TabPage ();
			TabPage tabPageD = new TabPage ();
			tabPages.Add (tabPageA);
			Assert.AreSame (tabPageA, tabPages [0], "#1");
			tabPages [0] = tabPageB;
			Assert.AreSame (tabPageB, tabPages [0], "#2");
			tabPages.Add (tabPageC);
			Assert.AreSame (tabPageB, tabPages [0], "#3");
			Assert.AreSame (tabPageC, tabPages [1], "#4");
			tabPages.Remove (tabPageB);
			Assert.AreSame (tabPageC, tabPages [0], "#5");
			tabPages [0] = tabPageD;
			Assert.AreSame (tabPageD, tabPages [0], "#6");

			Form form = new Form ();
			form.ShowInTaskbar = false;
			form.Controls.Add (tab);
			form.Show ();
			form.Dispose ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:26,代码来源:TabControlTest.cs

示例6: Remove

 /// <summary>
 /// Remove a form from the collection
 /// </summary>
 /// <param name="form">Form</param>
 public void Remove(Form form)
 {
     form.Dispose();
     _forms.Remove(form);
 }
开发者ID:Layoric,项目名称:xWinFormsLib,代码行数:9,代码来源:FormCollection.cs

示例7: EditShowInfo


//.........这里部分代码省略.........
                                                // Show a form with a combo box with the series available
                                                ComboBox comboBox = new ComboBox();
                                                comboBox.Location = new System.Drawing.Point(10, 40);
                                                comboBox.Size = new System.Drawing.Size(180, 150);
                                                for (int i = 1; i < titles.Length; i++)
                                                {
                                                    string comboLabel = titles[i].ToString() + " (" + years[i].ToString() + ")";
                                                    comboBox.Items.Add(comboLabel);
                                                }
                                                comboBox.SelectedIndex = 0;
                                                multipleListingsForm = new Form();
                                                multipleListingsForm.Text = "Select Movie Name";
                                                multipleListingsForm.Size = new System.Drawing.Size(200, 140);
                                                multipleListingsForm.Controls.Add(comboBox);
                                                Button selectButton = new Button();
                                                Button skipButton = new Button();
                                                selectButton.Text = "Select";
                                                selectButton.Click += new System.EventHandler(this.selectButton_Click);
                                                selectButton.Location = new System.Drawing.Point(10, 70);
                                                selectButton.Size = new System.Drawing.Size(80, 30);
                                                skipButton.Text = "Skip";
                                                skipButton.Click += new System.EventHandler(this.skipButton_Click);
                                                skipButton.Location = new System.Drawing.Point(80, 70);
                                                skipButton.Size = new System.Drawing.Size(80, 30);
                                                Label label = new Label();
                                                label.Text = row["Name"].ToString();
                                                label.Location = new System.Drawing.Point(10, 10);
                                                label.Size = new System.Drawing.Size(180, 30);
                                                multipleListingsForm.Controls.Add(label);
                                                multipleListingsForm.Controls.Add(selectButton);
                                                multipleListingsForm.Controls.Add(skipButton);
                                                multipleListingsForm.StartPosition = FormStartPosition.CenterScreen;
                                                multipleListingsForm.ShowDialog();
                                                multipleListingsForm.Dispose();
                                                // Check if a movie was selected or skipped
                                                if (DEBUG)
                                                    MessageBox.Show("Selected item: " + comboBox.SelectedIndex);
                                                int movieIndex = comboBox.SelectedIndex + 1;
                                                if (!isSkip)
                                                {
                                                    // Set the series name to the selected item
                                                    movieTitle = titles[movieIndex];
                                                    imdbID = imdbIDs[movieIndex];
                                                    tryAgain = false;
                                                    break;
                                                }
                                                else
                                                {
                                                    tryAgain = false;
                                                    searchError = true;
                                                    continue;
                                                }
                                            }
                                            else
                                            {
                                                if (DEBUG)
                                                    MessageBox.Show("Found Only One Result");

                                                imdbID = imdbIDs[1];
                                                movieTitle = titles[1];
                                                tryAgain = false;
                                                break;
                                            }
                                        }
                                        else
                                        {
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:67,代码来源:PluginMovieTagger.cs

示例8: EditShowInfo


//.........这里部分代码省略.........
                                        // Show a form with a combo box with the series available
                                        ComboBox comboBox = new ComboBox();
                                        comboBox.Location = new System.Drawing.Point(10, 40);
                                        comboBox.Size = new System.Drawing.Size(180, 150);
                                        for (int i = 0; i < seriesNamesList.Count; i++)
                                        {
                                            //Console.WriteLine((i + 1).ToString() + " :" + seriesNamesList.Item(i).InnerText);
                                            comboBox.Items.Add(seriesNamesList.Item(i).InnerText);
                                        }
                                        comboBox.SelectedIndex = 0;
                                        multipleListingsForm = new Form();
                                        multipleListingsForm.Text = "Select Series Name";
                                        multipleListingsForm.Size = new System.Drawing.Size(200, 140);
                                        multipleListingsForm.Controls.Add(comboBox);
                                        Button selectButton = new Button();
                                        Button skipButton = new Button();
                                        selectButton.Text = "Select";
                                        selectButton.Click += new System.EventHandler(this.selectButton_Click);
                                        selectButton.Location = new System.Drawing.Point(10, 70);
                                        selectButton.Size = new System.Drawing.Size(80, 30);
                                        skipButton.Text = "Skip";
                                        skipButton.Click += new System.EventHandler(this.skipButton_Click);
                                        skipButton.Location = new System.Drawing.Point(80, 70);
                                        skipButton.Size = new System.Drawing.Size(80, 30);
                                        Label label = new Label();
                                        label.Text = row["Name"].ToString();
                                        label.Location = new System.Drawing.Point(10, 10);
                                        label.Size = new System.Drawing.Size(180, 30);
                                        multipleListingsForm.Controls.Add(label);
                                        multipleListingsForm.Controls.Add(selectButton);
                                        multipleListingsForm.Controls.Add(skipButton);
                                        multipleListingsForm.StartPosition = FormStartPosition.CenterScreen;
                                        multipleListingsForm.ShowDialog();
                                        multipleListingsForm.Dispose();
                                        // Check if a series was selected or skipped
                                        seriesIndex = comboBox.SelectedIndex;
                                        if (!isSkip)
                                        {
                                            // Set the series name to the selected item
                                            formalName = seriesNamesList.Item(seriesIndex).InnerText;
                                            tryAgain = false;
                                        }
                                        else
                                            // Skip search
                                            searchError = true;
                                            break;
                                    }
                                }

                                // If there was an error in the manual search, skip
                                if (searchError)
                                    continue;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else if (seriesCount == 1)
                        {
                            // Only one show found, so assume this is it
                            if (DEBUG)
                                MessageBox.Show("Found: " + seriesNamesList.Item(0).InnerText);
                            formalName = seriesNamesList.Item(0).InnerText;
                        }
                        else
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:67,代码来源:PluginTagFromTheTVDB.cs

示例9: GoTo

    public int GoTo(string LineNumber)
    {
        Form frmDialog=new Form();

        TextBox LineBox=new TextBox();
        Button cmdOK=new Button();
        Button cmdCancel=new Button();

        cmdOK.Text="OK";
        cmdOK.DialogResult=DialogResult.OK;
        cmdOK.Click-=new EventHandler(Find_Click);

        cmdCancel.Text="Cancel";
        cmdCancel.DialogResult=DialogResult.Cancel;
        LineBox.Text=LineNumber;
        if(LineBox.Text.Length==0) LineBox.Text="0";
        frmDialog.Size=new Size(230,100);
        frmDialog.Text="Go to Line";
        frmDialog.AcceptButton=cmdOK;
        frmDialog.CancelButton=cmdCancel;
        frmDialog.MaximizeBox=false;
        frmDialog.MinimizeBox=false;
        frmDialog.FormBorderStyle=FormBorderStyle.FixedDialog;
        frmDialog.Location=new Point(this.Left+Math.Abs((this.Width-frmDialog.Width))/2,this.Top + 100);

        LineBox.Location=new Point(10,10);
        cmdOK.Location=new Point(LineBox.Left+LineBox.Width+20,10);
        cmdCancel.Location=new Point(cmdOK.Left,cmdOK.Top+cmdOK.Height+10);

        frmDialog.Controls.Add(LineBox);
        frmDialog.Controls.Add(cmdOK);
        frmDialog.Controls.Add(cmdCancel);
        frmDialog.ShowDialog(this);

        if(frmDialog.DialogResult==DialogResult.OK)
        {
            try
            {
                frmDialog.Dispose();
                return Int32.Parse(LineBox.Text);
            }
            catch(Exception)
            {
                return -1;
            }
        }
        return 0;
    }
开发者ID:mymindleaks,项目名称:iText,代码行数:48,代码来源:CPad.cs


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