XmlDocView is a view that shows a complete list as a single view. A RecordClerk class does most of the work of managing the list and current object. list management and navigation is entirely(?) handled by the RecordClerk. The actual view of each object is specified by a child node of the view node. This specifies how to display an individual list item.
Inheritance: SIL.FieldWorks.XWorks.XWorksViewBase
Beispiel #1
0
        public ExportDialog(Mediator mediator)
        {
            m_mediator = mediator;
            m_cache    = (FdoCache)mediator.PropertyTable.GetValue("cache");

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            m_helpTopic = "khtpExportLexicon";

            this.helpProvider = new System.Windows.Forms.HelpProvider();
            this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
            this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(m_helpTopic, 0));
            this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);

            // Determine whether we can support "configured" type export by trying to obtain
            // the XmlVc for an XmlDocView.  Also obtain the database id and class id of the
            // root object.

            object objCurrentControl;

            objCurrentControl = m_mediator.PropertyTable.GetValue("currentContentControlObject", null);
            //XmlDocView docView = objCurrentControl as XmlDocView;
            //if (docView == null)
            //{
            //    XCore.MultiPane xmp = objCurrentControl as XCore.MultiPane;
            //    if (xmp != null)
            //        docView = xmp.FirstVisibleControl as XmlDocView;
            //}
            XmlDocView docView = FindXmlDocView(objCurrentControl as Control);

            if (docView != null)
            {
                m_seqView = docView.Controls[0] as XmlSeqView;
            }
            if (m_seqView != null)
            {
                m_xvc = m_seqView.Vc;
            }

            CmObject cmo = m_mediator.PropertyTable.GetValue("ActiveClerkSelectedObject", null)
                           as CmObject;

            if (cmo != null)
            {
                m_hvoRootObj = cmo.OwnerHVO;
                if (m_hvoRootObj != 0)
                {
                    m_clidRootObj = m_cache.GetClassOfObject(m_hvoRootObj);
                }
            }

            m_chkExportPictures.Checked = false;
            m_chkExportPictures.Visible = false;
            m_chkExportPictures.Enabled = false;
            m_fExportPicturesAndMedia   = false;
        }
Beispiel #2
0
 /// <summary>
 /// If one exists, find an XmlDocView control no matter how deeply it's embedded.
 /// </summary>
 /// <param name="control"></param>
 /// <returns></returns>
 private XmlDocView FindXmlDocView(Control control)
 {
     if (control == null)
     {
         return(null);
     }
     if (control is XmlDocView)
     {
         return(control as XmlDocView);
     }
     foreach (Control c in control.Controls)
     {
         XmlDocView xdv = FindXmlDocView(c);
         if (xdv != null)
         {
             return(xdv);
         }
     }
     return(null);
 }
Beispiel #3
0
        public void ItemClicked()
        {
            // test data
            var kick       = MakeEntry("kick", "strike with foot");
            var boot       = MakeEntry("boot", "strike with boot");
            var lexRefType = MakeLexRefType("TestRelation");
            var lexRef     = MakeLexReference(lexRefType, kick.SensesOS[0]);

            lexRef.TargetsRS.Add(boot.SensesOS[0]);

            // Make the view to test.
            using (var view = new TestRootSite(Cache, kick.Hvo))
            {
                view.Width = 1000;                 // keep everything on one line
                var dummy  = view.Handle;          // triggers MakeRoot as handle is created
                var dummy2 = view.RootBox.Width;   // triggers constructing boxes.
                view.PerformLayout();

                int widthKick      = view.Vc.ItemWidths[kick.LexemeFormOA.Hvo];
                int widthKickSense = view.Vc.ItemWidths[kick.SensesOS[0].Hvo];

                var mockItems = new MockSortItemProvider();
                mockItems.Items.AddRange(new[] { kick.Hvo, boot.Hvo });
                var nullAdjuster = new NullTargetAdjuster();

                // click on the lexeme form: should find nothing, it's a root object.
                Point where = new Point(1, 1);
                var result = XmlDocView.SubitemClicked(where, LexEntryTags.kClassId, view, Cache, mockItems, nullAdjuster);
                Assert.That(result, Is.Null);

                // click on the gloss of kick: should find nothing, it's still part of the root.
                where  = new Point(widthKick + 5, 1);
                result = XmlDocView.SubitemClicked(where, LexEntryTags.kClassId, view, Cache, mockItems, nullAdjuster);
                Assert.That(result, Is.Null);

                // click on the gloss, asking for a sense: should find nothing, no containing sense
                result = XmlDocView.SubitemClicked(where, LexSenseTags.kClassId, view, Cache, mockItems, nullAdjuster);
                Assert.That(result, Is.Null);

                // click on the synonym: should find the other entry.
                where  = new Point(widthKick + widthKickSense * 2 + 5, 1);
                result = XmlDocView.SubitemClicked(where, LexEntryTags.kClassId, view, Cache, mockItems, nullAdjuster);
                Assert.That(result, Is.EqualTo(boot));

                // Should not return the item it otherwise would if it is not a possible target.
                mockItems.Items.Remove(boot.Hvo);
                result = XmlDocView.SubitemClicked(where, LexEntryTags.kClassId, view, Cache, mockItems, nullAdjuster);
                Assert.That(result, Is.Null);

                // MainEntryFromSubEntryTargetAdjuster should convert subentry to main entry
                // Make boot a subentry of bootRoot
                var bootRoot = MakeEntry("boo", "fragment of boot");
                var ler      = Cache.ServiceLocator.GetInstance <ILexEntryRefFactory>().Create();
                boot.EntryRefsOS.Add(ler);
                ler.RefType = LexEntryRefTags.krtComplexForm;
                ler.PrimaryLexemesRS.Add(bootRoot);
                mockItems.Items.Add(boot.Hvo);                 // not rejected as item
                mockItems.Items.Add(bootRoot.Hvo);             // has to be valid itself also
                var subentryAdjuster = new MainEntryFromSubEntryTargetAdjuster();
                result = XmlDocView.SubitemClicked(where, LexEntryTags.kClassId, view, Cache, mockItems, subentryAdjuster);
                Assert.That(result, Is.EqualTo(bootRoot));
            }
        }