Пример #1
0
        public FormDrag(Addon addon)
        {
            InitializeComponent();

              this.addon = addon;
              Addon.SetShortcuts(false);

              ScreenBox.BackColor = Color.FromArgb(128, Color.SkyBlue);
              picWidth.BackColor = Color.FromArgb(0, Color.Black);
              picHeight.BackColor = Color.FromArgb(0, Color.Black);

              this.settings = new Settings("settings.txt");

              this.Screens = new Rectangle[Screen.AllScreens.Length];

              for (int i = 0; i < this.Screens.Length; i++)
            this.Screens[i] = Screen.AllScreens[i].Bounds;

              this.Width = this.Screens[0].Width;
              this.Height = this.Screens[0].Height;

              //TODO: Fix the whole multi-monitor issue. D:
              //      Maybe we could make some kind of "perfect" class for every kind of use? (GetFullScreenRectangle?) Shouldn't be /too/ hard.. right?

              // This works because WinForms has an internal way of setting the maximum width/height of a Control (Form)
              // Check it with ILSpy, System.Windows.Forms.Control.Width (set)
              for (int i = 0; i < Screen.AllScreens.Length; i++) {
            if (Screen.AllScreens[i].Bounds.Left < this.Left) {
              this.Width += this.Left - Screen.AllScreens[i].Bounds.Left;
              this.Left = Screen.AllScreens[i].Bounds.Left;
            } else
              this.Width += Screen.AllScreens[i].Bounds.Width;

            if (Screen.AllScreens[i].Bounds.Top < this.Top) {
              this.Height += this.Top - Screen.AllScreens[i].Bounds.Top;
              this.Top = Screen.AllScreens[i].Bounds.Top;
            } else
              this.Height += Screen.AllScreens[i].Bounds.Height;
              }

              this.Opacity = 0.5f;
              this.TopMost = true;

              this.beginImage = new Bitmap(this.Width, this.Height, PixelFormat.Format32bppRgb);
              Graphics beginGfx = Graphics.FromImage(this.beginImage);
              beginGfx.CopyFromScreen(this.Location, Point.Empty, this.Size);
              beginGfx.Dispose();

              this.bgForm = new Form();
              //TODO: Fix me, doesn't work too well on weird multi-monitor setups for some reason. :(
              /*this.bgForm.Left = this.Left;
              this.bgForm.Top = this.Top;
              this.bgForm.Width = this.Width;
              this.bgForm.Height = this.Height;
              this.bgForm.BackgroundImage = this.beginImage;
              this.bgForm.FormBorderStyle = FormBorderStyle.None;
              this.bgForm.Show();*/
        }
Пример #2
0
        public FormAnimation(FormDrag dragForm, Rectangle rect, Action <DragCallback> callback)
        {
            InitializeComponent();

            this.addon    = dragForm.addon;
            this.dragForm = dragForm;

            this.timerFrame.Interval = 1000 / dragForm.settings.GetInt("DragAnimFPS");

            rect.Width  -= rect.Width % 4;
            rect.Height -= rect.Height % 4;

            this.screenRectangle = rect;
            this.doneDragging    = callback;

            this.Left = this.screenRectangle.X;
            this.Top  = this.screenRectangle.Y + this.screenRectangle.Height + 14;

            if (this.Top + this.Height > Screen.PrimaryScreen.WorkingArea.Height)
            {
                this.Top      = this.screenRectangle.Y - this.Height - 14;
                spawnLocation = 1;
            }

            Point offset = screenOffset();

            this.Left += offset.X;
            this.Top  += offset.Y;

            this.animBox       = new FormAnimationBox(rect);
            this.animBox.Left += offset.X;
            this.animBox.Top  += offset.Y;
            this.animBox.Show();

            this.trackScale.Value = dragForm.settings.GetInt("DragAnimScale");

            if (dragForm.settings.GetBool("DragAnimAuto"))
            {
                buttonRecord_Click(null, null);
            }

            initialized = true;
        }
