Пример #1
0
        private void AnalyzeFolderInput_Click(object sender, EventArgs e)
        {
            if (!System.IO.Directory.Exists(FolderPathInput.Text))
            {
                ShowMessage($"Input folder does not exist: \"{FolderPathInput.Text}\"");
                return;
            }

            _WorkerInit(ref _WorkerUi);
            _WorkerUi.DoWork += _DoWorkAnalyzeFolder;
            _WorkerUi.RunWorkerAsync();
        }
Пример #2
0
        private void checkButton_Click(object sender, RoutedEventArgs e)
        {
            switch (bw.Status)
            {
            case WorkerStatus.Idle:
                stop = false;
                Globals.LogInfo(Components.ProxyManager, "Disabling the UI and starting the checker");
                checkButton.Content  = "ABORT";
                botsSlider.IsEnabled = false;
                bw.RunWorkerAsync();
                bw.Status = WorkerStatus.Running;
                break;

            case WorkerStatus.Running:
                stop = true;
                Globals.LogWarning(Components.ProxyManager, "Abort signal sent");
                checkButton.Content = "HARD ABORT";
                bw.Status           = WorkerStatus.Stopping;
                break;

            case WorkerStatus.Stopping:
                Globals.LogWarning(Components.ProxyManager, "Hard abort signal sent");
                bw.CancelAsync();
                break;
            }
        }
        private void startDebuggerButton_Click(object sender, RoutedEventArgs e)
        {
            switch (debugger.Status)
            {
            case WorkerStatus.Idle:
                if (vm.View == StackerView.Blocks)
                {
                    vm.LS.FromBlocks(vm.GetList());
                }
                else
                {
                    vm.LS.Script = loliScriptEditor.Text;
                }

                if (debuggerTabControl.SelectedIndex == 1)
                {
                    logRTB.Focus();
                }
                vm.ControlsEnabled = false;
                if (!OB.OBSettings.General.PersistDebuggerLog)
                {
                    logRTB.Clear();
                }
                dataRTB.Document.Blocks.Clear();

                if (!debugger.IsBusy)
                {
                    debugger.RunWorkerAsync();
                    OB.Logger.LogInfo(Components.Stacker, "Started the debugger");
                }
                else
                {
                    OB.Logger.LogError(Components.Stacker, "Cannot start the debugger (busy)");
                }

                startDebuggerButton.Content = "Abort";
                debugger.Status             = WorkerStatus.Running;
                break;

            case WorkerStatus.Running:
                if (debugger.IsBusy)
                {
                    debugger.CancelAsync();
                    OB.Logger.LogInfo(Components.Stacker, "Sent Cancellation Request to the debugger");
                }

                startDebuggerButton.Content = "Force";
                debugger.Status             = WorkerStatus.Stopping;
                break;

            case WorkerStatus.Stopping:
                debugger.Abort();
                OB.Logger.LogInfo(Components.Stacker, "Hard aborted the debugger");
                startDebuggerButton.Content = "Start";
                debugger.Status             = WorkerStatus.Idle;
                vm.ControlsEnabled          = true;
                break;
            }
        }
Пример #4
0
        private void init()
        {
            conn.ReceivedData        += new ReceivedEventHandler(DataReceive);
            autoSendingTimer.Elapsed += new ElapsedEventHandler(AutoSendingEvent);
            replyTimer.Elapsed       += new ElapsedEventHandler(ReplyTimeOutEvent);

            work.DoWork             += WorkProcess;                      // Select Update Job
            work.RunWorkerCompleted += WorkComplete;                     // Select Done Job
            work.RunWorkerAsync();                                       // Start Job
            work.WorkerSupportsCancellation = true;
        }
