상속: MonoBehaviour
예제 #1
0
        protected virtual string GetTreeNodeLabel(ICmObject obj, out Font font)
        {
            string      displayPropertyName = GetDisplayPropertyName;
            ObjectLabel label = ObjectLabel.CreateObjectLabel(obj.Cache, obj, displayPropertyName, m_bestWS);
            int         ws    = TsStringUtils.GetWsAtOffset(label.AsTss, 0);

            if (!m_dictFonts.TryGetValue(ws, out font))
            {
                string sFont = m_cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName;
                font = new Font(sFont, m_typeSize);
                m_dictFonts.Add(ws, font);
            }
            return(TsStringUtils.NormalizeToNFC(label.DisplayName));
        }
예제 #2
0
        protected virtual string GetTreeNodeLabel(ICmObject obj, out Font font)
        {
            string      displayPropertyName = GetDisplayPropertyName;
            ObjectLabel label = ObjectLabel.CreateObjectLabel(obj.Cache, obj.Hvo, displayPropertyName, m_bestWS);
            int         ws    = StringUtils.GetWsAtOffset(label.AsTss, 0);

            if (!m_dictFonts.TryGetValue(ws, out font))
            {
                string sFont = obj.Cache.GetUnicodeProperty(ws, (int)LgWritingSystem.LgWritingSystemTags.kflidDefaultSerif);
                font = new Font(sFont, m_typeSize);
                m_dictFonts.Add(ws, font);
            }
            return(StringUtils.NormalizeToNFC(label.DisplayName));
        }
예제 #3
0
        //methods

        public override ObjectLabel Execute()
        {
            // Make create lex entry dialog and invoke it.
            ObjectLabel result = null;

            using (InsertEntryDlg dlg = new InsertEntryDlg())
            {
                var morphType = GetMorphType();
                dlg.SetDlgInfo(m_cache, morphType, MsaType.kInfl, m_slot, m_mediator,
                               m_fPrefix ? InsertEntryDlg.MorphTypeFilterType.Prefix : InsertEntryDlg.MorphTypeFilterType.Suffix);
                dlg.DisableAffixTypeMainPosAndSlot();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    bool      fCreated;
                    ILexEntry entry;
                    dlg.GetDialogInfo(out entry, out fCreated);
                    if (entry == null)
                    {
                        throw new ArgumentNullException("Expected entry cannot be null", "entry");
                    }
                    // TODO: what do to make sure it has an infl affix msa?
                    // this just assumes it will
                    bool fInflAffix = false;
                    foreach (var msa in entry.MorphoSyntaxAnalysesOC)
                    {
                        if (msa is IMoInflAffMsa)
                        {
                            fInflAffix = true;
                            break;
                        }
                    }
                    if (!fInflAffix)
                    {
                        UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(DetailControlsStrings.ksUndoCreatingInflectionalAffixCategoryItem,
                                                                        DetailControlsStrings.ksRedoCreatingInflectionalAffixCategoryItem,
                                                                        m_cache.ActionHandlerAccessor,
                                                                        () => {
                            var newby = m_cache.ServiceLocator.GetInstance <IMoInflAffMsaFactory>().Create();
                            entry.MorphoSyntaxAnalysesOC.Add(newby);
                        });
                    }
                    if (entry.MorphoSyntaxAnalysesOC.Count > 0)
                    {
                        result = ObjectLabel.CreateObjectLabel(m_cache, entry.MorphoSyntaxAnalysesOC.First(), "");
                    }
                }
            }
            return(result);
        }
예제 #4
0
        private bool PerformUpdate(object param)
        {
            CreateSearcher();
            try
            {
                m_changingSelection = true;
                try
                {
                    m_listBox.BeginUpdate();
                    m_listBox.Items.Clear();
                    // TODO: sort the results
                    foreach (ICmPossibility poss in m_searcher.Search(0, (ITsString)param))
                    {
                        // Every so often see whether the user has typed something that makes our search irrelevant.
                        if (ShouldAbort())
                        {
                            return(false);
                        }

                        var autoCompleteItem = ObjectLabel.CreateObjectLabel(m_cache, poss, m_displayNameProperty, m_displayWs);
                        if (m_listBox.Items.OfType <ObjectLabel>().All(item => !ReferenceEquals(item.Object, autoCompleteItem.Object)))
                        {
                            m_listBox.Items.Add(autoCompleteItem);
                        }
                    }
                }
                finally
                {
                    m_listBox.EndUpdate();
                }

                if (m_listBox.Items.Count > 0)
                {
                    m_listBox.AdjustSize(500, 400);
                    m_listBox.SelectedIndex = 0;
                    m_listBox.Launch(m_control.RectangleToScreen(m_control.Bounds), Screen.GetWorkingArea(m_control));
                }
                else
                {
                    m_listBox.HideForm();
                }
            }
            finally
            {
                m_changingSelection = false;
            }
            return(true);
        }
