Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Destroy ribbon framework
        /// </summary>
        void DestroyFramework()
        {
            if (Initalized)
            {
                // destroy ribbon framework
                Framework.Destroy();
                Marshal.ReleaseComObject(Framework);

                // remove reference to framework object
                Framework = null;
            }

            // Unregister event handlers
            RegisterForm(null);

            if (_loadedDllHandle != IntPtr.Zero)
            {
                // free dynamic library
                NativeMethods.FreeLibrary(_loadedDllHandle);
                _loadedDllHandle = IntPtr.Zero;
            }

            if (_imageFromBitmap != null)
            {
                // remove reference to imageFromBitmap object
                _imageFromBitmap = null;
            }

            if (_application != null)
            {
                // remove reference to application object
                _application = null;
            }

            // remove references to ribbon controls
            _mapRibbonControls.Clear();

            if (!string.IsNullOrEmpty(_tempDllFilename))
            {
                try
                {
                    File.Delete(_tempDllFilename);
                    _tempDllFilename = null;
                }
                catch { }
            }
        }
        /// <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);
            }
        }
        /// <summary>
        /// Destroy ribbon framework
        /// </summary>
        void DestroyFramework()
        {
            if (Initalized)
            {
                // destroy ribbon framework
                Framework.Destroy();
                Marshal.ReleaseComObject(Framework);

                // remove reference to framework object
                Framework = null;
            }

            // Unregister event handlers
            RegisterForm(null);

            if (_loadedDllHandle != IntPtr.Zero)
            {
                // free dynamic library
                NativeMethods.FreeLibrary(_loadedDllHandle);
                _loadedDllHandle = IntPtr.Zero;
            }

            if (_imageFromBitmap != null)
            {
                // remove reference to imageFromBitmap object
                _imageFromBitmap = null;
            }

            if (_application != null)
            {
                // remove reference to application object
                _application = null;
            }

            // remove references to ribbon controls
            _mapRibbonControls.Clear();

            if (!string.IsNullOrEmpty(_tempDllFilename))
            {
                try
                {
                    File.Delete(_tempDllFilename);
                    _tempDllFilename = null;
                }
                catch { }
            }
        }