Skip to content

Commit

Permalink
1.3.1 - loop images, tile images, copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-ward committed Sep 14, 2018
1 parent 9bb07bb commit 709e542
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 38 deletions.
2 changes: 1 addition & 1 deletion tweetz/Setup/Setup.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define MyAppName "Tweetz Desktop"
#define MyAppVersion "1.3.0"
#define MyAppVersion "1.3.1"
#define MyAppPublisher "Mike Ward"
#define MyAppURL "http://mike-ward.net"
#define MyAppExeName "tweetz.exe"
Expand Down
52 changes: 26 additions & 26 deletions tweetz/tweetz5/Assets/Themes/Classic/Common.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,11 @@
Name="Path"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 8 L 8 8 L 4 0 Z"
Fill="{StaticResource StandardBrush}"
Stretch="None"
Stroke="{StaticResource StandardBorderBrush}"
StrokeThickness="0.5"
Data="M 0 8 L 8 8 L 4 0 Z"
Stretch="None" />
StrokeThickness="0.5" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
Expand All @@ -467,11 +467,11 @@
Name="Path"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 4 8 L 8 0 Z"
Fill="{StaticResource StandardBrush}"
Stretch="None"
Stroke="{StaticResource StandardBorderBrush}"
StrokeThickness="0.5"
Data="M 0 0 L 4 8 L 8 0 Z"
Stretch="None" />
StrokeThickness="0.5" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
Expand All @@ -495,8 +495,8 @@
Name="Path"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{StaticResource StandardBrush}"
Data="M 0 0 L -8 4 L 0 8 Z"
Fill="{StaticResource StandardBrush}"
Stretch="None" />
</Grid>
<ControlTemplate.Triggers>
Expand All @@ -521,8 +521,8 @@
Name="Path"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{StaticResource StandardBrush}"
Data="M 0 0 L 8 4 L 0 8 Z"
Fill="{StaticResource StandardBrush}"
Stretch="None" />
</Grid>
<ControlTemplate.Triggers>
Expand Down Expand Up @@ -564,29 +564,29 @@
<RepeatButton
Grid.Row="0"
Height="9"
Style="{StaticResource LineButtonUpStyle}"
Command="ScrollBar.LineUpCommand" />
Command="ScrollBar.LineUpCommand"
Style="{StaticResource LineButtonUpStyle}" />

<Track
Name="PART_Track"
Grid.Row="1"
IsDirectionReversed="True">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButtonStyle}" Command="ScrollBar.PageUpCommand" />
<RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource VerticalScrollBarThumbStyle}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButtonStyle}" Command="ScrollBar.PageDownCommand" />
<RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
</Track.IncreaseRepeatButton>
</Track>

<RepeatButton
Grid.Row="2"
Height="9"
Style="{StaticResource LineButtonDownStyle}"
Command="ScrollBar.LineDownCommand" />
Command="ScrollBar.LineDownCommand"
Style="{StaticResource LineButtonDownStyle}" />
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
Expand All @@ -605,28 +605,28 @@
<RepeatButton
Grid.Column="0"
Width="9"
Style="{StaticResource LineButtonLeftStyle}"
Command="ScrollBar.LineLeftCommand" />
Command="ScrollBar.LineLeftCommand"
Style="{StaticResource LineButtonLeftStyle}" />

