예제 #1
0
        private void RemovePage(EdgeBarPage edgeBarPage)
        {
            IntPtr hWndEdgeBarPage = edgeBarPage.Handle;

            // We use the IUnknown pointer of the document as the dictionary key.
            IntPtr pUnk = Marshal.GetIUnknownForObject(edgeBarPage.Document);

            Marshal.Release(pUnk);

            if (_edgeBarPageDictionary.ContainsKey(pUnk))
            {
                _edgeBarPageDictionary.Remove(pUnk);
                edgeBarPage.Dispose();

                _edgeBar.RemovePage(edgeBarPage.Document, hWndEdgeBarPage.ToInt32(), 0);
            }
        }
예제 #2
0
        private EdgeBarPage AddPage(object theDocument, EdgeBarControl edgeBarControl)
        {
            EdgeBarPage edgeBarPage = null;
            IntPtr      hWndPage    = IntPtr.Zero;

            // We use the IUnknown pointer of the document as the dictionary key.
            IntPtr pUnk = Marshal.GetIUnknownForObject(theDocument);

            Marshal.Release(pUnk);

            // Only add a new EdgeBarPage if one hasn't already been added.
            if (!_edgeBarPageDictionary.ContainsKey(pUnk))
            {
                if (_myAddIn.ResourceAssembly != null)
                {
                    System.Reflection.Assembly resourceAssembly = _myAddIn.ResourceAssembly;

                    // If ResourceAssembly is null, default to the currently executing assembly.
                    if (resourceAssembly == null)
                    {
                        resourceAssembly = Assembly.GetExecutingAssembly();
                    }

                    hWndPage = new IntPtr(_edgeBar.AddPageEx(theDocument, resourceAssembly.Location, edgeBarControl.BitmapID, edgeBarControl.ToolTip, 2));
                }

                // ISolidEdgeBarEx.AddPage() may return null.
                if (!hWndPage.Equals(IntPtr.Zero))
                {
                    edgeBarPage = new EdgeBarPage(hWndPage, theDocument, edgeBarControl);
                }

                _edgeBarPageDictionary.Add(pUnk, edgeBarPage);
            }
            else
            {
                edgeBarPage = _edgeBarPageDictionary[pUnk];
            }

            return(edgeBarPage);
        }