public static IEnumerable<Ctrl.CommandItem> CreateCommandItems( Hix.IFormatImporter importer ) { var format = Hix.FormatRegistry.FindFormat( importer.FormatType ); if ( format != null ) { string name = "Import." + format.Name; string caption = string.Format( "{0} ({1})", format.Caption, format.FileFilter ); yield return CreateCommandItem( importer, typeof( void ), "File." + name, caption ); yield return CreateCommandItem( importer, typeof( Core.Document ), name, caption ); yield return CreateCommandItem( importer, typeof( Core.IEntry ), name, caption ); } }
static string GetFilterString( Hix.IFormatImporter importer ) { var format = Hix.FormatRegistry.FindFormat( importer.FormatType ); return string.Format( "{0} ({1})|{1}|All files (*.*)|*.*", format.Caption, format.FileFilter ); }
static Ctrl.CommandItem CreateCommandItem( Hix.IFormatImporter importer, Type target, string name, string caption ) { return new Hisui.Ctrl.CommandItem( new FormatImportCommand( importer, target ), name, caption ); }
FormatImportCommand( Hix.IFormatImporter importer, Type target ) { _importer = importer; _target = target; }
void Import( string filename, Hix.IFormatImporter importer, Ctrl.IContext con ) { using ( var progress = SI.PushProgress( "importing: " + filename ) ) { var entry = this.GetDestination( con ).Put( null ); using ( var stream = File.OpenRead( filename ) ) { progress.Step( 0.8 ); importer.Import( stream, entry ); } entry.Caption = Path.GetFileNameWithoutExtension( filename ); progress.Step( 0.2 ); con.View.Fit(); } }
public static Ctrl.CommandItem CreateCommandItem( Hix.IImporter importer, Type target ) { var command = new ImportCommand( importer, target ); return new Ctrl.CommandItem( command, command.Name, importer.MakeCaptionString() ); }
public ImportCommand( Hix.IImporter importer, Type target ) { _importer = importer; _target = target; }