// Constructor public EditModeInfo(Plugin plugin, Type type, EditModeAttribute attr) { // Initialize this.plugin = plugin; this.type = type; this.attribs = attr; // Make switch action info if (!string.IsNullOrEmpty(attribs.SwitchAction)) { switchactionattr = new BeginActionAttribute(attribs.SwitchAction); } // Make button info if (!string.IsNullOrEmpty(attr.ButtonImage)) { using (Stream stream = plugin.GetResourceStream(attr.ButtonImage)) { if (stream != null) { buttonimage = Image.FromStream(stream); buttondesc = attr.DisplayName + (attribs.IsDeprecated ? " (deprecated)" : ""); buttonorder = attr.ButtonOrder; } } } // We have no destructor GC.SuppressFinalize(this); }
// Constructor public EditModeInfo(Plugin plugin, Type type, EditModeAttribute attr) { // Initialize this.plugin = plugin; this.type = type; this.attribs = attr; // Make switch action info if ((attribs.SwitchAction != null) && (attribs.SwitchAction.Length > 0)) { switchactionattr = new BeginActionAttribute(attribs.SwitchAction); } // Make button info if (attr.ButtonImage != null) { buttonimagestream = plugin.GetResourceStream(attr.ButtonImage); if (buttonimagestream != null) { buttonimage = Image.FromStream(buttonimagestream); buttondesc = attr.DisplayName; buttonorder = attr.ButtonOrder; } } // We have no destructor GC.SuppressFinalize(this); }
/// <summary> /// Provides basic user input interface functionality for a Doom Builder editing mode. /// </summary> public EditMode() { // Fetch attributes object[] attrs = this.GetType().GetCustomAttributes(true); foreach (object a in attrs) { if (a is EditModeAttribute) { attributes = (EditModeAttribute)a; break; } } // No attributes found? if (attributes == null) { throw new Exception("Editing mode \"" + this.GetType().Name + "\" is missing EditMode attributes!"); } // We have no destructor GC.SuppressFinalize(this); }