/// <summary> /// Updates the info in the data files section. /// </summary> /// <param name="control"></param> /// <param name="datafile"></param> private static void UpdateDatafileInfo(DatafileControl control, Datafile datafile) { // Data file info FileInfo fileInfo = new FileInfo(Path.Combine(datafileDir, datafile.Filename)); // Assign info control.gbDatafile.Text = datafile.Filename; control.lblMD5Sum.Text = datafile.MD5Sum; control.dtpDatafiles.Value = fileInfo.LastWriteTime; }
/// <summary> /// Adds a control for each data file. /// </summary> private void CustomLayout() { int startLocation = 70; int pad = 5; gbDatafiles.Controls.Remove(datafileControl); Height -= datafileControl.Height; SuspendLayout(); try { foreach (var datafile in s_datafiles.OrderBy(x => x.Filename)) { // Add a new datafile control var newDatafileControl = new DatafileControl(); gbDatafiles.Controls.Add(newDatafileControl); // Control info UpdateDatafileInfo(newDatafileControl, datafile); // Set Properties newDatafileControl.Location = new Point(9, startLocation); newDatafileControl.Font = new Font(Font, FontStyle.Regular); newDatafileControl.Anchor |= AnchorStyles.Right; newDatafileControl.Size = new Size(gbDatafiles.Width - (pad * 3), newDatafileControl.Height); newDatafileControl.Name = String.Format("gbDatafile_{0}", newDatafileControl.gbDatafile.Text.Replace(datafileHeader, String.Empty).Replace(datafileTail, String.Empty)); // Calculate window height and next control point Height += datafileControl.Height + pad; startLocation += datafileControl.Height + pad; // Subscribe Events newDatafileControl.rtbDatafileMessage.Enter += Control_Enter; newDatafileControl.rtbDatafileMessage.Leave += Control_Leave; newDatafileControl.rtbDatafileMessage.DoubleClick += Control_DoubleClick; } } finally { // Update the message of each data file control UpdateDatafilesMessage(); ResumeLayout(); } CenterToScreen(); }