<Track
Name="PART_Track"
Grid.Column="1"
IsDirectionReversed="False">
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButtonStyle}" Command="ScrollBar.PageLeftCommand" />
<RepeatButton Command="ScrollBar.PageLeftCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource HorizontalScrollBarThumbStyle}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButtonStyle}" Command="ScrollBar.PageRightCommand" />
<RepeatButton Command="ScrollBar.PageRightCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton
Grid.Column="2"
Width="9"
Style="{StaticResource LineButtonRightStyle}"
Command="ScrollBar.LineRightCommand" />
Command="ScrollBar.LineRightCommand"
Style="{StaticResource LineButtonRightStyle}" />
</Grid>
</ControlTemplate>
<Style TargetType="{x:Type ScrollBar}">
Expand All @@ -652,10 +652,10 @@
<Rectangle
Name="thumb"
Height="2"
Cursor="SizeNS"
Fill="{DynamicResource TitleBarBackgroundBrush}"
Stroke="{DynamicResource TitleBarBackgroundBrush}"
StrokeThickness="1"
Cursor="SizeNS" />
StrokeThickness="1" />
<ControlTemplate.Triggers>
<Trigger Property="IsDragging" Value="True">
<Setter Property="Cursor" Value="SizeNS" />
Expand All @@ -673,10 +673,10 @@
<Rectangle
Name="thumb"
Height="2"
Cursor="SizeNS"
Fill="{DynamicResource AppBackgroundBrush}"
Stroke="{DynamicResource AppBackgroundBrush}"
StrokeThickness="1"
Cursor="SizeNS" />
StrokeThickness="1" />
<ControlTemplate.Triggers>
<Trigger Property="IsDragging" Value="True">
<Setter Property="Cursor" Value="SizeNS" />
Expand All @@ -694,10 +694,10 @@
<Rectangle
Name="thumb"
Width="1"
Cursor="SizeWE"
Fill="{DynamicResource AppBackgroundBrush}"
Stroke="{DynamicResource AppBackgroundBrush}"
StrokeThickness="1"
Cursor="SizeWE" />
StrokeThickness="1" />
<ControlTemplate.Triggers>
<Trigger Property="IsDragging" Value="True">
<Setter Property="Cursor" Value="SizeWE" />
Expand Down
32 changes: 31 additions & 1 deletion tweetz/tweetz5/Commands/ImageViewCommand.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using tweetz5.Model;
using tweetz5.Utilities.System;

Expand Down Expand Up @@ -59,7 +62,7 @@ private static MediaElement CreateMediaElement(Uri uri)
var mediaTimeline = new MediaTimeline
{
Source = uri,
RepeatBehavior = RepeatBehavior.Forever
RepeatBehavior = RepeatBehavior.Forever,
};

var storyboard = new Storyboard();
Expand All @@ -73,9 +76,36 @@ private static MediaElement CreateMediaElement(Uri uri)
var mediaElement = new MediaElement();
mediaElement.Triggers.Add(eventTrigger);

mediaElement.MediaOpened += (sender, args) => Task
.Delay(TimeSpan.FromMilliseconds(100))
.ContinueWith(t => mediaElement.Dispatcher.Invoke(() => CopyUIElementToClipboard(mediaElement)));

return mediaElement;
}

private static void CopyUIElementToClipboard(FrameworkElement element)
{
try
{
var width = element.ActualWidth;
var height = element.ActualHeight;
var bmpCopied = new RenderTargetBitmap((int)Math.Round(width), (int)Math.Round(height), 96, 96, PixelFormats.Default);
var dv = new DrawingVisual();
using (var dc = dv.RenderOpen())
{
var vb = new VisualBrush(element);
dc.DrawRectangle(vb, null, new Rect(new Point(), new Size(width, height)));
}
bmpCopied.Render(dv);
Clipboard.SetImage(bmpCopied);
}
catch
{
// ignored
}
}


private static Uri MediaSource(Media media)
{
if (media.VideoInfo?.Variants?[0] == null)
Expand Down
18 changes: 10 additions & 8 deletions tweetz/tweetz5/Controls/Timeline.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,16 @@
Visibility="{Binding Source={x:Static model:Settings.ApplicationSettings}, Path=ShowMedia, Converter={StaticResource BoolToVisibility}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding MediaUrl, IsAsync=True}" Style="{StaticResource TweetMediaStyle}">
<Image.InputBindings>
<MouseBinding
Command="{x:Static commands:ImageViewCommand.Command}"
CommandParameter="{Binding}"
MouseAction="LeftClick" />
</Image.InputBindings>
</Image>
<Border Margin="0,0,1,1">
<Image Source="{Binding MediaUrl, IsAsync=True}" Style="{StaticResource TweetMediaStyle}">
<Image.InputBindings>
<MouseBinding
Command="{x:Static commands:ImageViewCommand.Command}"
CommandParameter="{Binding}"
MouseAction="LeftClick" />
</Image.InputBindings>
</Image>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
Expand Down
4 changes: 2 additions & 2 deletions tweetz/tweetz5/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

[assembly: ThemeInfo(ResourceDictionaryLocation.None,ResourceDictionaryLocation.SourceAssembly)]

[assembly: AssemblyVersion("1.3.0")]
[assembly: AssemblyFileVersion("1.3.0")]
[assembly: AssemblyVersion("1.3.1")]
[assembly: AssemblyFileVersion("1.3.1")]
[assembly: Guid("B21EBDFF-5222-451A-AB7D-F07EF6DF2813")]

0 comments on commit 709e542

Please sign in to comment.