Example #1
0
        private void Contextmenu_captureiefromlist_Click(object sender, EventArgs e)
        {
            if (!_coreConfiguration.IECapture)
            {
                Log.Info().WriteLine("IE Capture is disabled.");
                return;
            }
            var clickedItem = (ToolStripMenuItem)sender;
            var tabData     = (KeyValuePair <IInteropWindow, int>)clickedItem.Tag;

            BeginInvoke((MethodInvoker) delegate
            {
                var ieWindowToCapture = tabData.Key;
                if (ieWindowToCapture != null && ieWindowToCapture.IsMinimized())
                {
                    ieWindowToCapture.Restore();
                }
                try
                {
                    IeCaptureHelper.ActivateIeTab(ieWindowToCapture, tabData.Value);
                }
                catch (Exception exception)
                {
                    Log.Error().WriteLine(exception);
                }
                try
                {
                    CaptureHelper.CaptureIe(false, ieWindowToCapture);
                }
                catch (Exception exception)
                {
                    Log.Error().WriteLine(exception);
                }
            });
        }
Example #2
0
        /// <summary>
        ///     Build a selectable list of IE tabs when we enter the menu item
        /// </summary>
        private void CaptureIeMenuDropDownOpening(object sender, EventArgs e)
        {
            if (!_coreConfiguration.IECapture)
            {
                return;
            }
            try
            {
                var tabs = IeCaptureHelper.GetBrowserTabs();
                contextmenu_captureiefromlist.DropDownItems.Clear();
                if (tabs.Count > 0)
                {
                    contextmenu_captureie.Enabled         = true;
                    contextmenu_captureiefromlist.Enabled = true;
                    var counter = new Dictionary <IInteropWindow, int>();

                    foreach (var tabData in tabs)
                    {
                        var title = tabData.Value;
                        if (title == null)
                        {
                            continue;
                        }
                        if (title.Length > _coreConfiguration.MaxMenuItemLength)
                        {
                            title = title.Substring(0, Math.Min(title.Length, _coreConfiguration.MaxMenuItemLength));
                        }
                        var captureIeTabItem = contextmenu_captureiefromlist.DropDownItems.Add(title);
                        var index            = counter.ContainsKey(tabData.Key) ? counter[tabData.Key] : 0;
                        captureIeTabItem.Image  = tabData.Key.GetDisplayIcon();
                        captureIeTabItem.Tag    = new KeyValuePair <IInteropWindow, int>(tabData.Key, index++);
                        captureIeTabItem.Click += Contextmenu_captureiefromlist_Click;
                        contextmenu_captureiefromlist.DropDownItems.Add(captureIeTabItem);
                        if (counter.ContainsKey(tabData.Key))
                        {
                            counter[tabData.Key] = index;
                        }
                        else
                        {
                            counter.Add(tabData.Key, index);
                        }
                    }
                }
                else
                {
                    contextmenu_captureie.Enabled         = false;
                    contextmenu_captureiefromlist.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                Log.Warn().WriteLine("Problem accessing IE information: {0}", ex.Message);
            }
        }
Example #3
0
        private void ContextMenuOpening(object sender, CancelEventArgs e)
        {
            using (var clipboardAccessToken = ClipboardNative.Access())
            {
                contextmenu_captureclipboard.Enabled = clipboardAccessToken.HasImage();
            }
            contextmenu_capturelastregion.Enabled = _coreConfiguration.LastCapturedRegion != NativeRect.Empty;

            // IE context menu code
            try
            {
                if (_coreConfiguration.IECapture && IeCaptureHelper.IsIeRunning())
                {
                    contextmenu_captureie.Enabled         = true;
                    contextmenu_captureiefromlist.Enabled = true;
                }
                else
                {
                    contextmenu_captureie.Enabled         = false;
                    contextmenu_captureiefromlist.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                Log.Warn().WriteLine("Problem accessing IE information: {0}", ex.Message);
            }

            // Multi-Screen captures
            contextmenu_capturefullscreen.Click           -= CaptureFullScreenToolStripMenuItemClick;
            contextmenu_capturefullscreen.DropDownOpening -= MultiScreenDropDownOpening;
            contextmenu_capturefullscreen.DropDownClosed  -= MultiScreenDropDownClosing;
            if (Screen.AllScreens.Length > 1)
            {
                contextmenu_capturefullscreen.DropDownOpening += MultiScreenDropDownOpening;
                contextmenu_capturefullscreen.DropDownClosed  += MultiScreenDropDownClosing;
            }
            else
            {
                contextmenu_capturefullscreen.Click += CaptureFullScreenToolStripMenuItemClick;
            }

            var now = DateTime.Now;

            if (now.Month == 12 && now.Day > 19 && now.Day < 27 || // christmas
                now.Month == 3 && now.Day > 13 && now.Day < 21)
            {
                // birthday
                var resources = new ComponentResourceManager(typeof(MainForm));
                contextmenu_donate.Image = (Image)resources.GetObject("contextmenu_present.Image");
            }
        }