Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void OnSplitterMoved(object sender, SplitterEventArgs e)
        {
            if (m_inSplitterMovedMethod)
            {
                return;
            }

            if (m_firstMainControl == null || m_secondMainControl == null)
            {
                m_previousSplitterPosition = SplitterDistance;                 // Remember it, if nothing else.
                return;
            }

            m_inSplitterMovedMethod = true;
            try
            {
                // See if some ISnapSplitPosition wants to take over.
                if (Orientation == Orientation.Vertical && m_previousSplitterPosition != kCollapsedSize)
                {
                    // The old position was not shrunk to the icon, and this has a vertical splitter bar.
                    int splitDistance = SplitterDistance;
                    if ((m_firstMainControl is ISnapSplitPosition &&
                         (m_firstMainControl as ISnapSplitPosition).SnapSplitPosition(ref splitDistance)))
                    {
                        // m_firstMainControl decided to take control. We only do this when the splitter is vertical.
                        SplitterDistance           = splitDistance;
                        m_previousSplitterPosition = splitDistance;
                        return;
                    }
                    // It may be a PaneBarContainer
                    if (m_firstMainControl is PaneBarContainer)
                    {
                        PaneBarContainer pbc = m_firstMainControl as PaneBarContainer;
                        // pbc.MainControl could be a nested MultiPane, but we don't care about it.
                        // MultiPane won't implement ISnapSplitPosition, so we are good on that point.
                        if (pbc.MainControl is ISnapSplitPosition &&
                            (pbc.MainControl as ISnapSplitPosition).SnapSplitPosition(ref splitDistance))
                        {
                            SplitterDistance           = splitDistance;
                            m_previousSplitterPosition = splitDistance;
                            return;
                        }
                    }
                }

                // In order to get here, no ISnapSplitPosition took over in the above code,
                // if it had a chance at all, that is.
                if (m_wantResetControls)
                {
                    ResetControls();
                    m_previousSplitterPosition = SplitterDistance;
                }
            }
            finally
            {
                m_inSplitterMovedMethod = false;
            }
        }
Exemplo n.º 2
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);
            }
        }