コード例 #1
0
        private static void SaveLayoutScreenshot(string name, DirectoryInfo dir, WindowLayoutServiceCommandsBase wlscb)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (dir == null)
            {
                return;
            }

            if (wlscb == null)
            {
                return;
            }

            try
            {
                if (!Directory.Exists(dir.FullName))
                {
                    return;
                }

                string path =
                    Path.Combine(
                        dir.FullName + Path.DirectorySeparatorChar,
                        name + ScreenshotExtension);

                using (var bmp = wlscb.GetApplicationScreenshot())
                {
                    using (var stream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Write))
                    {
                        bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }
            }
            catch (Exception ex)
            {
                Outputs.WriteLine(
                    OutputMessageType.Error,
                    "{0}: Exception saving layout screenshot: {1}",
                    wlscb, ex.Message);
            }
        }
コード例 #2
0
        private static void SaveLayoutScreenshot(string name, DirectoryInfo dir, WindowLayoutServiceCommandsBase wlscb)
        {
            if (string.IsNullOrEmpty(name))
                return;

            if (dir == null)
                return;

            if (wlscb == null)
                return;

            try
            {
                if (!Directory.Exists(dir.FullName))
                    return;

                string path =
                    Path.Combine(
                        dir.FullName + Path.DirectorySeparatorChar,
                        name + ScreenshotExtension);

                using (var bmp = wlscb.GetApplicationScreenshot())
                {
                    using (var stream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Write))
                    {
                        bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }
            }
            catch (Exception ex)
            {
                Outputs.WriteLine(
                    OutputMessageType.Error,
                    "{0}: Exception saving layout screenshot: {1}",
                    wlscb, ex.Message);
            }
        }