public static TableContents GetContents() { if (File.Exists(contentsFile)) { TableContents tableContents = JsonConvert.DeserializeObject <TableContents>(File.ReadAllText(contentsFile, Encoding.UTF8)); var defaultColumns = GetColumns(); if (tableContents.Columns.Count != defaultColumns.Count) { for (int i = tableContents.Columns.Count; i < defaultColumns.Count; i++) { tableContents.Columns.Add(defaultColumns[i]); } } return(tableContents); } else { var tableContents = new TableContents { Columns = GetColumns(), TableData = new List <TableContent> { } }; SaveContents(tableContents); return(tableContents); } }
private void DataGridView1_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e) { for (int i = 0; i < dataGridView1.Columns.Count; i++) { var column = dataGridView1.Columns[i]; contents.Columns[i].ColumnWidth = column.Width; } TableContents.SaveContents(contents); }
public MainWindow() { InitializeComponent(); contents = TableContents.GetContents(); SetupWindow(); RefreshTableContents(); ClearSelectedRows(); timer.Tick += Timer_Tick; timer.Interval = 200; // millis otherTimer.Tick += OtherTimer_Tick; otherTimer.Interval = 200; // millis }
private void addButton_Click(object sender, EventArgs e) { var content = new TableContent { FileName = this.fileNameTextBox.Text ?? "", Referer = this.refererTextBox.Text ?? "", Url = this.urltextBox.Text ?? "" }; if (content.FileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { errorLabel.Text = "File name invalid"; } else { MainWindow.contents.TableData.Add(content); TableContents.SaveContents(MainWindow.contents); this.Close(); } }
private void MainWindow_ResizeEnd(object sender, EventArgs e) { contents.Size = this.ClientSize; TableContents.SaveContents(contents); }
public static void SaveContents(TableContents contents) { File.WriteAllText(path: contentsFile, contents: JsonConvert.SerializeObject(contents), encoding: Encoding.UTF8); }