예제 #1
0
        public SettingsForm(string [] languages, OCRConfiguration config)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            this.config = config;
            InitializeComponent();
            AcceptButton = buttonOK;
            CancelButton = buttonCancel;
            this.Icon    = GreenshotResources.getGreenshotIcon();

            comboBox_languages.Items.Clear();
            int index = 0;

            // Preventing Tracker #3234560, although this should not happen...
            string languageFromConfig = "ENGLISH";

            if (config.Language != null)
            {
                languageFromConfig = config.Language;
            }
            foreach (string availableLanguage in languages)
            {
                string displayLanguage = availableLanguage.Substring(0, 1).ToUpper() + availableLanguage.Substring(1).ToLower();
                comboBox_languages.Items.Add(displayLanguage);
                if (availableLanguage.Equals(languageFromConfig, StringComparison.CurrentCultureIgnoreCase))
                {
                    comboBox_languages.SelectedIndex = index;
                }
                index++;
            }
        }
예제 #2
0
 public TornEdgeSettingsForm(TornEdgeEffect effect)
 {
     this.effect = effect;
     InitializeComponent();
     this.Icon = GreenshotResources.getGreenshotIcon();
     ShowSettings();
 }
예제 #3
0
 public DropShadowSettingsForm(DropShadowEffect effect)
 {
     this.effect = effect;
     InitializeComponent();
     this.Icon = GreenshotResources.getGreenshotIcon();
     ShowSettings();
 }
예제 #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Icon = GreenshotResources.getGreenshotIcon();

            // Fix for Vista/XP differences
            if (Environment.OSVersion.Version.Major >= 6)
            {
                trackBarJpegQuality.BackColor = SystemColors.Window;
            }
            else
            {
                trackBarJpegQuality.BackColor = SystemColors.Control;
            }

            // This makes it possible to still capture the settings screen
            fullscreen_hotkeyControl.Enter += EnterHotkeyControl;
            fullscreen_hotkeyControl.Leave += LeaveHotkeyControl;
            window_hotkeyControl.Enter     += EnterHotkeyControl;
            window_hotkeyControl.Leave     += LeaveHotkeyControl;
            region_hotkeyControl.Enter     += EnterHotkeyControl;
            region_hotkeyControl.Leave     += LeaveHotkeyControl;
            ie_hotkeyControl.Enter         += EnterHotkeyControl;
            ie_hotkeyControl.Leave         += LeaveHotkeyControl;
            lastregion_hotkeyControl.Enter += EnterHotkeyControl;
            lastregion_hotkeyControl.Leave += LeaveHotkeyControl;

            DisplayPluginTab();
            UpdateUI();
            ExpertSettingsEnableState(false);
            DisplaySettings();
            CheckSettings();
        }
예제 #5
0
 public PleaseWaitForm()
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     Icon = GreenshotResources.getGreenshotIcon();
 }
예제 #6
0
        public AboutForm()
        {
            InitializeComponent();
            Icon            = GreenshotResources.getGreenshotIcon();
            lblLicense.Text = @"Copyright (C) 2007-2014 Thomas Braun, Jens Klingen, Robin Krom
Greenshot comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
Details about the GNU General Public License:";
        }
예제 #7
0
 public DropShadowSettingsForm(DropShadowEffect effect)
 {
     this.effect = effect;
     InitializeComponent();
     this.Icon       = GreenshotResources.getGreenshotIcon();
     trackBar1.Value = (int)(effect.Darkness * 40);
     offsetX.Value   = effect.ShadowOffset.X;
     offsetY.Value   = effect.ShadowOffset.Y;
 }
예제 #8
0
 public PleaseWaitForm(IGreenshotLanguage greenshotLanguage)
 {
     _greenshotLanguage = greenshotLanguage;
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     Icon = GreenshotResources.GetGreenshotIcon();
 }
예제 #9
0
 public PrintOptionsDialog()
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     Icon = GreenshotResources.getGreenshotIcon();
     checkbox_dontaskagain.Checked = false;
 }
예제 #10
0
 private BugReportForm()
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     Icon = GreenshotResources.getGreenshotIcon();
     WindowDetails.ToForeground(Handle);
 }
예제 #11
0
 public SettingsForm(FlickrConfiguration config)
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     Icon         = GreenshotResources.getGreenshotIcon();
     CancelButton = buttonCancel;
     AcceptButton = buttonOK;
 }
예제 #12
0
 private LanguageDialog()
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     Icon         = GreenshotResources.getGreenshotIcon();
     Load        += FormLoad;
     FormClosing += PreventFormClose;
 }
예제 #13
0
        /// <summary>
        /// Setup the Bitmap scaling (for icons)
        /// </summary>
        private void SetupBitmapScaleHandler()
        {
            ContextMenuDpiHandler = contextMenu.AttachDpiHandler();

            var dpiChangeSubscription = DpiHandler.OnDpiChangeInfo.Subscribe(info =>
            {
                switch (info.DpiChangeEventType)
                {
                case DpiChangeEventTypes.Before:
                    // Change the ImageScalingSize before setting the bitmaps
                    var width = DpiHandler.ScaleWithDpi(coreConfiguration.IconSize.Width, info.NewDpi);
                    var size  = new Size(width, width);
                    contextMenu.SuspendLayout();
                    contextMenu.ImageScalingSize   = size;
                    contextmenu_quicksettings.Size = new Size(170, width + 8);
                    break;

                case DpiChangeEventTypes.After:
                    // Redraw the form
                    contextMenu.ResumeLayout(true);
                    contextMenu.Refresh();
                    notifyIcon.Icon = GreenshotResources.GetGreenshotIcon();
                    break;
                }
            });

            var contextMenuResourceScaleHandler = BitmapScaleHandler.WithComponentResourceManager(ContextMenuDpiHandler, GetType(), (bitmap, dpi) => bitmap.ScaleIconForDisplaying(dpi));

            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturewindow, "contextmenu_capturewindow.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturearea, "contextmenu_capturearea.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturelastregion, "contextmenu_capturelastregion.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturefullscreen, "contextmenu_capturefullscreen.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_captureclipboard, "contextmenu_captureclipboard.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_openfile, "contextmenu_openfile.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_settings, "contextmenu_settings.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_help, "contextmenu_help.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_donate, "contextmenu_donate.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_exit, "contextmenu_exit.Image");

            // this is special handling, for the icons which come from the executables
            var exeBitmapScaleHandler = BitmapScaleHandler.Create <string>(ContextMenuDpiHandler,
                                                                           (path, dpi) => PluginUtils.GetCachedExeIcon(path, 0, dpi >= 120),
                                                                           (bitmap, dpi) => bitmap.ScaleIconForDisplaying(dpi));

            exeBitmapScaleHandler.AddTarget(contextmenu_captureie, PluginUtils.GetExePath("iexplore.exe"));

            // Add cleanup
            Application.ApplicationExit += (sender, args) =>
            {
                dpiChangeSubscription.Dispose();
                ContextMenuDpiHandler.Dispose();
                contextMenuResourceScaleHandler.Dispose();
                exeBitmapScaleHandler.Dispose();
            };
        }
예제 #14
0
 public TornEdgeSettingsForm(TornEdgeEffect effect)
 {
     this.effect = effect;
     InitializeComponent();
     this.Icon                  = GreenshotResources.getGreenshotIcon();
     trackBar1.Value            = (int)(effect.Darkness * 40);
     offsetX.Value              = effect.ShadowOffset.X;
     offsetY.Value              = effect.ShadowOffset.Y;
     toothsize.Value            = effect.ToothHeight;
     verticaltoothrange.Value   = effect.VerticalToothRange;
     horizontaltoothrange.Value = effect.HorizontalToothRange;
 }
예제 #15
0
 protected override void OnLoad(EventArgs e)
 {
     // Every GreenshotForm should have it's default icon
     // And it might not ne needed for a Tool Window, but still for the task manager / switcher it's important
     Icon = GreenshotResources.GetGreenshotIcon();
     if (!ManualLanguageApply)
     {
         ApplyLanguage();
     }
     FillFields();
     base.OnLoad(e);
 }
