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


C# RenderArgs.Dispose方法代码示例

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


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

示例1: OnExecute

        public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace)
        {
            if (this.layerIndex < 1 || this.layerIndex >= historyWorkspace.Document.Layers.Count)
            {
                throw new ArgumentException("layerIndex must be greater than or equal to 1, and a valid layer index. layerIndex=" + 
                    layerIndex + ", allowableRange=[0," + historyWorkspace.Document.Layers.Count + ")");
            }

            int bottomLayerIndex = this.layerIndex - 1;
            Rectangle bounds = historyWorkspace.Document.Bounds;
            PdnRegion region = new PdnRegion(bounds);

            BitmapHistoryMemento bhm = new BitmapHistoryMemento(
                null,
                null,
                historyWorkspace,
                bottomLayerIndex,
                region);

            BitmapLayer topLayer = (BitmapLayer)historyWorkspace.Document.Layers[this.layerIndex];
            BitmapLayer bottomLayer = (BitmapLayer)historyWorkspace.Document.Layers[bottomLayerIndex];
            RenderArgs bottomRA = new RenderArgs(bottomLayer.Surface);

            EnterCriticalRegion();

            topLayer.Render(bottomRA, region);
            bottomLayer.Invalidate();

            bottomRA.Dispose();
            bottomRA = null;

            region.Dispose();
            region = null;

            DeleteLayerFunction dlf = new DeleteLayerFunction(this.layerIndex);
            HistoryMemento dlhm = dlf.Execute(historyWorkspace);

            CompoundHistoryMemento chm = new CompoundHistoryMemento(StaticName, StaticImage, new HistoryMemento[] { bhm, dlhm });
            return chm;
        }
开发者ID:metadeta96,项目名称:openpdn,代码行数:40,代码来源:MergeLayerDownFunction.cs

示例2: PerformAction

        public bool PerformAction()
        {
            bool success = true;

            if (this.documentWorkspace.Selection.IsEmpty ||
                !(this.documentWorkspace.ActiveLayer is BitmapLayer))
            {
                return false;
            }

            try
            {
                using (new WaitCursorChanger(this.documentWorkspace))
                {
                    Utility.GCFullCollect();
                    PdnRegion selectionRegion = this.documentWorkspace.Selection.CreateRegion();
                    PdnGraphicsPath selectionOutline = this.documentWorkspace.Selection.CreatePath();
                    BitmapLayer activeLayer = (BitmapLayer)this.documentWorkspace.ActiveLayer;
                    RenderArgs renderArgs = new RenderArgs(activeLayer.Surface);
                    MaskedSurface maskedSurface = new MaskedSurface(renderArgs.Surface, selectionOutline);
                    SurfaceForClipboard surfaceForClipboard = new SurfaceForClipboard(maskedSurface);
                    Rectangle selectionBounds = Utility.GetRegionBounds(selectionRegion);

                    if (selectionBounds.Width > 0 && selectionBounds.Height > 0)
                    {
                        Surface copySurface = new Surface(selectionBounds.Width, selectionBounds.Height);
                        Bitmap copyBitmap = copySurface.CreateAliasedBitmap();
                        Bitmap copyOpaqueBitmap = new Bitmap(copySurface.Width, copySurface.Height, PixelFormat.Format24bppRgb);

                        using (Graphics copyBitmapGraphics = Graphics.FromImage(copyBitmap))
                        {
                            copyBitmapGraphics.Clear(Color.White);
                        }

                        maskedSurface.Draw(copySurface, -selectionBounds.X, -selectionBounds.Y);

                        using (Graphics copyOpaqueBitmapGraphics = Graphics.FromImage(copyOpaqueBitmap))
                        {
                            copyOpaqueBitmapGraphics.Clear(Color.White);
                            copyOpaqueBitmapGraphics.DrawImage(copyBitmap, 0, 0);
                        }

                        DataObject dataObject = new DataObject();

                        dataObject.SetData(DataFormats.Bitmap, copyOpaqueBitmap);
                        dataObject.SetData(surfaceForClipboard);

                        int retryCount = 2;

                        while (retryCount >= 0)
                        {
                            try
                            {
                                using (new WaitCursorChanger(this.documentWorkspace))
                                {
                                    Clipboard.SetDataObject(dataObject, true);
                                }

                                break;
                            }

                            catch
                            {
                                if (retryCount == 0)
                                {
                                    success = false;
                                    Utility.ErrorBox(this.documentWorkspace,
                                        PdnResources.GetString("CopyAction.Error.TransferToClipboard"));
                                }
                                else
                                {
                                    Thread.Sleep(200);
                                }
                            }

                            finally
                            {
                                --retryCount;
                            }
                        }

                        copySurface.Dispose();
                        copyBitmap.Dispose();
                        copyOpaqueBitmap.Dispose();
                    }

                    selectionRegion.Dispose();
                    selectionOutline.Dispose();
                    renderArgs.Dispose();
                    maskedSurface.Dispose();
                }
            }

            catch (OutOfMemoryException)
            {
                success = false;
                Utility.ErrorBox(this.documentWorkspace, PdnResources.GetString("CopyAction.Error.OutOfMemory"));
            }

            catch (Exception)
//.........这里部分代码省略.........
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:101,代码来源:CopyToClipboardAction.cs

示例3: ShowExpandCanvasTaskDialog

        private static DialogResult ShowExpandCanvasTaskDialog(IWin32Window owner, Surface thumbnail)
        {
            DialogResult result;

            Icon formIcon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuEditPasteIcon.png").Reference);
            string formTitle = PdnResources.GetString("ExpandCanvasQuestion.Title");

            RenderArgs taskImageRA = new RenderArgs(thumbnail);
            Image taskImage = taskImageRA.Bitmap;
            string introText = PdnResources.GetString("ExpandCanvasQuestion.IntroText");

            TaskButton yesTB = new TaskButton(
                PdnResources.GetImageResource("Icons.ExpandCanvasQuestion.YesTB.Image.png").Reference,
                PdnResources.GetString("ExpandCanvasQuestion.YesTB.ActionText"),
                PdnResources.GetString("ExpandCanvasQuestion.YesTB.ExplanationText"));

            TaskButton noTB = new TaskButton(
                PdnResources.GetImageResource("Icons.ExpandCanvasQuestion.NoTB.Image.png").Reference,
                PdnResources.GetString("ExpandCanvasQuestion.NoTB.ActionText"),
                PdnResources.GetString("ExpandCanvasQuestion.NoTB.ExplanationText"));

            TaskButton cancelTB = new TaskButton(
                TaskButton.Cancel.Image,
                PdnResources.GetString("ExpandCanvasQuestion.CancelTB.ActionText"),
                PdnResources.GetString("ExpandCanvasQuestion.CancelTB.ExplanationText"));

            int width96dpi = (TaskDialog.DefaultPixelWidth96Dpi * 3) / 2;

            TaskButton clickedTB = TaskDialog.Show(
                owner,
                formIcon,
                formTitle,
                taskImage,
                false, 
                introText,
                new TaskButton[] { yesTB, noTB, cancelTB },
                yesTB,
                cancelTB,
                width96dpi);

            if (clickedTB == yesTB)
            {
                result = DialogResult.Yes;
            }
            else if (clickedTB == noTB)
            {
                result = DialogResult.No;
            }
            else
            {
                result = DialogResult.Cancel;
            }

            taskImageRA.Dispose();
            taskImageRA = null;

            return result;
        }
开发者ID:herbqiao,项目名称:paint.net,代码行数:58,代码来源:PasteAction.cs


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