예제 #5
0
        public override ObjectLabel Execute()
        {
            ObjectLabel result = null;

            if (m_lexEntryRef != null)
            {
                using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
                {
                    ILexEntry le = null;
                    // assume the owner is the entry (e.g. owner of LexEntryRef)
                    le = m_lexEntryRef.OwnerOfClass <ILexEntry>();
                    dlg.SetDlgInfo(m_cache, m_mediator, m_propertyTable, le);
                    dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense");
                    if (dlg.ShowDialog(m_parentWindow) == DialogResult.OK)
                    {
                        ICmObject obj = dlg.SelectedObject;
                        if (obj != null)
                        {
                            if (!m_lexEntryRef.PrimaryLexemesRS.Contains(obj))
                            {
                                try
                                {
                                    UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(
                                        LexEdStrings.ksUndoCreatingEntry,
                                        LexEdStrings.ksRedoCreatingEntry,
                                        Cache.ActionHandlerAccessor,
                                        () =>
                                    {
                                        if (!m_lexEntryRef.ComponentLexemesRS.Contains(obj))
                                        {
                                            m_lexEntryRef.ComponentLexemesRS.Add(obj);
                                        }
                                        m_lexEntryRef.PrimaryLexemesRS.Add(obj);
                                    });
                                }
                                catch (ArgumentException)
                                {
                                    MessageBoxes.ReportLexEntryCircularReference(m_lexEntryRef.Owner, obj, true);
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
예제 #6
0
        //methods

        public override ObjectLabel Execute()
        {
            // Make create lex entry dialog and invoke it.
            ObjectLabel result = null;

            using (InsertEntryDlg dlg = new InsertEntryDlg())
            {
                IMoMorphType morphType = GetMorphType();
                dlg.SetDlgInfo(m_cache, morphType, MsaType.kInfl, m_slot, m_mediator,
                               m_fPrefix ? InsertEntryDlg.MorphTypeFilterType.prefix : InsertEntryDlg.MorphTypeFilterType.suffix);
                dlg.DisableAffixTypeMainPosAndSlot();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    bool fCreated;
                    int  entryID;
                    dlg.GetDialogInfo(out entryID, out fCreated);
                    if (entryID <= 0)
                    {
                        throw new ArgumentException("Expected entry ID to be greater than 0", "entryID");
                    }
                    ILexEntry lex = LexEntry.CreateFromDBObject(m_cache, entryID);
                    // TODO: what do to make sure it has an infl affix msa?
                    // this just assumes it will
                    bool fInflAffix = false;
                    foreach (IMoMorphSynAnalysis msa in lex.MorphoSyntaxAnalysesOC)
                    {
                        if (msa is IMoInflAffMsa)
                        {
                            fInflAffix = true;
                            break;
                        }
                    }
                    if (!fInflAffix)
                    {
                        int hvoNew = m_cache.CreateObject((int)MoInflAffMsa.kClassId,
                                                          lex.Hvo, (int)LexEntry.LexEntryTags.kflidMorphoSyntaxAnalyses, 0);
                    }
                    int[] hvos = lex.MorphoSyntaxAnalysesOC.HvoArray;
                    if (hvos.Length > 0)
                    {
                        result = ObjectLabel.CreateObjectLabel(m_cache, hvos[0], "");
                    }
                }
            }
            return(result);
        }
예제 #7
0
        protected virtual string GetTreeNodeLabel(ICmObject obj, out Font font)
        {
            string      displayPropertyName = GetDisplayPropertyName;
            ObjectLabel label = ObjectLabel.CreateObjectLabel(obj.Cache, obj, displayPropertyName, m_bestWS);
            // Get the ws of the name, not the abbreviation, if we can.  See FWNX-1059.
            // The string " - " is inserted by ObjectLabel.AsTss after the abbreviation
            // and before the name for semantic domains and anthropology codes.  When
            // localized, these lists are likely not to have localized the abbreviation.
            var tss = label.AsTss;
            int ws  = tss.get_WritingSystem(tss.RunCount - 1);

            if (!m_dictFonts.TryGetValue(ws, out font))
            {
                string sFont = m_cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName;
                font = new Font(sFont, m_typeSize);
                m_dictFonts.Add(ws, font);
            }
            return(TsStringUtils.NormalizeToNFC(label.DisplayName));
        }
예제 #8
0
        private void SearchSemanticDomains()
        {
            IEnumerable <ObjectLabel> labels = new List <ObjectLabel>();

            // The FindDomainsThatMatch method returns IEnumerable<ICmSemanticDomain>
            // based on the search string we give it.
            var searchString = TrimmedSearchBoxText;

            if (!string.IsNullOrEmpty(searchString))
            {
                if (m_searchIconSet)
                {
                    // When disabled, we use a Background image rather than a regular image so that it
                    // does not gray out. When showing the search icon, the button is never enabled,
                    // so it is a shame to have it grey-out our pretty magnifying glass. The X however
                    // can work as a normal button image (which avoids needing to make it larger
                    // than the button etc. in order to avoid repeating it as wallpaper, which is how
                    // BackgroundImage works.)
                    btnCancelSearch.Image           = FieldWorks.Resources.Images.X;
                    btnCancelSearch.BackgroundImage = null;
                    m_searchIconSet         = false;
                    btnCancelSearch.Enabled = true;
                }
                domainList.ItemChecked -= OnDomainListChecked;
                var semDomainsToShow = m_semdomRepo.FindDomainsThatMatch(searchString);
                SemanticDomainSelectionUtility.UpdateDomainListLabels(ObjectLabel.CreateObjectLabels(Cache, semDomainsToShow, string.Empty, DisplayWs), domainList, displayUsageCheckBox.Checked);
                domainTree.Visible      = false;
                domainList.Visible      = true;
                domainList.ItemChecked += OnDomainListChecked;
            }
            else
            {
                domainTree.Visible = true;
                domainList.Visible = false;
                if (!m_searchIconSet)
                {
                    btnCancelSearch.BackgroundImage = FieldWorks.Resources.Images.Search;
                    btnCancelSearch.Image           = null;
                    m_searchIconSet         = true;
                    btnCancelSearch.Enabled = false;
                }
            }
        }
        internal ICmObject DisplayChooser(string fieldName, string linkText, string toolName, string guiControl,
                                          IEnumerable <ICmObject> candidates)
        {
            ICmObject obj = null;

            var labels = ObjectLabel.CreateObjectLabels(m_cache, candidates);

            using (var chooser = new SimpleListChooser(m_persistenceProvider, labels,
                                                       fieldName, m_mediator.HelpTopicProvider))
            {
                chooser.Cache        = m_cache;
                chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOA.Hvo;
                Guid guidTextParam = m_cache.LangProject.PhonologicalDataOA.Guid;
                chooser.AddLink(linkText, SimpleListChooser.LinkType.kGotoLink,
                                new FwLinkArgs(toolName, guidTextParam));
                chooser.ReplaceTreeView(m_mediator, guiControl);
                if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.RegRuleFormulaControl)
                {
                    chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-RegRuleFormulaControl");
                }
                else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl)
                {
                    chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-MetaRuleFormulaControl");
                }
                else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.AffixRuleFormulaControl)
                {
                    chooser.SetHelpTopic("khtpChoose-LexiconEdit-PhonFeats-AffixRuleFormulaControl");
                }

                DialogResult res = chooser.ShowDialog();
                if (res != DialogResult.Cancel)
                {
                    chooser.HandleAnyJump();

                    if (chooser.ChosenOne != null)
                    {
                        obj = chooser.ChosenOne.Object;
                    }
                }
            }

            return(obj);
        }
예제 #10
0
        //methods

        public override ObjectLabel Execute()
        {
            var slot = m_cache.ServiceLocator.GetInstance <IMoInflAffixSlotFactory>().Create();
            var pos  = m_cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(m_posHvo);

            UndoableUnitOfWorkHelper.Do(DetailControlsStrings.ksUndoCreateSlot, DetailControlsStrings.ksRedoCreateSlot,
                                        Cache.ActionHandlerAccessor,
                                        () =>
            {
                pos.AffixSlotsOC.Add(slot);
                string sNewSlotName = StringTable.Table.GetString("NewSlotName", "Linguistics/Morphology/TemplateTable");
                int defAnalWs       = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
                slot.Name.set_String(defAnalWs, TsStringUtils.MakeString(sNewSlotName, defAnalWs));
                slot.Optional = m_fOptional;
            });
            // Enhance JohnT: usually the newly created slot will also get inserted into a template.
            // Ideally we would make both part of the same UOW. However the code is in two distinct DLLs (see MorphologyEditor.dll).
            return(ObjectLabel.CreateObjectLabel(m_cache, slot, ""));
        }
예제 #11
0
        /// <summary>
        /// Override method to handle launching of a chooser for selecting lexical entries.
        /// </summary>
        protected override void HandleChooser()
        {
            string displayWs = "analysis vernacular";

#pragma warning disable 219
            string postDialogMessageTrigger = null;
#pragma warning restore 219

            if (m_configurationNode != null)
            {
                XmlNode node = m_configurationNode.SelectSingleNode("deParams");
                if (node != null)
                {
                    displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
                    postDialogMessageTrigger = XmlUtils.GetAttributeValue(node, "postChangeMessageTrigger", null);
                }
            }

            var labels = ObjectLabel.CreateObjectLabels(m_cache, m_obj.ReferenceTargetCandidates(m_flid),
                                                        m_displayNameProperty, displayWs);

            using (MorphTypeChooser chooser = GetChooser(labels))
            {
                chooser.InitializeExtras(m_configurationNode, Mediator, m_propertyTable);
                chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);
                chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());

                var hvoType      = m_cache.DomainDataByFlid.get_ObjectProp(m_obj.Hvo, m_flid);
                var morphTypeRep = m_cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>();
                var type         = hvoType != 0 ? morphTypeRep.GetObject(hvoType) : null;
                chooser.MakeSelection(type);
                // LT-4433 changed the Alternate Forms to choose between Stem and Affix automatically
                // when inserting.  Thus, we need the check box in that environment as well.
                //if (m_obj.OwningFlid != (int)LexEntry.LexEntryTags.kflidLexemeForm)
                //    chooser.ShowAllTypesCheckBoxVisible = false;
                if (chooser.ShowDialog() == DialogResult.OK)
                {
                    var selected = (IMoMorphType)chooser.ChosenOne.Object;
                    MakeMorphTypeChange(selected);
                }
            }
        }
예제 #12
0
		/// <summary>
		/// Initializes a new instance of the <see cref="LabelNode"/> class.
		/// </summary>
		/// <param name="label">The label.</param>
		/// <param name="stylesheet">The stylesheet.</param>
		/// <param name="displayUsage"><c>true</c> if usage statistics will be displayed; otherwise, <c>false</c>.</param>
		public LabelNode(ObjectLabel label, IVwStylesheet stylesheet, bool displayUsage)
		{
			Tag = label;
			m_stylesheet = stylesheet;
			m_displayUsage = displayUsage;
			m_fEnabled = true;
			m_enabledColor = ForeColor;
			ITsString tssDisplay = label.AsTss;
			int wsVern;
			if (HasVernacularText(tssDisplay, label.Cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Select(ws => ws.Handle),
								  out wsVern))
			{
				NodeFont = GetVernacularFont(label.Cache.WritingSystemFactory, wsVern, stylesheet);
			}
			SetNodeText();
			if (label.HaveSubItems)
				// this is a hack to make the node expandable before we have filled in any
				// actual children
				Nodes.Add(new TreeNode("should not see this"));
		}
예제 #13
0
        private void m_showAllTypesCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            // If a node is selected, try selecting again when we get through.
            var selected = SelectedObject;
            IEnumerable <ICmObject> candidates;

            if (m_showAllTypesCheckBox.Checked)
            {
                var form = (IMoForm)m_obj;
                candidates = form.GetAllMorphTypeReferenceTargetCandidates();
            }
            else
            {
                candidates = m_obj.ReferenceTargetCandidates(m_flid);
            }
            IEnumerable <ObjectLabel> labels = ObjectLabel.CreateObjectLabels(m_cache, candidates,
                                                                              m_displayNameProperty, "best analorvern");

            LoadTree(labels, null, false);
            MakeSelection(selected);
        }
        /// <summary>
        /// Reload the vector in the root box, presumably after it's been modified by a chooser.
        /// </summary>
        public override void ReloadVector()
        {
            CheckDisposed();
            ITsStrFactory tsf = m_fdoCache.TsStrFactory;
            int           ws  = 0;

            if (m_rootObj != null && m_rootObj.IsValidObject)
            {
                ILgWritingSystemFactory wsf = m_fdoCache.WritingSystemFactory;
                int count = m_sda.get_VecSize(m_rootObj.Hvo, m_rootFlid);
                // This loop is mostly redundant now that the decorator will generate labels itself as needed.
                // It still serves the purpose of figuring out the WS that should be used for the 'fake' item where the user
                // is typing to select.
                for (int i = 0; i < count; ++i)
                {
                    int hvo = m_sda.get_VecItem(m_rootObj.Hvo, m_rootFlid, i);
                    Debug.Assert(hvo != 0);
                    ws = m_sda.GetLabelFor(hvo).get_WritingSystem(0);
                }

                if (ws == 0)
                {
                    var list = (ICmPossibilityList)m_rootObj.ReferenceTargetOwner(m_rootFlid);
                    ws = list.IsVernacular ? m_fdoCache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle
                                                 : m_fdoCache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
                    if (list.PossibilitiesOS.Count > 0)
                    {
                        ObjectLabel label = ObjectLabel.CreateObjectLabel(m_fdoCache, list.PossibilitiesOS[0], m_displayNameProperty, m_displayWs);
                        ws = label.AsTss.get_WritingSystem(0);
                    }
                }
            }

            if (ws == 0)
            {
                ws = m_fdoCache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
            }
            m_sda.Strings[khvoFake] = tsf.EmptyString(ws);
            base.ReloadVector();
        }
