コード例 #1
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);
            }
        }
コード例 #2
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();
            }
        }