Example #1
0
        // Default values used if configuration is missing
        public static CustomizationParameters createDefault()
        {
            CustomizationParameters defaultParameters = new CustomizationParameters();

            defaultParameters.clickValues                       = new ClickCustomization();
            defaultParameters.clickValues.timeout               = 100;
            defaultParameters.clickValues.clickBoundingBox      = 25;
            defaultParameters.layoutValues                      = new LayoutCustomization();
            defaultParameters.layoutValues.hiddenIconNames      = new List <string>();
            defaultParameters.layoutValues.restartOnCrash       = true;
            defaultParameters.layoutValues.startOnStartup       = false;
            defaultParameters.layoutValues.autoHide             = false;
            defaultParameters.layoutValues.startHeight          = 462;
            defaultParameters.layoutValues.startWidth           = 100;
            defaultParameters.layoutValues.startLeft            = 0;
            defaultParameters.layoutValues.startTop             = 0;
            defaultParameters.contextValues                     = new ContextCustomization();
            defaultParameters.contextValues.clickAndDragBitmaps = new List <Bitmap>();
            defaultParameters.contextValues.doubleClickBitmaps  = new List <Bitmap>();
            defaultParameters.contextValues.rightClickBitmaps   = new List <Bitmap>();
            defaultParameters.contextValues.supportScrollBars   = true;
            defaultParameters.contextValues.supportTitleBars    = true;
            defaultParameters.contextValues.supportTabs         = true;
            defaultParameters.contextValues.compareCursors      = true;
            return(defaultParameters);
        }
Example #2
0
        // Used by Customization UI (CustomUI) to clone configurations without "committing"
        public CustomizationParameters copy()
        {
            CustomizationParameters copy = new CustomizationParameters();

            copy.clickValues   = this.clickValues.copy();
            copy.layoutValues  = this.layoutValues.copy();
            copy.contextValues = this.contextValues.copy();
            return(copy);
        }
Example #3
0
 public ClickDetector(ClickStatus status, CursorCapture capture, CustomizationParameters parameters, MainForm form)
 {
     this.status = status;
     this.capture = capture;
     this.parameters = parameters;
     this.form = form;
     this.lastClick = new cursorInTime(-50, -50, null);
     InitTimer();
     this.automator = new CUIAutomation();
 }
Example #4
0
 public ClickDetector(ClickStatus status, CursorCapture capture, CustomizationParameters parameters, MainForm form)
 {
     this.status     = status;
     this.capture    = capture;
     this.parameters = parameters;
     this.form       = form;
     this.lastClick  = new cursorInTime(-50, -50, null);
     InitTimer();
     this.automator      = new CUIAutomation();
     this.lastSentToBack = 0;
 }
Example #5
0
 public void saveCustomParams(CustomizationParameters currentParams)
 {
     XmlSerializer writer = new XmlSerializer(typeof(CustomizationParameters));
     try
     {
         System.IO.StreamWriter file = new System.IO.StreamWriter(@"SmartClickerConfig.xml");
         writer.Serialize(file, currentParams);
         file.Close();
     }
     catch (IOException e)
     {
         //File is already open by a different process, nothing we can do
     }
 }
Example #6
0
        public void saveCustomParams(CustomizationParameters currentParams)
        {
            XmlSerializer writer = new XmlSerializer(typeof(CustomizationParameters));

            try
            {
                System.IO.StreamWriter file = new System.IO.StreamWriter(@"SmartClickerConfig.xml");
                writer.Serialize(file, currentParams);
                file.Close();
            }
            catch (IOException e)
            {
                //File is already open by a different process, nothing we can do
            }
        }
Example #7
0
        public Fetcher(MainForm mainForm, CustomizationParameters parameters)
        {
            InitializeComponent();
            this.mainForm        = mainForm;
            this.ShowInTaskbar   = false;
            mainForm.Move       += new EventHandler(move_On_Main_Form);
            this.StartPosition   = FormStartPosition.Manual;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.ControlBox      = false;
            this.MinimumSize     = new Size(10, 10);
            this.Size            = new Size(parameters.clickValues.clickBoundingBox, parameters.clickValues.clickBoundingBox);
            this.Location        = new Point(this.mainForm.Location.X, this.mainForm.Location.Y - this.Size.Height);
            this.TopMost         = true;

            this.MouseMove += new MouseEventHandler(Fetcher_MouseMove);
        }