예제 #16
0
 public BackgroundForm(string title, string text)
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     Icon                  = GreenshotResources.GetGreenshotIcon();
     _shouldClose          = false;
     Text                  = title;
     label_pleasewait.Text = text;
     FormClosing          += PreventFormClose;
     timer_checkforclose.Start();
 }
예제 #17
0
        public QualityDialog(SurfaceOutputSettings outputSettings)
        {
            Settings = outputSettings;
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            Icon = GreenshotResources.getGreenshotIcon();

            checkBox_reduceColors.Checked = Settings.ReduceColors;
            trackBarJpegQuality.Enabled   = OutputFormat.jpg.Equals(outputSettings.Format);
            trackBarJpegQuality.Value     = Settings.JPGQuality;
            textBoxJpegQuality.Enabled    = OutputFormat.jpg.Equals(outputSettings.Format);
            textBoxJpegQuality.Text       = Settings.JPGQuality.ToString();
        }
예제 #18
0
        public OAuthLoginForm(string browserTitle, Size size, string authorizationLink, string callbackUrl)
        {
            _callbackUrl = callbackUrl;
            InitializeComponent();
            ClientSize           = size;
            Icon                 = GreenshotResources.getGreenshotIcon();
            Text                 = browserTitle;
            _addressTextBox.Text = authorizationLink;

            // The script errors are suppressed by using the ExtendedWebBrowser
            _browser.ScriptErrorsSuppressed = false;
            _browser.DocumentCompleted     += Browser_DocumentCompleted;
            _browser.Navigated  += Browser_Navigated;
            _browser.Navigating += Browser_Navigating;
            _browser.Navigate(new Uri(authorizationLink));
        }
예제 #19
0
        public OAuthLoginForm(string browserTitle, Size size, string authorizationLink, string callbackUrl)
        {
            this.callbackUrl = callbackUrl;
            InitializeComponent();
            ClientSize          = size;
            Icon                = GreenshotResources.getGreenshotIcon();
            Text                = browserTitle;
            addressTextBox.Text = authorizationLink;

            // The script errors are suppressed by using the ExtendedWebBrowser
            browser.ScriptErrorsSuppressed = false;
            browser.DocumentCompleted     += new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
            browser.Navigate(new Uri(authorizationLink));

            WindowDetails.ToForeground(Handle);
        }
예제 #20
0
 protected override void OnLoad(EventArgs e)
 {
     // Every GreenshotForm should have it's default icon
     // And it might not ne needed for a Tool Window, but still for the task manager / switcher it's important
     Icon = GreenshotResources.getGreenshotIcon();
     if (!DesignMode)
     {
         FillFields();
         base.OnLoad(e);
     }
     else
     {
         LOG.Info("OnLoad called from designer.");
         InitializeForDesigner();
         base.OnLoad(e);
     }
 }
 public TornEdgeSettingsForm(TornEdgeEffect effect)
 {
     this.effect = effect;
     InitializeComponent();
     this.Icon = GreenshotResources.getGreenshotIcon();
     shadowCheckbox.Checked     = effect.GenerateShadow;
     shadowDarkness.Value       = (int)(effect.Darkness * 40);
     offsetX.Value              = effect.ShadowOffset.X;
     offsetY.Value              = effect.ShadowOffset.Y;
     toothsize.Value            = effect.ToothHeight;
     verticaltoothrange.Value   = effect.VerticalToothRange;
     horizontaltoothrange.Value = effect.HorizontalToothRange;
     top.Checked    = effect.Edges[0];
     right.Checked  = effect.Edges[1];
     bottom.Checked = effect.Edges[2];
     left.Checked   = effect.Edges[3];
 }
예제 #22
0
파일: JiraForm.cs 프로젝트: zhk/greenshot
        public JiraForm(JiraConnector jiraConnector)
        {
            InitializeComponent();
            Icon         = GreenshotResources.getGreenshotIcon();
            AcceptButton = uploadButton;
            CancelButton = cancelButton;

            InitializeComponentText();

            _columnSorter = new GreenshotColumnSorter();
            jiraListView.ListViewItemSorter = _columnSorter;

            _jiraConnector = jiraConnector;

            ChangeModus(false);

            uploadButton.Enabled = false;
            Load += OnLoad;
        }
