Skip to content
Open
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
74 changes: 36 additions & 38 deletions src/App.xaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="Rooler.App"
StartupUri='MainWindow.xaml' mc:Ignorable="d">
<Application.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes\Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="BackgroundBrush" Color="#92000000"/>

<Style x:Key="CloseButton" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid d:DesignWidth="12" d:DesignHeight="12">
<Ellipse Fill="{TemplateBinding Background}" Stroke="{DynamicResource ButtonBackground}"/>
<Path Stretch="Fill" Stroke="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}" Data="M0,0 L1,1" StrokeThickness="2"/>
<Path Stretch="Fill" Stroke="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}" Data="M0,1 L1,0" StrokeThickness="2"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="#00FF0000"/>
<Setter Property="Padding" Value="4,4,4,4"/>
<Setter Property="Foreground" Value="#FF666666"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#90707070"/>
</Trigger>
</Style.Triggers>
</Style>
<LinearGradientBrush x:Key="ButtonBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF656565" Offset="0"/>
<GradientStop Color="DarkGray" Offset="1"/>
</LinearGradientBrush>
</ResourceDictionary>

</Application.Resources>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes\Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="BackgroundBrush" Color="#92000000"/>

<Style x:Key="CloseButton" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid d:DesignWidth="12" d:DesignHeight="12">
<Ellipse Fill="{TemplateBinding Background}" Stroke="{DynamicResource ButtonBackground}"/>
<Path Stretch="Fill" Stroke="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}" Data="M0,0 L1,1" StrokeThickness="2"/>
<Path Stretch="Fill" Stroke="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}" Data="M0,1 L1,0" StrokeThickness="2"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="#00FF0000"/>
<Setter Property="Padding" Value="4,4,4,4"/>
<Setter Property="Foreground" Value="#FF666666"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#90707070"/>
</Trigger>
</Style.Triggers>
</Style>
<LinearGradientBrush x:Key="ButtonBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF656565" Offset="0"/>
<GradientStop Color="DarkGray" Offset="1"/>
</LinearGradientBrush>
</ResourceDictionary>
</Application.Resources>
</Application>
14 changes: 7 additions & 7 deletions src/BoundsTool.xaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<local:Tool
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Rooler.BoundsTool"
Foreground='Red'
xmlns:local="clr-namespace:Rooler"
xmlns:local="clr-namespace:Rooler"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="400">

<local:Tool.Resources>
<SolidColorBrush x:Key="MaskBackground" Color="#70CFCFCF"/>
</local:Tool.Resources>

<Grid x:Name='LayoutRoot'>

<Grid x:Name="Boundary" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" x:Name='BoundsOffsetX'/>
<ColumnDefinition Width="100" x:Name='BoundsWidth'/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="*" x:Name='BoundsOffsetY'/>
<RowDefinition Height="100" x:Name='BoundsHeight'/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Rectangle Fill="{DynamicResource MaskBackground}" Grid.ColumnSpan="3"/>
<Rectangle Fill="{DynamicResource MaskBackground}" Grid.Row="2" Grid.ColumnSpan="3"/>
<Rectangle Fill="{DynamicResource MaskBackground}" Grid.Row="1"/>
Expand Down
40 changes: 22 additions & 18 deletions src/BoundsTool.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Diagnostics;

