A MultiPane (actually currently more a DualPane) displays two child controls, either side by side or one above the other, with a splitter between them. It is normally created using XML like this: The vertical parameter causes the two controls to be one above the other, if true, or side by side, if false. (Default, if omitted, is true.) The id parameter gives the MultiPane a name (which should be unique across the whole containing application) to use in storing state, such as the position of the splitter, persistently. It is mandatory to specify the area that the control is part of, but I (JT) don't know why. If the mediator has a property called id_ShowFirstPane (e.g., LexEntryAndEditor_ShowFirstPane), it will control the visibility of the first pane (visible if the property is true).
IxCoreContentControl includes IxCoreColleague now, so only IxCoreContentControl needs to be declared here.
상속: XCore.CollapsingSplitContainer, IxCoreContentControl, IXCoreUserControl
예제 #1
0
        /// <summary></summary>
        public void Init(Mediator mediator, XmlNode configurationParameters)
        {
            CheckDisposed();

            SuspendLayout();

            m_mediator = mediator;
            m_configurationParameters = configurationParameters;

            // Make the IPaneBar.
            IPaneBar paneBar = CreatePaneBar();
            // initialize the panebar
            string groupId = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "PaneBarGroupId", null);

            if (groupId != null)
            {
                XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window");
                SIL.Utils.ImageCollection small = (SIL.Utils.ImageCollection)m_mediator.PropertyTable.GetValue("smallImages");
                paneBar.Init(small, (IUIMenuAdapter)window.MenuAdapter, m_mediator);
            }
            ReloadPaneBar(paneBar);
            m_paneBar = paneBar;
            Controls.Add(paneBar as Control);

            // Make the main control.
            XmlNode mainControlNode = m_configurationParameters.SelectSingleNode("control");
            Control mainControl     = DynamicLoader.CreateObjectUsingLoaderNode(mainControlNode) as Control;

            if (mainControl == null)
            {
                throw new ApplicationException("Soemthing went wrong trying to create the main control.");
            }

            if (!(mainControl is IxCoreContentControl))
            {
                throw new ApplicationException("A PaneBarContainer can only handle controls which implement IxCoreContentControl.");
            }

            mainControl.SuspendLayout();
            m_mainControl    = mainControl;
            mainControl.Dock = DockStyle.Fill;
            if (mainControl is IPaneBarUser)
            {
                (mainControl as IPaneBarUser).MainPaneBar = paneBar;
            }

            /*
             * if (mainControl is MultiPane)
             * {
             *      MultiPane mp = mainControl as MultiPane;
             *      mp.DefaultPrintPaneId = DefaultPrintPaneId;
             *      mp.ParentSizeHint = ParentSizeHint;
             * }*/
            (mainControl as IxCoreColleague).Init(m_mediator, mainControlNode.SelectSingleNode("parameters"));
            Controls.Add(mainControl);
            if (mainControl is MultiPane)
            {
                MultiPane mp = mainControl as MultiPane;
                mp.DefaultPrintPaneId = DefaultPrintPaneId;
                mp.ParentSizeHint     = ParentSizeHint;
                if (mp.FirstControl is IPaneBarUser)
                {
                    (mp.FirstControl as IPaneBarUser).MainPaneBar = paneBar;
                }
            }
            mainControl.BringToFront();
            mainControl.ResumeLayout(false);
            ResumeLayout(false);
        }
예제 #2
0
		/// <summary>
		/// When our parent changes, we may need to re-evaluate whether to show our info bar.
		/// </summary>
		/// <param name="e"></param>
		protected override void OnParentChanged(EventArgs e)
		{
			base.OnParentChanged (e);

			if (Parent == null)
				return;

			MultiPane mp = Parent as MultiPane;
			if (mp == null)
				mp = Parent.Parent as MultiPane;

			if (mp == null)
				return;

			string suppress = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "suppressInfoBar", "false");
			if (suppress == "ifNotFirst")
			{
				mp.ShowFirstPaneChanged += new EventHandler(mp_ShowFirstPaneChanged);
				m_mpParent = mp;
				mp_ShowFirstPaneChanged(mp, new EventArgs());
			}
		}