예제 #23
0
        public ResizeSettingsForm(ResizeEffect effect)
        {
            this.effect = effect;
            InitializeComponent();
            this.Icon     = GreenshotResources.getGreenshotIcon();
            value_pixel   = "Pixels";
            value_percent = "Percent";
            combobox_width.Items.Add(value_pixel);
            combobox_width.Items.Add(value_percent);
            combobox_width.SelectedItem = value_pixel;
            combobox_height.Items.Add(value_pixel);
            combobox_height.Items.Add(value_percent);
            combobox_height.SelectedItem = value_pixel;

            textbox_width.Text  = effect.Width.ToString();
            textbox_height.Text = effect.Height.ToString();
            newWidth            = effect.Width;
            newHeight           = effect.Height;
            combobox_width.SelectedIndexChanged  += new System.EventHandler(this.combobox_SelectedIndexChanged);
            combobox_height.SelectedIndexChanged += new System.EventHandler(this.combobox_SelectedIndexChanged);

            checkbox_aspectratio.Checked = effect.MaintainAspectRatio;
        }
예제 #24
0
        public OAuthLoginForm(string browserTitle, Size size, string authorizationLink, string callbackUrl)
        {
            // Make sure Greenshot uses the correct browser version
            IEHelper.FixBrowserVersion(false);

            _callbackUrl = callbackUrl;
            // Fix for BUG-2071
            if (callbackUrl.EndsWith("/"))
            {
                _callbackUrl = callbackUrl.Substring(0, callbackUrl.Length - 1);
            }
            InitializeComponent();
            ClientSize           = size;
            Icon                 = GreenshotResources.GetGreenshotIcon();
            Text                 = browserTitle;
            _addressTextBox.Text = authorizationLink;

            // The script errors are suppressed by using the ExtendedWebBrowser
            _browser.ScriptErrorsSuppressed = false;
            _browser.DocumentCompleted     += Browser_DocumentCompleted;
            _browser.Navigated  += Browser_Navigated;
            _browser.Navigating += Browser_Navigating;
            _browser.Navigate(new Uri(authorizationLink));
        }
예제 #25
0
        /// <summary>
        ///     Initialize the background brush
        /// </summary>
        static CaptureForm()
        {
            var backgroundForTransparency = GreenshotResources.GetBitmap("Checkerboard.Image");

            BackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
        }
