Пример #1
0
 public SerialPortSelectionItem(MainViewModel parent, string name)
 {
     _parent         = parent;
     Name            = name;
     SetValueCommand = new ActionCommandModel(() => true, () => IsChecked = true);
     _parent.CurrentSerialPort.PropertyChanged += CurrentSerialPort_PropertyChanged;
 }
Пример #2
0
        public MainViewModel(MainWindow mainWindow)
        {
            CurrentSerialPort        = new ViewModelProperty <string>(ConnectToArduino);
            CurrentProgrammerProfile = new ViewModelProperty <string>(LoadProfile);
            SerialPorts         = new ViewModelProperty <IEnumerable <string> >();
            ProgrammerProfiles  = new ViewModelProperty <IEnumerable <string> >();
            SerialPortMenuItems = new ReadOnlyViewModelProperty <List <SerialPortMenuItem> >(SerialPorts, () =>
            {
                var items = new List <SerialPortMenuItem>();
                if (SerialPorts.Value != null)
                {
                    foreach (var item in SerialPorts.Value)
                    {
                        items.Add(new SerialPortSelectionItem(this, item));
                    }
                }

                if (items.Count == 0)
                {
                    items.Add(NoPortsAvailable.Value);
                }

                return(items);
            });
            SerialMonitor         = new SerialMonitor();
            TestButtonDeckCommand = new ActionCommandModel(() => !string.IsNullOrEmpty(CurrentSerialPort.Value), OnTestButtonDeck);
            LoggingCommand        = new ActionCommandModel(() => true, OnOpenLogging);
            OpenProgrammer        = new ActionCommandModel(() => true, OnOpenProgrammer);

            LogListener   = new LogListener();
            RootLogger    = new LoggerFactory().Create(LogListener);
            Communication = new ButtonDeckCommunication(RootLogger);
            MainWindow    = mainWindow;
        }
 public ProgrammerProfileSelectionItem(MainViewModel parent, string name)
 {
     _parent         = parent;
     Name            = name;
     SetValueCommand = new ActionCommandModel(() => true, () => IsChecked = true);
     _parent.CurrentProgrammerProfile.PropertyChanged += CurrentProgrammerProfile_PropertyChanged;
 }
 public ButtonDeckTestViewModel()
 {
     Messages       = new ObservableCollection <string>();
     HeartbeatValue = new ViewModelProperty <int>();
     LEDBrightness  = new ViewModelProperty <int>
     {
         Value = 255
     };
     LEDBrightnessGet = new ViewModelProperty <bool>();
     SelectedToggle   = new ViewModelProperty <int>();
     SelectedLED      = new ViewModelProperty <int>
     {
         Value = 1
     };
     LEDColor = new ViewModelProperty <Color>
     {
         Value = Colors.Blue
     };
     ActionType  = new ViewModelProperty <ActionTypes>();
     AllLEDs     = new ViewModelProperty <bool>();
     SelectColor = new ActionCommandModel(() => true, OnSelectColor);
     Send        = new ActionCommandModel(() => true, OnSend);
 }