Example #1
0
 // Capture full screen
 private void fullScreenToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _otherformopen = true;
     Hide();
     // Get the screen we're capturing
     CaptureControl.CaptureScreen = Screen.FromPoint(Cursor.Position);
     CaptureControl.CaptureFullScreen();
 }
Example #2
0
        // Capture from clipboard
        private void clipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsImage() && !Common.ImageFileInClipboard && !Common.ImageUrlInClipboard)
            {
                return;
            }

            _otherformopen = true;
            Hide();
            CaptureControl.GetFromClipboard();
        }
Example #3
0
        private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _onClick       = false;
            _otherformopen = true;
            Hide();
            _fSettings = new frmSettings();
            _fSettings.ShowDialog();

            pbSelection.Visible = false;
            CaptureControl.GetBackgroundImage();
            Show();
            RefreshAccountList();
            RefreshFolderList();
        }
Example #4
0
        private async Task ProcessCapturedImages()
        {
            // upload captured images if we're ready
            await CaptureControl.CheckStartUpload();

            if (!Client.taskCheckAccount.IsCompleted)
            {
                return;
            }

            // URLs to all uploaded images
            var allLinks = new List <string>();

            foreach (var image in CaptureControl.CapturedImages)
            {
                var link = Common.GetLink(image.Name);
                allLinks.Add(link);
            }

            // Copy image links (?)
            if (tmCopyLink.Checked)
            {
                var textToCopy = string.Join(Environment.NewLine, allLinks);
                Clipboard.SetText(textToCopy);
            }

            foreach (var image in CaptureControl.CapturedImages)
            {
                // todo: this is probably no longer necessary
                // Delete temp files
                if (!Profile.FromFileMenu)
                {
                    Log.Write(l.Info, $"Cleaning up temp image file: {image.LocalPath}");
                    File.Delete(image.LocalPath);
                }

                // Open image link in browser (?)
                if (tmOpenInBrowser.Checked)
                {
                    var link = Common.GetLink(image.Name);
                    Common.ViewInBrowser(link);
                }
            }

            // New version?
            await CheckUpdateAsync();

            // Time to go
            Common.KillProcess();
        }
Example #5
0
 // set the starting point of the Selection Box
 private void frmCapture_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
     {
         return;
     }
     // Get the screen we're capturing
     CaptureControl.CaptureScreen = Screen.FromPoint(Cursor.Position);
     CaptureControl.GetBackgroundImage();
     this.TransparencyKey = Color.White;
     _onClick             = true;
     // Get the click point relative to the screen we are capturing
     NativeClickPoint     = MousePosition.Substract(CaptureControl.CaptureScreen.Bounds.Location);
     SelectionPoint       = new Point(e.X, e.Y);
     pbSelection.Location = SelectionPoint;
 }
Example #6
0
        private void frmCapture_Load(object sender, EventArgs e)
        {
            //  Setup the forms
            _fAccount.Tag = this;

            CapturedImage.Link     = "";
            CapturedImage.Uploaded = false;

            // If Host/Username/Password are not set, call StartUpError, otherwise check the account
            if ((new[] { Common.Profile.Host, Common.Profile.Username, Common.Profile.Password }).Any(String.IsNullOrEmpty))
            {
                StartUpError();
            }
            else
            {
                Client.CheckAccount();
            }

            // Checks for previous instance of this app and kills it, if it finds it
            var tKillPrevInstances = new Thread(() =>
            {
                try
                {
                    string procname        = Process.GetCurrentProcess().ProcessName;
                    Process[] allprocesses = Process.GetProcessesByName(procname);
                    if (allprocesses.Length <= 0)
                    {
                        return;
                    }

                    foreach (Process p in allprocesses.Where(p => p.Id != Process.GetCurrentProcess().Id))
                    {
                        p.Kill();
                    }
                }
                catch { }
            });

            tKillPrevInstances.Start();

            RefreshAccountList();
            RefreshFolderList();

            _activeAccount = Settings.DefaultProfile;

            // If uploading a file, hide the form and start uploading
            if (Profile.FromFileMenu)
            {
                _otherformopen = true;
                Visible        = false;
                Hide();
                CaptureControl.CaptureFromArgs();
            }
            else
            {
                var width  = 0;
                var height = 0;
                var top    = 0;
                var left   = 0;

                foreach (var screen in Screen.AllScreens)
                {
                    width  += screen.Bounds.Width;
                    height += screen.Bounds.Height;

                    if (screen.WorkingArea.Top < top)
                    {
                        top = screen.WorkingArea.Top;
                    }

                    if (screen.WorkingArea.Left < left)
                    {
                        left = screen.WorkingArea.Left;
                    }
                }

                Size     = new Size(width, height);
                Location = new Point(left, top);
            }
        }
