/* * * public static readonly DependencyProperty ArduinoSerialPortProperty = * DependencyProperty.Register("ArduinoSerialPortProperty", * typeof(ArduinoSerialPort), * typeof(SerialCommunicationViewModel), * new FrameworkPropertyMetadata(new ArduinoSerialPort())); * * public ArduinoSerialPort ArduinoSerialPort * { * get * { * return (ArduinoSerialPort)GetValue(ArduinoSerialPortProperty); * } * set * { * SetValue(ArduinoSerialPortProperty, value); * } * }*/ public SerialMonitorView() { InitializeComponent(); DataContext = new SerialCommunicationViewModel(); ((INotifyCollectionChanged)(SerialListView.Items)).CollectionChanged += SerialListView_CollectionChanged; this.DataContextChanged += SerialMonitorView_DataContextChanged; }
public PrintExecuteViewModel(GCodeManagerViewModel GCodeManagerViewModel, RealTimeStatusDataModel RealTimeStatusDataModel, CalibrationViewModel CalibrationViewModel, SerialCommunicationViewModel SerialCommunicationViewModel, SerialCommunicationOutgoingMessagesModel SerialCommunicationOutgoingMessagesModel, SerialMessageDisplayViewModel SerialMessageDisplayViewModel, PrintViewModel PrintViewModel) { _gCodeManagerViewModel = GCodeManagerViewModel; _realTimeStatusDataModel = RealTimeStatusDataModel; _calibrationViewModel = CalibrationViewModel; _serialCommunicationViewModel = SerialCommunicationViewModel; _serialCommunicationOutgoingMessagesModel = SerialCommunicationOutgoingMessagesModel; _serialMessageDisplayViewModel = SerialMessageDisplayViewModel; _printViewModel = PrintViewModel; _gCodeManagerViewModel.GCodeFileUploaded += new GCodeFileUploadedEventHandler(UpdateUploadedGCode); _printViewModel.PrintViewModelRepRapIDChanged += new PrintViewModelRepRapIDChanged(UpdateRepRapIDSet); _serialCommunicationViewModel.SerialCommunicationMainModel.SerialConnectionChanged += new SerialConnectionChangedEventHandler(UpdateSerialConnection); _serialCommunicationViewModel.SerialCommunicationMainModel.SerialCommunicationCompleted += new SerialCommunicationCompletedEventHandler(UpdatePrintFinished); _serialCommunicationViewModel.SerialCommunicationMainModel.SerialCommunicationPrintSequencePaused += new SerialCommunicationPrintSequencePausedEventHandler(UpdatePrintSequencePaused); _serialCommunicationViewModel.SerialCommunicationMainModel.SerialCommunicationMicrocontrollerResumed += new SerialCommunicationMicrocontrollerResumedEventHandler(UpdateMicrocontrollerResumed); _realTimeStatusDataModel.RecordSetMotorizedPrintheadExecuted += new RecordSetMotorizedPrintheadExecutedEventHandler(UpdateActivePrintheadType); _realTimeStatusDataModel.RecordSetValvePrintheadExecuted += new RecordSetValvePrintheadExecutedEventHandler(UpdateActivePrintheadType); _realTimeStatusDataModel.RecordLimitExecuted += new RecordLimitExecutedEventHandler(UpdateLimitHit); _calibrationViewModel.CalibrationModel.CalibrationBegun += new CalibrationBegunEventHandler(UpdateCalibrationBegun); }
public MainViewModel() { //Error Handling. _errorListViewModel = new ErrorListViewModel(); //Printer Model. _printerModel = new PrinterModel(); //Print Model. _printModel = new PrintModel(_printerModel); //Serial Communication Incoming and Outgoing Message Interpreter. _realTimeStatusDataModel = new RealTimeStatusDataModel(_printerModel); //Serial Communication. _serialCommunicationOutgoingMessagesModel = new SerialCommunicationOutgoingMessagesModel(); _serialCommunicationMainModel = new SerialCommunicationMainModel(_serialCommunicationOutgoingMessagesModel, _printerModel, _printModel, _realTimeStatusDataModel, _errorListViewModel); _serialMessageDisplayViewModel = new SerialMessageDisplayViewModel(); _serialCommunicationViewModel = new SerialCommunicationViewModel(_serialCommunicationMainModel, _serialCommunicationOutgoingMessagesModel, _serialMessageDisplayViewModel); //Printer View Model. _printerViewModel = new PrinterViewModel(_printerModel, _serialCommunicationMainModel.SerialCommunicationCommandSetsModel); //Print View Model. _printViewModel = new PrintViewModel(_printModel, _serialMessageDisplayViewModel); //Real Time Status. _realTimeStatusSerialInterpreterModel = new RealTimeStatusSerialInterpreterModel(_serialCommunicationMainModel, _printerModel, _printerViewModel, _realTimeStatusDataModel, _errorListViewModel); _realTimeStatusDataViewModel = new RealTimeStatusDataViewModel(_realTimeStatusDataModel, _printerViewModel, _serialCommunicationMainModel.SerialCommunicationCommandSetsModel, _errorListViewModel); //Manual Commmands and Calibration. _manualControlModel = new ManualControlModel(_printerModel, _serialCommunicationOutgoingMessagesModel, _realTimeStatusDataModel, _errorListViewModel); _calibrationModel = new CalibrationModel(_realTimeStatusDataModel, _printerModel, _serialCommunicationOutgoingMessagesModel, _errorListViewModel); _manualControlViewModel = new ManualControlViewModel(_manualControlModel, _realTimeStatusDataViewModel, _printerViewModel); _calibrationViewModel = new CalibrationViewModel(_calibrationModel, _manualControlViewModel, _realTimeStatusDataViewModel, _printerViewModel); //GCode. _uploadedGCodeModel = new GCodeModel(); _gCodeFileManagerModel = new GCodeFileManagerModel(_uploadedGCodeModel, _errorListViewModel); _gCodeConverterModel = new GCodeConverterModel(_printerModel, _printModel, _realTimeStatusDataModel, _errorListViewModel); _gcodeManagerViewModel = new GCodeManagerViewModel(_gCodeFileManagerModel, _gCodeConverterModel, _printViewModel); //Printing. _printExecuteViewModel = new PrintExecuteViewModel(_gcodeManagerViewModel, _realTimeStatusDataModel, _calibrationViewModel, _serialCommunicationViewModel, _serialCommunicationOutgoingMessagesModel, _serialMessageDisplayViewModel, _printViewModel); //Settings. _saveLoadViewModel = new SaveLoadViewModel(_gcodeManagerViewModel, _printerViewModel, _printViewModel, _errorListViewModel); //Unset Main Window. _unsetMainViewModel = new UnsetMainViewModel(); }
public MainWindow() { InitializeComponent(); ArduinoSerialPort = new ArduinoSerialPort(); ArduinoSerialPort.MainWindow = this; COMPortInfoListView.PortComboBox.SelectionChanged += PortComboBox_SelectionChanged; SerialCommunicationViewModel serialCommunicationViewModel = ArduinoSerialPortView.DataContext as SerialCommunicationViewModel; serialCommunicationViewModel.ArduinoSerialPort = ArduinoSerialPort; ManualControlViewModel manualControlViewModel = ManualControlView.DataContext as ManualControlViewModel; manualControlViewModel.ArduinoSerialPort = ArduinoSerialPort; }
public void Send(string message) { serialPort.WriteLine(message); SerialCommunicationViewModel.AddSentMessage(message); }