1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Desktop.UserControls
{
/// <summary>
/// Logique d'interaction pour Rank.xaml
/// </summary>
public partial class Rank : UserControl
{
#region Constructeur
public Rank()
{
InitializeComponent();
this.DataContext = this;
this.Loaded += new RoutedEventHandler(Rank_Loaded);
}
void Rank_Loaded(object sender, RoutedEventArgs e)
{
this.CurrentMark = this.Mark;
}
#endregion
#region DependencyProperty
public static DependencyProperty CurrentMarkProperty = DependencyProperty.Register("CurrentMark", typeof(Int32), typeof(Rank));
public Int32 CurrentMark
{
get { return (Int32)(this.GetValue(CurrentMarkProperty)); }
set
{
this.SetValue(CurrentMarkProperty, (Int32)value);
}
}
public static DependencyProperty MarkProperty = DependencyProperty.Register("Mark", typeof(Int32), typeof(Rank));
public Int32 Mark
{
get { return (Int32)(this.GetValue(MarkProperty)); }
set {
this.SetValue(MarkProperty, (Int32)value);
}
}
#endregion
private void ImageType_MouseEnter(object sender, MouseEventArgs e)
{
if (this.IsEnabled)
{
ImageType Img = sender as ImageType;
this.CurrentMark = Img.Number;
}
}
private void ImageType_MouseLeave(object sender, MouseEventArgs e)
{
if (this.IsEnabled)
{
this.CurrentMark = this.Mark;
}
}
private void ImageType_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (this.IsEnabled)
{
this.Mark = this.CurrentMark;
}
}
}
public class ImageType : Image
{
public Int32 Number
{
get;
set;
}
}
class Converter_MarkVisibility : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Int32 Mark = (Int32)value;
if (Mark == -1)
return (Visibility.Visible);
return (Visibility.Hidden);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
class Converter_NumberMark : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Int32 Mark = (Int32)value;
Int32 Number = System.Convert.ToInt32(parameter);
if (Mark >= Number)
return (1);
return (0.3);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
} |
Partager