Ejemplo n.º 1
0
        private void GBGCreateAndModify_Load(Object sender, EventArgs e)
        {
            txbName.Text             = _internalNode.Name;
            lbRecords.DataSource     = InternalNode.Settings.Records;
            elbRecords               = new ExtendedListControl <RecordBase>(lbRecords);
            recordListChangedHandler = new ListChangedEventHandler(Records_ListChanged);

            lbRecords.DisplayMember = "Display";
            setDefaultTitle();

            InternalNode.Settings.Records.ListChanged += recordListChangedHandler;
            InternalNode.Settings.Records.ResetBindings();
        }
Ejemplo n.º 2
0
        void profileController_ProfileControllerAction(Object sender, ProfileControllerActionEventArgs e)
        {
            if (e.Profile != null)
            {
                switch (e.Action)
                {
                case ProfileControllerAction.AlreadyLoaded:
                    WriteLogLine("ERROR: Profile \"", e.Profile.Name, "\" has already been loaded and cannot be loaded twice.");
                    WriteLogLine("If you want to reload your profiles, restart the bot. ",
                                 "May make this process more user friendly in the future.");
                    break;

                case ProfileControllerAction.Save:
                    WriteLogLine("Successfully saved profile: \"", e.Profile.Name, "\"");
                    break;

                case ProfileControllerAction.Load:
                    WriteLogLine("Loaded new profile: \"", e.Profile.Name, "\"");
                    cbProfileSelector.SelectedIndex = -1;
                    cbProfileSelector.SelectedIndex = profileController.IndexOfProfileWithFilePath(e.Profile.FilePath);
                    break;

                case ProfileControllerAction.Activated:
                    WriteLogLine("Activated profile: \"", e.Profile.Name, "\"");
                    BindingList <GenericNode> nodeList = e.Profile.NodeList;

                    if (lbNodes.DataSource is BindingList <GenericNode> && lbNodes.DataSource != null)
                    {
                        ((BindingList <GenericNode>)lbNodes.DataSource).ListChanged -= lbNodesListChangedEventHandler;
                    }

                    lbNodes.DataSource = nodeList;

                    // Extend ListControl
                    elbNodes = new ExtendedListControl <GenericNode>(lbNodes);

                    nodeList.ListChanged += lbNodesListChangedEventHandler;

                    lblCurrentProfile.Text = e.Profile.ToString();
                    nodeList.ResetBindings();     // Trigger event initially
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private void GBGMain_Load(Object sender, EventArgs e)
        {
            ttUpdater.Interval = 500;
            ttUpdater.Tick    += new EventHandler((o, ev) =>
            {
                long mil = totalRunTime.ElapsedMilliseconds,
                seconds  = mil / 1000,
                minutes  = seconds / 60 % 60,
                hours    = minutes / 60,
                days     = hours / 24;

                lblCurrentRunTime.Text = "Approx. " + days + "d " + (hours % 24) + "h " + (minutes % 60) + "m " + (seconds % 60) + "s";
            });

            bgw.WorkerSupportsCancellation = true;
            bgw.WorkerReportsProgress      = true;
            bgw.DoWork             += new DoWorkEventHandler(RunBot_Work);
            bgw.ProgressChanged    += new ProgressChangedEventHandler(bgw_ProgressChanged);
            bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);

            Hotkey hkRunBot = new Hotkey(Keys.F12, false, true, true, false);

            hkRunBot.Pressed += delegate
            {
                if (btnStopBot.Enabled)
                {
                    StopBot();
                }
                else if (btnRunBot.Enabled)
                {
                    RunBot();
                }
            };

            hkRunBot.Register(this);

            Text += ASMVersion;

            WriteLogLine("Version: ", ASMVersion);
            WriteLogLine("Disclaimer: if you get caught, it's not my nor anyone else's problem. "
                         + "This understanding should be tacit. Deal with it (or don't use the "
                         + "program). By using this program you are agreeing to hold no one "
                         + "other than your cheating self responsible if anything goes wrong. "
                         + "Don't even attempt to contact me.");
            WriteLogLine("Oh, and you should probably consider disabling the UAC when running ",
                         "this bot, especially if you're encountering problems.");
            WriteLogLine("Finishing initialization...");
            ResetRunStatistics();

            long frequency      = Stopwatch.Frequency;
            long nanosecPerTick = (1000L * 1000L * 1000L) / frequency;

            WriteLogLine("**Timer frequency in ticks per second = ", frequency);
            WriteLogLine("*-*Duration stopwatch estimated to be accurate to within ",
                         nanosecPerTick, " nanoseconds on this system");

            // Load/Save dialogs
            saveFileDialog       = new SaveFileDialog();
            saveFileDialog.Title = "Choose Profile Location...";

            openFileDialog       = new OpenFileDialog();
            openFileDialog.Title = "Select Profile...";

            saveFileDialog.InitialDirectory = openFileDialog.InitialDirectory = profileController.DefaultSaveDirectory;
            saveFileDialog.DefaultExt       = openFileDialog.DefaultExt = Properties.Settings.Default.ProfileFileExtension;
            saveFileDialog.Filter           = openFileDialog.Filter = "profiles (*."
                                                                      + Properties.Settings.Default.ProfileFileExtension
                                                                      + ")|*."
                                                                      + Properties.Settings.Default.ProfileFileExtension
                                                                      + "|All files (*.*)|*.*";

            // Set up MouseTracker
            Timer mouseTrackerTimer = new Timer();

            mouseTrackerTimer.Interval = 200;
            mouseTrackerTimer.Tick    += new EventHandler(mouseTrackerTimer_Tick);

            // Set up events
            profileController.Profiles.ListChanged += new ListChangedEventHandler((o, ev) =>
            {
                if (profileController.Profiles.Count > 0)
                {
                    cbProfileSelector.Enabled = true;
                }
                else
                {
                    cbProfileSelector.Enabled = false;
                }
            });

            lbNodesListChangedEventHandler = new ListChangedEventHandler(nodeList_ListChanged);

            // ListControls
            cbProfileSelector.DataSource    = profileController.Profiles;
            lbNodes.DisplayMember           = "Display";
            cbProfileSelector.DisplayMember = "Display";

            // Load/Create the default profile
            profileController.ProfileControllerAction +=
                new ProfileController.ProfileControllerActionHandler(profileController_ProfileControllerAction);

            String errpath = "(unknown location)";

            mouseTrackerTimer.Enabled = true;

            try
            {
                EnableInitialControls();

                if (File.Exists(profileController.PathOfDefaultProfile))
                {
                    profileController.LoadProfile(errpath = profileController.PathOfDefaultProfile);
                }

                else
                {
                    NodeProfile profile =
                        new NodeProfile("default", profileController.DefaultSaveDirectory, new BindingList <GenericNode>());

                    errpath = profile.FilePath;
                    profileController.SaveProfile(profile);
                    profileController.LoadProfile(profile.FilePath);
                }

                SetCurrentAction("Idle (fully initialized)");
                elbNodes = new ExtendedListControl <GenericNode>(lbNodes);
                profileController.Profiles.ResetBindings();
            }

            catch (System.Runtime.Serialization.SerializationException ouch)
            {
                WriteLogLine(
                    "ERROR: Failed to mutate your default profile.",
                    "If you continue to see this error, please  ",
                    "delete the following file: \"", errpath, "\".");
                WriteLogLine("WARNING: Due to Profile functionality being unavailable for the duration ",
                             "of this session, program functionality has become limited.");

                menuStripMain.Enabled = false;
                SetCurrentAction("Idle (bad startup; check logs)");
            }
        }
Ejemplo n.º 4
0
        private void GBGCreateAndModify_Load(Object sender, EventArgs e)
        {
            txbName.Text = _internalNode.Name;
            lbRecords.DataSource = InternalNode.Settings.Records;
            elbRecords = new ExtendedListControl<RecordBase>(lbRecords);
            recordListChangedHandler = new ListChangedEventHandler(Records_ListChanged);

            lbRecords.DisplayMember = "Display";
            setDefaultTitle();

            InternalNode.Settings.Records.ListChanged += recordListChangedHandler;
            InternalNode.Settings.Records.ResetBindings();
        }
Ejemplo n.º 5
0
        void profileController_ProfileControllerAction(Object sender, ProfileControllerActionEventArgs e)
        {
            if(e.Profile != null)
            {
                switch(e.Action)
                {
                    case ProfileControllerAction.AlreadyLoaded:
                        WriteLogLine("ERROR: Profile \"", e.Profile.Name, "\" has already been loaded and cannot be loaded twice.");
                        WriteLogLine("If you want to reload your profiles, restart the bot. ",
                            "May make this process more user friendly in the future.");
                        break;

                    case ProfileControllerAction.Save:
                        WriteLogLine("Successfully saved profile: \"",  e.Profile.Name, "\"");
                        break;

                    case ProfileControllerAction.Load:
                        WriteLogLine("Loaded new profile: \"", e.Profile.Name, "\"");
                        cbProfileSelector.SelectedIndex = -1;
                        cbProfileSelector.SelectedIndex = profileController.IndexOfProfileWithFilePath(e.Profile.FilePath);
                        break;

                    case ProfileControllerAction.Activated:
                        WriteLogLine("Activated profile: \"", e.Profile.Name, "\"");
                        BindingList<GenericNode> nodeList = e.Profile.NodeList;

                        if(lbNodes.DataSource is BindingList<GenericNode> && lbNodes.DataSource != null)
                            ((BindingList<GenericNode>) lbNodes.DataSource).ListChanged -= lbNodesListChangedEventHandler;

                        lbNodes.DataSource = nodeList;

                        // Extend ListControl
                        elbNodes = new ExtendedListControl<GenericNode>(lbNodes);

                        nodeList.ListChanged += lbNodesListChangedEventHandler;

                        lblCurrentProfile.Text = e.Profile.ToString();
                        nodeList.ResetBindings(); // Trigger event initially
                        break;
                }
            }
        }
Ejemplo n.º 6
0
        private void GBGMain_Load(Object sender, EventArgs e)
        {
            ttUpdater.Interval = 500;
            ttUpdater.Tick += new EventHandler((o, ev) =>
            {
                long mil = totalRunTime.ElapsedMilliseconds,
                     seconds = mil / 1000,
                     minutes = seconds / 60 % 60,
                     hours = minutes / 60,
                     days = hours / 24;

                lblCurrentRunTime.Text = "Approx. " + days + "d " + (hours % 24) + "h " + (minutes % 60) + "m " + (seconds % 60) + "s";
            });

            bgw.WorkerSupportsCancellation = true;
            bgw.WorkerReportsProgress = true;
            bgw.DoWork += new DoWorkEventHandler(RunBot_Work);
            bgw.ProgressChanged += new ProgressChangedEventHandler(bgw_ProgressChanged);
            bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);

            Hotkey hkRunBot = new Hotkey(Keys.F12, false, true, true, false);

            hkRunBot.Pressed += delegate
            {
                if (btnStopBot.Enabled)
                    StopBot();
                else if (btnRunBot.Enabled)
                    RunBot();
            };

            hkRunBot.Register(this);

            Text += ASMVersion;

            WriteLogLine("Version: ", ASMVersion);
            WriteLogLine("Disclaimer: if you get caught, it's not my nor anyone else's problem. "
                         + "This understanding should be tacit. Deal with it (or don't use the "
                         + "program). By using this program you are agreeing to hold no one "
                         + "other than your cheating self responsible if anything goes wrong. "
                         + "Don't even attempt to contact me.");
            WriteLogLine("Oh, and you should probably consider disabling the UAC when running ",
                "this bot, especially if you're encountering problems.");
            WriteLogLine("Finishing initialization...");
            ResetRunStatistics();

            long frequency = Stopwatch.Frequency;
            long nanosecPerTick = (1000L * 1000L * 1000L) / frequency;
            WriteLogLine("**Timer frequency in ticks per second = ", frequency);
            WriteLogLine("*-*Duration stopwatch estimated to be accurate to within ",
                nanosecPerTick, " nanoseconds on this system");

            // Load/Save dialogs
            saveFileDialog = new SaveFileDialog();
            saveFileDialog.Title = "Choose Profile Location...";

            openFileDialog = new OpenFileDialog();
            openFileDialog.Title = "Select Profile...";

            saveFileDialog.InitialDirectory = openFileDialog.InitialDirectory = profileController.DefaultSaveDirectory;
            saveFileDialog.DefaultExt = openFileDialog.DefaultExt = Properties.Settings.Default.ProfileFileExtension;
            saveFileDialog.Filter = openFileDialog.Filter = "profiles (*."
                + Properties.Settings.Default.ProfileFileExtension
                + ")|*."
                + Properties.Settings.Default.ProfileFileExtension
                + "|All files (*.*)|*.*";

            // Set up MouseTracker
            Timer mouseTrackerTimer = new Timer();
            mouseTrackerTimer.Interval = 200;
            mouseTrackerTimer.Tick += new EventHandler(mouseTrackerTimer_Tick);

            // Set up events
            profileController.Profiles.ListChanged += new ListChangedEventHandler((o, ev) =>
            {
                if(profileController.Profiles.Count > 0)
                    cbProfileSelector.Enabled = true;
                else
                    cbProfileSelector.Enabled = false;
            });

            lbNodesListChangedEventHandler = new ListChangedEventHandler(nodeList_ListChanged);

            // ListControls
            cbProfileSelector.DataSource = profileController.Profiles;
            lbNodes.DisplayMember = "Display";
            cbProfileSelector.DisplayMember = "Display";

            // Load/Create the default profile
            profileController.ProfileControllerAction +=
                new ProfileController.ProfileControllerActionHandler(profileController_ProfileControllerAction);

            String errpath = "(unknown location)";
            mouseTrackerTimer.Enabled = true;

            try
            {
                EnableInitialControls();

                if(File.Exists(profileController.PathOfDefaultProfile))
                    profileController.LoadProfile(errpath = profileController.PathOfDefaultProfile);

                else
                {
                    NodeProfile profile =
                        new NodeProfile("default", profileController.DefaultSaveDirectory, new BindingList<GenericNode>());

                    errpath = profile.FilePath;
                    profileController.SaveProfile(profile);
                    profileController.LoadProfile(profile.FilePath);
                }

                SetCurrentAction("Idle (fully initialized)");
                elbNodes = new ExtendedListControl<GenericNode>(lbNodes);
                profileController.Profiles.ResetBindings();
            }

            catch(System.Runtime.Serialization.SerializationException ouch)
            {
                WriteLogLine(
                    "ERROR: Failed to mutate your default profile.",
                    "If you continue to see this error, please  ",
                    "delete the following file: \"", errpath, "\".");
                WriteLogLine("WARNING: Due to Profile functionality being unavailable for the duration ",
                    "of this session, program functionality has become limited.");

                menuStripMain.Enabled = false;
                SetCurrentAction("Idle (bad startup; check logs)");
            }
        }