Esempio n. 1
0
 public void CloseDialog(IDialogViewModelBase vm, bool dialogResult = true)
 {
     if (openDialogWindows.TryGetValue(vm, out Window window))
     {
         window.DialogResult = dialogResult;
         window.Close();
     }
 }
Esempio n. 2
0
        protected void SetViewModel(IDialogViewModelBase viewModel)
        {
            var oldVm = DataContext as IDialogViewModelBase;

            if (oldVm != null)
            {
                oldVm.Closing -= OnViewModelClosing;
            }
            DataContext = viewModel;
            if (viewModel != null)
            {
                viewModel.Closing += OnViewModelClosing;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterBaseRowViewModel{T}"/> class.
        /// </summary>
        /// <param name="parameterBase">
        /// The associated <see cref="ParameterBase"/>
        /// </param>
        /// <param name="session">
        /// The associated <see cref="ISession"/>
        /// </param>
        /// <param name="containerViewModel">
        /// The <see cref="ElementBase{T}"/> row that contains this row.
        /// </param>
        /// <param name="isDialogReadOnly">
        /// Value indicating whether this row should be read-only because the dialog is read-only
        /// </param>
        protected ParameterBaseRowViewModel(T parameterBase, ISession session, IDialogViewModelBase <T> containerViewModel, bool isDialogReadOnly)
            : base(parameterBase, session, containerViewModel)
        {
            this.dialogViewModel        = containerViewModel;
            this.isCompoundType         = this.Thing.ParameterType is CompoundParameterType;
            this.ParameterType          = this.Thing.ParameterType;
            this.ParameterTypeClassKind = this.Thing.ParameterType.ClassKind;

            this.isDialogReadOnly = isDialogReadOnly;
            this.WhenAnyValue(vm => vm.Switch).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Manual).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Computed).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Reference).Subscribe(_ => this.UpdateActualValue());

            this.UpdateProperties();
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterValueBaseRowViewModel"/> class
        /// </summary>
        /// <param name="parameterBase">
        /// The associated <see cref="ParameterBase"/>
        /// </param>
        /// <param name="session">
        /// The <see cref="ISession"/>
        /// </param>
        /// <param name="actualOption">
        /// The actual <see cref="Option"/> represented if any
        /// </param>
        /// <param name="actualState">
        /// The actual <see cref="ActualFiniteState"/> represented if any
        /// </param>
        /// <param name="containerRow">
        /// The row container
        /// </param>
        /// <param name="valueIndex">
        /// The index of the component if applicable
        /// </param>
        /// <param name="isDialogReadOnly">
        /// Value indicating whether this row should be read-only because the dialog is read-only
        /// </param>
        protected ParameterValueBaseRowViewModel(ParameterBase parameterBase, ISession session, Option actualOption, ActualFiniteState actualState, IViewModelBase <Thing> containerRow, int valueIndex = 0, bool isDialogReadOnly = false)
            : base(parameterBase, session, containerRow)
        {
            this.ActualOption = actualOption;
            this.ActualState  = actualState;

            this.ValueIndex             = valueIndex;
            this.ParameterTypeClassKind = this.ParameterType.ClassKind;

            this.WhenAnyValue(vm => vm.Switch).Skip(1).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Manual).Skip(1).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Computed).Skip(1).Subscribe(_ => this.UpdateActualValue());
            this.WhenAnyValue(vm => vm.Reference).Skip(1).Subscribe(_ => this.UpdateActualValue());

            var option = this.ActualOption == null ? string.Empty : this.ActualOption.ShortName;
            var state  = this.ActualState == null ? string.Empty : this.ActualState.ShortName;

            this.RowCode = string.Format("{0}.{1}.{2}", option, state, this.ValueIndex);

            this.DialogViewModel = (IDialogViewModelBase <ParameterBase>) this.TopContainerViewModel;

            var subscription = this.Thing as ParameterSubscription;

            if (subscription != null)
            {
                var parameter = (ParameterOrOverrideBase)subscription.Container;
                if (parameter.Owner != null)
                {
                    this.OwnerName      = "[" + parameter.Owner.Name + "]";
                    this.OwnerShortName = "[" + parameter.Owner.ShortName + "]";
                }
            }
            else
            {
                if (this.Owner != null)
                {
                    this.OwnerName      = this.Owner.Name;
                    this.OwnerShortName = this.Owner.ShortName;
                }
            }
        }