Пример #3
0
        public FormDrag(Addon addon)
        {
            InitializeComponent();

            this.addon = addon;
            Addon.SetShortcuts(false);

            this.settings = new Settings("settings.txt");

            this.Screens = new Rectangle[Screen.AllScreens.Length];

            for (int i = 0; i < this.Screens.Length; i++)
                this.Screens[i] = Screen.AllScreens[i].Bounds;

            this.Width = this.Screens[0].Width;
            this.Height = this.Screens[0].Height;

            // This works because WinForms has an internal way of setting the maximum width/height of a Control (Form)
            // Check it with ILSpy, System.Windows.Forms.Control.Width (set)
            for (int i = 0; i < Screen.AllScreens.Length; i++) {
                if (Screen.AllScreens[i].Bounds.Left < this.Left) {
                    this.Width += this.Left - Screen.AllScreens[i].Bounds.Left;
                    this.Left = Screen.AllScreens[i].Bounds.Left;
                } else
                    this.Width += Screen.AllScreens[i].Bounds.Width;

                if (Screen.AllScreens[i].Bounds.Top < this.Top) {
                    this.Height += this.Top - Screen.AllScreens[i].Bounds.Top;
                    this.Top = Screen.AllScreens[i].Bounds.Top;
                } else
                    this.Height += Screen.AllScreens[i].Bounds.Height;
            }

            this.Opacity = 0.5f;
            //this.TopMost = true;

            this.beginImage = new Bitmap(this.Width, this.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            Graphics beginGfx = Graphics.FromImage(this.beginImage);
            beginGfx.CopyFromScreen(this.Location, Point.Empty, this.Size);
            beginGfx.Dispose();
        }
Пример #4
0
        public FormAnimation(FormDrag dragForm, Rectangle rect, Action<DragCallback> callback)
        {
            InitializeComponent();

            this.addon = dragForm.addon;
            this.dragForm = dragForm;

            this.timerFrame.Interval = 1000 / dragForm.settings.GetInt("DragAnimFPS");

            rect.Width -= rect.Width % 4;
            rect.Height -= rect.Height % 4;

            this.screenRectangle = rect;
            this.doneDragging = callback;

            this.Left = this.screenRectangle.X;
            this.Top = this.screenRectangle.Y + this.screenRectangle.Height + 14;

            if(this.Top + this.Height > Screen.PrimaryScreen.WorkingArea.Height) {
                this.Top = this.screenRectangle.Y - this.Height - 14;
                spawnLocation = 1;
            }

            Point offset = screenOffset();
            this.Left += offset.X;
            this.Top += offset.Y;

            this.animBox = new FormAnimationBox(rect);
            this.animBox.Left += offset.X;
            this.animBox.Top += offset.Y;
            this.animBox.Show();

            this.trackScale.Value = dragForm.settings.GetInt("DragAnimScale");

            if(dragForm.settings.GetBool("DragAnimAuto")) {
                buttonRecord_Click(null, null);
            }

            initialized = true;
        }
Пример #5
0
 private void FormDrag_FormClosing(object sender, FormClosingEventArgs e)
 {
     Addon.SetShortcuts(true);
     this.beginImage.Dispose();
     this.Dispose();
 }
Пример #6
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                this.Close();
            }
            else if (keyData == Keys.P)
            {
                if (this.Selection.Width > 0 && this.Selection.Height > 0)
                {
                    Bitmap img = null;
                    try {
                        img = this.SelectionImage;
                    } catch { }

                    if (img != null)
                    {
                        if (this.settings.GetInt("DragEditor") == 0)
                        {
                            Addon.SetShortcuts(true);
                            new FormEditor(img, this.DoneDragging).Show();
                        }
                        else if (this.settings.GetInt("DragEditor") == 1)
                        {
                            string exePath = this.settings.GetString("DragExtraPath");

                            if (File.Exists(exePath))
                            {
                                string localTempPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Temp\\" + Addon.RandomString(16) + ".png";

                                MemoryStream ms = new MemoryStream();
                                img.Save(ms, ImageFormat.Png);
                                File.WriteAllBytes(localTempPath, ms.GetBuffer());

                                Process.Start(exePath, "\"" + localTempPath + "\"");
                            }
                        }

                        this.Close();

                        if (DoneDragging != null)
                        {
                            //TODO: What do with this? Could return NULL as image, but then every addon must respond
                            //      accordingly to that. Can also not be triggered, but could break some addon code
                            //      in the progress. Same goes with doing a DragCallback with DragCallbackType.None,
                            //      it could potentially break existing addon code. Decisions, decisions...
                        }
                    }
                }
            }
            else if (keyData == Keys.O)
            {
                if (this.AnimationAllowed)
                {
                    this.Close();
                    Addon.SetShortcuts(true);
                    new FormAnimation(this, this.Selection, this.DoneDragging).Show();
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }