Exemple #1
0
		private bool SetDlgInfo1(Mediator mediator, XmlNode configurationParameters)
		{
			using (new WaitCursor(this))
			{
				m_mediator = mediator;
				m_configurationParameters = configurationParameters;

				m_btnRefresh.Image = SIL.FieldWorks.Resources.ResourceHelper.RefreshIcon;

				m_rbDiscardAnalyses.Checked = m_mediator.PropertyTable.GetBoolProperty("RemoveAnalyses", true);
				m_rbKeepAnalyses.Checked = !m_rbDiscardAnalyses.Checked;
				m_rbDiscardAnalyses.Click += new EventHandler(m_rbDiscardAnalyses_Click);
				m_rbKeepAnalyses.Click += new EventHandler(m_rbDiscardAnalyses_Click);

				m_cbUpdateLexicon.Checked = m_mediator.PropertyTable.GetBoolProperty("UpdateLexiconIfPossible", true);
				m_cbCopyAnalyses.Checked = m_mediator.PropertyTable.GetBoolProperty("CopyAnalysesToNewSpelling", true);
				m_cbCopyAnalyses.Click += new EventHandler(m_cbCopyAnalyses_Click);
				m_cbMaintainCase.Checked = m_mediator.PropertyTable.GetBoolProperty("MaintainCaseOnChangeSpelling", true);
				m_cbMaintainCase.Click += new EventHandler(m_cbMaintainCase_Click);
				m_cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
				m_cbNewSpelling.TextBox.MaxLength = m_cache.MaxFieldLength((int) WfiWordform.WfiWordformTags.kflidForm);
				if (m_cache.IsDummyObject(m_srcwfiWordform.Hvo))
				{
					m_srcwfiWordform = (IWfiWordform)(m_cache.LangProject.WordformInventoryOA as WordformInventory).ConvertDummyToReal(WordformInventory.ConcordanceWordformsFlid(m_cache), m_srcwfiWordform.Hvo);
					// wfClerk now has the defunct dummy wf, so it needs to be updated to include the new real wf.
					if (m_wfClerk != null)
						m_wfClerk.UpdateList(true);
				}

				// We need to use the 'best vern' ws,
				// since that is what is showing in the Words-Analyses detail edit control.
				// Access to this respeller dlg is currently (Jan. 2008) only via a context menu in the detail edit pane.
				// The user may be showing multiple wordform WSes in the left hand browse view,
				// but we have no way of knowing if the user thinks one of those alternatives is wrong without asking.
				m_vernWs = m_cache.LangProject.ActualWs(
					LangProject.kwsFirstVern,
					m_srcwfiWordform.Hvo,
					(int)WfiWordform.WfiWordformTags.kflidForm);
				// Bail out if no vernacular writing system was found (see LT-8892).
				Debug.Assert(m_vernWs != 0);
				if (m_vernWs == 0)
					return false;
				// Bail out, rather than run into a null reference exception.
				// (Should fix LT-7666.)
				if (m_srcwfiWordform.Form.GetAlternativeTss(m_vernWs) == null || m_srcwfiWordform.Form.GetAlternativeTss(m_vernWs).Length == 0)
					return false;

				m_cbNewSpelling.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
				m_cbNewSpelling.WritingSystemCode = m_vernWs;
				m_cbNewSpelling.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
				Debug.Assert(m_cbNewSpelling.StyleSheet != null); // if it is we get a HUGE default font (and can't get the correct size)
				if (m_cbNewSpelling.WritingSystemFactory.get_EngineOrNull(m_vernWs).RightToLeft)
				{
					m_cbNewSpelling.RightToLeft = RightToLeft.Yes;
				}
				m_cbNewSpelling.Tss = m_srcwfiWordform.Form.GetAlternativeTss(m_vernWs);
				m_cbNewSpelling.AdjustForStyleSheet(this, null, m_cbNewSpelling.StyleSheet);
				if (!Application.RenderWithVisualStyles)
					m_cbNewSpelling.Padding = new Padding(1, 2, 1, 1);

				SetSuggestions();

				m_btnApply.Enabled = false;
				m_cbNewSpelling.TextChanged += new EventHandler(m_dstWordform_TextChanged);

				// Setup source browse view.
				XmlNode toolNode = configurationParameters.SelectSingleNode("controls/control[@id='srcSentences']/parameters");
				m_srcClerk = RecordClerkFactory.CreateClerk(m_mediator, toolNode);
				m_srcClerk.OwningObject = m_srcwfiWordform;
				m_sourceSentences.Init(m_mediator, toolNode);

				m_sourceSentences.CheckBoxChanged += new CheckBoxChangedEventHandler(sentences_CheckBoxChanged);

				m_moreMinSize = Size;
				m_moreMinSize.Height -= m_sourceSentences.Height / 2;
				m_lessMinSize = m_moreMinSize;
				m_lessMinSize.Height -= m_optionsPanel.Height;
				AdjustHeightAndMinSize(Height - m_optionsPanel.Height, m_lessMinSize);
				m_optionsPanel.Visible = false;
				m_btnMore.Image = ResourceHelper.MoreButtonDoubleArrowIcon;
				m_btnMore.Click += new EventHandler(btnMore_Click);
				m_sMoreButtonText = m_btnMore.Text;

				m_optionsPanel.Paint += new PaintEventHandler(m_optionsPanel_Paint);
				m_btnPreviewClear.Click += new EventHandler(m_btnPreviewClear_Click);

				// no good...code in MakeRoot of XmlBrowseView happens later and overrides. Control with
				// selectionType attr in Xml configuration.
				//m_sourceSentences.BrowseViewer.SelectedRowHighlighting = XmlBrowseViewBase.SelectionHighlighting.none;

				m_lblExplainText = m_lblExplainDisabled.Text;
				// We only reload the list when refresh is pressed.
				m_srcClerk.ListLoadingSuppressed = true;
				// We initially check everything.
				m_enabledItems.AddRange(m_sourceSentences.BrowseViewer.AllItems);
				foreach (int hvoCba in m_enabledItems)
				{
					m_cache.VwCacheDaAccessor.CacheIntProp(hvoCba, m_sourceSentences.BrowseViewer.PreviewEnabledTag, 1);
					m_cache.VwCacheDaAccessor.CacheIntProp(hvoCba, XmlBrowseViewBaseVc.ktagItemSelected, 1);
				}
				CheckForOtherOccurrences();
				SetEnabledState();
			}
			return true;
		}