Mega Code Archive
Set cursor area
Display Area Only
Entire Appliation
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Input;
using System.IO;
using System.Collections;
namespace WpfApplication1
{
public partial class Window1 : Window
{
Cursor CustomCursor;
public Window1()
{
CustomCursor = new Cursor(Directory.GetCurrentDirectory() +Path.DirectorySeparatorChar + "CustomCursor.cur");
}
public void CursorTypeChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox source = e.Source as ComboBox;
if (source != null)
{
ComboBoxItem selectedCursor = source.SelectedItem as ComboBoxItem;
switch (selectedCursor.Content.ToString())
{
case "AppStarting":
DisplayArea.Cursor = Cursors.AppStarting;
break;
case "ArrowCD":
DisplayArea.Cursor = Cursors.ArrowCD;
break;
default:
break;
}
if (cursorScopeElementOnly == false)
{
Mouse.OverrideCursor = DisplayArea.Cursor;
}
}
}
public void CursorScopeSelected(object sender, RoutedEventArgs e)
{
RadioButton source = e.Source as RadioButton;
if (source != null)
{
if (source.Name == "rbScopeElement")
{
cursorScopeElementOnly = true;
Mouse.OverrideCursor = null;
}
if (source.Name == "rbScopeApplication")
{
cursorScopeElementOnly = false;
Mouse.OverrideCursor = DisplayArea.Cursor;
}
}
}
public void OnLoaded(object sender, RoutedEventArgs e)
{
((ComboBoxItem)CursorSelector.Items[0]).IsSelected = true;
}
private bool cursorScopeElementOnly = true;
}
}