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


C# System.Windows.Forms.Form.Dispose方法代码示例

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


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

示例1: TimelineAndTableAlwaysTogether


//.........这里部分代码省略.........
            FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            form.Controls.Add (panel);
            form.Show ();

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout ("mynewpanel", true, null);
            NoteDataXML basicNote = new NoteDataXML ();
            basicNote.Caption = "note1";

            panel.AddNote (basicNote);
            //basicNote.CreateParent(panel);

            //panel.MoveNote(
            // create four panels A and B at root level. C inside A. D inside C
            FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel ();
            panelA.Caption = "PanelA";
            panelA.GuidForNote = "panela";
            FAKE_NoteDataXML_Panel panelB = new FAKE_NoteDataXML_Panel ();
            panelB.Caption = "PanelB";
            panelB.GuidForNote = "panelb";
            FAKE_NoteDataXML_Panel panelC = new FAKE_NoteDataXML_Panel ();
            panelC.Caption = "PanelC";
            panelC.GuidForNote = "panelc";

            _w.output ("panels made");

            panel.AddNote (panelA);  // 1
            panel.AddNote (panelB);  // 2
            //panelA.CreateParent(panel); should not need to call this when doing LayoutPanel.AddNote because it calls CreateParent insid eof it

            basicNote = new NoteDataXML ();
            basicNote.Caption = "note2";

            panelA.AddNote (basicNote);  // Panel A has 1 note
            basicNote.CreateParent (panelA.myLayoutPanel ());  // DO need to call it when adding notes like this (to a subpanel, I think)
            panel.SaveLayout ();
            Assert.AreEqual (1, panelA.CountNotes (), "Panel A holds one note");  // So this counts as  + 2

            // so we have (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6
            _w.output ("STARTCOUNT");
            Assert.AreEqual (6, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");

            _w.output ("ENDCOUNT");

            // add timeline into a PANEL
            // count 1 row
            NoteDataXML_Timeline MyTimeLine = new NoteDataXML_Timeline(100,100);
            MyTimeLine.Caption = "My Timeline!";
            panelA.AddNote(MyTimeLine);
            MyTimeLine.CreateParent(panelA.GetPanelsLayout());

            panel.SaveLayout(); // I needed this save else it would not work?

            Assert.AreEqual (8, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");

            string guidOfTimeline = MyTimeLine.GuidForNote;
            string guidOfTimelineTable = guidOfTimeline + "table";

            NoteDataXML_Table FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable);
            Assert.NotNull(FoundTable);

            Assert.AreEqual (1, FoundTable.RowCount());
            FoundTable = null;

            // move the TABLE associated with the timeline OUT to parent
            // count 1 row

            panelA.myLayoutPanel ().MoveNote(guidOfTimelineTable, "up");

            // And for kicks add another timeline just to see if it messages anytnig up
            NoteDataXML_Timeline MyTimeLine2 = new NoteDataXML_Timeline(100,1020);
            MyTimeLine2.Caption = "My Timeline! #2";
            panel.AddNote(MyTimeLine2);

            panel.SaveLayout();
            Assert.AreEqual (10, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");

            Assert.Null(FoundTable);
            FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable);
            Assert.NotNull(FoundTable);

            Assert.AreEqual (1, FoundTable.RowCount());

            // move the TABLE into ANOTHER panel
            // count 1 row
            _w.output("Moving into panelb now");
            panel.MoveNote(guidOfTimelineTable, "panelb");
            panel.SaveLayout();

            Assert.AreEqual (10, panel.CountNotes (), "Total notes SHOULD BE 6 :  (1 + 1 note on it)panel A + (1)panelB + basicNote +DefaultNote = 5  + (NEW) LinkTable = 6");
            _w.output("done counting");

            FoundTable = null;
            Assert.Null(FoundTable);
            FoundTable = (NoteDataXML_Table)panel.FindNoteByGuid(guidOfTimelineTable);
            Assert.NotNull(FoundTable);

            Assert.AreEqual (1, FoundTable.RowCount());
            form.Dispose ();
        }
开发者ID:BrentKnowles,项目名称:YourOtherMind,代码行数:101,代码来源:TimelineTest.cs