Esempio n. 5
0
        private Window ConfigureOpenWindow(Type windowType, IDialogViewModelBase viewModel, IDialogViewModelBase owner = null)
        {
            Window ownerWindow = null;

            if (owner != null)
            {
                openDialogWindows.TryGetValue(owner, out ownerWindow);
            }

            Assembly asm    = Assembly.GetAssembly(windowType);
            Window   dialog = (Window)asm.CreateInstance(windowType.FullName);

            dialog.Owner       = ownerWindow ?? MainWindow;
            dialog.DataContext = viewModel;
            openDialogWindows.Add(viewModel, dialog);
            dialog.Closed       += DialogOnClosed;
            dialog.ShowActivated = true;
            if (MainWindow == null)
            {
                MainWindow = dialog;
            }

            return(dialog);
        }
Esempio n. 6
0
 public MessageBoxResult ShowMessageBox(IDialogViewModelBase owner, string title, string information, MessageBoxButton button, MessageBoxImage image)
 {
     openDialogWindows.TryGetValue(owner, out Window ownerWindow);
     return(ShowMessageBox(title, information, button, image, ownerWindow));
 }
Esempio n. 7
0
 public void OpenWindow(Type windowType, IDialogViewModelBase viewModel, IDialogViewModelBase owner = null)
 {
     ConfigureOpenWindow(windowType, viewModel, owner).Show();
 }
Esempio n. 8
0
 public bool?OpenDialogWindow(Type windowType, IDialogViewModelBase viewModel, IDialogViewModelBase owner = null)
 {
     return(ConfigureOpenWindow(windowType, viewModel, owner).ShowDialog());
 }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParameterOverrideRowViewModel"/> class.
 /// </summary>
 /// <param name="parameterOverride">
 /// The parameter Override.
 /// </param>
 /// <param name="session">
 /// The session.
 /// </param>
 /// <param name="containerViewModel">
 /// The container view-model.
 /// </param>
 /// <param name="isDialogReadOnly">
 /// Value indicating whether this row should be read-only because the dialog is read-only
 /// </param>
 public ParameterOverrideRowViewModel(ParameterOverride parameterOverride, ISession session, IDialogViewModelBase <ParameterOverride> containerViewModel, bool isDialogReadOnly = false)
     : base(parameterOverride, session, containerViewModel, isDialogReadOnly)
 {
 }
 protected void OpenDialog(Type windowType, IDialogViewModelBase vm)
 {
     DialogService.OpenDialogWindow(windowType, vm, this);
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParameterOrOverrideBaseRowViewModel"/> class
 /// </summary>
 /// <param name="parameter">
 /// The associated <see cref="ParameterOrOverrideBase"/>
 /// </param>
 /// <param name="session">
 /// The associated <see cref="ISession"/>
 /// </param>
 /// <param name="containerViewModel">
 /// The container Row.
 /// </param>
 /// <param name="isDialogReadOnly">
 /// Value indicating whether this row should be read-only because the dialog is read-only
 /// </param>
 protected ParameterOrOverrideBaseRowViewModel(ParameterOrOverrideBase parameter, ISession session, IDialogViewModelBase <ParameterOrOverrideBase> containerViewModel, bool isDialogReadOnly)
     : base(parameter, session, containerViewModel, isDialogReadOnly)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ParameterSubscriptionRowViewModel"/> class
 /// </summary>
 /// <param name="parameterSubscription">
 /// The associated <see cref="ParameterSubscription"/>
 /// </param>
 /// <param name="session">
 /// The <see cref="ISession"/>
 /// </param>
 /// <param name="containerViewModel">
 /// the container view-model
 /// </param>
 /// <param name="isDialogReadOnly">
 /// The is Dialog Read Only.
 /// </param>
 public ParameterSubscriptionRowViewModel(ParameterSubscription parameterSubscription, ISession session, IDialogViewModelBase <ParameterSubscription> containerViewModel, bool isDialogReadOnly = false)
     : base(parameterSubscription, session, containerViewModel, isDialogReadOnly)
 {
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParameterRowViewModel"/> class.
 /// </summary>
 /// <param name="parameter">
 /// The parameter.
 /// </param>
 /// <param name="session">
 /// The session.
 /// </param>
 /// <param name="containerViewModel">
 /// The container row.
 /// </param>
 /// <param name="isDialogReadOnly">
 /// Value indicating whether this row should be read-only because the dialog is read-only
 /// </param>
 public ParameterRowViewModel(Parameter parameter, ISession session, IDialogViewModelBase <Parameter> containerViewModel, bool isDialogReadOnly = false)
     : base(parameter, session, containerViewModel, isDialogReadOnly)
 {
 }