예제 #15
0
        /// <summary>
        /// Handle launching of the standard chooser.
        /// </summary>
        /// <remarks>
        /// Subclasses should override this method, if the SimpleListChooser is not suitable.
        /// </remarks>
        protected override void HandleChooser()
        {
            const string displayWs = "best analysis";
            var          sense     = m_obj as ILexSense;

            if (sense == null)
            {
                Debug.Assert(sense != null, "This chooser can only be applied to senses");
                // ReSharper disable HeuristicUnreachableCode
                //reachable in release mode you usually intelligent program.
                return;
                // ReSharper restore HeuristicUnreachableCode
            }
            var linkCommandNode = m_configurationNode.SelectSingleNode("descendant::chooserLink");
            var chooser         = new SemanticDomainsChooser
            {
                Mediator          = m_mediator,
                Cache             = m_cache,
                DisplayWs         = displayWs,
                Sense             = sense,
                LinkNode          = linkCommandNode,
                HelpTopicProvider = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider")
            };

            var labels = ObjectLabel.CreateObjectLabels(m_cache, m_obj.ReferenceTargetCandidates(m_flid),
                                                        m_displayNameProperty, displayWs);

            chooser.Initialize(labels, sense.SemanticDomainsRC, m_propertyTable);
            var result = chooser.ShowDialog();

            if (result == DialogResult.OK)
            {
                UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(Resources.DetailControlsStrings.ksUndoSet,
                                                                Resources.DetailControlsStrings.ksRedoSet,
                                                                m_cache.ActionHandlerAccessor,
                                                                () => sense.SemanticDomainsRC.Replace(sense.SemanticDomainsRC, chooser.SemanticDomains));
            }
        }
예제 #16
0
        public bool OnMoveReversalPOS(object cmd)
        {
            FdoCache cache  = Cache;
            var      labels = new List <ObjectLabel>();

            foreach (IPartOfSpeech pos in MergeOrMoveCandidates)
            {
                if (!pos.SubPossibilitiesOS.Contains(POS))
                {
                    labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos, "ShortNameTSS", "best analysis"));
                }
            }
            using (SimpleListChooser dlg = new SimpleListChooser(cache, null, m_mediator.HelpTopicProvider, labels, null,
                                                                 LexEdStrings.ksCategoryToMoveTo, null))
            {
                dlg.SetHelpTopic("khtpChoose-CategoryToMoveTo");
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    IPartOfSpeech currentPOS = POS;
                    IPartOfSpeech newOwner   = (IPartOfSpeech)dlg.ChosenOne.Object;
                    UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoMoveRevCategory,
                                                LexEdStrings.ksRedoMoveRevCategory, cache.ActionHandlerAccessor,
                                                () =>
                    {
                        newOwner.MoveIfNeeded(currentPOS);                                         //important when an item is moved into it's own subcategory
                        if (!newOwner.SubPossibilitiesOS.Contains(currentPOS))                     //this is also prevented in the interface, but I'm paranoid
                        {
                            newOwner.SubPossibilitiesOS.Add(currentPOS);
                        }
                    });
                    // Note: PropChanged should happen on the old owner and the new in the 'Add" method call.
                    // Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories.
                    m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainPossibility.Hvo);
                }
            }

            return(true);
        }
            public ITsString GetLabelFor(int hvo)
            {
                ITsString value;

                if (m_strings.TryGetValue(hvo, out value))
                {
                    return(value);
                }
                Debug.Assert(Cache != null);
                var obj = Cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(hvo);

                Debug.Assert(obj != null);

                ObjectLabel label = ObjectLabel.CreateObjectLabel(Cache, obj, DisplayNameProperty, DisplayWs);
                ITsString   tss   = label.AsTss;

                if (tss == null)
                {
                    tss = Cache.TsStrFactory.EmptyString(Cache.DefaultUserWs);
                }
                Strings[hvo] = tss;
                return(tss);                // never return null!
            }
예제 #18
0
        public override ObjectLabel Execute()
        {
            ObjectLabel result = null;

            if (m_lexEntry != null)
            {
                using (var dlg = new EntryGoDlg())
                {
                    dlg.SetDlgInfo(m_cache, null, m_mediator, m_propertyTable);
                    dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense");                     // TODO: When LT-11318 is fixed, use its help topic ID.
                    dlg.SetOkButtonText(LexEdStrings.ksMakeComponentOf);
                    if (dlg.ShowDialog(m_parentWindow) == DialogResult.OK)
                    {
                        try
                        {
                            if (m_lexSense != null)
                            {
                                UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoAddComplexForm, LexEdStrings.ksRedoAddComplexForm,
                                                            m_lexEntry.Cache.ActionHandlerAccessor,
                                                            () => ((ILexEntry)dlg.SelectedObject).AddComponent((ICmObject)m_lexSense ?? m_lexEntry));
                            }
                            else
                            {
                                UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoAddComplexForm, LexEdStrings.ksRedoAddComplexForm,
                                                            m_lexEntry.Cache.ActionHandlerAccessor,
                                                            () => ((ILexEntry)dlg.SelectedObject).AddComponent(m_lexEntry));
                            }
                        }
                        catch (ArgumentException)
                        {
                            MessageBoxes.ReportLexEntryCircularReference(dlg.SelectedObject, m_lexEntry, false);
                        }
                    }
                }
            }
            return(result);
        }
