Skip to content

Commit

Permalink
Merge pull request #61 from telerik/sdkUpdates
Browse files Browse the repository at this point in the history
New version of Telerik SDK examples.
  • Loading branch information
StenlyGrigorov authored Nov 19, 2024
2 parents d1375fe + 1073e94 commit 18adaff
Show file tree
Hide file tree
Showing 68 changed files with 298 additions and 695 deletions.
12 changes: 1 addition & 11 deletions AutoCompleteBox/DataValidation/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ public Employee SelectedEmployee
if (this.selectedEmployee != value)
{
this.selectedEmployee = value;
#if !SILVERLIGHT
Mouse.Capture(null);
#endif
this.OnPropertyChanged(() => this.SelectedEmployee);
this.OnPropertyChanged(() => this.EmployeeSearchText);
}
Expand Down Expand Up @@ -203,12 +201,7 @@ public string this[string columnName]

private void OnSelectionChangedExecute(object obj)
{
#if SILVERLIGHT
var teamsCollection = obj as Telerik.Windows.Controls.SelectionChangedEventArgs;
#else
var teamsCollection = obj as SelectionChangedEventArgs;
#endif

if (teamsCollection.AddedItems.Count > 0)
{
var addedTeam = teamsCollection.AddedItems[0] as Team;
Expand All @@ -235,11 +228,8 @@ private void OnSelectionChangedExecute(object obj)
this.SelectedEmployee = null;
}

this.ForceTextSearchValidation();

#if !SILVERLIGHT
this.ForceTextSearchValidation();
Mouse.Capture(null);
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,115 +47,91 @@ private static void OnIsHelperEnabledChanged(DependencyObject d, DependencyPrope

private static void OnKeyDown(object sender, KeyEventArgs e)
{
#if SILVERLIGHT
if(Application.Current.HasElevatedPermissions)
{
#endif
var autoComplete = sender as RadAutoCompleteBox;
var autoComplete = sender as RadAutoCompleteBox;

var watermark = autoComplete.ChildrenOfType<TextBox>().FirstOrDefault();
if (watermark != null)
{
countries = (autoComplete.DataContext as ViewModel).Countries;
}
var watermark = autoComplete.ChildrenOfType<TextBox>().FirstOrDefault();
if (watermark != null)
{
countries = (autoComplete.DataContext as ViewModel).Countries;
}

var textSearchMode = autoComplete.TextSearchMode;
selectedItems = new ObservableCollection<Country>(autoComplete.SelectedItems.Cast<Country>());
#if SILVERLIGHT
var textSearchMode = autoComplete.TextSearchMode;
selectedItems = new ObservableCollection<Country>(autoComplete.SelectedItems.Cast<Country>());

if (!(e.Key == Key.Shift || e.Key == Key.Space || e.Key == Key.Tab || e.Key == Key.Up
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right))
#else
if (!(e.Key == Key.LeftShift || e.Key == Key.RightShift || e.Key == Key.Space || e.Key == Key.Tab || e.Key == Key.Up
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Capital || e.Key == Key.Return))
#endif
{
var pressedKey = (char)KeyInterop.VirtualKeyFromKey(e.Key);
var text = watermark.Text;
var caretIndex = watermark.SelectionStart;
bool CapsLock = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;

if (watermark.SelectionLength != 0)
{
#if SILVERLIGHT
var pressedKey = (char)e.PlatformKeyCode;
#else
var pressedKey = (char)KeyInterop.VirtualKeyFromKey(e.Key);
#endif
var text = watermark.Text;
var caretIndex = watermark.SelectionStart;
bool CapsLock = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;

if (watermark.SelectionLength != 0)
{
text = text.Substring(0, watermark.Text.Length - watermark.SelectionLength);
}
text = text.Substring(0, watermark.Text.Length - watermark.SelectionLength);
}

switch (textSearchMode)
{
case TextSearchMode.Contains:
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, null);
break;
case TextSearchMode.ContainsCaseSensitive:
if (CapsLock && Keyboard.Modifiers == ModifierKeys.Shift)
switch (textSearchMode)
{
case TextSearchMode.Contains:
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, null);
break;
case TextSearchMode.ContainsCaseSensitive:
if (CapsLock && Keyboard.Modifiers == ModifierKeys.Shift)
{
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, false);
}
else
{
if (CapsLock)
{
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, false);
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, true);
}
else
{
if (CapsLock)
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, true);
}
else
{
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, true);
}
else
{
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, false);
}
e.Handled = IsEnteredTextContainedInsideExistingItems(text, caretIndex, pressedKey, false);
}
}

break;
case TextSearchMode.StartsWith:
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, null);
break;
case TextSearchMode.StartsWithCaseSensitive:
CapsLock = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;

if (CapsLock && Keyboard.Modifiers == ModifierKeys.Shift)
}

break;
case TextSearchMode.StartsWith:
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, null);
break;
case TextSearchMode.StartsWithCaseSensitive:
CapsLock = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;

if (CapsLock && Keyboard.Modifiers == ModifierKeys.Shift)
{
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, false);
}
else
{
if (CapsLock)
{
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, false);
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, true);
}
else
{
if (CapsLock)
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, true);
}
else
{
if (Keyboard.Modifiers == ModifierKeys.Shift)
{
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, true);
}
else
{
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, false);
}
e.Handled = IsEnteredTextStartsWithExistingItems(text, caretIndex, pressedKey, false);
}
}

break;
}
}
break;
}
#if SILVERLIGHT
}
else
{
var autoComplete = sender as RadAutoCompleteBox;
autoComplete.IsEnabled = false;
MessageBox.Show("You need to enable trusted applications to run inside the browser! Please, check the description of the sample for some more detailed inforamtion how to achieve this.");
}
#endif
}

private static bool IsEnteredTextContainedInsideExistingItems(string text, int caretIndex, char pressedKey, bool? isUpper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
#if WPF

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
Expand All @@ -38,7 +38,6 @@
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
#endif

// Version information for an assembly consists of the following four values:
//
Expand Down
6 changes: 0 additions & 6 deletions ComboBox/DropDownWithHeaders/Example.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System.Windows.Controls;
using Telerik.Windows.Controls;
#if SILVERLIGHT
using SelectionChangedEventArgs = Telerik.Windows.Controls.SelectionChangedEventArgs;
#endif

namespace DropDownWithHeaders
{
/// <summary>
/// Interaction logic for Example.xaml
/// </summary>
public partial class Example : UserControl
{
public Example()
Expand Down
7 changes: 0 additions & 7 deletions ComboBox/SelectedItemsBinding/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,5 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/System.Windows.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml"/>
<ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.Input.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Loading

0 comments on commit 18adaff

Please sign in to comment.