Exemplo n.º 1
0
        public PsnSignalViewModel(IPsnChannel model)
        {
            _model = model;
            _isTrendLoadInProgress = false;

            _cmdLoadTrend = new DependedCommand(() =>
            {
                IsTrendLoadInProgress = true;

                _model.LoadTrendAsync(ea => {
                    MessageSystem.ShowMessage(ea.Message);

                    switch (ea.ResultCode)
                    {
                    case OnCompleteEventArgs.CompleteResult.Ok:
                        MessageSystem.ShowMessage("DataPoints count: " + _model.Trend.Count);
                        IsTrendLoadInProgress = false;
                        return;

                    case OnCompleteEventArgs.CompleteResult.Error:
                        IsTrendLoadInProgress = false;
                        return;
                    }
                });
            }, () => !IsTrendLoadInProgress);
            _cmdLoadTrend.AddDependOnProp(this, "IsTrendLoadInProgress");


            _cmdUnloadTrend = new DependedCommand(() => _model.FreeTrend(), () => true);
        }
Exemplo n.º 2
0
        public SectionViewModel(ISection model)
        {
            _model = model;

            _isInEditMode = false;
            _newName      = _model.Name;

            _psnLogs = new ObservableCollection <PsnLogViewModel>();
            foreach (var psnLog in _model.Psns)
            {
                _psnLogs.Add(new PsnLogViewModel(psnLog));
            }

            _cmdStartModifyName = new DependedCommand(() =>
            {
                IsInEditMode = true;
            }, () => !IsInEditMode);
            _cmdStartModifyName.AddDependOnProp(this, "IsInEditMode");


            _cmdSetName = new DependedCommand(() =>
            {
                IsInEditMode = false;
                Name         = _newName;
            }, () => IsInEditMode);
            _cmdSetName.AddDependOnProp(this, "IsInEditMode");
        }
Exemplo n.º 3
0
        public LocomotiveViewModel(ILocomotive model)
        {
            _model    = model;
            _sections = new ObservableCollection <SectionViewModel>();
            foreach (var section in model.Sections)
            {
                _sections.Add(new SectionViewModel(section));
            }

            _isInEditMode = false;
            _newName      = _model.Name;



            _cmdStartModifyName = new DependedCommand(() => {
                IsInEditMode = true;
            }, () => !IsInEditMode);
            _cmdStartModifyName.AddDependOnProp(this, "IsInEditMode");


            _cmdSetName = new DependedCommand(() =>
            {
                IsInEditMode = false;
                Name         = _newName;
            }, () => IsInEditMode);
            _cmdSetName.AddDependOnProp(this, "IsInEditMode");
        }
Exemplo n.º 4
0
 public RecordViewModel(IThreadNotifier notifier, IWindowSystem windowSystem)
 {
     _notifier           = notifier;
     _windowSystem       = windowSystem;
     _isRecording        = false;
     _recordedData       = new List <IList <byte> >();
     _startRecordCommand = new DependedCommand(StartRecord, () => !IsRecording);
     _stopRecordCommand  = new DependedCommand(StopRecord, () => IsRecording);
     _startRecordCommand.AddDependOnProp(this, () => IsRecording);
     _stopRecordCommand.AddDependOnProp(this, () => IsRecording);
 }
Exemplo n.º 5
0
        public TestSystemViewModel(IThreadNotifier uiNotifier, string testName, ITestSysAsync asyncTest, Colors testCompleteColor)
        {
            _uiNotifier             = uiNotifier;
            TestName                = testName;
            AssociatedWithModelTest = asyncTest;
            TestCompleteColor       = testCompleteColor;


            _runTestAsync = new DependedCommand(RunTest, () => !IsRunningTest);
            _runTestAsync.AddDependOnProp(this, () => IsRunningTest);

            _cancelTestAsync = new DependedCommand(CancelTest, () => IsRunningTest);
            _cancelTestAsync.AddDependOnProp(this, () => IsRunningTest);

            TestLogLines = new ObservableCollection <LogLineColored>();
        }