예제 #19
0
        protected void ShowDialogAndConvert(int targetClassId)
        {
            // maybe there's a better way, but
            // this creates a temporary LexEntryRef in a temporary LexEntry
            var leFactory  = m_cache.ServiceLocator.GetInstance <ILexEntryFactory>();
            var entry      = leFactory.Create();
            var lerFactory = m_cache.ServiceLocator.GetInstance <ILexEntryRefFactory>();
            var ler        = lerFactory.Create();

            entry.EntryRefsOS.Add(ler);
            m_flid = LexEntryRefTags.kflidVariantEntryTypes;
            m_obj  = ler;
            var labels = ObjectLabel.CreateObjectLabels(m_cache,
                                                        m_obj.ReferenceTargetCandidates(m_flid),
                                                        "LexEntryType" /*"m_displayNameProperty*/,
                                                        "best analysis");

            using (SimpleListChooser chooser = GetChooser(labels, targetClassId))
            {
                chooser.Cache = m_cache;
                chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);
                chooser.SetHelpTopic(s_helpTopic);
                var tv = chooser.TreeView;
                DisableNodes(tv.Nodes, targetClassId);
                m_dlg.Visible = false;                 // no reason to show the utility dialog, too
                var res = chooser.ShowDialog(m_dlg.FindForm());
                if (res == DialogResult.OK && chooser.ChosenObjects.Any())
                {
                    var itemsToChange = (from lexEntryType in chooser.ChosenObjects
                                         where lexEntryType.ClassID != targetClassId
                                         select lexEntryType).Cast <ILexEntryType>();
                    Convert(itemsToChange);
                }
            }
            entry.Delete();             // remove the temporary LexEntry
            m_dlg.Visible = true;       // now we show the utility dialog again
        }
예제 #20
0
		private void OnOKClick(object sender, System.EventArgs e)
		{
			Persist();
			if (m_linkCmd != null)
			{
				this.Visible = false;
				m_chosenLabel = m_linkCmd.Execute();
				m_fLinkExecuted = true;
			}
			else if (m_labelsTreeView != null &&
				m_labelsTreeView.SelectedNode != null &&
				m_labelsTreeView.SelectedNode.Tag != null &&
				m_labelsTreeView.SelectedNode.Tag is ChooserCommand)
			{
				HandleCommmandChoice(m_labelsTreeView.SelectedNode as ChooserCommandNode);
			}
			// TODO: Do something similar for a selected item in a FlatListView.
			else
			{
				SetChosen();
			}
		}
예제 #21
0
		private void SetChosen()
		{
			if (m_rghvoChosen != null)
			{
				m_chosenLabel = null;
				if (m_labelsTreeView != null)
				{
					m_rghvoNewChosen = new List<int>();
					// Walk the tree of labels looking for Checked == true.  This allows us to
					// return an ordered list of hvos (sorted by list display order).
					for (int i = 0; i < m_labelsTreeView.Nodes.Count; ++i)
					{
						if (m_labelsTreeView.Nodes[i].Checked)
							m_rghvoNewChosen.Add(((LabelNode)m_labelsTreeView.Nodes[i]).Label.Hvo);
						CheckChildrenForChosen(((LabelNode)m_labelsTreeView.Nodes[i]));
					}
				}
				else
				{
					m_rghvoNewChosen = m_flvLabels.GetCheckedItems();
				}
			}
			else
			{
				if (m_labelsTreeView != null)
				{
					if (m_labelsTreeView.SelectedNode == null)
						m_chosenLabel = null;
					else
						m_chosenLabel = ((LabelNode)m_labelsTreeView.SelectedNode).Label;
				}
				else
				{
					int idx = m_flvLabels.SelectedIndex;
					m_chosenLabel = m_labels[idx];
				}
			}
		}
예제 #22
0
        /// <summary>
        /// Override method to handle launching of a chooser for selecting lexical entries.
        /// </summary>
        protected override void HandleChooser()
        {
            string displayWs = "analysis vernacular";
            string postDialogMessageTrigger = null;

            if (m_configurationNode != null)
            {
                XmlNode node = m_configurationNode.SelectSingleNode("deParams");
                if (node != null)
                {
                    displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
                    postDialogMessageTrigger = XmlUtils.GetAttributeValue(node, "postChangeMessageTrigger", null);
                }
            }
            Set <int>             candidates = m_obj.ReferenceTargetCandidates(m_flid);
            ObjectLabelCollection labels     = new ObjectLabelCollection(m_cache, candidates,
                                                                         m_displayNameProperty, displayWs);

            using (MorphTypeChooser chooser = GetChooser(labels))
            {
                bool      fMadeMorphTypeChange = false;
                ILexEntry entry = LexEntry.CreateFromDBObject(m_cache, m_obj.OwnerHVO);
                chooser.InitializeExtras(m_configurationNode, Mediator);
                chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);
                int hvoType = m_cache.GetObjProperty(m_obj.Hvo, m_flid);
                chooser.MakeSelection(hvoType);
                // LT-4433 changed the Alternate Forms to choose between Stem and Affix automatically
                // when inserting.  Thus, we need the check box in that environment as well.
                //if (m_obj.OwningFlid != (int)LexEntry.LexEntryTags.kflidLexemeForm)
                //    chooser.ShowAllTypesCheckBoxVisible = false;
                if (chooser.ShowDialog() == DialogResult.OK)
                {
                    ObjectLabel selected    = chooser.ChosenOne;
                    int         hvoOriginal = TargetHvo;
                    string      sUndo       = m_mediator.StringTbl.GetStringWithXPath("ChangeLexemeMorphTypeUndo", m_ksPath);
                    string      sRedo       = m_mediator.StringTbl.GetStringWithXPath("ChangeLexemeMorphTypeRedo", m_ksPath);

                    bool fRemoveComponents = false;
                    if (selected.Hvo == entry.Cache.GetIdFromGuid(new Guid(MoMorphType.kguidMorphRoot)) ||
                        selected.Hvo == entry.Cache.GetIdFromGuid(new Guid(MoMorphType.kguidMorphBoundRoot)))
                    {
                        // changing to root...not allowed to have complex forms.
                        foreach (LexEntryRef ler in entry.EntryRefsOS)
                        {
                            if (ler.RefType == LexEntryRef.krtComplexForm)
                            {
                                fRemoveComponents = true;
                                // If there are no components we will delete without asking...but must then check for more
                                // complex forms that DO have components.
                                if (ler.ComponentLexemesRS.Count > 0)
                                {
                                    if (MessageBox.Show(FindForm(), DetailControlsStrings.ksRootNoComponentsMessage,
                                                        DetailControlsStrings.ksRootNoComponentsCaption, MessageBoxButtons.YesNo,
                                                        MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 0, FwApp.App.HelpFile,
                                                        HelpNavigator.Topic, "khtRootCannotHaveComponents") != DialogResult.Yes)
                                    {
                                        return;
                                    }
                                    break;
                                }
                            }
                        }
                    }

                    using (new UndoRedoTaskHelper(entry.Cache, sUndo, sRedo))
                    {
                        if (fRemoveComponents)
                        {
                            Set <int> delObjs = new Set <int>();
                            foreach (LexEntryRef ler in entry.EntryRefsOS)
                            {
                                if (ler.RefType == LexEntryRef.krtComplexForm)
                                {
                                    delObjs.Add(ler.Hvo);
                                }
                            }
                            CmObject.DeleteObjects(delObjs, m_cache);
                        }

                        if (IsStemType(hvoOriginal) || m_obj is MoStemAllomorph)
                        {
                            if (IsStemType(selected.Hvo))
                            {
                                TargetHvo = selected.Hvo;
                            }
                            else
                            {
                                //have to switch from stem to affix
                                fMadeMorphTypeChange = ChangeStemToAffix(entry, selected.Hvo, sUndo, sRedo);
                            }
                        }
                        else
                        {
                            // original is affix variety
                            if (IsStemType(selected.Hvo))
                            {
                                //have to switch from affix to stem
                                fMadeMorphTypeChange = ChangeAffixToStem(entry, selected.Hvo, sUndo, sRedo);
                            }
                            else
                            {
                                TargetHvo = selected.Hvo;
                            }
                        }
                        if (selected.Hvo == entry.Cache.GetIdFromGuid(new Guid(MoMorphType.kguidMorphPhrase)))
                        {
                            ILexEntryRef ler = new LexEntryRef();
                            entry.EntryRefsOS.Append(ler);
                            ler.RefType        = LexEntryRef.krtComplexForm;
                            ler.HideMinorEntry = 1;
                            // No automatic propchanged for new objects, need to let the view see it.
                            // At that point our slice will be disposed, so don't do anything after this.
                            entry.Cache.PropChanged(entry.Hvo, (int)LexEntry.LexEntryTags.kflidEntryRefs, 0, 1, 0);
                        }
                    }
                }
            }
        }