Example #8
0
        public CustomUI(CustomizationParameters customParams, MainForm mainForm)
        {
            InitializeComponent();
            this.customParams         = customParams;
            this.changedParams        = customParams.copy();
            this.mainform             = mainForm;
            this.timerText.Text       = (((double)changedParams.clickValues.timeout) / 100).ToString();
            this.boundingBoxText.Text = changedParams.clickValues.clickBoundingBox.ToString();
            CheckBox[] modes           = { displayClickDragMode, displayContextMode, displayDoubleMode, displayLeftMode, displayRightMode, displaySleepMode };
            CheckBox[] contextSettings = { contextCompareCursors, contextScrollBars, contextTabs, contextTitleBars };
            // Read several parameters from the customization classes
            this.startupBoot.Checked      = this.changedParams.layoutValues.startOnStartup;
            this.crashReboot.Checked      = this.changedParams.layoutValues.restartOnCrash;
            this.autoHide.Checked         = this.changedParams.layoutValues.autoHide;
            contextCompareCursors.Checked = this.changedParams.contextValues.compareCursors;
            contextScrollBars.Checked     = this.changedParams.contextValues.supportScrollBars;
            contextTabs.Checked           = this.changedParams.contextValues.supportTabs;
            contextTitleBars.Checked      = this.changedParams.contextValues.supportTitleBars;


            ModeToStringMapping = new Dictionary <CheckBox, string>()
            {
                { displayLeftMode, "leftClick" },
                { displayRightMode, "rightClick" },
                { displayDoubleMode, "doubleClick" },
                { displayContextMode, "contextClick" },
                { displayClickDragMode, "clickAndDrag" },
                { displaySleepMode, "sleepClick" },
            };
            StringToModeMapping = new Dictionary <string, CheckBox>();
            // Initialize checkboxes on first tab, load settings
            foreach (CheckBox key in ModeToStringMapping.Keys)
            {
                StringToModeMapping.Add(this.ModeToStringMapping[key], key);
            }
            foreach (CheckBox box in modes)
            {
                box.Checked         = true;
                box.CheckedChanged += new EventHandler(box_CheckedChanged);
            }
            foreach (string hidden in this.changedParams.layoutValues.hiddenIconNames.ToList <string>())
            {
                StringToModeMapping[hidden].Checked = false;
            }
        }
Example #9
0
        public CustomizationParameters loadFromXML()
        {
            // if the file exists, load from the xml
            if (File.Exists(@"SmartClickerConfig.xml"))
            {
                XmlSerializer           reader            = new XmlSerializer(typeof(CustomizationParameters));
                System.IO.StreamReader  file              = new System.IO.StreamReader(@"SmartClickerConfig.xml");
                CustomizationParameters currentParameters = (CustomizationParameters)reader.Deserialize(file);
                file.Close();
                return(currentParameters);
            }

            else
            {
                //make new instance with default values
                return(CustomizationParameters.createDefault());
            }
        }
Example #10
0
        public CustomUI(CustomizationParameters customParams, MainForm mainForm)
        {
            InitializeComponent();
            this.customParams = customParams;
            this.changedParams = customParams.copy();
            this.mainform = mainForm;
            this.timerText.Text = (((double) changedParams.clickValues.timeout)/ 100).ToString();
            this.boundingBoxText.Text = changedParams.clickValues.clickBoundingBox.ToString();
            CheckBox[] modes = { displayClickDragMode, displayContextMode, displayDoubleMode, displayLeftMode, displayRightMode, displaySleepMode };
            CheckBox[] contextSettings = { contextCompareCursors, contextScrollBars, contextTabs, contextTitleBars };
            this.startupBoot.Checked = this.changedParams.layoutValues.startOnStartup;
            this.crashReboot.Checked = this.changedParams.layoutValues.restartOnCrash;
            contextCompareCursors.Checked = this.changedParams.contextValues.compareCursors;
            contextScrollBars.Checked = this.changedParams.contextValues.supportScrollBars;
            contextTabs.Checked = this.changedParams.contextValues.supportTabs;
            contextTitleBars.Checked = this.changedParams.contextValues.supportTitleBars;

            ModeToStringMapping = new Dictionary<CheckBox, string>()
            {
                {displayLeftMode, "leftClick"},
                {displayRightMode, "rightClick"},
                {displayDoubleMode, "doubleClick"},
                {displayContextMode, "contextClick"},
                {displayClickDragMode, "clickAndDrag"},
                {displaySleepMode, "sleepClick"},
                {displayHelp, "help"},
            };
            StringToModeMapping = new Dictionary<string,CheckBox>();
            foreach (CheckBox key in ModeToStringMapping.Keys)
            {
                StringToModeMapping.Add(this.ModeToStringMapping[key], key);
            }
            foreach (CheckBox box in modes)
            {
                box.Checked = true;
                box.CheckedChanged += new EventHandler(box_CheckedChanged);
            }
            foreach (string hidden in this.changedParams.layoutValues.hiddenIconNames.ToList<string>())
            {
                StringToModeMapping[hidden].Checked = false;
            }
        }
 public static CustomizationParameters createDefault()
 {
     CustomizationParameters defaultParameters = new CustomizationParameters();
     defaultParameters.clickValues = new ClickCustomization();
     defaultParameters.clickValues.timeout = 100;
     defaultParameters.clickValues.clickBoundingBox = 25;
     defaultParameters.layoutValues = new LayoutCustomization();
     defaultParameters.layoutValues.hiddenIconNames = new List<string>();
     defaultParameters.layoutValues.restartOnCrash = true;
     defaultParameters.layoutValues.startOnStartup = false;
     defaultParameters.layoutValues.startHeight = 462;
     defaultParameters.layoutValues.startWidth = 100;
     defaultParameters.layoutValues.startLeft = Screen.PrimaryScreen.Bounds.Width - (100);;
     defaultParameters.layoutValues.startTop = Screen.PrimaryScreen.Bounds.Height / 2 - (465 / 2);;
     defaultParameters.contextValues = new ContextCustomization();
     defaultParameters.contextValues.clickAndDragBitmaps = new List<Bitmap>();
     defaultParameters.contextValues.doubleClickBitmaps = new List<Bitmap>();
     defaultParameters.contextValues.rightClickBitmaps = new List<Bitmap>();
     defaultParameters.contextValues.supportScrollBars = true;
     defaultParameters.contextValues.supportTitleBars = true;
     defaultParameters.contextValues.supportTabs = true;
     defaultParameters.contextValues.compareCursors = true;
     return defaultParameters;
 }
 public void merge(CustomizationParameters newCustomization)
 {
     this.clickValues = newCustomization.clickValues;
     this.layoutValues = newCustomization.layoutValues;
     this.contextValues = newCustomization.contextValues;
 }
 public CustomizationParameters copy()
 {
     CustomizationParameters copy = new CustomizationParameters();
     copy.clickValues = this.clickValues.copy();
     copy.layoutValues = this.layoutValues.copy();
     copy.contextValues = this.contextValues.copy();
     return copy;
 }
