示例#1
0
        /// <summary>
        ///     Loads a current workspace.
        /// </summary>
        private void LoadWorkspace(string path)
        {
            if (path == null)
            {
                return;
            }

            if (File.Exists(path))
            {
                ApplicationStatusMediator.SetStatus("Loading workspace");
                var reader = new MultiAlignWorkspaceReader();
                try
                {
                    CurrentWorkspace = reader.Read(path);
                }
                catch
                {
                    ApplicationStatusMediator.SetStatus(string.Format("Could not load the default workspace: {0}"));
                }
            }
            else
            {
                CurrentWorkspace = new MultiAlignWorkspace();
            }
        }
示例#2
0
        /// <summary>
        ///     Adds the  folder containing dataset specific elements
        /// </summary>
        public void AddFolderDelegate()
        {
            var supportedTypes = DatasetLoader.SupportedFileTypes;
            var extensions     = new List <string>();

            supportedTypes.ForEach(x => extensions.Add("*" + x.Extension));

            var option = ShouldSearchSubDirectories;

            if (DataFolderPath == null)
            {
                ApplicationStatusMediator.SetStatus("The directory specified does not exist.");
                return;
            }

            if (!Directory.Exists(DataFolderPath))
            {
                ApplicationStatusMediator.SetStatus("The directory specified does not exist.");
                return;
            }

            var datasetLoader = new DatasetLoader();
            var files         = datasetLoader.GetValidDatasets(DataFolderPath,
                                                               extensions,
                                                               option);

            AddDatasets(files);
        }
示例#3
0
        /// <summary>
        ///     Shows the new analysis setup
        /// </summary>
        private void ShowNewAnalysisSetup()
        {
            string message;
            var    canStart = StateModerator.CanPerformNewAnalysis(out message);

            Status = message;
            if (!canStart)
            {
                return;
            }

            ApplicationStatusMediator.SetStatus("Creating new analysis.");

            StateModerator.CurrentViewState     = ViewState.SetupAnalysisView;
            StateModerator.CurrentAnalysisState = AnalysisState.Setup;

            var config = new AnalysisConfig
            {
                Analysis     = new MultiAlignAnalysis(),
                AnalysisPath = MainDataDirectory,
                AnalysisName = MainDataName
            };

            config.Analysis.AnalysisType = AnalysisType.Full;
            config.Analysis.Options.AlignmentOptions.IsAlignmentBaselineAMasstagDB = false;

            AnalysisSetupViewModel = new AnalysisSetupViewModel(config);
            AnalysisSetupViewModel.AnalysisQuit  += AnalysisSetupViewModel_AnalysisQuit;
            AnalysisSetupViewModel.AnalysisStart += AnalysisSetupViewModel_AnalysisStart;
            AnalysisSetupViewModel.CurrentStep    = AnalysisSetupStep.DatasetSelection;
        }
示例#4
0
 private void OnStatus(string message)
 {
     ThreadSafeDispatcher.Invoke(() =>
     {
         ApplicationStatusMediator.SetStatus(message);
         Status = message;
     });
 }
示例#5
0
        /// <summary>
        ///     Adds datasets from a single file
        /// </summary>
        private void AddSingleFileDelegate()
        {
            var fileExists = File.Exists(SingleFilePath);

            if (fileExists)
            {
                var datasetLoader = new DatasetLoader();
                AddDatasets(datasetLoader.GetValidDatasets(new List <string> {
                    SingleFilePath
                }));
            }
            else
            {
                ApplicationStatusMediator.SetStatus("The input file does not exist.");
            }
        }
