private void OnPropertyGridCustomRecordCellEdit(object sender, DevExpress.XtraVerticalGrid.Events.GetCustomRowCellEditEventArgs e) { PropertyDescriptor desc = this.propertyGridControl1.GetPropertyDescriptor(e.Row); FileNameAttribute attr = GetFileNameAttribute(desc); if (attr == null) { return; } e.RepositoryItem = this.reFileEditorButton; }
static long GetSize(MasterFileTableEntry entry) { foreach (var attr in entry.Attributes) { FileNameAttribute fna = attr as FileNameAttribute; if (fna != null) { return(fna.RealSize); } } return(0); }
/// <summary> /// Read our XML configuration file /// </summary> public static void DetermineFileTypes() { //Add in our list of file paths foreach (Type FoundType in typeof(MM_Line_Data).Assembly.GetTypes()) { UpdateCommandAttribute UpdateCommand = null; RetrievalCommandAttribute RetrievalCommand = null; FileNameAttribute FileName = null; foreach (object obj in FoundType.GetCustomAttributes(false)) { if (obj is UpdateCommandAttribute) { UpdateCommand = (UpdateCommandAttribute)obj; } else if (obj is FileNameAttribute) { FileName = (FileNameAttribute)obj; } else if (obj is RetrievalCommandAttribute) { RetrievalCommand = (RetrievalCommandAttribute)obj; } } if (UpdateCommand != null && FileName != null) { MM_EMSReader_TCP.InputTypes.Add(FileName.FileName, FoundType); MM_EMSReader_TCP.UpdateCommands.Add(FileName.FileName, UpdateCommand.UpdateCommand); if (!String.IsNullOrEmpty(Settings.Default.TEDESourceFolder)) { MM_EMSReader_File.FileInfo.Add(FileName.FileName, new MM_EMSReader_File(Path.Combine(Settings.Default.TEDESourceFolder, FileName.FileName), UpdateCommand.UpdateCommand, FoundType)); } } // FileInfo.Add(FileName.FileName, new MM_EMSReader_FileInformation(Path.Combine(Settings.Default.SourceFolder,FileName.FileName), UpdateCommand.UpdateCommand, FoundType)); //Check our update command, make sure it's okay if (UpdateCommand != null && FileName != null && typeof(IMM_ConversationMessage_Types).GetMethod(UpdateCommand.UpdateCommand) == null) { MM_Notification.WriteLine(ConsoleColor.Yellow, "Unable to find update command {0} for type {1}", UpdateCommand.UpdateCommand, FileName.FileName); } if (RetrievalCommand != null && FileName != null && typeof(IMM_EMS_Types).GetMethod(RetrievalCommand.RetrievalCommand) == null) { MM_Notification.WriteLine(ConsoleColor.Yellow, "Unable to find retrieval command {0} for type {1}", RetrievalCommand.RetrievalCommand, FileName.FileName); } } }
public string GetAttribute(Type t) { // Get instance of the attribute. FileNameAttribute MyAttribute = (FileNameAttribute)Attribute.GetCustomAttribute(t, typeof(FileNameAttribute)); if (MyAttribute == null) { Console.WriteLine("The attribute was not found."); return(""); } else { // Get the Name value. return(MyAttribute.FileName); } }
private void reFileEditorButton_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { PropertyDescriptor desc = this.propertyGridControl1.GetPropertyDescriptor(this.propertyGridControl1.FocusedRow); FileNameAttribute attr = GetFileNameAttribute(desc); if (attr == null) { throw new Exception("FileAttribute == null"); } if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Open Simulation File"; dlg.Filter = attr.FilterString; if (dlg.ShowDialog() == DialogResult.OK) { this.propertyGridControl1.SetCellValue(this.propertyGridControl1.FocusedRow, 0, dlg.FileName); this.propertyGridControl1.CloseEditor(); } } }
static string GetPath(MasterFileTable mft, MasterFileTableEntry entry) { if (entry.SequenceNumber == MasterFileTable.RootDirectoryIndex) { return("<root>"); } FileNameAttribute fna = null; foreach (var attr in entry.Attributes) { FileNameAttribute thisFna = attr as FileNameAttribute; if (thisFna != null) { if (fna == null || thisFna.FileNameNamespace == NtfsNamespace.Win32 || thisFna.FileNameNamespace == NtfsNamespace.Win32AndDos) { fna = thisFna; } } } if (fna == null) { return("<unknown>"); } string parentPath = "<unknown>"; MasterFileTableEntry parentEntry = mft[fna.ParentDirectory.RecordIndex]; if (parentEntry != null) { if (parentEntry.SequenceNumber == fna.ParentDirectory.RecordSequenceNumber || parentEntry.SequenceNumber == fna.ParentDirectory.RecordSequenceNumber + 1) { parentPath = GetPath(mft, parentEntry); } } return(parentPath + "\\" + fna.FileName); }
/// <summary> /// Unloads any existing collision and loads a new collision flle. /// Warning: Calling this asynchronously (outside of main thread) is dangerous. /// If calling asynchronously, recommend using <see cref="Queue"/> to call this function. /// </summary> /// <param name="stage">Stage to load the collision for.</param> public static void LoadCollision(Definitions.Enums.Stage stage) { LoadCollision(FileNameAttribute.GetFileName(stage)); }