Ejemplo n.º 1
0
        private void RemoveJokersFromTextBox(SplitButton ASplitButton,
            TextBox AAssociatedTextBox,
            TMatches ALastSelection)
        {
            string NewText;

            try
            {
                if (AAssociatedTextBox != null)
                {
                    // Remove * Joker character(s)
                    NewText = AAssociatedTextBox.Text.Replace("*", String.Empty);

                    // If an EXACT search is wanted, we need to remove the % Joker character(s) as well
                    if (ALastSelection == TMatches.EXACT)
                    {
                        NewText = NewText.Replace("%", String.Empty);
                    }

//                    TLogging.Log(
//                        "RemoveJokersFromTextBox:  Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (1): " + AAssociatedTextBox.Text);
//                    FFindCriteriaDataTable.Rows[0].BeginEdit();
//                    AAssociatedTextBox.Text = AAssociatedTextBox.Text.Replace("*", String.Empty);
//                    FFindCriteriaDataTable.Rows[0].EndEdit();
                    string fieldname = ((TextBox)AAssociatedTextBox).DataBindings[0].BindingMemberInfo.BindingMember;
                    FFindCriteriaDataTable.Rows[0][fieldname] = NewText;
                    fieldname = ((SplitButton)ASplitButton).DataBindings[0].BindingMemberInfo.BindingMember;
                    FFindCriteriaDataTable.Rows[0][fieldname] = Enum.GetName(typeof(TMatches), ALastSelection);

//
//                    AAssociatedTextBox.Text = NewText;
//
//                    TLogging.Log(
//                        "RemoveJokersFromTextBox:  Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (2): " + AAssociatedTextBox.Text);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Exception in RemoveJokersFromTextBox: " + exp.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="ATextBox"></param>
        /// <param name="ACriteriaControl"></param>
        public void GeneralLeaveHandler(TextBox ATextBox, SplitButton ACriteriaControl)
        {
            TMatches NewMatchValue = TMatches.BEGINS;
            string TextBoxText = ATextBox.Text;
            string CriteriaValue;

            //            TLogging.Log("GeneralLeaveHandler for " + ATextBox.Name + ". SplitButton: " + ACriteriaControl.Name);

            if (TextBoxText.Contains("*")
                || (TextBoxText.Contains("%"))
                || (TextBoxText.EndsWith("||")))
            {
                if (TextBoxText.EndsWith("||")
                    && !(TextBoxText.StartsWith("||")))
                {
//                    TLogging.Log(ATextBox.Name + " ends with ||  = ENDS");
                    NewMatchValue = TMatches.ENDS;
                }
                else if (TextBoxText.EndsWith("||")
                         && (TextBoxText.StartsWith("||")))
                {
//                        TLogging.Log(ATextBox.Name + " begins with || and ends with ||  = EXACT");
                    NewMatchValue = TMatches.EXACT;
                }
                else if (TextBoxText.EndsWith("*")
                         && !(TextBoxText.StartsWith("*")))
                {
//                    TLogging.Log(ATextBox.Name + " ends with *  = BEGINS");
                    NewMatchValue = TMatches.BEGINS;
                }
                else if ((TextBoxText.EndsWith("*")
                          && (TextBoxText.StartsWith("*")))
                         || (TextBoxText.StartsWith("*")))
                {
//                    TLogging.Log(ATextBox.Name + " begins and ends with *, or begins with *  = CONTAINS");
                    NewMatchValue = TMatches.CONTAINS;
                }

                /*
                 * See what the Criteria Value would be without any 'joker' characters
                 * ( * and % ).
                 */
                CriteriaValue = TextBoxText.Replace("*", String.Empty);
                CriteriaValue = CriteriaValue.Replace("%", String.Empty);

                if (CriteriaValue != String.Empty)
                {
                    // There is still a valid CriteriaValue
                    PutNewMatchValueIntoFindCriteriaDT(ACriteriaControl, NewMatchValue, ATextBox, TextBoxText);
                }
                else
                {
                    // No valid Criteria Value, therefore empty the TextBox's Text.
                    ATextBox.Text = String.Empty;
                }
            }
            else
            {
                // Ensure that 'BEGINS' is restored in case the user used the '*' joker before but
                // has cleared it now!
                PutNewMatchValueIntoFindCriteriaDT(ACriteriaControl, NewMatchValue, ATextBox, TextBoxText);
            }
        }
Ejemplo n.º 3
0
        private void PutNewMatchValueIntoFindCriteriaDT(SplitButton ACriteriaControl, TMatches NewMatchValue,
            TextBox ATextBox, string ATextBoxText)
        {
            FFindCriteriaDataTable.Rows[0].BeginEdit();
            ACriteriaControl.SelectedValue = Enum.GetName(typeof(TMatches), NewMatchValue);
            FFindCriteriaDataTable.Rows[0].EndEdit();

            //TODO: It seems databinding is broken on this control
            // this needs to happen in the SplitButton control really
            string fieldname = ((SplitButton)ACriteriaControl).DataBindings[0].BindingMemberInfo.BindingMember;
            FFindCriteriaDataTable.Rows[0][fieldname] = Enum.GetName(typeof(TMatches), NewMatchValue);

            //TODO: DataBinding is really doing strange things here; we have to
            //assign the just entered Text again, otherwise it is lost!!!
            ATextBox.Text = ATextBoxText;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// todoComment
 /// </summary>
 /// <param name="ATextBox"></param>
 /// <param name="ACriteriaControl"></param>
 /// <param name="e"></param>
 public void GeneralKeyHandler(TextBox ATextBox, SplitButton ACriteriaControl, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F12)
     {
         // This is needed
         // without it, databinding fails
         ACriteriaControl.ShowContextMenu();
     }
 }