public
static
string
ProcessEnglishHebrewSentence(
string
sentence)
{
var ret =
new
List<
string
>();
string
[] words = sentence.Split(
' '
);
var curHebrewList =
new
List<
string
>();
var curEnglishList =
new
List<
string
>();
bool
curLangIsHebrew =
false
;
string
w;
string
reversed;
for
(
int
i = words.Length; i > 0; i--)
{
w = words[i - 1];
if
(System.Text.RegularExpressions.Regex.IsMatch(w, @
"\p{IsHebrew}"
) && curLangIsHebrew)
// we have a word in Hebrew and the last word was in Hebrew too
{
curHebrewList.Add(w);
}
else
if
(System.Text.RegularExpressions.Regex.IsMatch(w, @
"\p{IsHebrew}"
) && !curLangIsHebrew)
// we have a word in Hebrew and the last word was in English
{
if
(curEnglishList.Any())
{
curEnglishList.Reverse();
ret.AddRange(curEnglishList);
}
// reverse current list of English words and add to List
curEnglishList =
new
List<
string
>();
// create a new empty list for the next series of English words
curHebrewList.Add(w);
curLangIsHebrew =
true
;
// set current language to Hebrew
}
else
if
(!System.Text.RegularExpressions.Regex.IsMatch(w, @
"\p{IsHebrew}"
) && !curLangIsHebrew)
// we have a word in English and the last word was in English
{
if
(System.Text.RegularExpressions.Regex.IsMatch(w, @
"[a-zA-Z]"
))
{
reversed =
new
string
(w.Reverse().ToArray());
reversed = reversed.Replace(
"("
,
"^"
);
reversed = reversed.Replace(
")"
,
"("
);
reversed = reversed.Replace(
"^"
,
")"
);
}
else
reversed = w;
curEnglishList.Add(reversed);
// reverse and add it to the current series of English words
}
else
if
(!System.Text.RegularExpressions.Regex.IsMatch(w, @
"\p{IsHebrew}"
) && curLangIsHebrew)
// we have a word in English and the last word was in Hebrew
{
if
(curHebrewList.Any())
{
curHebrewList.Reverse();
ret.AddRange(curHebrewList);
// add current list of Hebrew words to List of Lists
}
curHebrewList =
new
List<
string
>();
// create a new empty list for the next series of Hebrew words
if
(System.Text.RegularExpressions.Regex.IsMatch(w, @
"[a-zA-Z]"
))
{
reversed =
new
string
(w.Reverse().ToArray());
reversed = reversed.Replace(
"("
,
"^"
);
reversed = reversed.Replace(
")"
,
"("
);
reversed = reversed.Replace(
"^"
,
")"
);
}
else
reversed = w;
curEnglishList.Add(reversed);
curLangIsHebrew =
false
;
// set current language to English
}
else
{
throw
new
Exception(
"there should be no other case..."
);
}
}
if
(curHebrewList.Any())
{
curHebrewList.Reverse();
ret.AddRange(curHebrewList);
}
if
(curEnglishList.Any())
{
curEnglishList.Reverse();
ret.AddRange(curEnglishList);
}
return
ret.Aggregate((a, b) => a +
" "
+ b);
}
Helo !
I used RadTextBoxControl in winforms.(win7, .net4.0)
I used this control to search records (Text box to search records with autocomplete feature).
Now, i want my autocomplete to be similar as of google search box works.
like, the moment i started typing text in the textboxcontrol the first matching record should appear as watermark, instead of highlighted and selected.This autocomplete records being pulled from database.
While typing the text in radtextboxcontrol, the matching characters should be highlighted with bold fonts and the rest characters from matching records should be watermarked. Contents being displayed in dropdown should be inversely formatted with respect to contents in textbox(e.g. matching characters should be watermarked and rest should be bold)
For illustration of my problem you may have look on google searchtextbox.
Looking ahead for your response.
Thanks,
Arpus
public
class
MyHeaderCellElement : GridHeaderCellElement
{
GridViewColumn _col;
public
MyHeaderCellElement(GridViewColumn col, GridRowElement row)
:
base
(col, row)
{
_col = col;
this
.TextAlignment = ContentAlignment.TopCenter;
}
RadDropDownListElement dropDownListElement1;
RadCheckBoxElement checkBox1 =
new
RadCheckBoxElement();
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
if
(dropDownListElement1 ==
null
|| dropDownListElement1.DataSource ==
null
)
{
dropDownListElement1 =
new
RadDropDownListElement();
checkBox1.StretchHorizontally =
true
;
checkBox1.ToggleStateChanged +=
new
StateChangedEventHandler(checkBox1_ToggleStateChanged);
this
.Children.Add(checkBox1);
dropDownListElement1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
List<
string
> lst = solusDataAccess.GetMasterFields(solusGeneric.strConnectionString).AsEnumerable().Select(x => x[0].ToString()).ToList();
dropDownListElement1.DataSource = lst;
dropDownListElement1.Margin =
new
Padding(15, 0, 0, 0);
dropDownListElement1.StretchHorizontally =
true
;
dropDownListElement1.SelectedIndexChanged +=
new
Telerik.WinControls.UI.Data.PositionChangedEventHandler(dropDownListElement1_SelectedIndexChanged);
this
.Children.Add(dropDownListElement1);
}
}
void
checkBox1_ToggleStateChanged(
object
sender, StateChangedEventArgs args)
{
if
(solusGeneric.dicStrColumnFlag.ContainsKey(_col.Name))
solusGeneric.dicStrColumnFlag.Remove(_col.Name);
solusGeneric.dicStrColumnFlag.Add(_col.Name, checkBox1.Checked);
}
public
override
bool
IsCompatible(GridViewColumn data,
object
context)
{
return
data
is
GridViewTextBoxColumn && context
is
GridHeaderCellElement; ;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridHeaderCellElement);
}
}
}
SaveToXml() method itself. The problem I am having is that toolwindow does not behave correctly. I can't close it or float around etc. Code snippet: