Create custom classes that inherit from NOpenCommandAction, NSaveAsCommandAction and NInsertImageCommandAction and override the GetFormats method to return only the text/image file formats you want to show in the file dialogs.
For example, the following custom commands will show only the Microsoft Word (DOCX) and Rich Text (RTF) file formats:
Custom Rich Text "Open" command action |
Copy Code
|
---|---|
public class CustomOpenCommandAction : NOpenCommandAction { public CustomOpenCommandAction() { } static CustomOpenCommandAction() { CustomOpenCommandActionSchema = NSchema.Create(typeof(CustomOpenCommandAction), NOpenCommandActionSchema); } protected override NTextFormat[] GetFormats() { return new NTextFormat[] { new NDocxTextFormat(), new NRtfTextFormat() }; } public static readonly NSchema CustomOpenCommandActionSchema; } |
Custom Rich Text "Save As" command action |
Copy Code
|
---|---|
public class CustomSaveAsCommandAction : NSaveAsCommandAction { public CustomSaveAsCommandAction() { } static CustomSaveAsCommandAction() { CustomSaveAsCommandActionSchema = NSchema.Create(typeof(CustomSaveAsCommandAction), NSaveAsCommandActionSchema); } protected override NTextFormat[] GetFormats() { return new NTextFormat[] { new NDocxTextFormat(), new NRtfTextFormat() }; } public static readonly NSchema CustomSaveAsCommandActionSchema; } |
You can change the file formats shown in the Insert Image dialog in the same way - create a command action that inherits from NInsertImageCommandAction and override its GetFormats method:
Custom Rich Text "Insert Image" command action |
Copy Code
|
---|---|
private class CustomInsertImageCommandAction : NInsertImageCommandAction { public CustomInsertImageCommandAction() { } static CustomInsertImageCommandAction() { CustomInsertImageCommandActionSchema = NSchema.Create(typeof(CustomInsertImageCommandAction), NInsertImageCommandActionSchema); } protected override NImageFormat[] GetFormats() { return new NImageFormat[] { NImageFormat.Jpeg, NImageFormat.Png }; } public static readonly NSchema CustomInsertImageCommandActionSchema; } |