Example #14
0
 // Used by Customization UI to save new configurations while application is running
 public void merge(CustomizationParameters newCustomization)
 {
     this.clickValues   = newCustomization.clickValues;
     this.layoutValues  = newCustomization.layoutValues;
     this.contextValues = newCustomization.contextValues;
 }
Example #15
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);
        }
Example #16
0
        public MainForm(ClickStatus status, CustomizationParameters customParams)
        {
            // Initialize Fetcher icon, that pulls main form forward when moused over, and is always TopForm
            this.fetcher = new Fetcher(this, customParams);
            fetcher.Show();

            // Set starting variables
            InitializeComponent();
            this.clickStatus  = status;
            this.customParams = customParams;

            // Set Windows Application parameters and add tray icon
            this.ShowInTaskbar = false;
            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;

            // This holds every hide-able picturebox for different program modes
            this.buttons = new PictureBox[] { sleepClick, contextClick, leftClick, rightClick, doubleClick, clickAndDrag };
            foreach (PictureBox mode in buttons)
            {
                mode.MouseHover += new EventHandler(pictureBox_MouseHover);
            }

            // Need to add a mouse hover handler to the config button too
            CustomForm.MouseHover += new EventHandler(CustomForm_MouseHover);

            // Create a mapping from picture boxes to default program modes, so we can set them if they are selected
            ModeMapping = new Dictionary <PictureBox, ProgramMode>()
            {
                { leftClick, ProgramMode.leftClick },
                { rightClick, ProgramMode.rightClick },
                { doubleClick, ProgramMode.doubleClick },
                { contextClick, ProgramMode.contextClick },
                { clickAndDrag, ProgramMode.clickAndDrag },
                { sleepClick, ProgramMode.sleepClick }
            };

            // Create an inverse mapping so the detector can also change how pictureboxes look
            inverseModeMapping = new Dictionary <ProgramMode, PictureBox>();
            foreach (PictureBox box in ModeMapping.Keys)
            {
                inverseModeMapping.Add(ModeMapping[box], box);
            }

            // Redraw the MainForm to match XML configuration
            this.redraw();

            // Initialize the form to the XML/default parameters
            this.MaximizeBox   = false;
            this.MinimizeBox   = false;
            this.Text          = String.Empty;
            this.StartPosition = FormStartPosition.Manual;
            this.Left          = Math.Min(this.customParams.layoutValues.startLeft, Screen.PrimaryScreen.Bounds.Width - this.customParams.layoutValues.startWidth);
            this.Top           = Math.Max(this.customParams.layoutValues.startTop, this.customParams.clickValues.clickBoundingBox);
            this.Width         = this.customParams.layoutValues.startWidth;
            this.Height        = this.customParams.layoutValues.startHeight;

            // Add handler to ask "Are you sure?" dialog
            this.FormClosing += new FormClosingEventHandler(MainForm_FormClosing);
            setPictureBoxLock(contextClick);
        }