예제 #1
0
        /// <summary>
        /// Initialize ribbon framework
        /// </summary>
        /// <param name="resourceName">Identifier of the ribbon resource</param>
        /// <param name="hInstance">Pointer to HINSTANCE of module where we can find ribbon resource</param>
        void InitFramework(string resourceName, IntPtr hInstance)
        {
            // create ribbon framework object
            Framework        = CreateRibbonFramework();
            _imageFromBitmap = CreateImageFromBitmapFactory();

            // create ribbon application object
            _application = new RibbonUIApplication(this, this);

            // init ribbon framework
            HRESULT hr = Framework.Initialize(this.WindowHandle, _application);

            if (NativeMethods.Failed(hr))
            {
                Marshal.ThrowExceptionForHR((int)hr);
            }

            // load ribbon ui
            hr = Framework.LoadUI(hInstance, resourceName);

            if (!(Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor <= 1 || Environment.OSVersion.Version.Major < 6))
            {
                IUIEventingManager eventingManager = Framework as IUIEventingManager;
                if (eventingManager != null)
                {
                    EventLogger = new EventLogger(eventingManager);
                }
            }

            if (NativeMethods.Failed(hr))
            {
                Marshal.ThrowExceptionForHR((int)hr);
            }
        }
예제 #2
0
파일: Ribbon.cs 프로젝트: nangs/RibbonLib
        /// <summary>
        /// Initalize ribbon framework
        /// </summary>
        /// <param name="form">Form where ribbon should reside</param>
        /// <param name="resourceName">Identifier of the ribbon resource</param>
        /// <param name="hInstance">Pointer to HINSTANCE of module where we can find ribbon resource</param>
        void InitFramework(string resourceName, IntPtr hInstance)
        {
            // create ribbon framework object
            Framework        = CreateRibbonFramework();
            _imageFromBitmap = CreateImageFromBitmapFactory();

            // create ribbon application object
            _application = new RibbonUIApplication(this, this);

            // init ribbon framework
            HRESULT hr = Framework.Initialize(this.WindowHandle, _application);

            if (NativeMethods.Failed(hr))
            {
                Marshal.ThrowExceptionForHR((int)hr);
            }

            // load ribbon ui
            hr = Framework.LoadUI(hInstance, resourceName);


            if (NativeMethods.Failed(hr))
            {
                Marshal.ThrowExceptionForHR((int)hr);
            }
        }
        private void InitializeRibbon()
        {

            IUIFramework framework = (IUIFramework)Activator.CreateInstance<Framework>();

            Trace.Assert(framework != null, "Failed to create IUIFramework.");

            ribbonControl = new RibbonControl(_htmlEditor.IHtmlEditorComponentContext, _htmlEditor);

            int initializeResult = framework.Initialize(_mainFrameWindow.Handle, this);
            Trace.Assert(initializeResult == HRESULT.S_OK, "Ribbon framework failed to initialize: " + initializeResult);

            _framework = framework;

            string nativeResourceDLL = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\OpenLiveWriter.Ribbon.dll";
            IntPtr hMod = Kernel32.LoadLibrary(nativeResourceDLL);

            using (new QuickTimer("IUIRibbonFramework::LoadUI"))
            {
                int loadResult = _framework.LoadUI(hMod, "RIBBON_RIBBON");
                Trace.Assert(loadResult == HRESULT.S_OK, "Ribbon failed to load: " + loadResult);
            }

            _framework.SetModes(mode);

            CommandManager.Invalidate(CommandId.MRUList);
            CommandManager.Invalidate(CommandId.OpenDraftSplit);
            CommandManager.Invalidate(CommandId.OpenPostSplit);

            ApplicationDiagnostics.TestModeChanged += OnTestModeChanged;
            TestMode = ApplicationDiagnostics.TestMode;
        }