Ejemplo n.º 1
0
        public MainForm(ClickStatus status, CustomizationParameters customParams)
        {
            fetcher = new Fetcher(this);

            fetcher.Show();

            InitializeComponent();
            this.ShowInTaskbar = false;
            this.clickStatus = status;
            this.customParams = customParams;

            ContextMenu trayMenu = new ContextMenu();
            trayMenu.MenuItems.Add("Exit", OnExit);
            this.trayIcon = new NotifyIcon();
            trayIcon.Text = "SmartClicker";
            trayIcon.Icon = this.Icon;
            // Add menu to tray icon and show it.
            trayIcon.ContextMenu = trayMenu;
            trayIcon.Visible = true;
            //buttons1 = new PictureBox[] { sleepClick, contextClick, leftClick, rightClick, doubleClick, clickAndDrag, CustomForm, help };
            this.buttons = new PictureBox[] {sleepClick, contextClick, leftClick, rightClick , doubleClick, clickAndDrag, help};
            foreach (PictureBox mode in buttons)
            {
                if (!(mode.Name == "help"))
                {
                    mode.MouseHover += new EventHandler(pictureBox_MouseHover);
                }
            }
            // need to add a mouse hover handler to the config and help button too
            CustomForm.MouseHover += new EventHandler(CustomForm_MouseHover);
            //CustomForm.MouseHover += new EventHandler(pictureBox_MouseHover);
            help.MouseHover += new EventHandler(help_MouseHover);

            ModeMapping = new Dictionary<PictureBox, ProgramMode>()
            {
                {leftClick, ProgramMode.leftClick},
                {rightClick, ProgramMode.rightClick},
                {doubleClick, ProgramMode.doubleClick},
                {contextClick, ProgramMode.contextClick},
                {clickAndDrag, ProgramMode.clickAndDrag},
                {sleepClick, ProgramMode.sleepClick}
            };

            inverseModeMapping = new Dictionary<ProgramMode, PictureBox>();
            foreach(PictureBox box in ModeMapping.Keys)
            {
                inverseModeMapping.Add(ModeMapping[box], box);
            }

            // need to read from xml and redraw based on prefs
            this.redraw();

            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Text = String.Empty;
            this.StartPosition = FormStartPosition.Manual;
            this.Left = this.customParams.layoutValues.startLeft;
            this.Top = this.customParams.layoutValues.startTop;
            this.Width = this.customParams.layoutValues.startWidth;
            this.Height = this.customParams.layoutValues.startHeight;
            this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            setPictureBoxLock(contextClick);
        }