예제 #23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates the label node.
		/// </summary>
		/// <param name="nol">The nol.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected override LabelNode CreateLabelNode(ObjectLabel nol)
		{
			return new LeafLabelNode(nol, m_stylesheet, m_leafFlid);
		}
        protected override void HandleChooser()
        {
            // YAGNI: may eventually need to make configurable how it comes up with the list of candidates.
            // Currently this is used only for properties of a ghost notebook record.
            var candidateList = (ICmPossibilityList)ReferenceTargetServices.RnGenericRecReferenceTargetOwner(m_cache, m_flid);
            var candidates    = candidateList == null ? null : candidateList.PossibilitiesOS.Cast <ICmObject>();
            // YAGNI: see ReferenceLauncher implementation of this method for a possible approach to
            // making the choice of writing system configurable.
            var labels = ObjectLabel.CreateObjectLabels(m_cache, candidates,
                                                        m_displayNameProperty, "analysis vernacular");
            var chooser = new SimpleListChooser(m_persistProvider,
                                                labels,
                                                m_fieldName,
                                                m_cache,
                                                new ICmObject[0],
                                                m_mediator.HelpTopicProvider);

            chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());

            chooser.SetObjectAndFlid(0, m_flid);
            if (Slice.ConfigurationNode != null)
            {
                // Review JohnT: can any of this be made relevant without an object?
                //    // Handle the default case ("owner") for text parameters.

                //    // This (old approach) works only if
                //    // all of the list items are owned by the same object as the first one in the
                //    // list.  (Later elements can be owned by elements owned by that first owner,
                //    // if you know what I mean.)
                //    //if (candidates.Count != 0)
                //    //    chooser.TextParamHvo = m_cache.GetOwnerOfObject((int)candidates[0]);
                //    // JohnT: this approach depends on a new FDO method.
                //    ICmObject referenceTargetOwner = m_obj.ReferenceTargetOwner(m_flid);
                //    if (referenceTargetOwner != null)
                //        chooser.TextParamHvo = referenceTargetOwner.Hvo;
                //    chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());
                chooser.InitializeExtras(Slice.ConfigurationNode, Mediator);
            }
            var res = chooser.ShowDialog(FindForm());

            if (DialogResult.Cancel == res)
            {
                return;
            }

            if (chooser.HandleAnyJump())
            {
                return;
            }

            if (chooser.ChosenObjects != null && chooser.ChosenObjects.Count() > 0)
            {
                UndoableUnitOfWorkHelper.Do(string.Format(DetailControlsStrings.ksUndoSet, m_fieldName),
                                            string.Format(DetailControlsStrings.ksRedoSet, m_fieldName), m_obj,
                                            () =>
                {
                    // YAGNI: creating the real object may eventually need to be configurable,
                    // perhaps by indicating in the configuration node what class of object to create
                    // and so forth, or perhaps by just putting a "doWhat" attribute on the configuration node
                    // and making a switch here to control what is done. For now this slice is only used
                    // in one situation, where we need to create a notebook record, associate the current object
                    // with it, and add the values to it.
                    ((IText)m_obj).AssociateWithNotebook(false);
                    IRnGenericRec notebookRec;
                    DataTree.NotebookRecordRefersToThisText(m_obj as IText, out notebookRec);
                    var recHvo   = notebookRec.Hvo;
                    var values   = (from obj in chooser.ChosenObjects select obj.Hvo).ToArray();
                    var listFlid = m_flid;
                    if (m_flid == RnGenericRecTags.kflidParticipants)
                    {
                        var defaultRoledParticipant = notebookRec.MakeDefaultRoledParticipant();
                        recHvo   = defaultRoledParticipant.Hvo;
                        listFlid = RnRoledParticTags.kflidParticipants;
                    }
                    m_cache.DomainDataByFlid.Replace(recHvo, listFlid, 0, 0, values, values.Length);
                    // We don't do anything about updating the display because creating the real object
                    // will typically destroy this slice altogether and replace it with a real one.
                });
                // Structure has changed drastically, start over.
                var index    = Slice.IndexInContainer;
                var dataTree = Slice.ContainingDataTree;
                dataTree.RefreshList(false);                 // Slice will be destroyed!!
                if (index <= dataTree.Slices.Count - 1)
                {
                    dataTree.CurrentSlice = dataTree.FieldAt(index);
                }
            }
        }
예제 #25
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the <see cref="T:LabelNode"/> class.
			/// </summary>
			/// <param name="label">The label.</param>
			/// <param name="stylesheet">The stylesheet.</param>
			/// --------------------------------------------------------------------------------
			public LabelNode(ObjectLabel label, IVwStylesheet stylesheet) : base()
			{
				Tag = label;
				m_stylesheet = stylesheet;
				ITsString tssDisplay = label.AsTss;
				int wsVern;
				if (HasVernacularText(tssDisplay,
					label.Cache.LangProject.CurVernWssRS.HvoArray,
					out wsVern))
				{
					NodeFont = GetVernacularFont(label.Cache.LanguageWritingSystemFactoryAccessor, wsVern, stylesheet);
				}
				Text = tssDisplay.Text;
				if (label.GetHaveSubItems())
					// this is a hack to make the node expandable before we have filled in any
					// actual children
					Nodes.Add(new TreeNode("should not see this"));
			}
예제 #26
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Checks for selection.
			/// </summary>
			/// <param name="label">The label.</param>
			/// <param name="hvoToSelect">The hvo to select.</param>
			/// <param name="node">The node.</param>
			/// <param name="nodeRepresentingCurrentChoice">The node representing current choice.</param>
			/// <param name="ownershipStack">The ownership stack.</param>
			/// <returns></returns>
			/// --------------------------------------------------------------------------------
			protected virtual LabelNode CheckForSelection(ObjectLabel label, int hvoToSelect,
				LabelNode node, LabelNode nodeRepresentingCurrentChoice, Stack ownershipStack)
			{
				if (label.Hvo == hvoToSelect)		//make it look selected
				{
					nodeRepresentingCurrentChoice = node;
				}
				return nodeRepresentingCurrentChoice;
			}
예제 #27
0
        /// <summary>
        /// Handle launching of the environment chooser.
        /// </summary>
        /// <remarks>
        /// Subclasses should override this method, if the SimpleListChooser is not suitable.
        /// </remarks>
        protected override void HandleChooser()
        {
            // get all valid environments
            var candidates = new HashSet <ICmObject>();

            foreach (var env in m_cache.LangProject.PhonologicalDataOA.EnvironmentsOS)
            {
                ConstraintFailure failure;
                if (env.CheckConstraints(PhEnvironmentTags.kflidStringRepresentation, false, out failure))
                {
                    candidates.Add(env);
                }
            }

            string         displayWs   = "analysis vernacular";
            IPhEnvironment selectedEnv = null;

            if (m_configurationNode != null)
            {
                XmlNode node = m_configurationNode.SelectSingleNode("deParams");
                if (node != null)
                {
                    displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
                }
            }

            var labels = ObjectLabel.CreateObjectLabels(m_cache, candidates.OrderBy(e => e.ShortName), null, displayWs);

            using (var chooser = new SimpleListChooser(m_persistProvider, labels,
                                                       m_fieldName, m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider")))
            {
                chooser.Cache        = m_cache;
                chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOA.Hvo;
                chooser.SetHelpTopic(Slice.GetChooserHelpTopicID(Slice.HelpTopicID));
                chooser.InitializeExtras(m_configurationNode, m_mediator, m_propertyTable);

                DialogResult res = chooser.ShowDialog();
                if (res != DialogResult.Cancel)
                {
                    chooser.HandleAnyJump();

                    if (chooser.ChosenOne != null)
                    {
                        selectedEnv = chooser.ChosenOne.Object as IPhEnvironment;
                    }
                }
            }

            // return focus to the view
            m_view.Select();
            if (selectedEnv != null)
            {
                int cellId = -1;
                UndoableUnitOfWorkHelper.Do(MEStrings.ksRuleUndoUpdateEnv, MEStrings.ksRuleRedoUpdateEnv, selectedEnv, () =>
                {
                    cellId = UpdateEnvironment(selectedEnv);
                });

                ReconstructView(cellId, -1, true);
            }
        }
예제 #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates the label node.
		/// </summary>
		/// <param name="nol">The nol.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected virtual LabelNode CreateLabelNode(ObjectLabel nol)
		{
			return new LabelNode(nol, m_stylesheet);
		}
예제 #29
0
    // Use this for initialization
    void Start()
    {
        if (MainMenu.levelProgressWrapper == null)
        {
            MainMenu.levelProgressWrapper = LevelProgressHelper.GetLevelProgress();
        }
        MainMenu.redirectToShopScreen = false;
        var levelList = GameMaster.ReLoadMaps();

        int totalCount   = levelList.Count - 1;
        int cells        = (int)Mathf.CeilToInt((levelList.Count / RowCount));
        int totalCounter = 0;
        var position     = new Vector3(XStart, YStart);
        //Kuna meil on Y telg sassis siis arvutame seda teist pidi ehk peegelpildis
        var positionText = new Vector3(XStart, YStart - YMargin);

        for (int s = 0; s < cells; s++)
        {
            for (int i = 0; i < RowCount; i++)
            {
                if (totalCounter > totalCount)
                {
                    break;
                }
                var levelMap      = levelList[totalCounter];
                var levelProgress = MainMenu.levelProgressWrapper.LevelProgress.FirstOrDefault(x => x.LevelName == levelMap.FileName);
                if (levelProgress == null)
                {
                    levelProgress = new LevelProgress {
                        LevelName = levelMap.FileName, IsUnLocked = AllwaysUnLocked
                    };
                    MainMenu.levelProgressWrapper.LevelProgress.Add(levelProgress);
                }
                else if (AllwaysUnLocked)
                {
                    levelProgress.IsUnLocked = AllwaysUnLocked;
                }
                GameObject clone     = GetGridElement(levelMap, levelProgress, levelList, MainMenu.levelProgressWrapper, position);
                var        starCount = LevelProgressHelper.GetLevelStarCount(levelProgress, levelMap);
                foreach (Transform child in clone.transform)
                {
                    LevelSelect levelSelectButton = child.GetComponent(typeof(LevelSelect)) as LevelSelect;
                    if (levelSelectButton != null)
                    {
                        levelSelectButton.LevelName  = levelMap.FileName;
                        levelSelectButton.LevelPath  = Application.dataPath + "/Resources/LevelData/" + levelMap.FileName + ".txt";
                        levelSelectButton.IsUnLocked = levelProgress.IsCompleted;
                    }
                    ObjectLabel objectLabel = child.GetComponent(typeof(ObjectLabel)) as ObjectLabel;
                    if (objectLabel)
                    {
                        GUIText gUiText = objectLabel.GetComponent <GUIText>();
                        if (gUiText != null)
                        {
                            gUiText.text = (totalCounter + 1).ToString();
                        }
                    }
                    if (child.name == "stars_select" && starCount > 0)
                    {
                        starCount--;
                        child.GetComponent <Renderer>().material.mainTextureOffset = new Vector2(0, 0);
                    }
                }
                position.x     += XMargin;
                positionText.x += XMargin;
                totalCounter++;
            }
            position.x      = XStart;
            position.y     -= YMargin;
            positionText.y += YMargin;
            positionText.x  = XStart;
        }
        GameMaster.AdjustGUISizes();
        LevelProgressHelper.UpdateLevelProgress(MainMenu.levelProgressWrapper);
    }
예제 #30
0
			/// <summary>
			/// In this class we want only those nodes that have interesting leaves somewhere.
			/// Unfortunately this method is duplicated on LeafChooser. I can't see a clean way to
			/// avoid this.
			/// </summary>
			/// <param name="label"></param>
			/// <returns></returns>
			public override bool WantNodeForLabel(ObjectLabel label)
			{
				if (!base.WantNodeForLabel(label)) // currently does nothing, but just in case...
					return false;
				if (HasLeaves(label))
					return true;
				foreach (ObjectLabel labelSub in label.SubItems)
					if (WantNodeForLabel(labelSub))
						return true;
				return false;
			}
예제 #31
0
        /// <summary>
        /// Handle launching of the standard chooser.
        /// </summary>
        /// <remarks>
        /// Subclasses should override this method, if the SimpleListChooser is not suitable.
        /// </remarks>
        protected override void HandleChooser()
        {
            string displayWs = "analysis vernacular";
            //string displayWs = "best analysis";
            string postDialogMessageTrigger = null;

            if (m_configurationNode != null)
            {
                XmlNode node = m_configurationNode.SelectSingleNode("deParams");
                if (node != null)
                {
                    displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
                    postDialogMessageTrigger = XmlUtils.GetAttributeValue(node, "postChangeMessageTrigger", null);
                }
            }
            var labels = ObjectLabel.CreateObjectLabels(m_cache, m_obj.ReferenceTargetCandidates(m_flid),
                                                        m_displayNameProperty, displayWs);

            // I (JH) started down this road to sorting the object labels... it proved bumpy
            // and I bailed out and just turned on the "sorted" property of the chooser,
            // which gives us a dumb English sort.
            // but when it is time to get back to this... what I was doing what is misguided
            // because this sorter wants FdoObjects, but object labels don't have those on the
            // surface.  instead, they can readily give a string, through ToString().which is
            // what made me realize that until we have a way to sort something based on ICU, I
            // might as well let .net do the sorting.

            // I'm thinking there's a good chance we will eventually use FieldWorks controls for
            // the chooser in fact we will probably just using normal browse view. Then, that
            // chooser can just do the normal sorting that browse view stew, including letting
            // the user sort based on different properties.

            // however, we need a TreeView in many cases... I think there's also a FieldWorks
            // one of those that probably doesn't have sorting built-in yet...in which case we
            // might want to do the sorting here.

            //SIL.FieldWorks.Filters.RecordSorter sorter =
            //	new SIL.FieldWorks.Filters.PropertyRecordSorter("ShortName");
            //sorter.Sort ((ArrayList) labels);

            using (SimpleListChooser chooser = GetChooser(labels))
            {
                chooser.Cache = m_cache;
                chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);                    // may set TextParamHvo
                if (m_configurationNode != null)
                {
                    // Handle the default case ("owner") for text parameters.

                    // This (old approach) works only if
                    // all of the list items are owned by the same object as the first one in the
                    // list.  (Later elements can be owned by elements owned by that first owner,
                    // if you know what I mean.)
                    //if (candidates.Count != 0)
                    //    chooser.TextParamHvo = m_cache.GetOwnerOfObject((int)candidates[0]);
                    // JohnT: this approach depends on a new FDO method.
                    ICmObject referenceTargetOwner = m_obj.ReferenceTargetOwner(m_flid);
                    if (referenceTargetOwner != null)
                    {
                        chooser.TextParamHvo = referenceTargetOwner.Hvo;
                    }
                    chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());
                    chooser.InitializeExtras(m_configurationNode, Mediator, m_propertyTable);
                }

                var res = chooser.ShowDialog(MainControl.FindForm());
                if (DialogResult.Cancel == res)
                {
                    return;
                }

                if (m_configurationNode != null)
                {
                    chooser.HandleAnyJump();
                }

                if (chooser.ChosenOne != null)
                {
                    AddItem(chooser.ChosenOne.Object);
                }
                else if (chooser.ChosenObjects != null)
                {
                    SetItems(chooser.ChosenObjects);
                }
            }

            //if the configuration file says that we should put up a message dialog after a change has been made,
            //do that now.
            if (postDialogMessageTrigger != null)
            {
                XCore.XMessageBoxExManager.Trigger(postDialogMessageTrigger);
            }
            // If the configuration file says to refresh the slice list, do that now.
            if (ChoicesMade != null)
            {
                ChoicesMade(this, new EventArgs());
            }
        }