예제 #26
0
        /// <summary>
        /// Share the surface by using the Share-UI of Windows 10
        /// </summary>
        /// <param name="shareInfo">ShareInfo</param>
        /// <param name="handle">IntPtr with the handle for the hosting window</param>
        /// <param name="surface">ISurface with the bitmap to share</param>
        /// <param name="captureDetails">ICaptureDetails</param>
        /// <returns>Task with string, which describes the application which was used to share with</returns>
        private async Task Share(ShareInfo shareInfo, IntPtr handle, ISurface surface, ICaptureDetails captureDetails)
        {
            using (var imageStream = new MemoryRandomAccessStream())
                using (var logoStream = new MemoryRandomAccessStream())
                    using (var thumbnailStream = new MemoryRandomAccessStream())
                    {
                        var outputSettings = new SurfaceOutputSettings();
                        outputSettings.PreventGreenshotFormat();

                        // Create capture for export
                        ImageOutput.SaveToStream(surface, imageStream, outputSettings);
                        imageStream.Position = 0;
                        Log.Debug().WriteLine("Created RandomAccessStreamReference for the image");
                        var imageRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(imageStream);

                        // Create thumbnail
                        RandomAccessStreamReference thumbnailRandomAccessStreamReference;
                        using (var tmpImageForThumbnail = surface.GetBitmapForExport())
                            using (var thumbnail = tmpImageForThumbnail.CreateThumbnail(240, 160))
                            {
                                ImageOutput.SaveToStream(thumbnail, null, thumbnailStream, outputSettings);
                                thumbnailStream.Position             = 0;
                                thumbnailRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(thumbnailStream);
                                Log.Debug().WriteLine("Created RandomAccessStreamReference for the thumbnail");
                            }

                        // Create logo
                        RandomAccessStreamReference logoRandomAccessStreamReference;
                        using (var logo = GreenshotResources.GetGreenshotIcon().ToBitmap())
                            using (var logoThumbnail = logo.CreateThumbnail(30, 30))
                            {
                                ImageOutput.SaveToStream(logoThumbnail, null, logoStream, outputSettings);
                                logoStream.Position             = 0;
                                logoRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(logoStream);
                                Log.Info().WriteLine("Created RandomAccessStreamReference for the logo");
                            }

                        var dataTransferManagerHelper = new DataTransferManagerHelper(handle);
                        dataTransferManagerHelper.DataTransferManager.ShareProvidersRequested += (sender, args) =>
                        {
                            shareInfo.AreShareProvidersRequested = true;
                            Log.Debug().WriteLine("Share providers requested: {0}", string.Join(",", args.Providers.Select(p => p.Title)));
                        };
                        dataTransferManagerHelper.DataTransferManager.TargetApplicationChosen += (dtm, args) =>
                        {
                            shareInfo.ApplicationName = args.ApplicationName;
                            Log.Debug().WriteLine("TargetApplicationChosen: {0}", args.ApplicationName);
                        };
                        var filename    = FilenameHelper.GetFilename(OutputFormats.png, captureDetails);
                        var storageFile = await StorageFile.CreateStreamedFileAsync(filename, async streamedFileDataRequest =>
                        {
                            shareInfo.IsDeferredFileCreated = true;
                            // Information on the "how" was found here: https://socialeboladev.wordpress.com/2013/03/15/how-to-use-createstreamedfileasync/
                            Log.Debug().WriteLine("Creating deferred file {0}", filename);
                            try
                            {
                                using (var deferredStream = streamedFileDataRequest.AsStreamForWrite())
                                {
                                    await imageStream.CopyToAsync(deferredStream).ConfigureAwait(false);
                                    await imageStream.FlushAsync().ConfigureAwait(false);
                                }
                                // Signal that the stream is ready
                                streamedFileDataRequest.Dispose();
                            }
                            catch (Exception)
                            {
                                streamedFileDataRequest.FailAndClose(StreamedFileFailureMode.Incomplete);
                            }
                        }, imageRandomAccessStreamReference).AsTask().ConfigureAwait(false);

                        dataTransferManagerHelper.DataTransferManager.DataRequested += (dataTransferManager, dataRequestedEventArgs) =>
                        {
                            var deferral = dataRequestedEventArgs.Request.GetDeferral();
                            try
                            {
                                shareInfo.IsDataRequested = true;
                                Log.Debug().WriteLine("DataRequested with operation {0}", dataRequestedEventArgs.Request.Data.RequestedOperation);
                                var dataPackage = dataRequestedEventArgs.Request.Data;
                                dataPackage.OperationCompleted += (dp, eventArgs) =>
                                {
                                    Log.Debug().WriteLine("OperationCompleted: {0}, shared with", eventArgs.Operation);
                                    shareInfo.CompletedWithOperation = eventArgs.Operation;
                                    shareInfo.AcceptedFormat         = eventArgs.AcceptedFormatId;

                                    shareInfo.ShareTask.TrySetResult(true);
                                };
                                dataPackage.Destroyed += (dp, o) =>
                                {
                                    shareInfo.IsDestroyed = true;
                                    Log.Debug().WriteLine("Destroyed");
                                    shareInfo.ShareTask.TrySetResult(true);
                                };
                                dataPackage.ShareCompleted += (dp, shareCompletedEventArgs) =>
                                {
                                    shareInfo.IsShareCompleted = true;
                                    Log.Debug().WriteLine("ShareCompleted");
                                    shareInfo.ShareTask.TrySetResult(true);
                                };
                                dataPackage.Properties.Title               = captureDetails.Title;
                                dataPackage.Properties.ApplicationName     = "Greenshot";
                                dataPackage.Properties.Description         = "Share a screenshot";
                                dataPackage.Properties.Thumbnail           = thumbnailRandomAccessStreamReference;
                                dataPackage.Properties.Square30x30Logo     = logoRandomAccessStreamReference;
                                dataPackage.Properties.LogoBackgroundColor = Color.FromArgb(0xff, 0x3d, 0x3d, 0x3d);
                                dataPackage.SetStorageItems(new[] { storageFile });
                                dataPackage.SetBitmap(imageRandomAccessStreamReference);
                            }
                            finally
                            {
                                deferral.Complete();
                                Log.Debug().WriteLine("Called deferral.Complete()");
                            }
                        };
                        dataTransferManagerHelper.ShowShareUi();
                        Log.Debug().WriteLine("ShowShareUi finished.");
                        await shareInfo.ShareTask.Task.ConfigureAwait(false);
                    }
        }
예제 #27
0
        /// <summary>
        /// Share the screenshot with a windows app
        /// </summary>
        /// <param name="manuallyInitiated"></param>
        /// <param name="surface"></param>
        /// <param name="captureDetails"></param>
        /// <returns>ExportInformation</returns>
        public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            var exportInformation = new ExportInformation(Designation, Description);

            try
            {
                var handle = PluginUtils.Host.GreenshotForm.Handle;

                var exportTarget = Task.Run(async() =>
                {
                    var taskCompletionSource = new TaskCompletionSource <string>();

                    using (var imageStream = new MemoryRandomAccessStream())
                        using (var logoStream = new MemoryRandomAccessStream())
                            using (var thumbnailStream = new MemoryRandomAccessStream())
                            {
                                var outputSettings = new SurfaceOutputSettings();
                                outputSettings.PreventGreenshotFormat();

                                // Create capture for export
                                ImageOutput.SaveToStream(surface, imageStream, outputSettings);
                                imageStream.Position = 0;
                                Log.Info("Created RandomAccessStreamReference for the image");
                                var imageRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(imageStream);
                                RandomAccessStreamReference thumbnailRandomAccessStreamReference;
                                RandomAccessStreamReference logoRandomAccessStreamReference;

                                // Create thumbnail
                                using (var tmpImageForThumbnail = surface.GetImageForExport())
                                {
                                    using (var thumbnail = ImageHelper.CreateThumbnail(tmpImageForThumbnail, 240, 160))
                                    {
                                        ImageOutput.SaveToStream(thumbnail, null, thumbnailStream, outputSettings);
                                        thumbnailStream.Position             = 0;
                                        thumbnailRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(thumbnailStream);
                                        Log.Info("Created RandomAccessStreamReference for the thumbnail");
                                    }
                                }
                                // Create logo
                                using (var logo = GreenshotResources.getGreenshotIcon().ToBitmap())
                                {
                                    using (var logoThumbnail = ImageHelper.CreateThumbnail(logo, 30, 30))
                                    {
                                        ImageOutput.SaveToStream(logoThumbnail, null, logoStream, outputSettings);
                                        logoStream.Position             = 0;
                                        logoRandomAccessStreamReference = RandomAccessStreamReference.CreateFromStream(logoStream);
                                        Log.Info("Created RandomAccessStreamReference for the logo");
                                    }
                                }
                                string applicationName        = null;
                                var dataTransferManagerHelper = new DataTransferManagerHelper(handle);
                                dataTransferManagerHelper.DataTransferManager.TargetApplicationChosen += (dtm, args) =>
                                {
                                    Log.InfoFormat("Trying to share with {0}", args.ApplicationName);
                                    applicationName = args.ApplicationName;
                                };
                                var filename    = FilenameHelper.GetFilename(OutputFormat.png, captureDetails);
                                var storageFile = await StorageFile.CreateStreamedFileAsync(filename, async streamedFileDataRequest =>
                                {
                                    // Information on how was found here: https://socialeboladev.wordpress.com/2013/03/15/how-to-use-createstreamedfileasync/
                                    Log.DebugFormat("Creating deferred file {0}", filename);
                                    try
                                    {
                                        using (var deferredStream = streamedFileDataRequest.AsStreamForWrite())
                                        {
                                            await imageStream.CopyToAsync(deferredStream).ConfigureAwait(false);
                                            await imageStream.FlushAsync().ConfigureAwait(false);
                                        }
                                        // Signal that the stream is ready
                                        streamedFileDataRequest.Dispose();
                                    }
                                    catch (Exception)
                                    {
                                        streamedFileDataRequest.FailAndClose(StreamedFileFailureMode.Incomplete);
                                    }
                                    // Signal transfer ready to the await down below
                                    taskCompletionSource.TrySetResult(applicationName);
                                }, imageRandomAccessStreamReference).AsTask().ConfigureAwait(false);

                                dataTransferManagerHelper.DataTransferManager.DataRequested += (sender, args) =>
                                {
                                    var deferral = args.Request.GetDeferral();
                                    args.Request.Data.OperationCompleted += (dp, eventArgs) =>
                                    {
                                        Log.DebugFormat("OperationCompleted: {0}, shared with", eventArgs.Operation);
                                        taskCompletionSource.TrySetResult(applicationName);
                                    };
                                    var dataPackage = args.Request.Data;
                                    dataPackage.Properties.Title               = captureDetails.Title;
                                    dataPackage.Properties.ApplicationName     = "Greenshot";
                                    dataPackage.Properties.Description         = "Share a screenshot";
                                    dataPackage.Properties.Thumbnail           = thumbnailRandomAccessStreamReference;
                                    dataPackage.Properties.Square30x30Logo     = logoRandomAccessStreamReference;
                                    dataPackage.Properties.LogoBackgroundColor = Color.FromArgb(0xff, 0x3d, 0x3d, 0x3d);
                                    dataPackage.SetStorageItems(new List <IStorageItem> {
                                        storageFile
                                    });
                                    dataPackage.SetBitmap(imageRandomAccessStreamReference);
                                    dataPackage.Destroyed += (dp, o) =>
                                    {
                                        Log.Debug("Destroyed.");
                                    };
                                    deferral.Complete();
                                };
                                dataTransferManagerHelper.ShowShareUi();
                                return(await taskCompletionSource.Task.ConfigureAwait(false));
                            }
                }).Result;
                if (string.IsNullOrWhiteSpace(exportTarget))
                {
                    exportInformation.ExportMade = false;
                }
                else
                {
                    exportInformation.ExportMade             = true;
                    exportInformation.DestinationDescription = exportTarget;
                }
            }
            catch (Exception ex)
            {
                exportInformation.ExportMade   = false;
                exportInformation.ErrorMessage = ex.Message;
            }

            ProcessExport(exportInformation, surface);
            return(exportInformation);
        }
예제 #28
0
 public EditorSettingsForm()
 {
     InitializeComponent();
     Icon = GreenshotResources.getGreenshotIcon();
     LoadSettings();
 }
예제 #29
0
        public void Initialize()
        {
            Log.Debug().WriteLine("Initializing MainForm.");
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            try
            {
                InitializeComponent();
                SetupBitmapScaleHandler();
            }
            catch (ArgumentException ex)
            {
                // Added for Bug #1420, this doesn't solve the issue but maybe the user can do something with it.
                ex.Data.Add("more information here", "http://support.microsoft.com/kb/943140");
                throw;
            }
            notifyIcon.Icon = GreenshotResources.GetGreenshotIcon();

            // Disable access to the settings, for feature #3521446
            contextmenu_settings.Visible = !_coreConfiguration.DisableSettings;

            UpdateUi();

            if (_coreConfiguration.DisableQuickSettings)
            {
                contextmenu_quicksettings.Visible = false;
            }
            else
            {
                // Do after all plugins & finding the destination, otherwise they are missing!
                InitializeQuickSettingsMenu();
            }

            // Set the Greenshot icon visibility depending on the configuration. (Added for feature #3521446)
            // Setting it to true this late prevents Problems with the context menu
            notifyIcon.Visible = !_coreConfiguration.HideTrayicon;

            // Check if it's the first time launch?
            if (_coreConfiguration.IsFirstLaunch)
            {
                _coreConfiguration.IsFirstLaunch = false;
                Log.Info().WriteLine("FirstLaunch: Created new configuration, showing balloon.");
                try
                {
                    notifyIcon.BalloonTipClicked += BalloonTipClicked;
                    notifyIcon.BalloonTipClosed  += BalloonTipClosed;
                    notifyIcon.ShowBalloonTip(2000, "Greenshot", string.Format(_greenshotLanguage.TooltipFirststart, HotkeyControl.GetLocalizedHotkeyStringFromString(_coreConfiguration.RegionHotkey)), ToolTipIcon.Info);
                }
                catch (Exception ex)
                {
                    Log.Warn().WriteLine(ex, "Exception while showing first launch: ");
                }
            }

            // Make Greenshot use less memory after startup
            if (_coreConfiguration.MinimizeWorkingSetSize)
            {
                PsApi.EmptyWorkingSet();
            }
        }