示例#6
0
        public void MoveNext()
        {
            // Validate the move
            var errorMessage = "";
            var isValid      = MultiAlignAnalysisValidator.IsStepValid(AnalysisConfiguration, CurrentStep, ref errorMessage);

            // Then display the error if exists...
            if (!isValid)
            {
                ApplicationStatusMediator.SetStatus(errorMessage);
                return;
            }
            ApplicationStatusMediator.SetStatus(errorMessage);

            // Then move the UI.
            switch (CurrentStep)
            {
            case AnalysisSetupStep.DatasetSelection:
                CurrentStep = AnalysisSetupStep.OptionsSelection;
                break;

            case AnalysisSetupStep.OptionsSelection:
                BaselineSelectionViewModel.UpdateDatasets();
                CurrentStep = AnalysisSetupStep.BaselineSelection;
                break;

            case AnalysisSetupStep.BaselineSelection:
                CurrentStep = AnalysisSetupStep.Naming;
                break;

            case AnalysisSetupStep.Naming:
                CurrentStep = AnalysisSetupStep.Started;
                if (AnalysisStart != null)
                {
                    AnalysisConfiguration.ParameterFile = AnalysisConfiguration.AnalysisName + ".xml";
                    AnalysisStart(this, null);
                }
                break;

            case AnalysisSetupStep.Started:
                break;

            default:
                break;
            }
        }
示例#7
0
        /// <summary>
        ///     Adds a MultiAlign file
        /// </summary>
        private void AddInputFileDelegate()
        {
            var fileExists = File.Exists(InputFilePath);

            if (fileExists)
            {
                // Read input files
                try
                {
                    var datasetLoader = new DatasetLoader();
                    var info          = MultiAlignFileInputReader.ReadInputFile(InputFilePath);
                    AddDatasets(datasetLoader.GetValidDatasets(info.Files, false));
                }
                catch
                {
                    ApplicationStatusMediator.SetStatus("Could not read the input file.  Check the file format.");
                }
            }
            else
            {
                ApplicationStatusMediator.SetStatus("The input file does not exist.");
            }
        }
示例#8
0
        private void AnalysisEnded(string reason, bool isCancelled, bool isComplete)
        {
            Action workAction = delegate
            {
                IsAnalysisRunning = false;
                ApplicationStatusMediator.SetStatus(reason);

                Controller.AnalysisComplete  -= Controller_AnalysisComplete;
                Controller.AnalysisError     -= Controller_AnalysisError;
                Controller.AnalysisCancelled -= Controller_AnalysisCancelled;

                if (isComplete)
                {
                    if (AnalysisComplete != null)
                    {
                        AnalysisComplete(this, new AnalysisStatusArgs(m_configuration));
                    }
                    return;
                }
                if (!isCancelled)
                {
                    if (AnalysisComplete != null)
                    {
                        AnalysisComplete(this, new AnalysisStatusArgs(m_configuration));
                    }
                }
                else
                {
                    if (AnalysisCancelled != null)
                    {
                        AnalysisCancelled(this, new AnalysisStatusArgs(m_configuration));
                    }
                }
            };

            ThreadSafeDispatcher.Invoke(workAction);
        }
示例#9
0
        public MainViewModel()
        {
            // Create the state moderation (between views)
            BuildStateModerator();

            MainDataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            MainDataName      = "analysis.db3";


            // Titles and Status
            var version = ApplicationUtility.GetEntryAssemblyData();

            Title = version;

            // Command Setup
            ShowAnalysisCommand = new BaseCommand(ShowAnalysis, BaseCommand.AlwaysPass);
            ShowStartCommand    = new BaseCommand(ShowStart, BaseCommand.AlwaysPass);

            // View Models

            var workSpacePath = ApplicationUtility.GetApplicationDataFolderPath("MultiAlign");

            workSpacePath           = Path.Combine(workSpacePath, Settings.Default.WorkspaceFile);
            GettingStartedViewModel = new GettingStartedViewModel(workSpacePath, StateModerator);

            GettingStartedViewModel.NewAnalysisStarted       += GettingStartedViewModel_NewAnalysisStarted;
            GettingStartedViewModel.ExistingAnalysisSelected += GettingStartedViewModel_ExistingAnalysisSelected;

            AnalysisRunningViewModel = new AnalysisRunningViewModel();
            AnalysisRunningViewModel.AnalysisCancelled += AnalysisRunningViewModel_AnalysisCancelled;
            AnalysisRunningViewModel.AnalysisComplete  += AnalysisRunningViewModel_AnalysisComplete;

            LoadingAnalysisViewModel = new AnalysisLoadingViewModel();
            LoadingAnalysisViewModel.AnalysisLoaded += LoadingAnalysisViewModel_AnalysisLoaded;

            ApplicationStatusMediator.SetStatus("Ready.");
        }
