Merge branch 'master' into add-RangeSlider
This commit is contained in:
commit
2628cfa29e
204 files changed
+2387
-1666
No files matched your search
@@ -1,47 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using HandyControl.Interactivity;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class LinkElement
|
||||
{
|
||||
public static readonly DependencyProperty LinkProperty = DependencyProperty.RegisterAttached(
|
||||
"Link", typeof(string), typeof(LinkElement), new PropertyMetadata(default(string), OnLinkChanged));
|
||||
|
||||
private static void OnLinkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is UIElement element)
|
||||
{
|
||||
CreateTrigger(element, (string) e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly DependencyProperty CommandBindingProperty = DependencyProperty.RegisterAttached(
|
||||
"CommandBinding", typeof(CommandBinding), typeof(LinkElement), new PropertyMetadata(default(CommandBinding)));
|
||||
|
||||
private static void SetCommandBinding(DependencyObject element, CommandBinding value)
|
||||
=> element.SetValue(CommandBindingProperty, value);
|
||||
|
||||
private static CommandBinding GetCommandBinding(DependencyObject element)
|
||||
=> (CommandBinding) element.GetValue(CommandBindingProperty);
|
||||
|
||||
private static void CreateTrigger(UIElement element, string link)
|
||||
{
|
||||
element.CommandBindings.Remove(GetCommandBinding(element));
|
||||
element.SetCurrentValue(CommandBindingProperty, DependencyProperty.UnsetValue);
|
||||
|
||||
if (string.IsNullOrEmpty(link)) return;
|
||||
var commandBinding = new CommandBinding(ControlCommands.OpenLink, (sender, args) => Process.Start(link));
|
||||
SetCommandBinding(element, commandBinding);
|
||||
element.CommandBindings.Add(commandBinding);
|
||||
}
|
||||
|
||||
public static void SetLink(DependencyObject element, string value)
|
||||
=> element.SetValue(LinkProperty, value);
|
||||
|
||||
public static string GetLink(DependencyObject element)
|
||||
=> (string) element.GetValue(LinkProperty);
|
||||
}
|
||||
}
|
||||
@@ -453,7 +453,7 @@ namespace HandyControl.Controls
|
||||
|
||||
var button = new Button
|
||||
{
|
||||
Margin = new Thickness(0, 0, 12, 12),
|
||||
Margin = new Thickness(6),
|
||||
Style = ResourceHelper.GetResource<Style>(ResourceToken.ButtonCustom),
|
||||
Content = new Border
|
||||
{
|
||||
|
||||
@@ -137,11 +137,6 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
private double _imgWidHeiScale;
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经初始化
|
||||
/// </summary>
|
||||
private bool _isLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// 图片是否倾斜
|
||||
/// </summary>
|
||||
@@ -168,8 +163,6 @@ namespace HandyControl.Controls
|
||||
|
||||
public ImageViewer()
|
||||
{
|
||||
Loaded += ImageViewer_OnLoaded;
|
||||
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Save, ButtonSave_OnClick));
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Open, ButtonWindowsOpen_OnClick));
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Restore, ButtonActual_OnClick));
|
||||
@@ -177,6 +170,8 @@ namespace HandyControl.Controls
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Enlarge, ButtonEnlarge_OnClick));
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.RotateLeft, ButtonRotateLeft_OnClick));
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.RotateRight, ButtonRotateRight_OnClick));
|
||||
|
||||
Loaded += (s, e) => Init();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -217,7 +212,13 @@ namespace HandyControl.Controls
|
||||
"ShowImgMap", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
|
||||
"ImageSource", typeof(BitmapFrame), typeof(ImageViewer), new PropertyMetadata(default(BitmapFrame)));
|
||||
"ImageSource", typeof(BitmapFrame), typeof(ImageViewer), new PropertyMetadata(default(BitmapFrame), OnImageSourceChanged));
|
||||
|
||||
private static void OnImageSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ctl = (ImageViewer) d;
|
||||
ctl.Init();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsFullScreenProperty = DependencyProperty.Register(
|
||||
"IsFullScreen", typeof(bool), typeof(ImageViewer), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
@@ -410,7 +411,7 @@ namespace HandyControl.Controls
|
||||
if (_imageMain != null)
|
||||
{
|
||||
var t = new RotateTransform();
|
||||
BindingOperations.SetBinding(t, RotateTransform.AngleProperty, new Binding(ImageRotateProperty.Name) {Source = this});
|
||||
BindingOperations.SetBinding(t, RotateTransform.AngleProperty, new Binding(ImageRotateProperty.Name) { Source = this });
|
||||
_imageMain.LayoutTransform = t;
|
||||
_imageMain.MouseLeftButtonDown += ImageMain_OnMouseLeftButtonDown;
|
||||
}
|
||||
@@ -422,6 +423,8 @@ namespace HandyControl.Controls
|
||||
_canvasSmallImg.MouseMove += CanvasSmallImg_OnMouseMove;
|
||||
_canvasSmallImg.MouseLeave += CanvasSmallImg_OnMouseLeave;
|
||||
}
|
||||
|
||||
_borderSmallIsLoaded = false;
|
||||
}
|
||||
|
||||
private static void OnImageScaleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
@@ -439,7 +442,7 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
private void Init()
|
||||
{
|
||||
if (ImageSource == null) return;
|
||||
if (ImageSource == null || !IsLoaded) return;
|
||||
|
||||
double width;
|
||||
double height;
|
||||
@@ -486,8 +489,10 @@ namespace HandyControl.Controls
|
||||
|
||||
ImageMargin = new Thickness((ActualWidth - ImageWidth) / 2, (ActualHeight - ImageHeight) / 2, 0, 0);
|
||||
|
||||
_imgActualScale = 1;
|
||||
_imgActualScale = ImageScale;
|
||||
_imgActualMargin = ImageMargin;
|
||||
|
||||
InitBorderSmall();
|
||||
}
|
||||
|
||||
private void ButtonActual_OnClick(object sender, RoutedEventArgs e)
|
||||
@@ -571,8 +576,11 @@ namespace HandyControl.Controls
|
||||
{
|
||||
base.OnRenderSizeChanged(sizeInfo);
|
||||
|
||||
if (!_isLoaded) return;
|
||||
OnRenderSizeChanged();
|
||||
}
|
||||
|
||||
private void OnRenderSizeChanged()
|
||||
{
|
||||
if (ImageWidth < 0.001 || ImageHeight < 0.001) return;
|
||||
|
||||
_canMoveX = true;
|
||||
@@ -601,13 +609,6 @@ namespace HandyControl.Controls
|
||||
MoveSmallImg(_imgSmallMouseDownMargin.Left, _imgSmallMouseDownMargin.Top);
|
||||
}
|
||||
|
||||
private void ImageViewer_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_isLoaded) return;
|
||||
Init();
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
||||
private void ImageMain_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
_imgMouseDownPoint = Mouse.GetPosition(_panelMain);
|
||||
@@ -649,6 +650,7 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
private void InitBorderSmall()
|
||||
{
|
||||
if (_canvasSmallImg == null) return;
|
||||
var scaleWindow = _canvasSmallImg.MaxWidth / _canvasSmallImg.MaxHeight;
|
||||
if (_imgWidHeiScale > scaleWindow)
|
||||
{
|
||||
@@ -773,7 +775,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
_imgActualRotate = rotate;
|
||||
|
||||
_isOblique = ((int) _imgActualRotate - 90) % 180 == 0;
|
||||
_isOblique = ((int)_imgActualRotate - 90) % 180 == 0;
|
||||
ShowSmallImgInternal = false;
|
||||
Init();
|
||||
InitBorderSmall();
|
||||
|
||||
@@ -159,6 +159,10 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var ctl = (NumericUpDown) d;
|
||||
var v = (double) e.NewValue;
|
||||
if (ctl._textBox != null)
|
||||
{
|
||||
ctl._textBox.Text = v.ToString();
|
||||
}
|
||||
|
||||
ctl.OnValueChanged(new FunctionEventArgs<double>(ValueChangedEvent, ctl)
|
||||
{
|
||||
|
||||
@@ -85,21 +85,7 @@ namespace HandyControl.Controls
|
||||
_id = ++NextId;
|
||||
_callback = Callback;
|
||||
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
RegisterClass();
|
||||
if (Visibility == Visibility.Visible)
|
||||
{
|
||||
OnIconChanged();
|
||||
UpdateIcon(true);
|
||||
}
|
||||
|
||||
_dispatcherTimerPos = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(200)
|
||||
};
|
||||
_dispatcherTimerPos.Tick += DispatcherTimerPos_Tick;
|
||||
};
|
||||
Loaded += (s, e) => Init();
|
||||
|
||||
if (Application.Current != null) Application.Current.Exit += (s, e) => Dispose();
|
||||
}
|
||||
@@ -109,6 +95,22 @@ namespace HandyControl.Controls
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
RegisterClass();
|
||||
if (Visibility == Visibility.Visible)
|
||||
{
|
||||
OnIconChanged();
|
||||
UpdateIcon(true);
|
||||
}
|
||||
|
||||
_dispatcherTimerPos = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(200)
|
||||
};
|
||||
_dispatcherTimerPos.Tick += DispatcherTimerPos_Tick;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||
"Text", typeof(string), typeof(NotifyIcon), new PropertyMetadata(default(string)));
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
|
||||
|
||||
namespace HandyControl.Controls
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace HandyControl.Controls
|
||||
|
||||
private readonly Dictionary<object, TransferEntry> _entryDic = new Dictionary<object, TransferEntry>();
|
||||
|
||||
private readonly List<TransferEntry> _entryList = new List<TransferEntry>();
|
||||
|
||||
private SimpleItemsControl _itemsOrigin;
|
||||
|
||||
private SimpleItemsControl _itemsSelected;
|
||||
@@ -79,8 +81,8 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (_initEnumerable != null)
|
||||
{
|
||||
OnItemsSourceChanged(null, _itemsSourceInternal);
|
||||
_itemsSourceInternal = null;
|
||||
OnItemsSourceChanged(null, _initEnumerable);
|
||||
_initEnumerable = null;
|
||||
}
|
||||
|
||||
if (_initArgs != null)
|
||||
@@ -89,7 +91,10 @@ namespace HandyControl.Controls
|
||||
_initArgs = null;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
if (_itemsOrigin.Items.Count == 0)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +115,7 @@ namespace HandyControl.Controls
|
||||
SelectedItem = selected
|
||||
};
|
||||
_entryDic.Add(item, entry);
|
||||
_entryList.Add(entry);
|
||||
_itemsOrigin.Items.Add(origin);
|
||||
_itemsSelected.Items.Add(selected);
|
||||
}
|
||||
@@ -121,12 +127,14 @@ namespace HandyControl.Controls
|
||||
_itemsOrigin.Items.Remove(entry.OriginItem);
|
||||
_itemsSelected.Items.Remove(entry.SelectedItem);
|
||||
_entryDic.Remove(item);
|
||||
_entryList.Remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearItems()
|
||||
{
|
||||
_entryDic.Clear();
|
||||
_entryList.Clear();
|
||||
_itemsOrigin.Items.Clear();
|
||||
_itemsSelected.Items.Clear();
|
||||
}
|
||||
@@ -221,10 +229,10 @@ namespace HandyControl.Controls
|
||||
|
||||
protected override void Refresh()
|
||||
{
|
||||
if (_entryDic.Count > 0)
|
||||
if (_entryList.Count > 0)
|
||||
{
|
||||
_entryDic.Select(item => item.Value.OriginItem).Do(item => _itemsOrigin.Items.Add(item));
|
||||
_entryDic.Select(item => item.Value.SelectedItem).Do(item => _itemsSelected.Items.Add(item));
|
||||
_entryList.Select(item => item.OriginItem).Do(item => _itemsOrigin.Items.Add(item));
|
||||
_entryList.Select(item => item.SelectedItem).Do(item => _itemsSelected.Items.Add(item));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
_imageViewer.ImageSource = BitmapFrame.Create(uri);
|
||||
_imageViewer.ImgPath = uri.AbsolutePath;
|
||||
|
||||
if (File.Exists(_imageViewer.ImgPath))
|
||||
{
|
||||
var info = new FileInfo(_imageViewer.ImgPath);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Media;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
@@ -156,6 +157,7 @@ namespace HandyControl.Controls
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.SuccessGeometry);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.SuccessBrush);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
@@ -185,6 +187,7 @@ namespace HandyControl.Controls
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetImage(messageBox, MessageBoxImage.Information);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
@@ -214,6 +217,7 @@ namespace HandyControl.Controls
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetImage(messageBox, MessageBoxImage.Warning);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
@@ -243,6 +247,7 @@ namespace HandyControl.Controls
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OK);
|
||||
SetImage(messageBox, MessageBoxImage.Error);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
@@ -276,6 +281,7 @@ namespace HandyControl.Controls
|
||||
messageBox.ShowImage = true;
|
||||
messageBox.Image = ResourceHelper.GetResource<Geometry>(ResourceToken.FatalGeometry);
|
||||
messageBox.ImageBrush = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
@@ -305,6 +311,7 @@ namespace HandyControl.Controls
|
||||
messageBox = CreateMessageBox(null, messageBoxText, caption, MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel);
|
||||
SetButtonStatus(messageBox, MessageBoxButton.OKCancel);
|
||||
SetImage(messageBox, MessageBoxImage.Question);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
@@ -350,6 +357,7 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
messageBox.Style = info.Style;
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
@@ -398,6 +406,7 @@ namespace HandyControl.Controls
|
||||
messageBox = CreateMessageBox(owner, messageBoxText, caption, button, icon, defaultResult);
|
||||
SetButtonStatus(messageBox, button);
|
||||
SetImage(messageBox, icon);
|
||||
SystemSounds.Asterisk.Play();
|
||||
messageBox.ShowDialog();
|
||||
});
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user