- mpcv_src.zip
- Components
- FolderBrowserModel
- MPCV
- MVVM
- Powershell
- mpcv_bin.zip
- de
- System.Windows.Interactivity.resources.dll
- en
- System.Windows.Interactivity.resources.dll
- es
- System.Windows.Interactivity.resources.dll
- fr
- System.Windows.Interactivity.resources.dll
- Help
- it
- System.Windows.Interactivity.resources.dll
- ja
- System.Windows.Interactivity.resources.dll
- ko
- System.Windows.Interactivity.resources.dll
- Lobster.Components.dll
- Lobster.FolderBrowser.dll
- Lobster.MVVM.dll
- Lobster.Powershell.dll
- MPCV.exe
- System.Windows.Interactivity.dll
- System.Windows.Interactivity.xml
- zh-Hans
- System.Windows.Interactivity.resources.dll
- zh-Hant
- System.Windows.Interactivity.resources.dll
|
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace Lobster.MVVM
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class MiniColorComponentCtrl : UserControl, INotifyPropertyChanged
{
public MiniColorComponentCtrl()
{
InitializeComponent();
}
public object InnerBackground
{
get { return (object)GetValue(InnerBackgroundProperty); }
set { SetValue(InnerBackgroundProperty, value); }
}
// Using a DependencyProperty as the backing store for InnerBackground. This enables animation, styling, binding, etc...
public static readonly DependencyProperty InnerBackgroundProperty =
DependencyProperty.Register("InnerBackground", typeof(object), typeof(MiniColorComponentCtrl), new UIPropertyMetadata());
private double ConvertVPosToColorComponent(double pos)
{
if (Box.ActualHeight == 0) return 0;
return ((1.0 - (double)pos / (double)Box.ActualHeight));
}
private double doubleValue;
public double DoubleValue
{
get
{
return doubleValue;
}
private set
{
var d = value;
d = Math.Max(Math.Min(d, 1), 0);
if (doubleValue!= d)
{
doubleValue = d;
this.OnPropertyChanged("ByteValue");
this.OnPropertyChanged("DoubleValue");
}
}
}
public byte ByteValue
{
get
{
return (byte)(doubleValue * 255);
}
set
{
DoubleValue = (double) value / 255.0;
}
}
#region ChangeNotifier
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
#endregion ChangeNotifier
private void Box_MouseDown(object sender, MouseButtonEventArgs e)
{
DoubleValue = this.ConvertVPosToColorComponent(e.GetPosition( (IInputElement) sender).Y);
}
private void Box_MouseMove(object sender, MouseEventArgs e)
{
var i = (UIElement)sender;
if (e.LeftButton == MouseButtonState.Pressed)
{
DoubleValue = this.ConvertVPosToColorComponent((int)e.GetPosition(i).Y);
i.CaptureMouse();
}
else
{
i.ReleaseMouseCapture();
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.