Пример #1
0
        public int Close(IOleParentUndoUnit pPUU, int fCommit)
        {
            if (pPUU == null)
            {
                return(VSConstants.S_FALSE);
            }

            if (_openParent == null)
            {
                return(VSConstants.S_FALSE);
            }

            var hr = _openParent.Close(pPUU, fCommit);

            if (VSErrorHandler.Failed(hr))
            {
                return(hr);
            }

            if (_openParent == pPUU)
            {
                _openParent = null;
                if (fCommit != 0)
                {
                    _children.Add(pPUU);
                }
                return(VSConstants.S_OK);
            }
            else
            {
                throw new ArgumentException("Closing the wrong parent unit!");
            }
        }
        private void LoadEDMPackage()
        {
            var vsShell = (IVsShell)GetService(typeof(SVsShell));

            Debug.Assert(vsShell != null, "unexpected null value for vsShell");
            IVsPackage package = null;

            if (vsShell != null)
            {
                var packageGuid = guidEscherPkg;
                vsShell.IsPackageLoaded(ref packageGuid, out package);
                if (package == null)
                {
                    var hr = vsShell.LoadPackage(ref packageGuid, out package);
                    if (VSErrorHandler.Failed(hr))
                    {
                        var msg = String.Format(CultureInfo.CurrentCulture, Resources.PackageLoadFailureExceptionMessage, hr);
                        throw new InvalidOperationException(msg);
                    }
                }
            }
        }
Пример #3
0
        public override int GetInitialExtent(out int line, out int startIdx, out int endIdx)
        {
            int returnCode = base.GetInitialExtent(out line, out startIdx, out endIdx);

            if (ErrorHandler.Failed(returnCode) || (view == null))
            {
                return(returnCode);
            }

            TextSpan secondary = new TextSpan();

            secondary.iStartLine  = secondary.iEndLine = line;
            secondary.iStartIndex = startIdx;
            secondary.iEndIndex   = endIdx;

            TextSpan primary = view.GetPrimarySpan(secondary);

            line     = primary.iStartLine;
            startIdx = primary.iStartIndex;
            endIdx   = primary.iEndIndex;

            return(returnCode);
        }