示例2: DrawSlide2

        private void DrawSlide2( DeckTraversalModel traversal, int index, System.Drawing.Rectangle displayBounds, System.Drawing.Graphics g )
        {
            float width_scale = g.DpiX / 100f;
            float height_scale = g.DpiY / 100f;

            Rectangle bounds = new Rectangle( 0, 0, (int)(displayBounds.Width * 3f), (int)(displayBounds.Height * 3f) );

            // Create an image using temporary graphics and graphics buffer object
            Bitmap imageForPrinting = new Bitmap( bounds.Width, bounds.Height );
            using( Graphics graphicsImage = Graphics.FromImage( imageForPrinting ) ) {
                using( DibGraphicsBuffer dib = new DibGraphicsBuffer() ) {
                    // Create temporary screen Graphics
                    System.Windows.Forms.Form tempForm = new System.Windows.Forms.Form();
                    Graphics screenGraphics = tempForm.CreateGraphics();

                    // Create temporary Graphics from the Device Independent Bitmap
                    using( Graphics graphicsTemp = dib.RequestBuffer( screenGraphics, imageForPrinting.Width, imageForPrinting.Height ) ) {

                        // Save the old state
                        System.Drawing.Drawing2D.GraphicsState oldState;

                        using( Synchronizer.Lock( traversal.SyncRoot ) ) {
                            using( Synchronizer.Lock( traversal.Deck.SyncRoot ) ) {
                                using( Synchronizer.Lock( traversal.Deck.TableOfContents.SyncRoot ) ) {
                                    TableOfContentsModel.Entry entry = traversal.Deck.TableOfContents.Entries[index];
                                    using( Synchronizer.Lock( entry.Slide.SyncRoot ) ) {

                                        //Draw the background color
                                        //First see if there is a Slide BG, if not, try the Deck. Otherwise, use transparent.
                                        if( entry.Slide.BackgroundColor != Color.Empty ) {
                                            graphicsTemp.Clear( entry.Slide.BackgroundColor );
                                        } else if( traversal.Deck.DeckBackgroundColor != Color.Empty ) {
                                            graphicsTemp.Clear( traversal.Deck.DeckBackgroundColor );
                                        } else {
                                            graphicsTemp.Clear( Color.Transparent );
                                        }

                                        //Get the Slide content and draw it
                                        oldState = graphicsTemp.Save();
                                        Model.Presentation.SlideModel.SheetCollection sheets = entry.Slide.ContentSheets;
                                        for( int i = 0; i < sheets.Count; i++ ) {
                                            SlideDisplayModel display = new SlideDisplayModel( graphicsTemp, null );

                                            Rectangle rect = new Rectangle( 0, 0, bounds.Width, bounds.Height );
                                            Rectangle slide = new Rectangle( rect.X, rect.Y, rect.Width, rect.Height );
                                            float zoom = 1f;
                                            if( entry.Slide != null ) {
                                                slide = entry.Slide.Bounds;
                                                zoom = entry.Slide.Zoom;
                                            }

                                            System.Drawing.Drawing2D.Matrix pixel, ink;
                                            display.FitSlideToBounds( System.Windows.Forms.DockStyle.Fill, rect, zoom, ref slide, out pixel, out ink );
                                            using( Synchronizer.Lock( display.SyncRoot ) ) {
                                                display.Bounds = slide;
                                                display.PixelTransform = pixel;
                                                display.InkTransform = ink;
                                            }

                                            Viewer.Slides.SheetRenderer r = Viewer.Slides.SheetRenderer.ForStaticSheet( display, sheets[i] );
                                            r.Paint( new System.Windows.Forms.PaintEventArgs( graphicsTemp, bounds ) );
                                            r.Dispose();
                                        }

                                    }
                                }
                            }
                        }

                        //Restore the Old State
                        graphicsTemp.Restore( oldState );

                        // Use the buffer to paint onto the final image
                        dib.PaintBuffer( graphicsImage, 0, 0 );

                        // Draw this image onto the printer graphics,
                        // adjusting for printer margins
                        g.DrawImage( imageForPrinting, displayBounds );

                        //Cleanup
                        graphicsTemp.Dispose();
                        screenGraphics.Dispose();
                        tempForm.Dispose();
                        dib.Dispose();
                        graphicsImage.Dispose();
                        imageForPrinting.Dispose();
                    }
                }
            }
        }
开发者ID:kevinbrink,项目名称:CP3_Enhancement,代码行数:90,代码来源:PrintingService.cs

示例3: Quicker_UpdateAfterLoadTest

        public void Quicker_UpdateAfterLoadTest()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

                System.Windows.Forms .Form form = new System.Windows.Forms.Form();

                FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);

                form.Controls.Add (panel);

                // 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();
                panel.NewLayout (panelname,true, null);
                LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel");
                _w.output ("herefirst");

                // ADD 1 of each type
                foreach (Type t in LayoutDetails.Instance.ListOfTypesToStoreInXML()) {
                    for (int i = 0; i < 5; i++) {
                        NoteDataInterface note = (NoteDataInterface)Activator.CreateInstance (t);
                        panel.AddNote (note);
                        note.CreateParent(panel);

                    note.UpdateAfterLoad();
                    }
                }

            panel.SaveLayout();
            form.Dispose ();
        }
开发者ID:BrentKnowles,项目名称:YourOtherMind,代码行数:38,代码来源:LayoutPanelTests.cs


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