public void Activate(bool activate, ViewType chgMode) { if (activate) { GrblSDCard.Load((GrblViewModel)DataContext); } }
private void Delete_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show(string.Format((string)FindResource("DeleteFile"), (string)currentFile["Name"]), "ioSender", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes) { Comms.com.WriteCommand(GrblConstants.CMD_SDCARD_UNLINK + (string)currentFile["Name"]); GrblSDCard.Load(DataContext as GrblViewModel); } }
public void Activate(bool activate, ViewType chgMode) { if (activate) { GrblSDCard.Load(); this.dgrSDCard.DataContext = GrblSDCard.data.DefaultView; } }
public void Activate(bool activate, ViewType chgMode) { if (activate) { GrblSDCard.Load(DataContext as GrblViewModel); CanUpload = GrblInfo.UploadProtocol != string.Empty; CanDelete = GrblInfo.Build >= 20210421; CanRewind = GrblInfo.IsGrblHAL; } else { (DataContext as GrblViewModel).Message = string.Empty; } }
private void Upload_Click(object sender, RoutedEventArgs e) { bool ok = false; string filename = string.Empty; OpenFileDialog file = new OpenFileDialog(); file.Filter = string.Format("GCode files ({0})|{0}|Text files (*.txt)|*.txt|All files (*.*)|*.*", FileUtils.ExtensionsToFilter(GCode.FileTypes)); if (file.ShowDialog() == true) { filename = file.FileName; } if (filename != string.Empty) { GrblViewModel model = DataContext as GrblViewModel; model.Message = (string)FindResource("Uploading"); if (GrblInfo.UploadProtocol == "FTP") { if (GrblInfo.IpAddress == string.Empty) { model.Message = (string)FindResource("NoConnection"); } else { using (new UIUtils.WaitCursor()) { model.Message = (string)FindResource("Uploading"); try { using (WebClient client = new WebClient()) { client.Credentials = new NetworkCredential("grblHAL", "grblHAL"); client.UploadFile(string.Format("ftp://{0}/{1}", GrblInfo.IpAddress, filename.Substring(filename.LastIndexOf('\\') + 1)), WebRequestMethods.Ftp.UploadFile, filename); ok = true; } } catch (WebException ex) { model.Message = ex.Message.ToString() + " " + ((FtpWebResponse)ex.Response).StatusDescription; } catch (System.Exception ex) { model.Message = ex.Message.ToString(); } } } } else { model.Message = (string)FindResource("Uploading"); YModem ymodem = new YModem(); ymodem.DataTransferred += Ymodem_DataTransferred; ok = ymodem.Upload(filename); } if (!(GrblInfo.UploadProtocol == "FTP" && !ok)) { model.Message = (string)FindResource(ok ? "TransferDone" : "TransferAborted"); } GrblSDCard.Load(model); } }