當前位置: 首頁>>代碼示例>>C#>>正文


C# PdnRegion.Dispose方法代碼示例

本文整理匯總了C#中PaintDotNet.PdnRegion.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# PdnRegion.Dispose方法的具體用法?C# PdnRegion.Dispose怎麽用?C# PdnRegion.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PaintDotNet.PdnRegion的用法示例。


在下文中一共展示了PdnRegion.Dispose方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnSelectionChanged

        private void OnSelectionChanged(object sender, EventArgs e)
        {
            this.render = true;
            PdnGraphicsPath path = this.selection.CreatePath(); //this.selection.GetPathReadOnly();

            if (this.selectedPath == null)
            {
                Invalidate();
            }
            else
            {
                this.selectedPath.Dispose(); //
                this.selectedPath = null;
            }

            bool fullInvalidate = false;
            this.selectedPath = path;

            // HACK: Sometimes the selection leaves behind artifacts. So do a full invalidate
            //       every 1 second.
            if (this.selectedPath.PointCount > 10 && (DateTime.Now - lastFullInvalidate > new TimeSpan(0, 0, 0, 1, 0)))
            {
                fullInvalidate = true;
            }

            // if we're moving to a simpler selection region ...
            if (this.selectedPath == null)// || this.selectedPath.PointCount == 0)
            {   
                // then invalidate everything
                fullInvalidate = true;
            }
            else
            {   
                // otherwise, be intelligent about it and only redraw the 'new' area
                PdnRegion xorMe = new PdnRegion(this.selectedPath);
                selectionRedrawInterior.Xor(xorMe);
                xorMe.Dispose();
            }

            float ratio = 1.0f / (float)OwnerList.ScaleFactor.Ratio;
            int ratioInt = (int)Math.Ceiling(ratio);

            if (this.Visible && (this.EnableSelectionOutline || this.EnableSelectionTinting))
            {
                using (PdnRegion simplified = Utility.SimplifyAndInflateRegion(selectionRedrawInterior, Utility.DefaultSimplificationFactor, 2 * ratioInt))
                {
                    Invalidate(simplified);
                }
            }

            if (fullInvalidate)
            {
                Rectangle rect = Rectangle.Inflate(Rectangle.Truncate(selectionRedrawOutline.GetBounds2()), 1, 1);
                Invalidate(rect);
                lastFullInvalidate = DateTime.Now;
            }
            

            this.selectionRedrawInterior.Dispose();
            this.selectionRedrawInterior = null;

            if (this.zoomInSelectedPath != null)
            {
                this.zoomInSelectedPath.Dispose();
                this.zoomInSelectedPath = null;
            }

            this.simplifiedRegionForTimer = null;

            // prepare for next call
            if (this.selectedPath != null && !this.selectedPath.IsEmpty)
            {
                this.selectionRedrawOutline = (PdnGraphicsPath)this.selectedPath.Clone();
                this.selectionRedrawInterior = new PdnRegion(this.selectedPath);
            }
            else
            {
                if (invertedTinting)
                {
                    this.selectionRedrawInterior = new PdnRegion(new Rectangle(0, 0, this.SourceSize.Width, this.SourceSize.Height));
                }
                else
                {
                    this.selectionRedrawInterior = new PdnRegion();
                    this.selectionRedrawInterior.MakeEmpty();
                }

                Invalidate();
                this.selectionRedrawOutline = new PdnGraphicsPath();
            }
        }
開發者ID:metadeta96,項目名稱:openpdn,代碼行數:91,代碼來源:SelectionRenderer.cs


注:本文中的PaintDotNet.PdnRegion.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。