Example #1
0
        public MainWindowViewModel(IDialogService dialog_service)
        {
            this.DialogService        = dialog_service;
            this.Documents            = new ObservableCollection <DocumentViewModel>();
            this.Anchorables          = new ObservableCollection <AnchorableViewModel>();
            this.WindowClosingCommand = new RelayCommand <CancelEventArgs>(WindowClosingExecute);
            this.NewFileCommand       = new RelayCommand(NewFileExecute);
            this.OpenFileCommand      = new RelayCommand(OpenFileExecute);
            this.SaveFileCommand      = new RelayCommand(SaveFileExecute, SaveFileCanExecute);
            this.SaveFileAsCommand    = new RelayCommand(SaveFileAsExecute, SaveFileAsCanExecute);
            this.SaveAllCommand       = new RelayCommand(SaveAllExecute, SaveAllCanExecute);
            this.UploadFileCommand    = new AwaitableRelayCommand(UploadFileExecute, UploadFileCanExecute);
            this.CloseFileCommand     = new RelayCommand(CloseFileExecute, CloseFileCanExecute);
            this.ExitCommand          = new RelayCommand(ExitExecute);
            this.ShowTerminalCommand  = new RelayCommand(ShowTerminalExecute);
            this.ShowSpiffsCommand    = new RelayCommand(ShowSpiffsExecute);
            this.RecentFileCommand    = new RelayCommand <string>(RecentFileExecute);
            this.LineNumbersCommand   = new RelayCommand(LineNumbersExecute, LineNumbersCanExecute);
            this.WordWrapCommand      = new RelayCommand(WordWrapExecute, WordWrapCanExecute);
            this.CancelCommand        = new RelayCommand(CancelExecute, CancelCanExecute);
            this.SettingsCommand      = new RelayCommand(SettingsExecute);
            this.GitHubCommand        = new RelayCommand(GitHubExecute);
            this.AboutCommand         = new RelayCommand(AboutExecute);
            this.WindowCommand        = new RelayCommand <DocumentViewModel>(WindowExecute);

            // Window title
            this.Title = "ESP Browser " + GetVersion();

            // Recent files history
            this.RecentFilesLength = Settings.Default.RecentFilesLength;
            this.RecentFiles       = new ObservableCollection <string>();
            if (Settings.Default.RecentFiles != null)
            {
                this.RecentFiles.AddRange(Settings.Default.RecentFiles.Cast <string>());
                this.IsRecentFilesVisible = true;
            }

            this.RecentFiles.CollectionChanged += RecentFiles_CollectionChanged;

            // Add terminal window
            this.Terminal = new TerminalViewModel(this, "terminal", "Terminal", "Serial terminal", "Image_SerialPort");
            this.Anchorables.Add(this.Terminal);

            // Register to PropertyChanged event of TerminalViewModel
            this.Terminal.PropertyChanged += Terminal_PropertyChanged;

            // Add SPIFFS window
            this.Spiffs = new SpiffsViewModel(this, "spiffs", "SPIFFS Explorer", "SPIFFS Explorer", "Image_FileGroup");
            this.Anchorables.Add(this.Spiffs);

            // Add new document
            NewFileExecute();

            // Set statusbar text and image
            RefreshStatusConnection();
            this.StatusWorkingText  = READY;
            this.StatusWorkingImage = WindowUtils.GetImage("Image_DotLarge");
        }
Example #2
0
 public ContentViewModel(MainWindowViewModel parent, string content_id, string title, string tooltip, string image_name)
 {
     this.parent       = parent;
     this.ContentId    = (!String.IsNullOrEmpty(content_id) ? content_id : Guid.NewGuid().ToString());
     this.Title        = title;
     this.ToolTip      = tooltip;
     this.IconSource   = (!String.IsNullOrEmpty(image_name) ? WindowUtils.GetImage(image_name) : null);
     this.CloseCommand = new RelayCommand(CloseExecute, CloseCanExecute);
 }
        public TerminalViewModel(MainWindowViewModel parent, string content_id, string title, string tooltip, string image_name)
            : base(parent, content_id, title, tooltip, image_name)
        {
            this.Document  = new TextDocument();
            this.PortNames = new ObservableCollection <string>();
            this.RefreshPortNamesCommand = new RelayCommand(RefreshPortNamesExecute, RefreshPortNamesCanExecute);
            this.ConnectCommand          = new RelayCommand(ConnectExecute, ConnectCanExecute);
            this.SendCommand             = new RelayCommand(SendExecute, SendCanExecute);
            this.ClearAllCommand         = new RelayCommand(ClearAllExecute);
            this.SoftResetCommand        = new RelayCommand(SoftResetExecute, SoftResetCanExecute);
            this.HardResetCommand        = new RelayCommand(HardResetExecute, HardResetCanExecute);
            this.ChipIdCommand           = new RelayCommand(ChipIdExecute, ChipIdCanExecute);
            this.HeapCommand             = new RelayCommand(HeapExecute, HeapCanExecute);
            this.InfoCommand             = new AwaitableRelayCommand(InfoExecute, InfoCanExecute);

            // Refresh port names
            RefreshPortNamesExecute();
            if (this.PortNames.Count > 0)
            {
                if (this.PortNames.Contains(Settings.Default.PortName))
                {
                    this.PortName = Settings.Default.PortName;
                }
                else
                {
                    this.PortName = this.PortNames[0];
                }
            }

            // Refresh baud rates
            this.BaudRates = new int[] { 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 230400 };
            this.BaudRate  = Settings.Default.BaudRate;

            // Timeout
            this.Timeout = Settings.Default.Timeout;

            // Send command history
            this.SendHistoryLength = Settings.Default.SendHistoryLength;
            this.SendHistory       = new ObservableCollection <string>();
            if (Settings.Default.SendHistory != null)
            {
                this.SendHistory.AddRange(Settings.Default.SendHistory.Cast <string>());
            }

            // Image of connect button
            this.ConnectImageSource = WindowUtils.GetImage("Image_Connect");

            this.IsDisconnected = true;
        }
Example #4
0
 public void SetStatusWorking(string text, string image_name)
 {
     this.StatusWorkingText  = text;
     this.StatusWorkingImage = WindowUtils.GetImage(image_name);
 }
Example #5
0
 public void RefreshStatusConnection()
 {
     this.StatusConnectionText  = (this.Terminal.IsConnected ? $"Connected to {this.Terminal.PortName} at {this.Terminal.BaudRate}" : "Disconnected");
     this.StatusConnectionImage = WindowUtils.GetImage(this.Terminal.IsConnected ? "Image_Plugged" : "Image_Unplugged");
 }