예제 #32
0
 // Start
 void Start()
 {
     cam       = Camera.main;
     entity    = GetComponent <Entity>();
     nameLabel = entity.nameLabel;
 }
예제 #33
0
 protected override LabelNode Create(ObjectLabel nol, IVwStylesheet stylesheet, bool displayUsage)
 {
     return(new DomainNode(nol, stylesheet, displayUsage));
 }
예제 #34
0
		/// <summary>
		/// Creates the label node.
		/// </summary>
		/// <param name="label">The label.</param>
		/// <param name="stylesheet"></param>
		/// <param name="selectedItems"></param>
		/// <param name="displayUsage">if set to <c>true</c> [display usage].</param>
		/// <returns></returns>
		private static DomainNode CreateLabelNode(ObjectLabel label, IVwStylesheet stylesheet, IEnumerable<ICmObject> selectedItems, bool displayUsage)
		{
			var node = new DomainNode(label, stylesheet, displayUsage);
			node.AddChildren(true, selectedItems);
			if (selectedItems.Contains(label.Object))
			{
				node.Checked = true;
			}
			return node;
		}
예제 #35
0
			private bool HasLeaves(ObjectLabel label)
			{
				return label.Cache.MainCacheAccessor.get_VecSize(label.Hvo, m_leafFlid) > 0;
			}
예제 #36
0
 public DomainNode(ObjectLabel label, IVwStylesheet stylesheet, bool displayUsage)
     : base(label, stylesheet, displayUsage)
 {
 }
예제 #37
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Wants the node for label.
		/// </summary>
		/// <param name="label">The label.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool WantNodeForLabel(ObjectLabel label)
		{
			CheckDisposed();

			return true; // by default want all nodes.
		}
예제 #38
0
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			Persist();
			m_chosenLabel = null;
		}
예제 #39
0
			protected override LabelNode Create(ObjectLabel nol, IVwStylesheet stylesheet, bool displayUsage)
			{
				return new DomainNode(nol, stylesheet, displayUsage);
			}
예제 #40
0
 public void CloneUnit(Unit oldClone)
 {
     isSelectable = oldClone.isSelectable;
     isSelected = oldClone.isSelected;
     id = oldClone.id;
     enemyName = oldClone.enemyName;
     leader = oldClone.leader;
     uName = oldClone.uName;
     teamColor = oldClone.teamColor;
     label = oldClone.label;
     status = oldClone.status;
     movementType = oldClone.movementType;
     kills = oldClone.kills;
     lastDamager = oldClone.lastDamager;
     health = oldClone.health;
     weapon = oldClone.weapon;
     _initialWeapon = oldClone._initialWeapon;
     aBase = oldClone.aBase;
     raycastIgnoreLayers = Commander.player.raycastIgnoreLayers;
     weapon.Pickup(this);
     leader.ReplaceUnit(id, this);
     if (isSelected)
         SetOutlineColor(selectedColor);
     else
         SetOutlineColor(outlineColor);
     orderData = oldClone.orderData;
     if (orderData != null)
         orderData.SetUnit(this);
     skipSpawn = true;
     SetTeamColor();
     Invoke("AllowSpawn", 5.0f);
 }
예제 #41
0
		/// --------------------------------------------------------------------------------
		/// <summary>
		/// Wants the node for label.
		/// </summary>
		/// <param name="label">The label.</param>
		/// <returns></returns>
		/// --------------------------------------------------------------------------------
		public virtual bool WantNodeForLabel(ObjectLabel label)
		{
			return true; // by default want all nodes.
		}
예제 #42
0
        protected override void HandleChooser()
        {
            string displayWs = "analysis vernacular";

#pragma warning disable 219
            string postDialogMessageTrigger = null;
#pragma warning restore 219

            if (m_configurationNode != null)
            {
                XmlNode node = m_configurationNode.SelectSingleNode("deParams");
                if (node != null)
                {
                    displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
                    postDialogMessageTrigger = XmlUtils.GetAttributeValue(node, "postChangeMessageTrigger", null);
                }
            }

            var labels = ObjectLabel.CreateObjectLabels(m_cache, m_obj.ReferenceTargetCandidates(m_flid),
                                                        m_displayNameProperty, displayWs);

            using (MorphTypeChooser chooser = GetChooser(labels))
            {
                bool fMadeMorphTypeChange = false;
                var  entry = (ILexEntry)m_obj.Owner;
                chooser.InitializeExtras(m_configurationNode, Mediator);
                chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);
                chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());

                var hvoType      = m_cache.DomainDataByFlid.get_ObjectProp(m_obj.Hvo, m_flid);
                var morphTypeRep = m_cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>();
                var type         = hvoType != 0 ? morphTypeRep.GetObject(hvoType) : null;
                chooser.MakeSelection(type);
                // LT-4433 changed the Alternate Forms to choose between Stem and Affix automatically
                // when inserting.  Thus, we need the check box in that environment as well.
                //if (m_obj.OwningFlid != (int)LexEntry.LexEntryTags.kflidLexemeForm)
                //    chooser.ShowAllTypesCheckBoxVisible = false;
                if (chooser.ShowDialog() == DialogResult.OK)
                {
                    var    selected = (IMoMorphType)chooser.ChosenOne.Object;
                    var    original = Target as IMoMorphType;
                    string sUndo    = m_mediator.StringTbl.GetStringWithXPath("ChangeLexemeMorphTypeUndo", m_ksPath);
                    string sRedo    = m_mediator.StringTbl.GetStringWithXPath("ChangeLexemeMorphTypeRedo", m_ksPath);

                    bool fRemoveComponents = false;
                    if (selected.Guid == MoMorphTypeTags.kguidMorphRoot ||
                        selected.Guid == MoMorphTypeTags.kguidMorphBoundRoot)
                    {
                        // changing to root...not allowed to have complex forms.
                        foreach (ILexEntryRef ler in entry.EntryRefsOS)
                        {
                            if (ler.RefType == LexEntryRefTags.krtComplexForm)
                            {
                                fRemoveComponents = true;
                                // If there are no components we will delete without asking...but must then check for more
                                // complex forms that DO have components.
                                if (ler.ComponentLexemesRS.Count > 0)
                                {
                                    // TODO-Linux: Help is not implemented in Mono
                                    if (MessageBox.Show(FindForm(), DetailControlsStrings.ksRootNoComponentsMessage,
                                                        DetailControlsStrings.ksRootNoComponentsCaption, MessageBoxButtons.YesNo,
                                                        MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 0, m_mediator.HelpTopicProvider.HelpFile,
                                                        HelpNavigator.Topic, "/Using_Tools/Lexicon_tools/Lexicon_Edit/change_the_morph_type.htm") != DialogResult.Yes)
                                    {
                                        return;
                                    }
                                    break;
                                }
                            }
                        }
                    }

                    UndoableUnitOfWorkHelper.Do(sUndo, sRedo, entry, () =>
                    {
                        if (fRemoveComponents)
                        {
                            foreach (var ler in entry.EntryRefsOS.Where(entryRef => entryRef.RefType == LexEntryRefTags.krtComplexForm))
                            {
                                entry.EntryRefsOS.Remove(ler);
                            }
                        }

                        if (IsStemType(original) || m_obj is IMoStemAllomorph)
                        {
                            if (IsStemType(selected))
                            {
                                Target = selected;
                            }
                            else
                            {
                                //have to switch from stem to affix
                                fMadeMorphTypeChange = ChangeStemToAffix(entry, selected);
                            }
                        }
                        else
                        {
                            // original is affix variety
                            if (IsStemType(selected))
                            {
                                //have to switch from affix to stem
                                fMadeMorphTypeChange = ChangeAffixToStem(entry, selected);
                            }
                            else
                            {
                                Target = selected;
                            }
                        }
                        if (selected.Guid == MoMorphTypeTags.kguidMorphPhrase)
                        {
                            ILexEntryRef ler = m_cache.ServiceLocator.GetInstance <ILexEntryRefFactory>().Create();
                            entry.EntryRefsOS.Add(ler);
                            ler.RefType        = LexEntryRefTags.krtComplexForm;
                            ler.HideMinorEntry = 1;
                        }
                    });
                }
            }
        }
