private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = dataGridViewFiles.Rows[e.RowIndex]; IBufferData d = row.Tag as IBufferData; int ri = e.ColumnIndex; string text = row.Cells[ri].Value + ""; if (ri == 1) { if (d.Comment.Equals(text)) { return; } d.Comment = text; return; } if (ri == 0) { if (d.Name.Equals(text)) { return; } IBufferDirectory dir = d.Parent as IBufferDirectory; List <string> l = dir.GetDirectoryNames(); string name = d.Name; l.Remove(name); if (l.Contains(text)) { MessageBox.Show(this, "Name already exist"); row.Cells[ri].Value = name; return; } d.Name = text; } }
void AddDirectory() { TreeNode s = selected; if (s == null) { return; } IBufferDirectory d = s.Tag as IBufferDirectory; try { List <string> l = d.GetDirectoryNames(); for (int i = 1; ; i++) { string n = "New folder" + i; if (!l.Contains(n)) { IBufferDirectory ld = d.Create(n, ""); TreeNode nd = ld.CreateNode(true); s.Nodes.Add(nd); return; } } } catch (Exception exception) { exception.ShowError(); } }
/// <summary> /// Creates a directory /// </summary> /// <param name="parent">Parent</param> /// <param name="name">Name</param> /// <param name="comment">Comment</param> /// <returns>Rhe directory</returns> static public IBufferDirectory Create(this IBufferDirectory parent, string name, string comment) { if (parent.GetDirectoryNames().Contains(name)) { throw new Exception(name + " already exists"); } IBufferDirectory result = new BufferDirectoryWrapper(parent as BufferDirectoryWrapper, data.Create(parent.Id, name, comment)); StaticExtensionDataPerformerInterfaces.Data.SubmitChanges(); return(result); }
/// <summary> /// Creates data /// </summary> /// <param name="directory">Directory</param> /// <param name="data">Data</param> /// <param name="name"></param> /// <param name="fileName">File name</param> /// <param name="comment">Comment</param> /// <returns>The data</returns> public static IBufferData CreateData(this IBufferDirectory directory, IEnumerable <byte[]> data, string name, string fileName, string comment) { IDatabaseInterface d = StaticExtensionDataPerformerInterfaces.data; /* !!! if (d.Filenames.Contains(fileName)) * { * throw new Exception("File " + fileName + " already exists"); * }*/ if (directory.GetDirectoryNames().Contains(name)) { throw new Exception(name + " already exists"); } IBufferData ld = d.Create(data, directory.Id, name, fileName, comment); return(new BufferItemWrapper(directory as BufferDirectoryWrapper, ld)); }
private void treeViewDir_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (e.Label == null) { return; } TreeNode s = e.Node; if (s == null) { return; } object o = s.Tag; if (o == null) { return; } if (o is IBufferItem) { IBufferItem item = o as IBufferItem; IBufferItem p = item.Parent; if (p == null | !(p is IBufferDirectory)) { MessageBox.Show("Prohibited"); return; } IBufferDirectory d = p as IBufferDirectory; List <string> names = d.GetDirectoryNames(); string name = e.Label; if (names.Contains(name)) { MessageBox.Show("Name alredy exists"); return; } try { item.Name = name; } catch (Exception exception) { exception.ShowError(); } } }