namespace Rooler {
/// <summary>
Expand All @@ -27,7 +25,7 @@ public BoundsTool(IScreenServiceHost host): base(host) {

this.Dimensions.CloseClicked += delegate {
this.CloseService();
};
};
}

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) {
Expand Down Expand Up @@ -86,7 +84,7 @@ protected override void OnMouseMove(MouseEventArgs e) {

private bool IsGrayed {
get {
return ((SolidColorBrush)this.Resources["MaskBackground"]).Color.A != 0;
return ((SolidColorBrush)this.Resources["MaskBackground"]).Color.A != 0;
}
set {
Color currentColor = ((SolidColorBrush)this.Resources["MaskBackground"]).Color;
Expand All @@ -110,8 +108,7 @@ private IntRect Bounds {
this.BoundsWidth.Width = new GridLength(this.bounds.Width, GridUnitType.Pixel);
this.BoundsHeight.Height = new GridLength(this.bounds.Height, GridUnitType.Pixel);

this.Dimensions.Visibility = Visibility.Visible;
this.Dimensions.Text = string.Format(@"{0} x {1}", this.screenBounds.Width, this.screenBounds.Height);
this.DisplayScreenBounds();
}
}

Expand All @@ -127,14 +124,30 @@ private void AnimateBounds(IntRect screenBounds) {
this.BoundsWidth.AnimateTo(this.bounds.Width, duration);
this.BoundsHeight.AnimateTo(this.bounds.Height, duration);

this.Dimensions.Visibility = Visibility.Visible;
this.Dimensions.Text = string.Format(@"{0} x {1}", this.screenBounds.Width, this.screenBounds.Height);
this.DisplayScreenBounds();
}

private void DisplayScreenBounds()
{
var widthWpf = this.bounds.Width;
var heightWpf = this.bounds.Height;
var widthNative = this.screenBounds.Width;
var heightNative = this.screenBounds.Height;

this.Dimensions.Visibility = Visibility.Visible;

if (!ScreenShot.HasDisplayScaling)
{
this.Dimensions.Text = $@"{(int) widthNative} x {(int) heightNative}";
}
else
{
this.Dimensions.Text = $@"{(int) widthWpf} x {(int) heightWpf} ({widthNative} x {heightNative})";
}
}

protected override void OnLostMouseCapture(MouseEventArgs e) {
base.OnLostMouseCapture(e);
base.OnLostMouseCapture(e);

if (this.bounds.Width == 0 || this.bounds.Height == 0) {
this.CloseService();
Expand All @@ -150,20 +163,11 @@ protected override void OnLostMouseCapture(MouseEventArgs e) {
startRect.Height -= 1;
IntRect screenBounds = ScreenCoordinates.Collapse(startRect, this.screenshot);


if (!screenBounds.IsEmpty)
this.AnimateBounds(screenBounds);

this.BoundsRect.Visibility = Visibility.Visible;
this.Dimensions.CanClose = true;

//BitmapFrame frame = BitmapFrame.Create(this.screenshot.Image);
//PngBitmapEncoder encoder = new PngBitmapEncoder();
//encoder.Frames.Add(frame);

//using (FileStream fs = new FileStream(@"C:\tmp\ss.png", FileMode.Create, FileAccess.Write)) {
// encoder.Save(fs);
//};
}
}
}
30 changes: 23 additions & 7 deletions src/Capture.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,13 @@ private Rect Bounds {
set {
this.bounds = value;

this.BoundsOffsetX.Width = new GridLength(this.bounds.Left, GridUnitType.Pixel);
this.BoundsOffsetY.Height = new GridLength(this.bounds.Top, GridUnitType.Pixel);
this.BoundsOffsetX.Width = new GridLength(this.Bounds.Left, GridUnitType.Pixel);
this.BoundsOffsetY.Height = new GridLength(this.Bounds.Top, GridUnitType.Pixel);

this.BoundsWidth.Width = new GridLength(this.bounds.Width, GridUnitType.Pixel);
this.BoundsHeight.Height = new GridLength(this.bounds.Height, GridUnitType.Pixel);
this.BoundsWidth.Width = new GridLength(this.Bounds.Width, GridUnitType.Pixel);
this.BoundsHeight.Height = new GridLength(this.Bounds.Height, GridUnitType.Pixel);

this.Dimensions.Visibility = Visibility.Visible;
this.Dimensions.Text = string.Format(@"{0} x {1}", this.bounds.Width, this.bounds.Height);
this.DisplayBounds();
}
}

Expand All @@ -125,8 +124,25 @@ private void AnimateBounds(Rect bounds) {
this.BoundsWidth.AnimateTo(this.bounds.Width, duration);
this.BoundsHeight.AnimateTo(this.bounds.Height, duration);

this.DisplayBounds();
}

private void DisplayBounds()
{
var widthWpf = this.Bounds.Width;
var heightWpf = this.Bounds.Height;
var widthNative = widthWpf * ScreenShot.XRatio;
var heightNative = heightWpf * ScreenShot.YRatio;

this.Dimensions.Visibility = Visibility.Visible;
this.Dimensions.Text = string.Format(@"{0} x {1}", this.bounds.Width, this.bounds.Height);
if (!ScreenShot.HasDisplayScaling)
{
this.Dimensions.Text = $@"{(int) widthNative} x {(int) heightNative}";
}
else
{
this.Dimensions.Text = $@"{(int) widthWpf} x {(int) heightWpf} ({(int) widthNative} x {(int) heightNative})";
}
}

protected override void OnLostMouseCapture(MouseEventArgs e) {
Expand Down
Loading