Merge branch 'master' into ColorPicker-event
This commit is contained in:
commit
ede66ad89c
58 files changed
+726
-318
No files matched your search
@@ -21,6 +21,8 @@ namespace HandyControl.Controls
|
||||
{
|
||||
private static readonly Guid GifGuid = new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}");
|
||||
|
||||
private static readonly Guid GifSingleFrameGuid = new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}");
|
||||
|
||||
internal IntPtr NativeImage;
|
||||
|
||||
private byte[] _rawData;
|
||||
@@ -204,8 +206,12 @@ namespace HandyControl.Controls
|
||||
streamInfo = Application.GetContentStream(uri) ?? Application.GetResourceStream(uri);
|
||||
}
|
||||
}
|
||||
|
||||
if (streamInfo == null)
|
||||
{
|
||||
throw new FileNotFoundException("Resource not found.", uri.ToString());
|
||||
}
|
||||
|
||||
CreateSourceFromStream(streamInfo.Stream);
|
||||
}
|
||||
catch
|
||||
@@ -214,20 +220,36 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchToCommonImage()
|
||||
{
|
||||
if (Source == null && Uri != null)
|
||||
{
|
||||
SetCurrentValue(SourceProperty, new BitmapImage(Uri));
|
||||
}
|
||||
}
|
||||
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
|
||||
internal static void EnsureSave(GifImage image, string filename, Stream dataStream)
|
||||
{
|
||||
if (!image.RawGuid.Equals(GifGuid)) return;
|
||||
var animatedGif = false;
|
||||
if (!image.RawGuid.Equals(GifGuid) && !image.RawGuid.Equals(GifSingleFrameGuid))
|
||||
{
|
||||
image.SwitchToCommonImage();
|
||||
return;
|
||||
}
|
||||
|
||||
var animatedGif = false;
|
||||
var dimensions = image.FrameDimensionsList;
|
||||
if (dimensions.Select(guid => new GifFrameDimension(guid)).Contains(GifFrameDimension.Time))
|
||||
{
|
||||
animatedGif = image.GetFrameCount(GifFrameDimension.Time) > 1;
|
||||
}
|
||||
|
||||
if (!animatedGif) return;
|
||||
if (!animatedGif)
|
||||
{
|
||||
image.SwitchToCommonImage();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -239,7 +239,6 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
_panel.Children.Clear();
|
||||
var dataContext = DataContext;
|
||||
|
||||
foreach (var item in SelectedItems)
|
||||
{
|
||||
@@ -251,7 +250,7 @@ namespace HandyControl.Controls
|
||||
Tag = checkComboBoxItem
|
||||
};
|
||||
|
||||
if (dataContext != null)
|
||||
if (ItemsSource != null)
|
||||
{
|
||||
tag.SetBinding(ContentControl.ContentProperty, new Binding(DisplayMemberPath) { Source = item });
|
||||
}
|
||||
|
||||
@@ -180,6 +180,10 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
Storyboard.Begin();
|
||||
if (!IsRunning)
|
||||
{
|
||||
Storyboard.Pause();
|
||||
}
|
||||
}
|
||||
|
||||
private Border CreateBorder(int index, double dotInterval, bool needHidden)
|
||||
|
||||
@@ -98,6 +98,10 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
Storyboard.Begin();
|
||||
if (!IsRunning)
|
||||
{
|
||||
Storyboard.Pause();
|
||||
}
|
||||
}
|
||||
|
||||
private Ellipse CreateEllipse(int index, double dotInterval, double dotDiameter)
|
||||
|
||||
@@ -578,37 +578,34 @@ namespace HandyControl.Controls
|
||||
|
||||
private IntPtr Callback(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
|
||||
{
|
||||
if (IsLoaded)
|
||||
if (msg == _wmTaskbarCreated)
|
||||
{
|
||||
if (msg == _wmTaskbarCreated)
|
||||
if (_messageWindowHandle == hWnd && Visibility == Visibility.Visible)
|
||||
{
|
||||
if (_messageWindowHandle == hWnd && Visibility == Visibility.Visible)
|
||||
{
|
||||
UpdateIcon(true);
|
||||
}
|
||||
UpdateIcon(true);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (lparam.ToInt64())
|
||||
{
|
||||
switch (lparam.ToInt64())
|
||||
{
|
||||
case InteropValues.WM_LBUTTONDBLCLK:
|
||||
WmMouseDown(MouseButton.Left, 2);
|
||||
break;
|
||||
case InteropValues.WM_LBUTTONUP:
|
||||
WmMouseUp(MouseButton.Left);
|
||||
break;
|
||||
case InteropValues.WM_RBUTTONUP:
|
||||
ShowContextMenu();
|
||||
WmMouseUp(MouseButton.Right);
|
||||
break;
|
||||
case InteropValues.WM_MOUSEMOVE:
|
||||
if (!_dispatcherTimerPos.IsEnabled)
|
||||
{
|
||||
_dispatcherTimerPos.Interval = TimeSpan.FromMilliseconds(200);
|
||||
_dispatcherTimerPos.Start();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InteropValues.WM_LBUTTONDBLCLK:
|
||||
WmMouseDown(MouseButton.Left, 2);
|
||||
break;
|
||||
case InteropValues.WM_LBUTTONUP:
|
||||
WmMouseUp(MouseButton.Left);
|
||||
break;
|
||||
case InteropValues.WM_RBUTTONUP:
|
||||
ShowContextMenu();
|
||||
WmMouseUp(MouseButton.Right);
|
||||
break;
|
||||
case InteropValues.WM_MOUSEMOVE:
|
||||
if (!_dispatcherTimerPos.IsEnabled)
|
||||
{
|
||||
_dispatcherTimerPos.Interval = TimeSpan.FromMilliseconds(200);
|
||||
_dispatcherTimerPos.Start();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (d is Pagination pagination)
|
||||
{
|
||||
pagination.OnAutoHidingChanged((bool)e.NewValue);
|
||||
pagination.OnAutoHidingChanged((bool) e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,12 @@ namespace HandyControl.Controls
|
||||
#region Calc AvailableSize
|
||||
|
||||
_childGraph.Reset(false);
|
||||
var boundingSize = _childGraph.GetBoundingSize(Width.IsNaN(), Height.IsNaN());
|
||||
|
||||
|
||||
var calcWidth = Width.IsNaN() && HorizontalAlignment != HorizontalAlignment.Stretch;
|
||||
var calcHeight = Height.IsNaN() && VerticalAlignment != VerticalAlignment.Stretch;
|
||||
|
||||
var boundingSize = _childGraph.GetBoundingSize(calcWidth, calcHeight);
|
||||
_childGraph.Reset();
|
||||
_childGraph.Measure(boundingSize);
|
||||
return boundingSize;
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace HandyControl.Controls
|
||||
_dataView.GroupDescriptions.Clear();
|
||||
_dataView.SortDescriptions.Clear();
|
||||
_dataView.SortDescriptions.Add(new SortDescription(PropertyItem.CategoryProperty.Name, ListSortDirection.Ascending));
|
||||
_dataView.SortDescriptions.Add(new SortDescription(PropertyItem.PropertyNameProperty.Name, ListSortDirection.Ascending));
|
||||
_dataView.SortDescriptions.Add(new SortDescription(PropertyItem.DisplayNameProperty.Name, ListSortDirection.Ascending));
|
||||
_dataView.GroupDescriptions.Add(new PropertyGroupDescription(PropertyItem.CategoryProperty.Name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,14 @@ namespace HandyControl.Controls
|
||||
}
|
||||
_isItemSelected = false;
|
||||
}
|
||||
|
||||
if (!item.HasItems)
|
||||
{
|
||||
RaiseEvent(new FunctionEventArgs<object>(SelectionChangedEvent, this)
|
||||
{
|
||||
Info = e.OriginalSource
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,12 +89,18 @@ namespace HandyControl.Controls
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (_previewContent == null) return;
|
||||
|
||||
var p = e.GetPosition(_adorner);
|
||||
var maximum = Maximum;
|
||||
var minimum = Minimum;
|
||||
|
||||
if (Orientation == Orientation.Horizontal)
|
||||
{
|
||||
var pos = (e.GetPosition(this).X - _thumb.ActualWidth / 2) / _track.ActualWidth * Maximum;
|
||||
if (pos > Maximum || pos < 0)
|
||||
|
||||
var pos = !IsDirectionReversed
|
||||
? (e.GetPosition(this).X - _thumb.ActualWidth * 0.5) / _track.ActualWidth * (maximum - minimum) + minimum
|
||||
: (1 - (e.GetPosition(this).X - _thumb.ActualWidth * 0.5) / _track.ActualWidth) * (maximum - minimum) + minimum;
|
||||
if (pos > maximum || pos < 0)
|
||||
{
|
||||
if (_thumb.IsMouseCaptureWithin)
|
||||
{
|
||||
@@ -103,15 +109,17 @@ namespace HandyControl.Controls
|
||||
return;
|
||||
}
|
||||
|
||||
_transform.X = p.X - _previewContent.ActualWidth / 2;
|
||||
_transform.X = p.X - _previewContent.ActualWidth * 0.5;
|
||||
_transform.Y = TranslatePoint(new Point(), _adorner).Y - _previewContent.ActualHeight - PreviewContentOffset;
|
||||
|
||||
PreviewPosition = _thumb.IsMouseCaptureWithin ? Value : pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
var pos = Maximum - (e.GetPosition(this).Y - _thumb.ActualHeight / 2) / _track.ActualHeight * Maximum;
|
||||
if (pos > Maximum || pos < 0)
|
||||
var pos = !IsDirectionReversed
|
||||
? (1 - (e.GetPosition(this).Y - _thumb.ActualHeight * 0.5) / _track.ActualHeight) * (maximum - minimum) + minimum
|
||||
: (e.GetPosition(this).Y - _thumb.ActualHeight * 0.5) / _track.ActualHeight * (maximum - minimum) + minimum;
|
||||
if (pos > maximum || pos < 0)
|
||||
{
|
||||
if (_thumb.IsMouseCaptureWithin)
|
||||
{
|
||||
@@ -121,7 +129,7 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
_transform.X = TranslatePoint(new Point(), _adorner).X - _previewContent.ActualWidth - PreviewContentOffset;
|
||||
_transform.Y = p.Y - _previewContent.ActualHeight / 2;
|
||||
_transform.Y = p.Y - _previewContent.ActualHeight * 0.5;
|
||||
|
||||
PreviewPosition = _thumb.IsMouseCaptureWithin ? Value : pos;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ namespace HandyControl.Controls
|
||||
|
||||
private bool _showNo;
|
||||
|
||||
private IntPtr _lastActiveWindowIntPtr;
|
||||
|
||||
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
|
||||
"Message", typeof(string), typeof(MessageBox), new PropertyMetadata(default(string)));
|
||||
|
||||
@@ -127,6 +129,16 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
base.OnSourceInitialized(e);
|
||||
|
||||
_lastActiveWindowIntPtr = InteropMethods.GetForegroundWindow();
|
||||
Activate();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
InteropMethods.SetForegroundWindow(_lastActiveWindowIntPtr);
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
|
||||
Reference in new issue
Block a user