예제 #1
0
 public HotKeyArgs(Keys key, HotKey.HotKeyModifiers modifiers)
 {
     this.modifiers = modifiers;
     this.key = key;
 }
예제 #2
0
        public Main()
        {
            InitializeComponent();

            FATAL = false;

            Form f = new Form();
            f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            f.ShowInTaskbar = false;
            Owner = f;

            ni = new NotifyIcon(this);

            if (!CheckServer.Check())
            {
                Alert("Le serveur ne réponds pas..", "Oups..", ToolTipIcon.Warning);
                CHECK_IF_UP = new Thread(() => Check_FTP());
                CHECK_IF_UP.Start();
            }
            else
                ni.ChangeState(NotifyIcon.IconState.READY);

            LISTEN = new Thread(() => new DataTransfert(this).Listen_Data());
            LISTEN.Start();

            HOTKEYS = new HotKey(this);
            Set_Hokteys(true);
            HOTKEYS.HotKeyPress += (ob, ev) =>
            {
                if (ev.Key == CONFIG.XML.PRINT_CROP.Key && ev.Modifiers == CONFIG.XML.PRINT_CROP.Modifiers)
                    Show_Crop();
                else if (ev.Key == CONFIG.XML.PRINT_WINDOW.Key && CROP == null)
                    Upload_Image(GetScreen(ev.Modifiers == CONFIG.XML.PRINT_WINDOW.Modifiers));
                else if (ev.Key == CONFIG.XML.PRINT_FILE.Key && ev.Modifiers == CONFIG.XML.PRINT_FILE.Modifiers && CROP == null)
                    Load_Clipboard();
            };

            FormClosing += (ob, ev) =>
            {
                if (ev.CloseReason != CloseReason.WindowsShutDown)
                {
                    if (ev.CloseReason == CloseReason.UserClosing && !FATAL && CONFIG.XML.ASK_ON_CLOSE)
                    {
                        if (MessageBox.Show("Êtes-vous sûr de vouloir quitter l'application?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != System.Windows.Forms.DialogResult.Yes)
                        {
                            ev.Cancel = true;
                            return;
                        }
                    }

                    if (!FATAL)
                    {
                        CONFIG.XML.RESET = false;
                        CONFIG.XML.CRASHED = false;
                        CONFIG.Save_Values();
                    }

                    Set_Hokteys(false);

                    if (CHECK_IF_UP != null)
                        CHECK_IF_UP.Abort();
                    LISTEN.Abort();
                }

                System.Diagnostics.Process.GetCurrentProcess().Kill();
            };

            if (CONFIG.XML.FIRST_TIME)
            {
                Alert("Double-cliquez sur l'application pour afficher les options.", "ScreenShot", ToolTipIcon.Info);
                CONFIG.XML.FIRST_TIME = false;
            }
        }