Пример #5
0
        private void btn_Start_Click(object sender, EventArgs e)
        {
            btn_Start.Text = "Stop Ping";
              btn_Start.Click -= btn_Start_Click;
              btn_Start.Click += btn_Stop_Click;
              tb_Result.Clear();

              bw = new AbortableBackgroundWorker();

              // this allows our worker to report progress during work
              bw.WorkerReportsProgress = true;

              // what to do in the background thread
              bw.DoWork += new DoWorkEventHandler(
              delegate(object o, DoWorkEventArgs args)
              {
            BackgroundWorker b = o as BackgroundWorker;

            // run ping() in an endless loop
            while (true)
            {
              b.ReportProgress(10, ping());
              Thread.Sleep(Convert.ToInt32(tb_Interval.Text));
            }

              });

              // what to do when progress changed (update the progress bar for example)
              bw.ProgressChanged += new ProgressChangedEventHandler(
              delegate(object o, ProgressChangedEventArgs args)
              {
            tb_Result.AppendText(string.Format("{0}", args.UserState));// = string.Format("{0}% Completed", args.ProgressPercentage);
            if (b_writeToFile)
              tw.Write(string.Format("{0}", args.UserState));
              });

              bw.RunWorkerAsync();
        }
Пример #6
0
        /// <summary>
        /// Initialize this Component
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            // Initialize
            if (Simulate == eSimulate.SimulateDontAsk)
            {
                throw new ForceSimulateException("Always Simulate");
            }

            Port = GetParent <RS232>();
            if (Port == null)
            {
                throw new ForceSimulateException("MEDAQLib needs an RS232 parent");
            }

            try
            {
                _iSensor = MEDAQLibDLL.CreateSensorInstance(MEDAQLibDLL.ME_SENSOR.SENSOR_ILD1402);
                if (_iSensor == 0)
                {
                    throw new Exception("CreateSensorInstance: Error occured, no sensor created");
                }

                lock (_lockCommands)
                {
                    Open();
                }

                SetupGetInfo();
                SetupCallback();

                // Write to controller
                OnMeasurementRate(MeasurementRate);
                SetAverageParameters();
                OnExtInputMode(ExtInputMode);
                _mmInput = this.FilterByTypeSingle <MillimeterInput>();
                if (MMInput == null)
                {
                    throw new ForceSimulateException("MEDAQLib needs a MDoubleInput");
                }

                OnChangedExternalTrigger(_mmInput.ExternalTrigger);
                OnChangedTriggerMode(MMInput.TriggerMode);
                OnOutputTime(MMInput.TriggerInterval);

                U.RegisterOnChanged(() => MMInput.TriggerMode, OnChangedTriggerMode);
                U.RegisterOnChanged(() => MMInput.ExternalTrigger, OnChangedExternalTrigger);
                U.RegisterOnChanged(() => MMInput.TriggerInterval, OnOutputTime);
                U.RegisterOnChanged(() => MeasurementRate, OnMeasurementRate);
                U.RegisterOnChanged(() => MedianAvg, OnMedianAvg);
                U.RegisterOnChanged(() => MovingCount, OnMovingCount);
                U.RegisterOnChanged(() => MedianChoice, OnMedianChoice);
                U.RegisterOnChanged(() => ExtInputMode, OnExtInputMode);
                _bw.RunWorkerAsync();
                Simulate = eSimulate.None;
            }
            catch (ForceSimulateException fsex)
            {
                throw fsex;
            }
            catch (Exception ex)
            {
                throw new ForceSimulateException(ex);
            }
        }