예제 #43
0
		/// <summary>
		/// Creates the specified LabelNode from the ObjectLabel.
		/// </summary>
		/// <param name="nol"></param>
		/// <param name="stylesheet"></param>
		/// <param name="displayUsage"><c>true</c> if usage statistics will be displayed; otherwise, <c>false</c>.</param>
		/// <returns></returns>
		protected virtual LabelNode Create(ObjectLabel nol, IVwStylesheet stylesheet, bool displayUsage)
		{
			return new LabelNode(nol, stylesheet, displayUsage);
		}
예제 #44
0
		private void HandleCommmandChoice(ChooserCommandNode node)
		{
			if (node != null)
			{
				ChooserCommand cmd = node.Tag as ChooserCommand;
				if (cmd != null)
				{
					if (cmd.ShouldCloseBeforeExecuting)
						this.Visible = false;
					m_chosenLabel = cmd.Execute();
				}
			}
		}
예제 #45
0
		/// <summary>
		/// Checks for selection.
		/// </summary>
		/// <param name="label">The label.</param>
		/// <param name="objToSelect">The obj to select.</param>
		/// <param name="node">The node.</param>
		/// <param name="nodeRepresentingCurrentChoice">The node representing current choice.</param>
		/// <returns></returns>
		protected virtual LabelNode CheckForSelection(ObjectLabel label, ICmObject objToSelect,
			LabelNode node, LabelNode nodeRepresentingCurrentChoice)
		{
			if (label.Object == objToSelect)		//make it look selected
			{
				nodeRepresentingCurrentChoice = node;
			}
			return nodeRepresentingCurrentChoice;
		}
예제 #46
0
        /// <summary>
        /// Override method to handle launching of a chooser for selecting lexical entries or senses.
        /// </summary>
        protected override void HandleChooser()
        {
            if (m_flid == LexEntryRefTags.kflidComponentLexemes)
            {
                using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
                {
                    ILexEntry le = null;
                    if (m_obj.ClassID == LexEntryTags.kClassId)
                    {
                        // filter this entry from the list.
                        le = m_obj as ILexEntry;
                    }
                    else
                    {
                        // assume the owner is the entry (e.g. owner of LexEntryRef)
                        le = m_obj.OwnerOfClass <ILexEntry>();
                    }
                    dlg.SetDlgInfo(m_cache, m_mediator, m_propertyTable, le);
                    String str = ShowHelp.RemoveSpaces(this.Slice.Label);
                    dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense-" + str);
                    if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
                    {
                        AddItem(dlg.SelectedObject);
                    }
                }
            }
            else if (m_flid == LexEntryRefTags.kflidPrimaryLexemes)
            {
                string displayWs = "analysis vernacular";
                if (m_configurationNode != null)
                {
                    XmlNode node = m_configurationNode.SelectSingleNode("deParams");
                    if (node != null)
                    {
                        displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
                    }
                }
                ILexEntryRef ler = m_obj as ILexEntryRef;
                Debug.Assert(ler != null);
                var labels = ObjectLabel.CreateObjectLabels(m_cache, ler.ComponentLexemesRS.Cast <ICmObject>(),
                                                            m_displayNameProperty, displayWs);
                using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(null,
                                                                                     labels, "PrimaryLexemes", m_cache, ler.PrimaryLexemesRS.Cast <ICmObject>(),
                                                                                     false, m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider")))
                {
                    chooser.HideDisplayUsageCheckBox();
                    chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);                        // may set TextParamHvo
                    chooser.Text = LexEdStrings.ksChooseWhereToShowSubentry;
                    chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());
                    chooser.InitializeExtras(null, Mediator, m_propertyTable);
                    chooser.AddLink(LexEdStrings.ksAddAComponent, ReallySimpleListChooser.LinkType.kDialogLink,
                                    new AddPrimaryLexemeChooserCommand(m_cache, false, null, m_mediator, m_propertyTable, m_obj, FindForm()));
                    DialogResult res = chooser.ShowDialog();
                    if (DialogResult.Cancel == res)
                    {
                        return;
                    }
                    if (chooser.ChosenObjects != null)
                    {
                        SetItems(chooser.ChosenObjects);
                    }
                }
            }
            else
            {
                string fieldName = m_obj.Cache.MetaDataCacheAccessor.GetFieldName(m_flid);
                Debug.Assert(m_obj is ILexEntry || m_obj is ILexSense);
                switch (fieldName)
                {
                case "ComplexFormEntries":
                    using (var dlg = new EntryGoDlg())
                    {
                        dlg.StartingEntry = m_obj as ILexEntry ?? (m_obj as ILexSense).Entry;
                        dlg.SetDlgInfo(m_cache, null, m_mediator, m_propertyTable);
                        String str = ShowHelp.RemoveSpaces(Slice.Label);
                        dlg.SetHelpTopic("khtpChooseComplexFormEntryOrSense-" + str);
                        dlg.SetOkButtonText(LexEdStrings.ksMakeComponentOf);
                        if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
                        {
                            try
                            {
                                UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoAddComplexForm, LexEdStrings.ksRedoAddComplexForm,
                                                            m_obj.Cache.ActionHandlerAccessor,
                                                            () => ((ILexEntry)dlg.SelectedObject).AddComponent(m_obj));
                            }
                            catch (ArgumentException)
                            {
                                MessageBoxes.ReportLexEntryCircularReference(dlg.SelectedObject, m_obj, false);
                            }
                        }
                    }
                    break;

                case "VisibleComplexFormEntries":                         // obsolete?
                case "Subentries":
                    HandleChooserForBackRefs(fieldName, false);
                    break;

                case "VisibleComplexFormBackRefs":
                    HandleChooserForBackRefs(fieldName, true);
                    break;

                default:
                    Debug.Fail("EntrySequenceReferenceLauncher should only be used for variants, components, or complex forms");
                    break;
                }
            }
        }
예제 #47
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Creates the specified nol.
			/// </summary>
			/// <param name="nol">The nol.</param>
			/// <param name="stylesheet">The stylesheet.</param>
			/// <returns></returns>
			/// --------------------------------------------------------------------------------
			protected virtual LabelNode Create(ObjectLabel nol, IVwStylesheet stylesheet)
			{
				return new LabelNode(nol, stylesheet);
			}
예제 #48
0
			public DomainNode(ObjectLabel label, IVwStylesheet stylesheet, bool displayUsage)
				: base(label, stylesheet, displayUsage)
			{
			}
예제 #49
0
			/// --------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the <see cref="T:LeafLabelNode"/> class.
			/// </summary>
			/// <param name="label">The label.</param>
			/// <param name="stylesheet">The stylesheet.</param>
			/// <param name="leafFlid">The leaf flid.</param>
			/// --------------------------------------------------------------------------------
			public LeafLabelNode(ObjectLabel label, IVwStylesheet stylesheet, int leafFlid)
				: base(label, stylesheet)
			{
				m_leafFlid = leafFlid;
			}