Ejemplo n.º 1
0
        public Hotkeys()
        {
            _windowId = new[] { GetHashCode(), GetHashCode() ^ 327 };
            WindowsApi.RegisterHotKey(Handle, _windowId[0], MOD_ALT, (int)Keys.PrintScreen);
            WindowsApi.RegisterHotKey(Handle, _windowId[1], MOD_ALT | MOD_CONTROL, (int)Keys.PrintScreen);

            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClose);
        }
Ejemplo n.º 2
0
        public Hotkeys()
        {
            _settings = new Settings();
            _windowId = new[] { GetHashCode(), GetHashCode() ^ 327 };
            WindowsApi.RegisterHotKey(Handle, _windowId[0], _settings.hotkeyModifier, _settings.hotkeyKey);
            //WindowsApi.RegisterHotKey(Handle, _windowId[1], MOD_ALT | MOD_CONTROL, (int)Keys.PrintScreen);

            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClose);
        }
Ejemplo n.º 3
0
        public MainForm()
        {
            DoubleBuffered = true;
            Icon           = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            InitializeComponent();

            if (WindowsApi.DwmIsCompositionEnabled(ref _dwmComposited) == 0)
            {
                if (_dwmComposited)
                {
                    ssButton.Location = new Point(ssButton.Location.X, 310);
                    var margin = new WindowsMargins(0, 0, 0, 35);
                    WindowsApi.DwmExtendFrameIntoClientArea(Handle, ref margin);
                }
            }

            _windowId = GetHashCode();
            WindowsApi.RegisterHotKey(Handle, _windowId, MOD_ALT,
                                      (int)Keys.PrintScreen);

            object value;

            _registryKey =
                Registry.CurrentUser.CreateSubKey(@"Software\AeroShot");
            if ((value = _registryKey.GetValue("LastPath")) != null &&
                value.GetType() == (typeof(string)))
            {
                if (((string)value).Substring(0, 1) == "*")
                {
                    folderTextBox.Text      = ((string)value).Substring(1);
                    clipboardButton.Checked = true;
                }
                else
                {
                    folderTextBox.Text = (string)value;
                    diskButton.Checked = true;
                }
            }
            else
            {
                folderTextBox.Text =
                    Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            }

            if ((value = _registryKey.GetValue("WindowSize")) != null &&
                value.GetType() == (typeof(long)))
            {
                var b = new byte[8];
                for (int i = 0; i < 8; i++)
                {
                    b[i] = (byte)(((long)value >> (i * 8)) & 0xff);
                }
                resizeCheckbox.Checked = (b[0] & 1) == 1;
                windowWidth.Value      = b[1] << 16 | b[2] << 8 | b[3];
                windowHeight.Value     = b[4] << 16 | b[5] << 8 | b[6];
            }

            if ((value = _registryKey.GetValue("Opaque")) != null &&
                value.GetType() == (typeof(long)))
            {
                var b = new byte[8];
                for (int i = 0; i < 8; i++)
                {
                    b[i] = (byte)(((long)value >> (i * 8)) & 0xff);
                }
                opaqueCheckbox.Checked = (b[0] & 1) == 1;
                if ((b[0] & 2) == 2)
                {
                    opaqueType.SelectedIndex = 0;
                }
                if ((b[0] & 4) == 4)
                {
                    opaqueType.SelectedIndex = 1;
                }

                checkerValue.Value = b[1] + 2;

                var hex = new StringBuilder(6);
                hex.AppendFormat("{0:X2}", b[2]);
                hex.AppendFormat("{0:X2}", b[3]);
                hex.AppendFormat("{0:X2}", b[4]);
                colourHexBox.Text = hex.ToString();
            }
            else
            {
                opaqueType.SelectedIndex = 0;
            }
            if ((value = _registryKey.GetValue("CapturePointer")) != null &&
                value.GetType() == (typeof(int)))
            {
                mouseCheckbox.Checked = ((int)value & 1) == 1;
            }

            groupBox1.Enabled = resizeCheckbox.Checked;
            groupBox2.Enabled = opaqueCheckbox.Checked;
            groupBox3.Enabled = mouseCheckbox.Checked;

            _ssButtonImage = Resources.capture;
        }