예제 #30
0
        /// <summary>
        ///     Show all the running instances
        /// </summary>
        private static void ShowInstances()
        {
            var instanceInfo = new StringBuilder();
            var index        = 1;

            foreach (var process in Process.GetProcesses())
            {
                try
                {
                    if (process.ProcessName.ToLowerInvariant().Contains("greenshot"))
                    {
                        instanceInfo.AppendFormat("{0} : {1} (pid {2})", index++, Kernel32Api.GetProcessPath(process.Id), process.Id);
                        instanceInfo.Append(Environment.NewLine);
                    }
                }
                catch (Exception)
                {
                    //Log.Debug().WriteLine(ex);
                }
                process.Dispose();
            }

            // Placehold for the Extension
            IGreenshotLanguage language = null;

            // A dirty fix to make sure the messagebox is visible as a Greenshot window on the taskbar
            using (var multiInstanceForm = new Form
            {
                Icon = GreenshotResources.GetGreenshotIcon(),
                ShowInTaskbar = true,
                MaximizeBox = false,
                MinimizeBox = false,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Location = new Point(int.MinValue, int.MinValue),
                Text = language.TranslationOrDefault(l => l.Error),
                AutoSize = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
                StartPosition = FormStartPosition.CenterScreen
            })
            {
                var flowLayoutPanel = new FlowLayoutPanel
                {
                    AutoScroll    = true,
                    FlowDirection = System.Windows.Forms.FlowDirection.TopDown,
                    WrapContents  = false,
                    AutoSize      = true,
                    AutoSizeMode  = AutoSizeMode.GrowAndShrink
                };
                var internalFlowLayoutPanel = new FlowLayoutPanel
                {
                    AutoScroll    = true,
                    FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight,
                    WrapContents  = false,
                    AutoSize      = true,
                    AutoSizeMode  = AutoSizeMode.GrowAndShrink
                };
                var pictureBox = new PictureBox
                {
                    Dock     = DockStyle.Left,
                    Image    = SystemIcons.Error.ToBitmap(),
                    SizeMode = PictureBoxSizeMode.AutoSize
                };
                internalFlowLayoutPanel.Controls.Add(pictureBox);
                var textbox = new Label
                {
                    Text     = language.TranslationOrDefault(l => l.ErrorMultipleinstances) + Environment.NewLine + instanceInfo,
                    AutoSize = true
                };
                internalFlowLayoutPanel.Controls.Add(textbox);
                flowLayoutPanel.Controls.Add(internalFlowLayoutPanel);
                var cancelButton = new Button
                {
                    Text   = language.TranslationOrDefault(l => l.BugreportCancel),
                    Dock   = DockStyle.Bottom,
                    Height = 20
                };
                flowLayoutPanel.Controls.Add(cancelButton);
                multiInstanceForm.Controls.Add(flowLayoutPanel);

                multiInstanceForm.CancelButton = cancelButton;

                multiInstanceForm.ShowDialog();
            }
        }