private void loaderWorker_SaveFile(object sender, System.ComponentModel.DoWorkEventArgs e) { Behaviors.Saving.SaverParams parameters; try { parameters = (Behaviors.Saving.SaverParams)e.Argument; } catch (InvalidCastException) { Logging.Logger.Log(Logging.SeverityGrades.Internal, "Invalid saver params"); throw; } _saver = SaverFactory.GetFactory(_file.Properties).Create(_file); _saver.Report += (s, pe) => ProgressReporter(pe.Percent); _saver.CancelJob += (s, ce) => ce.Cancel = _saver.Cancelled; _saver.ReportName += (s, tne) => ThreadHelper.ThreadSafeUpdateToolStrip<ToolStripStatusLabel>(_form.StatusLabel, lbl => { lbl.Text = tne.Name; }); float maxSampleValue = 0; try { if (parameters.OutputType != Behaviors.TileCreator.TileOutputType.Linear) { _cancellableAction = ((WorkerEventController)_creator); maxSampleValue = _creator.MaxValue; } _cancellableAction = _saver; _saver.Save(parameters, _creator.NormalizationFactor, maxSampleValue); } catch (OperationCanceledException) { e.Cancel = true; } if (_saver.Cancelled) { ClearWorkerData(() => File.Delete(parameters.Path)); } e.Result = parameters.Path; }
private void loaderWorker_InitFile(object sender, System.ComponentModel.DoWorkEventArgs e) { try { _properties = new Files.FileProperties((string)e.Argument); _header = Factories.Header.Abstract.HeaderFactory.GetFactory(_properties).Create(_properties.FilePath); _navi = Factories.NavigationContainer.Abstract.NavigationContainerFactory.GetFactory(_properties).Create(_properties, _header); _navi.Report += (s, pe) => ProgressReporter(pe.Percent); _navi.CancelJob += (s, ce) => ce.Cancel = _navi.Cancelled; _navi.ReportName += (s, tne) => ThreadHelper.ThreadSafeUpdateToolStrip<ToolStripStatusLabel>(_form.StatusLabel, lbl => { lbl.Text = tne.Name; }); _cancellableAction = _navi; _navi.GetNavigation(); } catch (OperationCanceledException) { e.Cancel = true; return; } _file = FileFactory.GetFactory(_properties).Create(_properties, _header, _navi); _ruler = new Behaviors.Ruler.RulerProxy(_file); _saver = SaverFactory.GetFactory(_properties).Create(_file); _searcher = Factories.NavigationSearcher.Abstract.PointFinderFactory.GetFactory(_file.Properties).Create(_file); _analyzer = new Behaviors.Analyzing.SampleAnalyzer(); _pointSelector = new Behaviors.PointSelector.PointSelector(); _areaSelector = new Behaviors.AreaSelector.AreaSelector(_file); _areaAligningWrapper = new Behaviors.AreaSelector.AreaSelectorsAlignerContainer(); if (_pointSharer != null) { _pointSharer.DataReceived -= (s, gde) => CrossAppDataReceivedCallback(s, gde); _pointSharer.Dispose(); } _pointSharer = Factories.PointSharer.Abstract.PointSharerFactory.GetFactory(_file.Properties).Create(_file, new Behaviors.CrossAppCommunication.UdpExchange(_settings.MulticastEp, Behaviors.CrossAppCommunication.CommunicationType.Multicast), System.Diagnostics.Process.GetCurrentProcess().Id); _pointSharer.DataReceived += (s, gde) => CrossAppDataReceivedCallback(s, gde); }
private void loaderWorker_NormalizeFile(object sender, System.ComponentModel.DoWorkEventArgs e) { _saver = SaverFactory.GetFactory(_file.Properties).Create(_file); _saver.Report += (s, pe) => ProgressReporter(pe.Percent); _saver.CancelJob += (s, ce) => ce.Cancel = _saver.Cancelled; _saver.ReportName += (s, tne) => ThreadHelper.ThreadSafeUpdateToolStrip<ToolStripStatusLabel>(_form.StatusLabel, lbl => { lbl.Text = tne.Name; }); _cancellableAction = _saver; var fileName = (string)e.Argument; try { var targetPoint = _pointSelector.First(); var normalizationCoef = targetPoint.Value / targetPoint.Rcs; _saver.SaveAsNormalized(fileName, normalizationCoef); } catch (OperationCanceledException) { e.Cancel = true; } if (_saver.Cancelled) { ClearWorkerData(() => File.Delete(fileName)); } e.Result = fileName; }