예제 #3
0
        private void MakeSubControl(XmlNode configuration, Size parentSizeHint, bool isFirst)
        {
            XmlNode dynLoaderNode = configuration.SelectSingleNode("dynamicloaderinfo");

            if (dynLoaderNode == null)
            {
                throw new ArgumentException("Required 'dynamicloaderinfo' XML node not found, while trying to make control for MultiPane.", "configuration");
            }

            string contentAssemblyPath = XmlUtils.GetManditoryAttributeValue(dynLoaderNode, "assemblyPath");
            string contentClass        = XmlUtils.GetManditoryAttributeValue(dynLoaderNode, "class");

            try
            {
                Control subControl = (Control)DynamicLoader.CreateObject(contentAssemblyPath, contentClass);
                if (subControl.AccessibleName == null)
                {
                    subControl.AccessibleName = contentClass;
                }
                if (!(subControl is IxCoreColleague))
                {
                    throw new ApplicationException(
                              "XCore can only handle controls which implement IxCoreColleague. " +
                              contentClass + " does not.");
                }
                if (!(subControl is IXCoreUserControl))
                {
                    throw new ApplicationException(
                              "XCore can only handle controls which implement IXCoreUserControl. " +
                              contentClass + " does not.");
                }

                subControl.SuspendLayout();

                subControl.Dock = DockStyle.Fill;

                // we add this before Initializing so that this child control will have access
                // to its eventual height and width, in case it needs to make initialization
                // decisions based on that.  for example, if the child is another multipane, it
                // will use this to come up with a reasonable default location for its splitter.
                if (subControl is MultiPane)
                {
                    MultiPane mpSubControl = subControl as MultiPane;
                    mpSubControl.ParentSizeHint = parentSizeHint;
                    // cause our subcontrol to inherit our DefaultPrintPane property.
                    mpSubControl.DefaultPrintPaneId = m_defaultPrintPaneId;
                }
                // we add this before Initializing so that this child control will have access
                // to its eventual height and width, in case it needs to make initialization
                // decisions based on that.  for example, if the child is another multipane, it
                // will use this to come up with a reasonable default location for its splitter.
                if (subControl is PaneBarContainer)
                {
                    PaneBarContainer mpSubControl = subControl as PaneBarContainer;
                    mpSubControl.ParentSizeHint = parentSizeHint;
                    // cause our subcontrol to inherit our DefaultPrintPane property.
                    mpSubControl.DefaultPrintPaneId = m_defaultPrintPaneId;
                }


                XmlNode parameters = null;
                if (configuration != null)
                {
                    parameters = configuration.SelectSingleNode("parameters");
                }
                ((IxCoreColleague)subControl).Init(m_mediator, parameters);

                // in normal situations, colleagues add themselves to the mediator when
                // initialized.  in this case, we don't want this colleague to add itself
                // because we want it to be subservient to this "papa" control.  however, since
                // this control is only experimental, I'm loathe to change the interfaces in
                // such a way as to tell a colleague that it should not add itself to the
                // mediator.  so, for now, we will just do this hack and remove the colleague
                // from the mediator.
                m_mediator.RemoveColleague((IxCoreColleague)subControl);

                if (isFirst)
                {
                    subControl.AccessibleName += ".First";
                    FirstControl = subControl;
                }
                else
                {
                    subControl.AccessibleName += ".Second";
                    SecondControl              = subControl;
                }
                subControl.ResumeLayout(false);
            }
            catch (Exception error)
            {
                string  s      = "Something went wrong trying to create a " + contentClass + ".";
                XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window");
                ErrorReporter.ReportException(new ApplicationException(s, error),
                                              window.ApplicationRegistryKey, m_mediator.FeedbackInfoProvider.SupportEmailAddress);
            }
        }
예제 #4
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing"><c>true</c> to release both managed and unmanaged
		/// resources; <c>false</c> to release only unmanaged resources.
		/// </param>
		/// -----------------------------------------------------------------------------------
		protected override void Dispose( bool disposing )
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if( disposing )
			{
				if(components != null)
					components.Dispose();
				if (ExistingClerk != null)
					ExistingClerk.BecomeInactive();
				if (m_mediator != null)
					m_mediator.RemoveColleague(this);
				if (m_mpParent != null)
				{
					m_mpParent.ShowFirstPaneChanged -= new EventHandler(mp_ShowFirstPaneChanged);
					m_mpParent.ShowFirstPaneChanged -= new EventHandler(mp_ShowFirstPaneChanged);
				}
			}
			m_mediator = null;
			m_informationBar = null; // Should be disposed automatically, since it is in the Controls collection.
			m_mpParent = null;

			base.Dispose( disposing );
		}