Пример #7
0
        private void sync_Start(Boolean updateSyncSchedule = true)
        {
            LogBox.Clear();

            if (Settings.Instance.UseGoogleCalendar == null ||
                Settings.Instance.UseGoogleCalendar.Id == null ||
                Settings.Instance.UseGoogleCalendar.Id == "") {
                MessageBox.Show("You need to select a Google Calendar first on the 'Settings' tab.");
                return;
            }
            //Check network availability
            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {
                Logboxout("There does not appear to be any network available! Sync aborted.", notifyBubble: true);
                return;
            }
            //Check if Outlook is Online
            try {
                if (OutlookCalendar.Instance.IOutlook.Offline() && Settings.Instance.AddAttendees) {
                    Logboxout("You have selected to sync attendees but Outlook is currently offline.");
                    Logboxout("Either put Outlook online or do not sync attendees.", notifyBubble: true);
                    return;
                }
            } catch (System.Exception ex) {
                Logboxout(ex.Message, notifyBubble: true);
                log.Error(ex.StackTrace);
                return;
            }
            GoogleCalendar.APIlimitReached_attendee = false;
            MainForm.Instance.syncNote(SyncNotes.QuotaExhaustedInfo, null, false);
            bSyncNow.Text = "Stop Sync";
            NotificationTray.UpdateItem("sync", "&Stop Sync");

            String cacheNextSync = lNextSyncVal.Text;
            lNextSyncVal.Text = "In progress...";

            DateTime SyncStarted = DateTime.Now;
            log.Info("Sync version: " + System.Windows.Forms.Application.ProductVersion);
            Logboxout("Sync started at " + SyncStarted.ToString());
            Logboxout("Syncing from " + Settings.Instance.SyncStart.ToShortDateString() +
                " to " + Settings.Instance.SyncEnd.ToShortDateString());
            Logboxout(Settings.Instance.SyncDirection.Name);
            Logboxout("--------------------------------------------------");

            if (Settings.Instance.OutlookPush) OutlookCalendar.Instance.DeregisterForPushSync();

            Boolean syncOk = false;
            int failedAttempts = 0;
            Social.TrackSync();
            GoogleCalendar.Instance.GetCalendarSettings();
            while (!syncOk) {
                // DJS - Suppress annoying MsgBox when we're offline
                if (failedAttempts > 0 &&
                    MessageBox.Show("The synchronisation failed - check the Sync tab for further details.\r\nDo you want to try again?", "Sync Failed",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.No)
                //if (failedAttempts > 0)
                {
                    bSyncNow.Text = "Start Sync";
                    NotificationTray.UpdateItem("sync", "&Sync Now");
                    break;
                }

                //Set up a separate thread for the sync to operate in. Keeps the UI responsive.
                bwSync = new AbortableBackgroundWorker();
                //Don't need thread to report back. The logbox is updated from the thread anyway.
                bwSync.WorkerReportsProgress = false;
                bwSync.WorkerSupportsCancellation = true;

                //Kick off the sync in the background thread
                bwSync.DoWork += new DoWorkEventHandler(
                    delegate(object o, DoWorkEventArgs args) {
                        BackgroundWorker b = o as BackgroundWorker;
                        try {
                            syncOk = synchronize();
                        } catch (System.Exception ex) {
                            MainForm.Instance.Logboxout("The following error was encountered during sync:-");
                            MainForm.Instance.Logboxout(ex.Message, notifyBubble: true);
                            log.Error(ex.StackTrace);
                            syncOk = false;
                        }
                    }
                );

                bwSync.RunWorkerAsync();
                while (bwSync != null && (bwSync.IsBusy || bwSync.CancellationPending)) {
                    System.Windows.Forms.Application.DoEvents();
                    System.Threading.Thread.Sleep(100);
                }
                try {
                    //Get Logbox text - this is a little bit dirty!
                    if (!syncOk && LogBox.Text.Contains("The RPC server is unavailable.")) {
                        Logboxout("Attempting to reconnect to Outlook...");
                        try { OutlookCalendar.Instance.Reset(); } catch { }
                    }
                } finally {
                    failedAttempts += !syncOk ? 1 : 0;
                }
            }
            Settings.Instance.CompletedSyncs += syncOk ? 1 : 0;
            bSyncNow.Text = "Start Sync";
            NotificationTray.UpdateItem("sync", "&Sync Now");

            Logboxout(syncOk ? "Sync finished with success!" : "Operation aborted after " + failedAttempts + " failed attempts!");

            if (Settings.Instance.OutlookPush) OutlookCalendar.Instance.RegisterForPushSync();

            lLastSyncVal.Text = SyncStarted.ToLongDateString() + " - " + SyncStarted.ToLongTimeString();
            Settings.Instance.LastSyncDate = SyncStarted;
            if (!updateSyncSchedule) {
                lNextSyncVal.Text = cacheNextSync;
            } else {
                if (syncOk) {
                    OgcsTimer.LastSyncDate = SyncStarted;
                    OgcsTimer.SetNextSync();
                } else {
                    if (Settings.Instance.SyncInterval != 0) {
                        Logboxout("Another sync has been scheduled to automatically run in 5 minutes time.");
                        OgcsTimer.SetNextSync(5, fromNow: true);
                    }
                }
            }
            bSyncNow.Enabled = true;
            if (OutlookCalendar.Instance.OgcsPushTimer != null)
                OutlookCalendar.Instance.OgcsPushTimer.ItemsQueued = 0; //Reset Push flag regardless of success (don't want it trying every 2 mins)

            checkSyncMilestone(); // DJS - annoying MsgBox ahead!
        }
Пример #8
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                if (_isWorking == false)
                {
                    if (string.IsNullOrEmpty(txtInputDirectory.Text) || string.IsNullOrEmpty(txtOutputDirectory.Text))
                    {
                        MessageBox.Show(@"Input and Output Directories Are Required.", @"CR2 To JPG", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (!Directory.Exists(txtInputDirectory.Text) || !Directory.Exists(txtOutputDirectory.Text))
                    {
                        MessageBox.Show(@"One or more directories are invalid or don't exist", @"CR2 To JPG", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    SetFormWorking(true);

                    pbProgress.Value = 0;

                    string[] arrFiles;

                    if (Settings.Subfolders)
                    {
                        arrFiles = Directory.GetFiles(txtInputDirectory.Text, "*.CR2", SearchOption.AllDirectories);
                        if (Settings.ProcessJpeg)
                        {
                            arrFiles = arrFiles.Concat(Directory.GetFiles(txtInputDirectory.Text, "*.JPG")).ToArray();
                        }
                    }
                    else
                    {
                        arrFiles = Directory.GetFiles(txtInputDirectory.Text, "*.CR2");
                        if (Settings.ProcessJpeg)
                        {
                            arrFiles = arrFiles.Concat(Directory.GetFiles(txtInputDirectory.Text, "*.JPG")).ToArray();
                        }
                    }

                    var converterOptions = new ConverterOptions
                    {
                        Files           = arrFiles,
                        OutputDirectory = txtOutputDirectory.Text,
                        Watermark       = WmContext
                    };

                    //MessageBox.Show(converterOptions.Files.Length.ToString());

                    pbProgress.Maximum = converterOptions.Files.Length;

                    BwConverter.RunWorkerAsync(converterOptions);

                    lblStatusValue.Text = @"Converting...0% (0/" + pbProgress.Maximum + @") - " + Settings.ImageProcessor;
                }
                else
                {
                    BwConverter.Abort();
                    _isWorking       = false;
                    pbProgress.Value = pbProgress.Maximum;
                    SetFormWorking(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), @"Error whilst converting", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (BwConverter.IsBusy)
                {
                    BwConverter.Abort();
                }
            }
        }
Пример #9
0
 private void RunManual_OnClick(object sender, RoutedEventArgs e)
 {
     bw = new AbortableBackgroundWorker();
     bw.DoWork += BackgroundMakeManual;
     bw.RunWorkerCompleted += bw_RunWorkerCompleted;
     Progress.Visibility = Visibility.Visible;
     ConfigBox.IsEnabled = false;
     AbortButton.Visibility = Visibility.Visible;
     bw.RunWorkerAsync();
 }
Пример #10
0
 public void Start()
 {
     //Start the bot
     botWorker.RunWorkerAsync();
 }
Пример #11
0
        private void startStopButton_Click(object sender, RoutedEventArgs e) {
            if (worker != null && worker.IsBusy) {
                Trace.WriteLine("Aborting...");
                worker.Abort();
                return;
            }

            var p = new Parameters {
                InputPath = inputPathTextBox.Text,
                OutputPath = outputPathTextBox.Text,
                ExtractTracks = (bool)extractTracksCheckBox.IsChecked,
                PreserveChapters = (bool)preserveChaptersCheckBox.IsChecked
            };

            p.Titles.AddRange(SelectedTitles);
            p.Tracks.AddRange(Tracks.Where(x => x.IsUsed));

            using (worker = new AbortableBackgroundWorker()) {
                worker.DoWork += (s, args) => {
                    var xin1Generator = new Xin1Generator.Xin1Generator(p);
                    xin1Generator.GenerateAll();
                };
                worker.RunWorkerCompleted += (s, args) => {
                    if (args.Error != null)
                        Trace.WriteLine(string.Format(
                            Xin1Generator.Properties.Resources.ErrorMessage,
                            args.Error.Message));
                    else if (args.Cancelled)
                        Trace.WriteLine("Aborted");
                    else
                        Trace.WriteLine("Completed");

                    UpdateStartStopButton();
                };
                worker.RunWorkerAsync();
            }

            UpdateStartStopButton();
        }