/// <summary> /// /// </summary> /// <param name="index"></param> private void SetControlsToSelectedCustomField(FDWrapper fdw) { CustomFieldName.Text = fdw.Fd.Userlabel; rtbDescription.Text = fdw.Fd.HelpString; SelectWSfromInt(fdw.Fd.WsSelector); SelectLocationfromInt(fdw.Fd.Class); }
private void SwitchDialogtoSelectedCustomField() { m_listViewItemChanging = true; //I think at this point all the changes are already saved //so I do not think I need to do anything //except I need to say what the current item is which the user just selected //m_fdwCurrentField = listViewCustomFields.FocusedItem.Tag as FDWrapper; m_fdwCurrentField = listViewCustomFields.SelectedItems[0].Tag as FDWrapper; //show the values that are in the item the user just selected SetControlsToSelectedCustomField(listViewCustomFields.SelectedItems[0].Tag as FDWrapper); EnableSettingsControls(false);//do not allow the user the change //the value for writingSystem or Sense/Entry //once we have m_listViewItemChanging = false; }
/// <summary> /// Create a new Custom field and insert it in /// m_customFields and listViewCustomFields /// </summary> /// <returns>true if a field was saved</returns> private FDWrapper CreateNewCustomField() { m_creatingNewCustomField = true; FDWrapper fdw = null; // create new custom field FieldDescription fd = new FieldDescription(m_cache); if (fd != null) { fd.Userlabel = "New Custom Field"; fd.HelpString = ""; //set the writting system to whatever was last selected in the control if (cbWritingSystem.Enabled || fd.Type == 0) { fd.WsSelector = (cbWritingSystem.SelectedItem as IdAndString).Id; if (fd.WsSelector == LangProject.kwsAnal || fd.WsSelector == LangProject.kwsVern) fd.Type = (int)CellarModuleDefns.kcptString; else fd.Type = (int)CellarModuleDefns.kcptMultiUnicode; } // set the Entry or Sense of the new custom field to whatever was // last selecte in the control. fd.Class = (cbCreateIn.SelectedItem as IdAndString).Id; fdw = new FDWrapper(fd, false); } m_customFields.Add(fdw); //add this new Custom Field to the list //now we need to add it to the listViewBox. listViewCustomFields.SuspendLayout(); ListViewItem lvi = new ListViewItem(fdw.Fd.Userlabel); lvi.Tag = fdw; lvi.Selected = true; lvi.SubItems.Add(GetClassName(fdw.Fd.Class)); listViewCustomFields.Items.Add(lvi); listViewCustomFields.ResumeLayout(true); CustomFieldName.Text = "New Custom Field"; rtbDescription.Text = ""; //now this is the current field m_fdwCurrentField = fdw; m_creatingNewCustomField = false; return fdw; }
/// <summary> /// Check to see if the user label field is nonempty and unique. If not show a message box. /// </summary> /// <returns>true if invalid, false otherwise.</returns> private bool CheckInvalidCustomField(FDWrapper fdwToCheck) { string Fieldname = fdwToCheck.Fd.Userlabel; string FieldName = Fieldname.TrimEnd(); //we don't allow a name of only spaces if (FieldName.Length == 0) { MessageBox.Show(xWorksStrings.FieldNameShouldNotBeEmpty, xWorksStrings.EmptyFieldName, System.Windows.Forms.MessageBoxButtons.OK); return true; } Fieldname = fdwToCheck.Fd.Userlabel; foreach (FDWrapper fdw in m_customFields) if (fdwToCheck != fdw && fdw.Fd.Userlabel == FieldName && fdwToCheck.Fd.Class == fdw.Fd.Class ) { string sClassName = GetClassName(fdw.Fd.Class); string str1 = string.Format(xWorksStrings.AlreadyFieldWithThisLabel, sClassName, FieldName); MessageBox.Show(str1, xWorksStrings.LabelAlreadyExists, System.Windows.Forms.MessageBoxButtons.OK); return true; } return false; }