public override HResult Initialize() { try { var hr = base.Initialize(); if (ErrorUtil.Failure(hr)) return hr; var commandManager = (INiCommandManager)GetService(typeof(INiCommandManager)); var menuManager = (NiMenuManager)GetService(typeof(INiMenuManager)); INiCommandBar toolbar; ErrorUtil.ThrowOnFailure(commandManager.FindCommandBar(_id, out toolbar)); if (toolbar != null) { _control = menuManager.CreateHost((NiCommandBar)toolbar); var toolStrip = (ToolStrip)_control.Control; toolStrip.GripStyle = ToolStripGripStyle.Hidden; Controls.Add(toolStrip); } return HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
protected override void Dispose(bool disposing) { if (!_disposed) { if (_control != null) { _control.Dispose(); _control = null; } _disposed = true; } base.Dispose(disposing); }