/// <summary>
        /// Initializes a new instance of the <see cref="BudgetViewerViewModel"/> class
        /// </summary>
        /// <param name="iteration">The associated <see cref="Iteration"/></param>
        /// <param name="session">The session</param>
        /// <param name="thingDialogNavigationService">The thing Dialog Navigation Service</param>
        /// <param name="panelNavigationService">The <see cref="IPanelNavigationService"/></param>
        /// <param name="dialogNavigationService">The <see cref="IDialogNavigationService"/></param>
        /// <param name="pluginSettingsService">
        /// The <see cref="IPluginSettingsService"/> used to read and write plugin setting files.
        /// </param>
        public BudgetViewerViewModel(Iteration iteration, ISession session, IThingDialogNavigationService thingDialogNavigationService, IPanelNavigationService panelNavigationService, IDialogNavigationService dialogNavigationService, IPluginSettingsService pluginSettingsService)
            : base(iteration, session, thingDialogNavigationService, panelNavigationService, dialogNavigationService, pluginSettingsService)
        {
            this.openSaveFileDialogService = ServiceLocator.Current.GetInstance <IOpenSaveFileDialogService>();

            this.Caption = "Budget Viewer";
            this.ToolTip = string.Format("{0}\n{1}\n{2}", ((EngineeringModel)this.Thing.Container).EngineeringModelSetup.Name, this.Thing.IDalUri, this.Session.ActivePerson.Name);

            this.CurrentModel     = this.CurrentEngineeringModelSetup.Name;
            this.CurrentIteration = this.Thing.IterationSetup.IterationNumber;

            var currentDomainOfExpertise = this.Session.QuerySelectedDomainOfExpertise(this.Thing);

            this.DomainOfExpertise = currentDomainOfExpertise == null ? "None" : $"{currentDomainOfExpertise.Name} [{currentDomainOfExpertise.ShortName}]";

            this.OptionOverviewViewModel = new OptionOverviewViewModel();
            this.BudgetViewModels        = new ReactiveList <OptionBudgetViewModel>();

            this.OpenConfigCommand = ReactiveCommand.Create();
            this.OpenConfigCommand.Subscribe(_ => this.ExecuteOpenConfigCommand());

            var confObs = this.WhenAnyValue(x => x.BudgetConfig).Select(x => x != null);

            this.RefreshBudgetCommand = ReactiveCommand.Create(confObs);
            this.RefreshBudgetCommand.CanExecuteObservable.Subscribe(_ => this.ComputeBudgets());

            this.SaveConfigCommand = ReactiveCommand.Create(confObs);
            this.SaveConfigCommand.Subscribe(_ => this.ExecuteSaveConfigCommand());

            this.LoadConfigCommand = ReactiveCommand.Create();
            this.LoadConfigCommand.Subscribe(_ => this.ExecuteLoadConfigCommand());
            this.ComputeBudgets();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReqIfExportDialogViewModel"/> class
        /// </summary>
        /// <param name="sessions">The list of <see cref="ISession"/> available</param>
        /// <param name="iterations">The list of <see cref="Iteration"/> available</param>
        /// <param name="fileDialogService">The <see cref="IOpenSaveFileDialogService"/></param>
        /// <param name="pluginSettingsService">The <see cref="IPluginSettingsService"/></param>
        /// <param name="serializer"></param>
        public ReqIfImportDialogViewModel(IEnumerable <ISession> sessions, IEnumerable <Iteration> iterations, IOpenSaveFileDialogService fileDialogService, IPluginSettingsService pluginSettingsService, IReqIFDeSerializer serializer)
        {
            this.Sessions              = sessions?.ToList() ?? throw new ArgumentNullException(nameof(sessions));
            this.fileDialogService     = fileDialogService ?? throw new ArgumentNullException(nameof(fileDialogService));
            this.pluginSettingsService = pluginSettingsService;
            this.serializer            = serializer ?? throw new ArgumentNullException(nameof(serializer));

            this.Iterations = new ReactiveList <ReqIfExportIterationRowViewModel>();

            foreach (var iteration in iterations ?? throw new ArgumentNullException(nameof(iterations)))
            {
                this.Iterations.Add(new ReqIfExportIterationRowViewModel(iteration));
            }

            this.AvailableMappingConfiguration = new ReactiveList <ImportMappingConfiguration>();

            this.ReloadSavedConfigurations();

            this.WhenAnyValue(vm => vm.Path).Subscribe(_ => this.UpdateCanExecuteImport());

            this.WhenAnyValue(vm => vm.SelectedIteration).Subscribe(_ => this.UpdateCanExecuteImport());

            var canOk = this.WhenAnyValue(vm => vm.CanExecuteImport);

            this.OkCommand = ReactiveCommand.CreateAsyncTask(canOk, async _ => await this.ExecuteOk());

            this.BrowseCommand = ReactiveCommand.Create();
            this.BrowseCommand.Subscribe(_ => this.ExecuteBrowse());

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataSourceExportViewModel"/> class.
        /// </summary>
        /// <param name="sessions">
        /// The sessions that encapsulate <see cref="IDal"/>s and the associated <see cref="Assembler"/>.
        /// </param>
        /// <param name="openSaveFileDialogService">
        /// The file Dialog Service.
        /// </param>
        public DataSourceExportViewModel(IEnumerable <ISession> sessions, IOpenSaveFileDialogService openSaveFileDialogService)
        {
            if (openSaveFileDialogService == null)
            {
                throw new ArgumentNullException("The openSaveFileDialogService may not be null", "openSaveFileDialogService");
            }

            this.openSaveFileDialogService = openSaveFileDialogService;
            this.AvailableDals             = new List <IDalMetaData>();
            this.OpenSessions            = new ReactiveList <ISession>(sessions);
            this.DialogNavigationService = ServiceLocator.Current.GetInstance <IDialogNavigationService>();
            this.IsBusy = false;

            this.OpenSessions.ChangeTrackingEnabled = true;

            var canOk = this.WhenAnyValue(
                vm => vm.PasswordRetype,
                vm => vm.Password,
                vm => vm.SelectedDal,
                vm => vm.SelectedSession,
                vm => vm.Path,
                (passwordRetype, password, selecteddal, selectedsession, path) => selecteddal != null && selectedsession != null &&
                !string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(password) && password == passwordRetype);

            this.OkCommand = ReactiveCommand.Create(canOk);
            this.OkCommand.Subscribe(_ => this.ExecuteOk());

            this.BrowseCommand = ReactiveCommand.Create();
            this.BrowseCommand.Subscribe(_ => this.ExecuteBrowse());

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());

            this.ResetProperties();
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReqIfRibbonViewModel"/> class
        /// </summary>
        public ReqIfRibbonViewModel()
        {
            this.DialogNavigationService      = ServiceLocator.Current.GetInstance <IDialogNavigationService>();
            this.ThingDialogNavigationService = ServiceLocator.Current.GetInstance <IThingDialogNavigationService>();
            this.PluginSettingsService        = ServiceLocator.Current.GetInstance <IPluginSettingsService>();
            this.OpenSaveDialogService        = ServiceLocator.Current.GetInstance <IOpenSaveFileDialogService>();

            this.Sessions   = new ReactiveList <ISession>();
            this.Iterations = new ReactiveList <Iteration>();
            this.Iterations.ChangeTrackingEnabled = true;

            CDPMessageBus.Current.Listen <SessionEvent>().Subscribe(this.SessionChangeEventHandler);

            CDPMessageBus.Current.Listen <ObjectChangedEvent>(typeof(Iteration))
            .Subscribe(this.IterationEventHandler);

            this.Iterations.CountChanged.Subscribe(x => { this.CanImportExport = (x > 0); });
            var isImportExportEnable = this.WhenAnyValue(x => x.CanImportExport);

            this.ExportCommand = ReactiveCommand.Create(isImportExportEnable);
            this.ExportCommand.Subscribe(x => this.ExecuteExportCommand());

            this.ImportCommand = ReactiveCommand.Create(isImportExportEnable);
            this.ImportCommand.Subscribe(x => this.ExecuteImportCommand());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlExportRequirementsSpecificationSelectionDialogViewModel"/>
        /// </summary>
        /// <param name="iterations">
        /// The <see cref="Iteration"/>s from which a <see cref="RequirementsSpecification"/> can be selected
        /// </param>
        /// <param name="openSaveFileDialogService">
        /// The <see cref="IOpenSaveFileDialogService"/> that can be used to select a file(path) to open or save
        /// </param>
        public HtmlExportRequirementsSpecificationSelectionDialogViewModel(IEnumerable <Iteration> iterations, IOpenSaveFileDialogService openSaveFileDialogService)
        {
            this.openSaveFileDialogService = openSaveFileDialogService;

            this.InitializeReactiveLists();

            this.WhenAnyValue(vm => vm.SelectedEngineeringModel).Where(em => em != null).Subscribe(this.LoadIterations);
            this.WhenAnyValue(vm => vm.SelectedIteration).Where(i => i != null).Subscribe(this.LoadRequirementsSpecifications);

            var canOk = this.WhenAnyValue(
                vm => vm.HtmlReportPath,
                vm => vm.SelectedIteration,
                (path, iteration) => !string.IsNullOrEmpty(path) && iteration != null);

            this.OkCommand = ReactiveCommand.Create(canOk);
            this.OkCommand.Subscribe(_ => this.ExecuteOk());

            this.BrowseCommand = ReactiveCommand.Create();
            this.BrowseCommand.Subscribe(_ => this.ExecuteBrowse());

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());

            this.LoadEngineeringModels(iterations);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReqIfExportDialogViewModel"/> class
        /// </summary>
        /// <param name="sessions">The list of <see cref="ISession"/> available</param>
        /// <param name="iterations">The list of <see cref="Iteration"/> available</param>
        /// <param name="fileDialogService">The <see cref="IOpenSaveFileDialogService"/></param>
        /// <param name="serializer">The <see cref="IReqIFSerializer"/></param>
        public ReqIfExportDialogViewModel(IEnumerable <ISession> sessions, IEnumerable <Iteration> iterations, IOpenSaveFileDialogService fileDialogService, IReqIFSerializer serializer)
        {
            if (sessions == null)
            {
                throw new ArgumentNullException("sessions");
            }

            if (iterations == null)
            {
                throw new ArgumentNullException("iterations");
            }

            if (fileDialogService == null)
            {
                throw new ArgumentNullException("fileDialogService");
            }

            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            this.Sessions          = sessions.ToList();
            this.Iterations        = new ReactiveList <ReqIfExportIterationRowViewModel>();
            this.fileDialogService = fileDialogService;
            this.serializer        = serializer;

            foreach (var iteration in iterations)
            {
                this.Iterations.Add(new ReqIfExportIterationRowViewModel(iteration));
            }

            var canOk = this.WhenAnyValue(
                vm => vm.Path,
                vm => vm.SelectedIteration,
                (path, iteration) => iteration != null && !string.IsNullOrEmpty(path));

            this.OkCommand = ReactiveCommand.CreateAsyncTask(canOk, async x => await this.ExecuteOk(), RxApp.MainThreadScheduler);

            this.OkCommand.ThrownExceptions.Select(ex => ex).Subscribe(x =>
            {
                this.ErrorMessage = x.Message;
            });

            this.BrowseCommand = ReactiveCommand.Create();
            this.BrowseCommand.Subscribe(_ => this.ExecuteBrowse());

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());

            this.OnClosingCommand = ReactiveCommand.CreateAsyncTask(this.OnClosing, RxApp.MainThreadScheduler);

            this.CancelReqIfCommand = ReactiveCommand.Create();

            this.CancelReqIfCommand.Subscribe(_ =>
            {
                this.cancellationTokenSource?.Cancel();
                this.LoadingMessage = "Cancelling...";
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ScriptingEngineRibbonPageGroupViewModel"/> class
        /// </summary>
        public ScriptingEngineRibbonPageGroupViewModel(IPanelNavigationService panelNavigationService, IOpenSaveFileDialogService fileDialogService, IScriptingProxy scriptingProxy)
        {
            if (panelNavigationService == null)
            {
                throw new ArgumentNullException(nameof(panelNavigationService));
            }

            if (fileDialogService == null)
            {
                throw new ArgumentNullException(nameof(fileDialogService));
            }

            if (scriptingProxy == null)
            {
                throw new ArgumentNullException(nameof(scriptingProxy));
            }

            this.PanelNavigationService = panelNavigationService;
            this.fileDialogService      = fileDialogService;
            this.scriptingProxy         = scriptingProxy;

            CDPMessageBus.Current.Listen <NavigationPanelEvent>()
            .Where(x => x.ViewModel.ToString().Contains("ScriptPanelViewModel") && x.PanelStatus == PanelStatus.Closed)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(this.HandleClosedPanel);

            this.OpenSessions = new ReactiveList <ISession>();
            this.OpenSessions.ChangeTrackingEnabled = true;
            this.OpenSessions.CountChanged.Select(x => x != 0).ToProperty(this, x => x.HasSession, out this.hasSession);
            CDPMessageBus.Current.Listen <SessionEvent>().Subscribe(this.SessionChangeEventHandler);

            this.initialDialogPath  = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "file.txt");
            this.PathScriptingFiles = new Dictionary <string, string>();
            this.CollectionScriptPanelViewModels = new ObservableCollection <IScriptPanelViewModel>();
            CDPMessageBus.Current.Listen <ScriptPanelEvent>().Subscribe(this.ScriptPanelEventHandler);

            this.NewPythonScriptCommand = ReactiveCommand.Create();
            this.NewPythonScriptCommand.Subscribe(_ => this.ExecuteCreateNewScript("python", ScriptingLaguageKindSupported.Python));

            this.NewLuaScriptCommand = ReactiveCommand.Create();
            this.NewLuaScriptCommand.Subscribe(_ => this.ExecuteCreateNewScript("lua", ScriptingLaguageKindSupported.Lua));

            this.NewTextScriptCommand = ReactiveCommand.Create();
            this.NewTextScriptCommand.Subscribe(_ => this.ExecuteCreateNewScript("text", ScriptingLaguageKindSupported.Text));

            this.OpenScriptCommand = ReactiveCommand.Create();
            this.OpenScriptCommand.Subscribe(_ => this.OpenScriptFile());

            this.SaveAllCommand = ReactiveCommand.Create();
            this.SaveAllCommand.Subscribe(_ => this.SaveAllScripts());
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReqIfExportDialogViewModel"/> class
        /// </summary>
        /// <param name="sessions">The list of <see cref="ISession"/> available</param>
        /// <param name="iterations">The list of <see cref="Iteration"/> available</param>
        /// <param name="fileDialogService">The <see cref="IOpenSaveFileDialogService"/></param>
        /// <param name="serializer">The <see cref="IReqIFSerializer"/></param>
        public ReqIfExportDialogViewModel(IEnumerable <ISession> sessions, IEnumerable <Iteration> iterations, IOpenSaveFileDialogService fileDialogService, IReqIFSerializer serializer)
        {
            if (sessions == null)
            {
                throw new ArgumentNullException("sessions");
            }

            if (iterations == null)
            {
                throw new ArgumentNullException("iterations");
            }

            if (fileDialogService == null)
            {
                throw new ArgumentNullException("fileDialogService");
            }

            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            this.Sessions          = sessions.ToList();
            this.Iterations        = new ReactiveList <ReqIfExportIterationRowViewModel>();
            this.fileDialogService = fileDialogService;
            this.serializer        = serializer;

            foreach (var iteration in iterations)
            {
                this.Iterations.Add(new ReqIfExportIterationRowViewModel(iteration));
            }

            var canOk = this.WhenAnyValue(
                vm => vm.Path,
                vm => vm.SelectedIteration,
                (path, iteration) => iteration != null && !string.IsNullOrEmpty(path));

            this.OkCommand = ReactiveCommand.Create(canOk);
            this.OkCommand.Subscribe(_ => this.ExecuteOk());

            this.BrowseCommand = ReactiveCommand.Create();
            this.BrowseCommand.Subscribe(_ => this.ExecuteBrowse());

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlExportGlossarySelectionDialogViewModel"/> class.
        /// </summary>
        /// <param name="openGlosarries">
        /// The list of open glossaries.
        /// </param>
        public HtmlExportGlossarySelectionDialogViewModel(List <Glossary> openGlosarries)
        {
            this.openSaveFileDialogService = ServiceLocator.Current.GetInstance <IOpenSaveFileDialogService>();

            this.InitializeReactiveLists();
            this.LoadGlossaries(openGlosarries);

            var canOk = this.WhenAnyValue <HtmlExportGlossarySelectionDialogViewModel, bool, string>(
                vm => vm.HtmlReportPath,
                path => !string.IsNullOrEmpty(path));

            this.OkCommand = ReactiveCommand.Create(canOk);
            this.OkCommand.Subscribe(_ => this.ExecuteOk());

            this.BrowseCommand = ReactiveCommand.Create();
            this.BrowseCommand.Subscribe(_ => this.ExecuteBrowse());

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataSourceExportViewModel"/> class.
        /// </summary>
        /// <param name="sessions">
        /// The sessions that encapsulate <see cref="IDal"/>s and the associated <see cref="Assembler"/>.
        /// </param>
        /// <param name="openSaveFileDialogService">
        /// The file Dialog Service.
        /// </param>
        public DataSourceExportViewModel(IEnumerable <ISession> sessions, IOpenSaveFileDialogService openSaveFileDialogService)
        {
            if (openSaveFileDialogService == null)
            {
                throw new ArgumentNullException(nameof(openSaveFileDialogService), "The openSaveFileDialogService may not be null.");
            }

            this.openSaveFileDialogService = openSaveFileDialogService;
            this.AvailableDals             = new List <IDalMetaData>();
            this.OpenSessions            = new ReactiveList <ISession>(sessions);
            this.DialogNavigationService = ServiceLocator.Current.GetInstance <IDialogNavigationService>();

            this.availableVersions = new Dictionary <string, Version>
            {
                { "ECSS-E-TM-10-25 (Version 2.4.1)", new Version("1.0.0") },
                { "COMET 1.1.0", new Version("1.1.0") },
                { "COMET 1.2.0", new Version("1.2.0") }
            };

            this.IsBusy = false;

            this.OpenSessions.ChangeTrackingEnabled = true;

            this.WhenAnyValue(
                vm => vm.SelectedSession).Subscribe(
                x =>
            {
                if (x == null)
                {
                    this.Versions = new Dictionary <string, Version>();
                }
                else
                {
                    this.Versions =
                        this.availableVersions
                        .Where(y => y.Value <= x.DalVersion)
                        .ToDictionary(k => k.Key, v => v.Value);

                    if (this.SelectedVersion.Key != null && !this.Versions.ContainsKey(this.SelectedVersion.Key))
                    {
                        this.SelectedVersion = default;
                    }
                }
            });

            var canOk = this.WhenAnyValue(
                vm => vm.PasswordRetype,
                vm => vm.Password,
                vm => vm.SelectedDal,
                vm => vm.SelectedSession,
                vm => vm.Path,
                vm => vm.SelectedVersion,
                (passwordRetype, password, selecteddal, selectedsession, path, selectedVersion)
                => selecteddal != null &&
                selectedsession != null &&
                !string.IsNullOrEmpty(path) &&
                !string.IsNullOrEmpty(password) &&
                password == passwordRetype &&
                selectedVersion.Key != default);

            this.OkCommand = ReactiveCommand.Create(canOk);
            this.OkCommand.Subscribe(_ => this.ExecuteOk());

            this.BrowseCommand = ReactiveCommand.Create();
            this.BrowseCommand.Subscribe(_ => this.ExecuteBrowse());

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());

            this.ResetProperties();
        }
Esempio n. 11
0
 public ScriptingEngineRibbon(IPanelNavigationService panelNavigationService, IOpenSaveFileDialogService fileDialogService, IScriptingProxy scriptingProxy)
 {
     this.InitializeComponent();
     this.DataContext = new ScriptingEngineRibbonPageGroupViewModel(panelNavigationService, fileDialogService, scriptingProxy);
 }