示例#1
0
        /// <summary>
        /// Attach secondary view contents to the view content.
        /// </summary>
        /// <param name="viewContent">The view content to attach to</param>
        /// <param name="isReattaching">This is a reattaching pass</param>
        public void AttachSubWindows(IViewContent viewContent, bool isReattaching)
        {
            SD.MainThread.VerifyAccess();
            if (viewContent == null)
            {
                throw new ArgumentNullException("viewContent");
            }

            foreach (DisplayBindingDescriptor binding in bindings)
            {
                if (binding.IsSecondary && binding.CanOpenFile(viewContent.PrimaryFileName))
                {
                    ISecondaryDisplayBinding displayBinding = binding.SecondaryBinding;
                    if (displayBinding != null &&
                        (!isReattaching || displayBinding.ReattachWhenParserServiceIsReady) &&
                        displayBinding.CanAttachTo(viewContent))
                    {
                        IViewContent[] subViewContents = binding.SecondaryBinding.CreateSecondaryViewContent(viewContent);
                        if (subViewContents != null)
                        {
                            Array.ForEach(subViewContents, viewContent.SecondaryViewContents.Add);
                        }
                        else
                        {
                            MessageService.ShowError("Can't attach secondary view content. " + binding.SecondaryBinding + " returned null for " + viewContent + ".\n(should never happen)");
                        }
                    }
                }
            }
        }
 public static void AttachSubWindows(IViewContent viewContent, bool isReattaching)
 {
     foreach (DisplayBindingDescriptor binding in bindings)
     {
         if (binding.IsSecondary && binding.CanAttachToFile(viewContent.FileName ?? viewContent.UntitledName))
         {
             ISecondaryDisplayBinding displayBinding = binding.SecondaryBinding;
             if (displayBinding != null &&
                 (!isReattaching || displayBinding.ReattachWhenParserServiceIsReady) &&
                 displayBinding.CanAttachTo(viewContent))
             {
                 ISecondaryViewContent[] subViewContents = binding.SecondaryBinding.CreateSecondaryViewContent(viewContent);
                 if (subViewContents != null)
                 {
                     viewContent.SecondaryViewContents.AddRange(subViewContents);
                 }
                 else
                 {
                     MessageService.ShowError("Can't attach secondary view content. " + binding.SecondaryBinding + " returned null for " + viewContent + ".\n(should never happen)");
                 }
             }
         }
     }
 }