示例#10
0
        public FrameFocusVM(IProfileService profileService, ImagingMediator imagingMediator, ApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            Title             = "LblFrameNFocus";
            ImageGeometry     = (System.Windows.Media.GeometryGroup)System.Windows.Application.Current.Resources["FocusSVG"];
            CancelSnapCommand = new RelayCommand(CancelCaptureImage);
            SnapCommand       = new AsyncCommand <bool>(() => Snap(new Progress <ApplicationStatus>(p => Status = p)));

            this.imagingMediator           = imagingMediator;
            this.applicationStatusMediator = applicationStatusMediator;

            Zoom = 1;
            SnapExposureDuration = 1;
        }
示例#11
0
        public ApplicationVM(IProfileService profileService) : base(profileService)
        {
            try {
                if (NINA.Properties.Settings.Default.UpdateSettings)
                {
                    NINA.Properties.Settings.Default.Upgrade();
                    NINA.Properties.Settings.Default.UpdateSettings = false;
                    NINA.Properties.Settings.Default.Save();
                }

                Logger.SetLogLevel(profileService.ActiveProfile.ApplicationSettings.LogLevel);
                cameraMediator            = new CameraMediator();
                telescopeMediator         = new TelescopeMediator();
                focuserMediator           = new FocuserMediator();
                filterWheelMediator       = new FilterWheelMediator();
                rotatorMediator           = new RotatorMediator();
                flatDeviceMediator        = new FlatDeviceMediator();
                guiderMediator            = new GuiderMediator();
                imagingMediator           = new ImagingMediator();
                applicationStatusMediator = new ApplicationStatusMediator();

                switchMediator      = new SwitchMediator();
                weatherDataMediator = new WeatherDataMediator();

                SwitchVM = new SwitchVM(profileService, applicationStatusMediator, switchMediator);

                ExitCommand                      = new RelayCommand(ExitApplication);
                ClosingCommand                   = new RelayCommand(ClosingApplication);
                MinimizeWindowCommand            = new RelayCommand(MinimizeWindow);
                MaximizeWindowCommand            = new RelayCommand(MaximizeWindow);
                CheckProfileCommand              = new RelayCommand(LoadProfile);
                CheckUpdateCommand               = new AsyncCommand <bool>(() => CheckUpdate());
                OpenManualCommand                = new RelayCommand(OpenManual);
                CheckASCOMPlatformVersionCommand = new RelayCommand(CheckASCOMPlatformVersion);
                ConnectAllDevicesCommand         = new AsyncCommand <bool>(async() => {
                    var diag = MyMessageBox.MyMessageBox.Show(Locale.Loc.Instance["LblReconnectAll"], "", MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
                    if (diag == MessageBoxResult.OK)
                    {
                        return(await Task <bool> .Run(async() => {
                            var cam = cameraMediator.Connect();
                            var fw = filterWheelMediator.Connect();
                            var telescope = telescopeMediator.Connect();
                            var focuser = focuserMediator.Connect();
                            var rotator = rotatorMediator.Connect();
                            var flatdevice = flatDeviceMediator.Connect();
                            var guider = guiderMediator.Connect();
                            var weather = weatherDataMediator.Connect();
                            var swtch = switchMediator.Connect();
                            await Task.WhenAll(cam, fw, telescope, focuser, rotator, flatdevice, guider, weather, swtch);
                            return true;
                        }));
                    }
                    else
                    {
                        return(false);
                    }
                });
                DisconnectAllDevicesCommand = new RelayCommand((object o) => {
                    var diag = MyMessageBox.MyMessageBox.Show(Locale.Loc.Instance["LblDisconnectAll"], "", MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
                    if (diag == MessageBoxResult.OK)
                    {
                        DisconnectEquipment();
                    }
                });

                InitAvalonDockLayout();

                OptionsVM.PropertyChanged += OptionsVM_PropertyChanged;

                profileService.ProfileChanged += ProfileService_ProfileChanged;
            } catch (Exception e) {
                Logger.Error(e);
                throw e;
            }
        }