예제 #1
0
        protected override void SetupDataContext()
        {
            TriggerMessageBoxIfAppropriate();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            //m_flid = RecordClerk.GetFlidOfVectorFromName(m_vectorName, Cache, out m_owningObject);
            RecordClerk clerk = Clerk;

            clerk.ActivateUI(false);
            m_fakeFlid = clerk.VirtualFlid;
            // retrieve persisted clerk index and set it.
            int idx = m_mediator.PropertyTable.GetIntProperty(clerk.PersistedIndexProperty, -1, PropertyTable.SettingsGroup.LocalSettings);

            if (idx >= 0 && !clerk.HasEmptyList)
            {
                int idxOld = clerk.CurrentIndex;
                try
                {
                    clerk.JumpToIndex(idx);
                }
                catch
                {
                    clerk.JumpToIndex(idxOld >= 0 ? idxOld : 0);
                }
            }
            clerk.SelectedRecordChanged();
            m_hvoOwner = clerk.OwningObject.Hvo;

            clerk.IsDefaultSort = false;

            // Create the main view

            // Review JohnT: should it be m_configurationParameters or .FirstChild?
            m_mainView = new XmlSeqView(m_hvoOwner, m_fakeFlid, m_configurationParameters);
            m_mainView.Init(m_mediator, m_configurationParameters);             // Required call to xCore.Colleague.
            m_mainView.Dock  = System.Windows.Forms.DockStyle.Fill;
            m_mainView.Cache = Cache;
            m_mainView.SelectionChangedEvent +=
                new FwSelectionChangedEventHandler(OnSelectionChanged);
            m_mainView.ShowRangeSelAfterLostFocus = true;               // This makes selections visible.
            // If the rootsite doesn't have a rootbox, we can't display the record!
            // Calling ShowRecord() from InitBase() sets the state to appear that we have
            // displayed (and scrolled), even though we haven't.  See LT-7588 for the effect.
            m_mainView.MakeRoot();
            SetupStylesheet();
            Controls.Add(m_mainView);
            if (Controls.Count == 2)
            {
                Controls.SetChildIndex(m_mainView, 1);
                m_mainView.BringToFront();
            }
            m_fullyInitialized = true;             // Review JohnT: was this really the crucial last step?
        }