Skip to content
Merged

Dev #40

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/WPFDevelopers.Net40/Themes/Theme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4414,16 +4414,6 @@
</Setter>
</Style>
<Style BasedOn="{StaticResource WD.CircularProgressBar}" TargetType="{x:Type controls:CircularProgressBar}" />
<Style x:Key="WD.CropControl" BasedOn="{StaticResource WD.ControlBasicStyle}" TargetType="{x:Type controls:CropControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:CropControl}">
<UniformGrid x:Name="PART_UniformGrid" Columns="{TemplateBinding RowColumn}" Rows="{TemplateBinding RowColumn}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource WD.CropControl}" TargetType="{x:Type controls:CropControl}" />
<Style x:Key="WD.EdgeLight" BasedOn="{StaticResource WD.ControlBasicStyle}" TargetType="{x:Type controls:EdgeLight}">
<Setter Property="BorderBrush" Value="{DynamicResource WD.PrimaryNormalSolidColorBrush}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
Expand Down
1 change: 1 addition & 0 deletions src/WPFDevelopers.Samples.Shared/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Samples;component/Controls/Prize/PrizeItemControl.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Samples;component/Controls/RainbowButtons/RainbowButtons.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Samples;component/Controls/SnowCanvas/SnowCanvas.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFDevelopers.Samples;component/Controls/CropControl/CropControl.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="avalonedit:TextEditor">
<Setter Property="Foreground" Value="{DynamicResource WD.PrimaryTextSolidColorBrush}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPFDevelopers.Controls
namespace WPFDevelopers.Samples.Controls
{
[TemplatePart(Name = UniformGridTemplateName, Type = typeof(UniformGrid))]
public class CropControl : Control
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Basic/ControlBasic.xaml" />
<ResourceDictionary Source="Basic/Animations.xaml" />
</ResourceDictionary.MergedDictionaries>
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers">
<Style
x:Key="WD.CropControl"
BasedOn="{StaticResource WD.ControlBasicStyle}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ws="https://github.com/WPFDevelopersOrg/WPFDevelopers"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
SnapsToDevicePixels="True" TextOptions.TextFormattingMode="Display"
SnapsToDevicePixels="True" WindowStyle="None"
TextOptions.TextFormattingMode="Display"
ResizeMode="NoResize"
Height="400" Width="300"
Background="{DynamicResource WD.BackgroundSolidColorBrush}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,57 @@
<UserControl x:Class="WPFDevelopers.Samples.ExampleViews.CountdownTimerExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl
x:Class="WPFDevelopers.Samples.ExampleViews.CountdownTimerExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<controls:CodeViewer>
<TabControl TabStripPlacement="Bottom">
<TabItem Header="Default">
<controls:CountdownTimer Number="3" x:Name="CountdownTimer1" FontSize="120"/>
<controls:CountdownTimer
x:Name="CountdownTimer1"
FontSize="120"
Number="3" />
</TabItem>
<TabItem Header="MultiColor">
<UniformGrid Columns="4" Visibility="Collapsed" x:Name="CountdownTimerGroup">
<controls:CountdownTimer Number="2" CountdownTimerEffect="MultiColor" FontSize="150" IsFinishStart="True"/>
<controls:CountdownTimer Number="0" CountdownTimerEffect="MultiColor" FontSize="150" IsFinishStart="True"/>
<controls:CountdownTimer Number="2" CountdownTimerEffect="MultiColor" FontSize="150" IsFinishStart="True"/>
<controls:CountdownTimer Number="2" CountdownTimerEffect="MultiColor" FontSize="150" IsFinishStart="True"/>
<UniformGrid
x:Name="CountdownTimerGroup"
Columns="4"
Visibility="Collapsed">
<controls:CountdownTimer
CountdownTimerEffect="MultiColor"
FontSize="150"
IsFinishStart="True"
Number="2" />
<controls:CountdownTimer
CountdownTimerEffect="MultiColor"
FontSize="150"
IsFinishStart="True"
Number="0" />
<controls:CountdownTimer
CountdownTimerEffect="MultiColor"
FontSize="150"
IsFinishStart="True"
Number="2" />
<controls:CountdownTimer
CountdownTimerEffect="MultiColor"
FontSize="150"
IsFinishStart="True"
Number="2" />
</UniformGrid>
</TabItem>
</TabControl>
<controls:CodeViewer.SourceCodes>
<controls:SourceCodeModel
CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CountdownTimerExample.xaml"
CodeType="Xaml"/>
<controls:SourceCodeModel
CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CountdownTimerExample.xaml.cs"
CodeType="CSharp"/>
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CountdownTimerExample.xaml" CodeType="Xaml" />
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CountdownTimerExample.xaml.cs" CodeType="CSharp" />
<controls:SourceCodeModel
CodeSource="/WPFDevelopers.SamplesCode;component/Controls/CountdownTimer/CountdownTimer.cs"
CodeType="CSharp"
Haader="CountdownTimer.cs" />
</controls:CodeViewer.SourceCodes>
</controls:CodeViewer>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<UserControl x:Class="WPFDevelopers.Samples.ExampleViews.CropControlExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl
x:Class="WPFDevelopers.Samples.ExampleViews.CropControlExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<controls:CodeViewer>
<wpfdev:CropControl ImageSource="pack://application:,,,/WPFDevelopers.Samples;component/Resources/Images/Crop/0.jpg"/>
<controls:CropControl ImageSource="pack://application:,,,/WPFDevelopers.Samples;component/Resources/Images/Crop/0.jpg" />
<controls:CodeViewer.SourceCodes>
<controls:SourceCodeModel
CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CropControlExample.xaml"
CodeType="Xaml"/>
<controls:SourceCodeModel
CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CropControlExample.xaml.cs"
CodeType="CSharp"/>
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CropControlExample.xaml" CodeType="Xaml" />
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CropControlExample.xaml.cs" CodeType="CSharp" />
<controls:SourceCodeModel
CodeSource="/WPFDevelopers.SamplesCode;component/Controls/CropControl/CropControl.xaml"
CodeType="Xaml"
Haader="CropControl" />
<controls:SourceCodeModel
CodeSource="/WPFDevelopers.SamplesCode;component/Controls/CropControl/CropControl.cs"
CodeType="CSharp"
Haader="CropControl.cs" />
</controls:CodeViewer.SourceCodes>
</controls:CodeViewer>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
<wpfdev:Window x:Class="WPFDevelopers.Samples.ExampleViews.TaskbarItemInfoExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples"
xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
Owner="{x:Static local:App.CurrentMainWindow}"
WindowStartupLocation="CenterOwner" Icon="/WPFDevelopers.ico"
Title="TaskbarItemInfoExample" TitleHeight="40"
WindowStyle="ToolWindow" ResizeMode="NoResize"
mc:Ignorable="d" Height="211" Width="363"
d:DesignHeight="450" d:DesignWidth="800">
<wpfdev:Window
x:Class="WPFDevelopers.Samples.ExampleViews.TaskbarItemInfoExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
Title="TaskbarItemInfoExample"
Width="363"
Height="211"
d:DesignHeight="450"
d:DesignWidth="800"
Icon="/WPFDevelopers.ico"
Owner="{x:Static local:App.CurrentMainWindow}"
ResizeMode="NoResize"
TitleHeight="40"
WindowStartupLocation="CenterOwner"
WindowStyle="ToolWindow"
mc:Ignorable="d">
<Window.TaskbarItemInfo>
<TaskbarItemInfo />
</Window.TaskbarItemInfo>
<Window.Resources>
<DataTemplate x:Key="TaskbarIcon">
<Border Width="20" Height="20"
Background="{StaticResource WD.PrimaryPressedSolidColorBrush}"
BorderBrush="{StaticResource WD.BackgroundSolidColorBrush}" BorderThickness="2">
<TextBlock Text="{Binding}" TextAlignment="Center" Foreground="White"
VerticalAlignment="Center"/>
<Border
Width="20"
Height="20"
Background="{StaticResource WD.PrimaryPressedSolidColorBrush}"
BorderBrush="{StaticResource WD.BackgroundSolidColorBrush}"
BorderThickness="2">
<TextBlock
VerticalAlignment="Center"
Foreground="White"
Text="{Binding}"
TextAlignment="Center" />
</Border>
</DataTemplate>
</Window.Resources>
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="增加" Click="Button_Click" Tag="add"
Style="{StaticResource WD.DefaultButton}" />
<Button Content="移除" Click="Button_Click" Tag="remove"/>
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Button
Click="Button_Click"
Content="增加"
Style="{StaticResource WD.PrimaryButton}"
Tag="add" />
<Button
Margin="10,0"
Click="Button_Click"
Content="移除"
Style="{StaticResource WD.SuccessPrimaryButton}"
Tag="remove" />
</WrapPanel>
</wpfdev:Window>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\CodeViewer\CodeViewer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\CodeViewer\SourceCodeModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\CountdownTimer\CountdownTimer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\CropControl\CropControl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\CutImage\CutImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\CutImage\DragDrop.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Dashboard\Dashboard.cs" />
Expand Down Expand Up @@ -420,6 +421,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Controls\CropControl\CropControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Controls\CutImage\CutImage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\SongWords\SongWords.cs" Link="Controls\SongWords\SongWords.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\ElementAdorner\ElementAdorner.cs" Link="Controls\ElementAdorner\ElementAdorner.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\ElementAdorner\ThumbAngle.cs" Link="Controls\ElementAdorner\ThumbAngle.cs" />
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\CropControl\CropControl.cs" Link="Controls\CropControl\CropControl.cs" />
</ItemGroup>
<ItemGroup>
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\AboutWindow.xaml">
Expand Down Expand Up @@ -431,5 +432,11 @@
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\SnowCanvas\SnowCanvas.xaml">
<Link>Controls\SnowCanvas\SnowCanvas.xaml</Link>
</Resource>
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\CropControl\CropControl.xaml">
<Link>Controls\CropControl\CropControl.xaml</Link>
</Resource>
<Resource Include="..\WPFDevelopers.Samples.Shared\Controls\CropControl\CropControl.xaml">
<Link>Controls\CropControl\CropControl.xaml</Link>
</Resource>
</ItemGroup>
</Project>
31 changes: 20 additions & 11 deletions src/WPFDevelopers.Shared/Controls/CropAvatar/CropAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CropAvatar : Control
private Image image;
private int initialX, initialY, voffsetX, voffsetY;
private bool isDown;
private bool isLeft;
private bool? isLeft;
private Path path;
private Point point;
private Button replaceButton, addButton;
Expand Down Expand Up @@ -97,13 +97,12 @@ private void Image_MouseLeave(object sender, MouseEventArgs e)

void SettingPoint()
{
if (isLeft)
if (isLeft == true)
{
_StartX = Canvas.GetLeft(image);
initialX = voffsetX;
}

else
else if(isLeft == false)
{
_StartY = Canvas.GetTop(image);
initialY = voffsetY;
Expand All @@ -120,7 +119,7 @@ private void Image_MouseMove(object sender, MouseEventArgs e)
if (e.LeftButton == MouseButtonState.Pressed && isDown)
{
var vPoint = e.GetPosition(this);
if (isLeft)
if (isLeft == true)
{
var voffset = vPoint.X - point.X;
vNewStartX = _StartX + voffset;
Expand All @@ -133,7 +132,7 @@ private void Image_MouseMove(object sender, MouseEventArgs e)
crop = new CroppedBitmap(bitmapFrame, new Int32Rect(voffsetX, 0, _size, _size));
}
}
else
else if (isLeft == false)
{
var voffset = vPoint.Y - point.Y;
vNewStartY = _StartY + voffset;
Expand All @@ -146,7 +145,6 @@ private void Image_MouseMove(object sender, MouseEventArgs e)
crop = new CroppedBitmap(bitmapFrame, new Int32Rect(0, voffsetY, _size, _size));
}
}

OutImageSource = crop;
}
}
Expand All @@ -173,7 +171,11 @@ private void InitialImage()
vNewStartY = 0;
var uri = ControlsHelper.ImageUri();
if (uri == null) return;
var bitmap = new BitmapImage(uri);
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.UriSource = uri;
bitmap.EndInit();
if (bitmap.Height > bitmap.Width)
{
var scale = bitmap.Width / path.Width;
Expand All @@ -188,6 +190,12 @@ private void InitialImage()
image.Height = _size;
isLeft = true;
}
else
{
image.Width = _size;
image.Height = _size;
isLeft = null;
}

bitmapFrame = ControlsHelper.CreateResizedImage(bitmap, (int)image.Width, (int)image.Height, 0);
image.Source = bitmapFrame;
Expand All @@ -203,19 +211,20 @@ private void InitialImage()
_StartY = (canvas.ActualHeight - image.Height) / 2.0d;
Canvas.SetLeft(image, _StartX);
Canvas.SetTop(image, _StartY);
if (isLeft)
if (isLeft == true)
{
initialX = ((int)image.Width - 200) / 2;
initialY = 0;
crop = new CroppedBitmap(bitmapFrame, new Int32Rect(initialX, 0, _size, _size));
}
else
else if (isLeft == false)
{
initialY = ((int)image.Height - 200) / 2;
initialX = 0;
crop = new CroppedBitmap(bitmapFrame, new Int32Rect(0, initialY, _size, _size));
}

else
crop = new CroppedBitmap(bitmapFrame, new Int32Rect(0, 0, _size, _size));
OutImageSource = crop;
}
}
Expand Down
Loading