Exemplo n.º 6
0
        public DispParamSettableViewModel(
            string displayName,
            IRecvParam <TRaw> recvModel,
            IThreadNotifier uiNotifier,
            Func <TRaw, TDisplay> displayValueGetter,
            TDisplay fallbackValue,
            TDisplay unknownValue,
            Action <TSet> sendValueValidator,
            TSet fallbackSettValue,
            TSet unknownSettValue,
            Action <TSet, Action <Exception> > asyncParamSetter)
        {
            DisplayName = displayName;

            _recvModel          = recvModel;
            _uiNotifier         = uiNotifier;
            _displayValueGetter = displayValueGetter;

            _fallbackValue   = fallbackValue;
            _unknownValue    = unknownValue;
            _displayValue    = unknownValue;
            _isValueUnknown  = true;
            _isValueFallback = false;


            _sendValueValidator  = sendValueValidator;
            _fallbackSettValue   = fallbackSettValue;
            _unknownSettValue    = unknownSettValue;
            _settValue           = unknownSettValue;
            _isSettValueUnknown  = true;
            _isSettValueFallback = false;

            _backgroundColor = Colors.Transparent;

            _asyncParamSetter = asyncParamSetter;
            _setCommand       = new DependedCommand(Set, () => IsSettValueNotFallbackAndNotUnknown);
            _setCommand.AddDependOnProp(this, () => IsSettValueNotFallbackAndNotUnknown);


            _recvModel.NotifyDataReceived += ParameterModelOnNotifyDataReceived;
        }
Exemplo n.º 7
0
 public SendableParameterBase(
     int paramIndex,
     string name,
     TRaw?defaultValue,
     IBuilderOneToOne <TRaw, string> stringBuilder,
     string toolTipText,
     IParameterSetter parameterSetter,
     IThreadNotifier uiNotifier,
     IBuilderOneToOne <TRaw, BytesPair> sendConverter)
     : base(paramIndex.ToString(), name, defaultValue, stringBuilder, toolTipText)
 {
     _isEnabled       = true;
     _paramIndex      = paramIndex;
     _parameterSetter = parameterSetter;
     _uiNotifier      = uiNotifier;
     _sendConverter   = sendConverter;
     //_resetCommand = new RelayCommand(Reset, () => ReceivedValueFormatted.HasValue);
     _setCommand = new DependedCommand(Set, () => FormattedValue != null && IsEnabled);
     _setCommand.AddDependOnProp(this, () => FormattedValue);
     _setCommand.AddDependOnProp(this, () => IsEnabled);
     _lastOperationColor = Colors.Transparent;
 }
Exemplo n.º 8
0
        public PsnLogViewModel(IPsnLog model)
        {
            _model = model;

            _isInEditMode = false;
            _newName      = _model.Name;
            _psnDevices   = new ObservableCollection <PsnDeviceViewModel>();
            foreach (var meter in _model.Meters)
            {
                _psnDevices.Add(new PsnDeviceViewModel(meter));
            }

            _cmdStartModifyName = new DependedCommand(() => {
                IsInEditMode = true;
            }, () => !IsInEditMode);
            _cmdStartModifyName.AddDependOnProp(this, "IsInEditMode");


            _cmdSetName = new DependedCommand(() => {
                IsInEditMode = false;
                Name         = _newName;
            }, () => IsInEditMode);
            _cmdSetName.AddDependOnProp(this, "IsInEditMode");

            CmdGetPagesStatistic = new RelayCommand(() => {
                _model.GetStatisticAsync((ex, text) => {
                    if (ex != null)
                    {
                        MessageSystem.ShowMessage(ex.ToString());
                    }
                    else
                    {
                        MessageSystem.ShowMessage(text.Aggregate(string.Empty, (current, line) => current + (line + Environment.NewLine)));
                    }
                });
            });

            model.IsSomethingWrongWithLogChanged += (sender, args) => RaisePropertyChanged(() => LogHealth);
        }
Exemplo n.º 9
0
        public SettParamViewModel(
            string displayName,
            IThreadNotifier uiNotifier,
            Action <TSet> sendValueValidator,
            TSet fallbackSettValue,
            TSet unknownSettValue,
            Action <TSet, Action <Exception> > asyncParamSetter)
        {
            DisplayName          = displayName;
            _uiNotifier          = uiNotifier;
            _sendValueValidator  = sendValueValidator;
            _fallbackSettValue   = fallbackSettValue;
            _unknownSettValue    = unknownSettValue;
            _settValue           = unknownSettValue;
            _isSettValueUnknown  = true;
            _isSettValueFallback = false;

            _backgroundColor = Colors.Transparent;

            _asyncParamSetter = asyncParamSetter;
            _setCommand       = new DependedCommand(Set, () => IsSettValueNotFallbackAndNotUnknown);
            _setCommand.AddDependOnProp(this, () => IsSettValueNotFallbackAndNotUnknown);
        }