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


C# Surface.Dispose方法代码示例

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


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

示例1: HandleCapture

        private void HandleCapture()
        {
            // Flag to see if the image was "exported" so the FileEditor doesn't
            // ask to save the file as long as nothing is done.
            bool outputMade = false;

            // Make sure the user sees that the capture is made
            if (_capture.CaptureDetails.CaptureMode == CaptureMode.File || _capture.CaptureDetails.CaptureMode == CaptureMode.Clipboard) {
                // Maybe not "made" but the original is still there... somehow
                outputMade = true;
            } else {
                // Make sure the resolution is set correctly!
                if (_capture.CaptureDetails != null && _capture.Image != null) {
                    ((Bitmap)_capture.Image).SetResolution(_capture.CaptureDetails.DpiX, _capture.CaptureDetails.DpiY);
                }
                DoCaptureFeedback();
            }

            LOG.Debug("A capture of: " + _capture.CaptureDetails.Title);

            // check if someone has passed a destination
            if (_capture.CaptureDetails.CaptureDestinations == null || _capture.CaptureDetails.CaptureDestinations.Count == 0) {
                AddConfiguredDestination();
            }

            // Create Surface with capture, this way elements can be added automatically (like the mouse cursor)
            Surface surface = new Surface(_capture);
            surface.Modified = !outputMade;

            // Register notify events if this is wanted
            if (conf.ShowTrayNotification && !conf.HideTrayicon) {
                surface.SurfaceMessage += SurfaceMessageReceived;

            }
            // Let the processors do their job
            foreach(IProcessor processor in ProcessorHelper.GetAllProcessors()) {
                if (processor.isActive) {
                    LOG.InfoFormat("Calling processor {0}", processor.Description);
                    processor.ProcessCapture(surface, _capture.CaptureDetails);
                }
            }

            // As the surfaces copies the reference to the image, make sure the image is not being disposed (a trick to save memory)
            _capture.Image = null;

            // Get CaptureDetails as we need it even after the capture is disposed
            ICaptureDetails captureDetails = _capture.CaptureDetails;
            bool canDisposeSurface = true;

            if (captureDetails.HasDestination(PickerDestination.DESIGNATION)) {
                DestinationHelper.ExportCapture(false, PickerDestination.DESIGNATION, surface, captureDetails);
                captureDetails.CaptureDestinations.Clear();
                canDisposeSurface = false;
            }

            // Disable capturing
            _captureMode = CaptureMode.None;
            // Dispose the capture, we don't need it anymore (the surface copied all information and we got the title (if any)).
            _capture.Dispose();
            _capture = null;

            int destinationCount = captureDetails.CaptureDestinations.Count;
            if (destinationCount > 0) {
                // Flag to detect if we need to create a temp file for the email
                // or use the file that was written
                foreach(IDestination destination in captureDetails.CaptureDestinations) {
                    if (PickerDestination.DESIGNATION.Equals(destination.Designation)) {
                        continue;
                    }
                    LOG.InfoFormat("Calling destination {0}", destination.Description);

                    ExportInformation exportInformation = destination.ExportCapture(false, surface, captureDetails);
                    if (EditorDestination.DESIGNATION.Equals(destination.Designation) && exportInformation.ExportMade) {
                        canDisposeSurface = false;
                    }
                }
            }
            if (canDisposeSurface) {
                surface.Dispose();
            }
        }
开发者ID:oneminot,项目名称:greenshot,代码行数:81,代码来源:CaptureHelper.cs

示例2: HandleCapture

        private void HandleCapture(string fullPath)
        {
            if (capture == null)
             {
            StopCapturing(true);
             }

             // Flag to see if the image was "exported" so the FileEditor doesn't
             // ask to save the file as long as nothing is done.
             bool outputMade = false;

             // Make sure the user sees that the capture is made
             if (capture.CaptureDetails.CaptureMode != CaptureMode.File && capture.CaptureDetails.CaptureMode != CaptureMode.Clipboard)
             {
            DoCaptureFeedback();
             }
             else
             {
            // If File || Clipboard
            // Maybe not "made" but the original is still there... somehow
            outputMade = true;
             }

             LOG.Debug("A capture of: " + capture.CaptureDetails.Title);

             // Create event OnCaptureTaken for all Plugins
             PluginHelper.instance.CreateCaptureTakenEvent(capture);

             // check if someone has passed a handler
             if (capture.CaptureDetails.CaptureHandler != null)
             {
            CaptureTakenEventArgs eventArgs = new CaptureTakenEventArgs(capture);
            capture.CaptureDetails.CaptureHandler(this, eventArgs);
             }
             else if (capture.CaptureDetails.CaptureDestinations == null || capture.CaptureDetails.CaptureDestinations.Count == 0)
             {
            AddConfiguredDestination(capture);
             }

             // Create Surface with capture, this way elements can be added automatically (like the mouse cursor)
             Surface surface = new Surface(capture);

             // As the surfaces copies the reference to the image, make sure the image is not being disposed (a trick to save memory)
             capture.Image = null;

             // Call plugins to do something with the screenshot
             PluginHelper.instance.CreateSurfaceFromCaptureEvent(capture, surface);

             // Disable capturing
             captureMode = CaptureMode.None;

             // Retrieve important information from the Capture object
             ICaptureDetails captureDetails = capture.CaptureDetails;
             List<CaptureDestination> captureDestinations = capture.CaptureDetails.CaptureDestinations;

             // Dispose the capture, we don't need it anymore (the surface copied all information and we got the title (if any)).
             capture.Dispose();
             capture = null;

             // Want to add more stuff to the surface?? DO IT HERE!
             int destinationsCount = captureDestinations.Count;
             if (captureDestinations.Contains(CaptureDestination.Editor))
             {
            destinationsCount--;
             }
             if (destinationsCount > 0)
             {
            // Create Image for writing/printing etc and use "using" as all code paths either output the image or copy the image
            using (Image image = surface.GetImageForExport())
            {
               // Flag to detect if we need to create a temp file for the email
               // or use the file that was written
               bool fileWritten = false;

               if (captureDestinations.Contains(CaptureDestination.espUrl))
               {
                  string title = captureDetails.Title;
                  if (string.IsNullOrEmpty(title))
                  {
                     title = "screen_" + captureDetails.DateTime.ToString("yyyyMMddHHmmssfff");
                  }

                  using (var ms = new MemoryStream())
                  {
                     ImageOutput.SaveToStream(image, ms, OutputFormat.png, 1);
                     ms.Seek(0, SeekOrigin.Begin);
                     new EspUrlClient().Upload(ms, title + ".png");
                  }
               }

               if (captureDestinations.Contains(CaptureDestination.File))
               {
                  string pattern = conf.OutputFileFilenamePattern;
                  if (pattern == null || string.IsNullOrEmpty(pattern.Trim()))
                  {
                     pattern = "espurl ${capturetime}";
                  }
                  string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails);
                  string filepath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
                  fullPath = Path.Combine(filepath, filename);
//.........这里部分代码省略.........
开发者ID:eservicepartner,项目名称:espUrl,代码行数:101,代码来源:CaptureForm.cs


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