private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Cancelled || e.Error != null) { this.DownloaderCompleted?.Invoke(sender, new DownloaderCompletedEventArgs(e.Cancelled, e.Error)); } else { var index = (int)e.UserState; SWFile swFile = SWFileManager.GetElementAt(index); if (swFile is ArchivedSWFile archivedSWFile) { archivedSWFile.Data = e.Result; } else { string swFilePath = Path.Combine(this.Language.Path, swFile.Path, Path.GetFileName(swFile.PathD)); string swFileDirectory = Path.GetDirectoryName(swFilePath); Directory.CreateDirectory(swFileDirectory); File.WriteAllBytes(swFilePath, e.Result); } if (SWFileManager.Count > ++index) { this.DownloadNext(index); } else { this.DownloaderCompleted?.Invoke(sender, new DownloaderCompletedEventArgs(this.Language, e.Cancelled, e.Error)); } } }
public ChangePropertyForm(Project Project, SWFile File) { InitializeComponent(); project = Project; file = File; this.valueGroupBox.Text = Settings.Default.propertyName; this.valueTextBox.Text = this.file.name; }
/// <summary> /// Updates file's name, path and status in grid view. Use only from thread that created the UI !!! /// </summary> /// <param name="f">File to update</param> public void updateFile(SWFile f) { foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Tag == f) { row.Cells[typeColumn.Index].Value = f.typeString; row.Cells[nameColumn.Index].Value = f.name; row.Cells[filepath.Index].Value = f.file; SWFileStatus s = f.getStatus(); if (s != f.lastShownStatus) { row.Cells[statusColumn.Index].Value = s.ToString(); row.Cells[dataGridView1.Columns["statusColumn"].Index].Style.ForeColor = s.Color; } f.lastShownStatus = s; break; } } }
/// <summary> /// Schedules update of file's name, path and status in grid view. Use this if calling update from foreign thread. /// </summary> /// <param name="f">File to update</param> public void scheduleFileUpdate(SWFile f) { filesToUpdate.Add(f); }
private void openFile(SWFile f) { int ret = f.open(); if (ret == SWFile.RET_FILE_MISSING) { MessageBox.Show(String.Format("Can\'t find file {0}", f.file), "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dataGridView1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo ht; ht = dataGridView1.HitTest(e.X, e.Y); if (ht.Type == DataGridViewHitTestType.Cell) { currentContextFile = getFileByRowIndex(ht.RowIndex); contextMenuStrip1.Items[changePropertyValueMenuItem.Name].Text = String.Format(contextMenuStrip1.Items[changePropertyValueMenuItem.Name].Text, Settings.Default.propertyName); // Enable items by default foreach (object x in contextMenuStrip1.Items) { if (x.GetType() == toolStripSeparator1.GetType()) { continue; } ToolStripMenuItem q = (ToolStripMenuItem)x; q.Enabled = true; } if (currentContextFile != null) { contextMenuStrip1.Items[chooseFileManuallyToolStripMenuItem.Name].Enabled = false; if (currentContextFile.getStatus().Type == SWFileStatusType.FILE_MISSING) { contextMenuStrip1.Items[chooseFileManuallyToolStripMenuItem.Name].Enabled = true; } } else { foreach (object x in contextMenuStrip1.Items) { if (x.GetType() == toolStripSeparator1.GetType()) { break; } ToolStripMenuItem q = (ToolStripMenuItem)x; q.Enabled = false; } } if (Settings.Default.showEmptyRows) { showEmptyRowsToolStripMenuItem.Checked = true; } contextMenuStrip1.Show(dataGridView1, e.Location); } } }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } currentContextFile = getFileByRowIndex(e.RowIndex); openFile(currentContextFile); }
private void chooseFile(SWFile f) { OpenFileDialog fd = new OpenFileDialog(); fd.Multiselect = false; if (f.typeString == new SWPart().typeString) { fd.Filter = "SolidWorks Part|*.sldprt"; } else { fd.Filter = "Solidworks Assembly|*.sldasm"; } DialogResult r = fd.ShowDialog(); if (r == DialogResult.OK) { if (!(fd.FileName.ToLower().StartsWith(project.workDir.ToLower()))) { MessageBox.Show("File is not in the workdir!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } f.file = Path.GetFileName(fd.FileName); updateFile(currentContextFile); } }