public frmLightCurveSettings(TangraConfig.LightCurvesDisplaySettings displaySettings, frmLightCurve frmLightCurve) { InitializeComponent(); m_frmLightCurve = frmLightCurve; m_DisplaySettings = displaySettings; m_DontApplySettingsBack = true; try { cpBackground.SelectedColor = m_DisplaySettings.BackgroundColor; cpLabels.SelectedColor = m_DisplaySettings.LabelsColor; cpGrid.SelectedColor = m_DisplaySettings.GridLinesColor; cbxColorScheme.SelectedIndex = (int)m_DisplaySettings.ColorScheme; cbxTangraTargetColors.Checked = m_DisplaySettings.UseTangraTargetColors; nudPointSize.Value = (decimal)m_DisplaySettings.DatapointSize; cbxDrawGrid.Checked = m_DisplaySettings.DrawGrid; cbxDrawInvalidDatapoints.Checked = m_DisplaySettings.DrawInvalidDataPoints; cpFocusArea.SelectedColor = m_DisplaySettings.SmallGraphFocusBackgroundBrushColor; cpSelectionCursor.SelectedColor = m_DisplaySettings.SelectionCursorColor; SetColorScheme(m_DisplaySettings.ColorScheme); } finally { m_DontApplySettingsBack = false; } }
public LightCurveController(Form mainFormView, VideoController videoController, AddinsController addinsController) { m_MainFormView = mainFormView; m_VideoController = videoController; m_AddinsController = addinsController; m_LightCurveForm = null; }
internal SingleMeasurement(frmLightCurve.BinnedValue binnedMeasurement, int targetNo, double binMiddleFrameNo, LCFile lcFile, bool dontIncludeTimes, int totalBins) { CurrFrameNo = (int)binnedMeasurement.BinNo; TargetNo = (byte)targetNo; Measurement = binnedMeasurement.IsSuccessfulReading ? (float)binnedMeasurement.AdjustedValue : INVALID_MEASUREMENT_VALUE; Background = binnedMeasurement.IsSuccessfulReading ? (float)binnedMeasurement.BackgroundValue : INVALID_MEASUREMENT_VALUE; string isCorrectedForInstrumentalDelay; if (dontIncludeTimes || /* If the times are entered by the user, only include the times for the first and last bin derived from the frame times enterred by the user*/ (!lcFile.Footer.ReductionContext.HasEmbeddedTimeStamps && binnedMeasurement.BinNo != 1 && binnedMeasurement.BinNo != totalBins)) { Timestamp = DateTime.MinValue; isCorrectedForInstrumentalDelay = null; } else { Timestamp = lcFile.GetTimeForFrame(binMiddleFrameNo, out isCorrectedForInstrumentalDelay); } IsCorrectedForInstrumentalDelay = lcFile.Header.InstrumentalDelayCorrectionsNotRequired() || !string.IsNullOrEmpty(isCorrectedForInstrumentalDelay); IsSuccessful = binnedMeasurement.IsSuccessfulReading; }
public void EnsureLightCurveFormClosed() { try { if (m_LightCurveForm != null && m_LightCurveForm.Visible) { // TODO: Ask if the user wants to save it /* Yes/No options only. No 'Cancel' option*/ // TODO: This should be moved to a different place and should be tested from all: (1) Closing Tangra's main form, (2) Closing LightCurve form, (3) Switching to a different operation m_LightCurveForm.CloseFormDontSendMessage(); } } finally { m_LightCurveForm = null; } }
internal void EnsureLightCurveForm() { m_LightCurveForm = new frmLightCurve(this, m_AddinsController); m_LightCurveForm.Show(m_MainFormView); m_LightCurveForm.Update(); }
public void OpenLcFile(string fileName) { var fi = new FileInfo(fileName); double expectedMemoryMbNeeded = 500 /* For Tangra to operate*/ + 20*fi.Length/(1024*1024) /* For the .lc file to be unpacked and loaded in memory */; double availableMemoryMb = CrossPlaform.GetAvailableMemoryInMegabytes(); if (expectedMemoryMbNeeded > availableMemoryMb) { if (MessageBox.Show( m_MainFormView, string.Format("It appears that you may be running in a low memory conditions and opening this file will require at least {0}Gb of free memory. Do you wish to continue?", (Math.Ceiling(expectedMemoryMbNeeded/512.0)/2).ToString("0.0")), "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } m_MainFormView.Cursor = Cursors.WaitCursor; LCFile lcFile = null; try { m_MainFormView.Update(); lcFile = LCFile.Load(fileName, m_VideoController); if (lcFile != null) { ReduceLightCurveOperation operation = (ReduceLightCurveOperation)m_VideoController.SetOperation<ReduceLightCurveOperation>(this, false); operation.SetLCFile(lcFile); string videoFile = GetVideoFileMatchingLcFile(lcFile, fileName); if (!string.IsNullOrEmpty(videoFile) && File.Exists(videoFile)) { if (m_VideoController.OpenVideoFile(videoFile, new TangraOpenFileArgs { FrameRate = lcFile.Header.FramesPerSecond, BitPix = lcFile.Footer.DataBitPix, SerTiming = lcFile.Header.SerTimingType })) { TangraContext.Current.CanPlayVideo = false; m_VideoController.UpdateViews(); } } else { // NOTE: No video file found, just show the saved averaged frame bool oldCanProcessLightCurvePixels = TangraContext.Current.CanProcessLightCurvePixels; TangraContext.Current.Reset(); TangraContext.Current.CanProcessLightCurvePixels = oldCanProcessLightCurvePixels; if (lcFile.Footer.AveragedFrameBytes != null) { if (m_VideoController.SingleBitmapFile(lcFile)) { TangraContext.Current.CanPlayVideo = false; m_VideoController.UpdateViews(); PSFFit.SetDataRange(lcFile.Footer.DataBitPix, lcFile.Footer.DataAav16NormVal); } } TangraContext.Current.CanPlayVideo = false; TangraContext.Current.CanScrollFrames = false; m_VideoController.UpdateViews(); } m_Context = new LightCurveContext(lcFile); m_LightCurveForm = new frmLightCurve(this, m_AddinsController, lcFile, fileName); m_LightCurveForm.SetGeoLocation(m_VideoController.GeoLocation); m_LightCurveForm.Show(m_MainFormView); m_LightCurveForm.Update(); // TODO: Review the VideoController-LightCurveController-ReduceLightCurveOperation relation and how they are initialized // TODO: Provide a clean way of initializing the controller/operation state when opening an .lc file! operation.EnterViewLightCurveMode(lcFile, m_VideoController, m_VideoController.ControlerPanel); RegisterRecentFile(RecentFileType.LightCurve, fileName); if (!string.IsNullOrEmpty(m_VideoController.CurrentVideoFileType)) { // Move to the first frame in the light curve m_VideoController.MoveToFrame((int) lcFile.Header.MinFrame); } TangraContext.Current.FileName = Path.GetFileName(fileName); TangraContext.Current.FileFormat = m_lcFile.Header.SourceInfo; m_VideoController.UpdateViews(); } } catch (IOException ioex) { MessageBox.Show(ioex.Message, "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { m_MainFormView.Cursor = Cursors.Default; } }