Example #7
0
        private void frmCapture_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                _onClick     = false;
                _donedrawing = true;
            }
            else if (e.Button == MouseButtons.Right)
            {
                clipboardToolStripMenuItem.Enabled = (Clipboard.ContainsImage() || Common.ImageFileInClipboard || Common.ImageUrlInClipboard);
            }

            if (_donedrawing)
            {
                _otherformopen = true;
                Hide();

                bool ValidRectangle = !(pbSelection.Size.Width == 0 && pbSelection.Size.Height == 0);
                if (_mouseMoved && ValidRectangle)
                {
                    if (pbSelection.Size.Width == 0 || pbSelection.Size.Height == 0)
                    {
                        string errorcase = (MousePosition.X == pbSelection.Location.X) ? "width" : "height";
                        string msg       = string.Format("Image {0} cannot be null", errorcase);
                        MessageBox.Show(null, msg, "upScreen", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Common.KillOrWait(true);
                        return;
                    }

                    // Calculate the final selected area
                    // Location should be relative to the screen we are capturing
                    var s_FinalPoint = MousePosition.Substract(CaptureControl.CaptureScreen.Bounds.Location);

                    var s_LeftX   = s_FinalPoint.X > NativeClickPoint.X ? NativeClickPoint.X : s_FinalPoint.X;
                    var s_RightX  = s_FinalPoint.X <= NativeClickPoint.X ? NativeClickPoint.X : s_FinalPoint.X;
                    var s_TopY    = s_FinalPoint.Y > NativeClickPoint.Y ? NativeClickPoint.Y : s_FinalPoint.Y;
                    var s_BottomY = s_FinalPoint.Y <= NativeClickPoint.Y ? NativeClickPoint.Y : s_FinalPoint.Y;

                    var s_Width  = s_RightX - s_LeftX;
                    var s_Height = s_BottomY - s_TopY;

                    // Capture the selected area
                    Rectangle area = new Rectangle(s_LeftX, s_TopY, s_Width, s_Height);
                    CaptureControl.CaptureArea(area);
                }
                else
                {
                    try
                    {
                        // when single-clicking over the taskbar, capture it. Otherwise, capture the window from the cursor point
                        if (NativeClickPoint.Y > CaptureControl.CaptureScreen.WorkingArea.Height)
                        {
                            Rectangle taskbar = new Rectangle(0, CaptureControl.CaptureScreen.WorkingArea.Height, CaptureControl.CaptureScreen.Bounds.Width, CaptureControl.CaptureScreen.Bounds.Height - CaptureControl.CaptureScreen.WorkingArea.Height);
                            CaptureControl.CaptureArea(taskbar);
                        }
                        else
                        {
                            CaptureControl.CaptureWindow(Cursor.Position);
                        }
                    }
                    catch
                    {
                        Common.KillOrWait(true);
                    }
                }
            }
        }
Example #8
0
        private async void frmCapture_Load(object sender, EventArgs e)
        {
            // Setup the forms
            _fAccount.Tag = this;

            // Checks for previous instance of this app and kills it, if it finds it
            var tKillPrevInstances = new Thread(() =>
            {
                try
                {
                    string procname        = Process.GetCurrentProcess().ProcessName;
                    Process[] allprocesses = Process.GetProcessesByName(procname);
                    if (allprocesses.Length <= 0)
                    {
                        return;
                    }

                    foreach (Process p in allprocesses.Where(p => p.Id != Process.GetCurrentProcess().Id))
                    {
                        p.Kill();
                    }
                }
                catch { }
            });

            tKillPrevInstances.Start();

            // If uploading a file, hide the form and start uploading
            if (Profile.FromFileMenu)
            {
                _otherformopen = true;
                CaptureControl.CaptureFromArgs();
            }
            else
            {
                var width  = 0;
                var height = 0;
                var top    = 0;
                var left   = 0;

                foreach (var screen in Screen.AllScreens)
                {
                    width  += screen.Bounds.Width;
                    height += screen.Bounds.Height;

                    if (screen.WorkingArea.Top < top)
                    {
                        top = screen.WorkingArea.Top;
                    }

                    if (screen.WorkingArea.Left < left)
                    {
                        left = screen.WorkingArea.Left;
                    }
                }

                Size     = new Size(width, height);
                Location = new Point(left, top);
            }

            // If Host/Username/Password are not set, call StartUpError,
            // otherwise check the account
            if (Common.Profile.IsNotSet)
            {
                StartUpError(false);

                // Refresh options in right-click menus
                RefreshMenuItems();
            }
            else
            {
                // Refresh options in right-click menus
                RefreshMenuItems();

                await CheckAccount();
            }
        }