Skip to content

Commit 9d51fe5

Browse files
committed
Changes
About Page Minor Fixes & User Interface changes
1 parent b7226a5 commit 9d51fe5

15 files changed

Lines changed: 833 additions & 183 deletions

PhotoToys/AboutPage.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using Microsoft.UI.Xaml.Controls;
3+
using Microsoft.UI.Xaml;
4+
using Microsoft.UI.Xaml.Automation;
5+
using Microsoft.UI.Xaml.Media.Animation;
6+
using Microsoft.UI.Xaml.Media;
7+
using System.Windows.Input;
8+
using Microsoft.UI.Xaml.Media.Imaging;
9+
using Windows.ApplicationModel;
10+
using System.Runtime.InteropServices;
11+
12+
namespace PhotoToys
13+
{
14+
class AboutPage : Grid
15+
{
16+
public AboutPage()
17+
{
18+
var version = Package.Current.Id.Version;
19+
Children.AddRange(new UIElement[]
20+
{
21+
new Grid
22+
{
23+
Margin = new Thickness(0, 30, 0, 0),
24+
VerticalAlignment = VerticalAlignment.Top,
25+
ColumnDefinitions = {
26+
new ColumnDefinition { Width = GridLength.Auto },
27+
new ColumnDefinition(),
28+
},
29+
Children =
30+
{
31+
new Image
32+
{
33+
VerticalAlignment = VerticalAlignment.Top,
34+
Source = new BitmapImage(new Uri("ms-appx:///Assets/PhotoToys.png")),
35+
Width = 100,
36+
Height = 100,
37+
},
38+
new SimpleUI.FluentVerticalStack(4)
39+
{
40+
Margin = new Thickness(20, 0, 0, 0),
41+
VerticalAlignment = VerticalAlignment.Top,
42+
Children =
43+
{
44+
new TextBlock
45+
{
46+
Text = "PhotoToys (Beta)"
47+
},
48+
new TextBlock
49+
{
50+
Text = "By Get"
51+
},
52+
new TextBlock
53+
{
54+
Text = $"Version: {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"
55+
},
56+
new TextBlock
57+
{
58+
VerticalAlignment = VerticalAlignment.Stretch,
59+
Text = "PhotoToys is open-sourced on Github"
60+
},
61+
new StackPanel
62+
{
63+
Orientation = Orientation.Horizontal,
64+
Children = {
65+
66+
new HyperlinkButton
67+
{
68+
Content = "Go to Github Repository",
69+
NavigateUri = new Uri("https://github.com/Get0457/PhotoToys")
70+
},
71+
}
72+
}
73+
}
74+
}.Edit(x => SetColumn(x, 1))
75+
}
76+
}
77+
});
78+
}
79+
}
80+
}

PhotoToys/Assets/PhotoToys.ico

4.19 KB
Binary file not shown.

PhotoToys/Assets/PhotoToys.png

2.77 MB
Loading

PhotoToys/Assets/PhotoToys.svg

Lines changed: 217 additions & 0 deletions
Loading

PhotoToys/Custom UI/MatImage.cs

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
using Windows.Storage;
1414
using Windows.Storage.Pickers;
1515
using Windows.Storage.Streams;
16-
16+
using WinRT;
1717
namespace PhotoToys;
1818
interface IMatDisplayer
1919
{
@@ -219,9 +219,18 @@ public MatImage(bool DisableView = false, string AddToInventoryLabel = "Add To I
219219
await SaveMat(Mat_);
220220
}),
221221
new MenuFlyoutItem
222+
{
223+
Text = "Share",
224+
Icon = new SymbolIcon(Symbol.Share),
225+
}.Edit(x => x.Click += async delegate
226+
{
227+
await Share();
228+
}),
229+
new MenuFlyoutSeparator(),
230+
new MenuFlyoutItem
222231
{
223232
Text = "View",
224-
Icon = new SymbolIcon(Symbol.Zoom),
233+
Icon = new SymbolIcon(Symbol.View),
225234
Visibility = DisableView ? Visibility.Collapsed : Visibility.Visible,
226235
}.Edit(x => x.Click += async delegate
227236
{
@@ -235,14 +244,54 @@ public MatImage(bool DisableView = false, string AddToInventoryLabel = "Add To I
235244
}.Edit(x => x.Click += async (_, _) =>
236245
{
237246
await AddToInventory();
238-
})
247+
}),
239248
}
240249
};
241250
}
242251
public async Task CopyToClipboard()
243252
{
244253
if (Mat_ != null) Clipboard.SetContent(await GetDataPackage());
245254
}
255+
static readonly Guid _dtm_iid =
256+
new Guid(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c);
257+
public async Task Share()
258+
{
259+
var t = new TaskCompletionSource();
260+
var Handle = App.CurrentWindowHandle;
261+
IDataTransferManagerInterop interop =
262+
Windows.ApplicationModel.DataTransfer.DataTransferManager.As
263+
<IDataTransferManagerInterop>();
264+
265+
IntPtr result = interop.GetForWindow(Handle, _dtm_iid);
266+
var dtm = WinRT.MarshalInterface
267+
<Windows.ApplicationModel.DataTransfer.DataTransferManager>.FromAbi(result);
268+
269+
async void A(DataTransferManager o, DataRequestedEventArgs e)
270+
{
271+
var d = e.Request.GetDeferral();
272+
try
273+
{
274+
if (Mat_ == null) return;
275+
var datacontent = await GetDataPackageContent();
276+
Debug.Assert(datacontent != null);
277+
var (bytes, stream, BitmapMemRef, StorageFile) = datacontent.Value;
278+
e.Request.Data.Properties.Title = "Share Image";
279+
e.Request.Data.SetData("PhotoToys Image", stream);
280+
e.Request.Data.SetData("PNG", stream);
281+
e.Request.Data.SetBitmap(BitmapMemRef);
282+
e.Request.Data.SetStorageItems(new IStorageItem[] { StorageFile }, readOnly: false);
283+
}
284+
finally
285+
{
286+
d.Complete();
287+
t.SetResult();
288+
}
289+
}
290+
dtm.DataRequested += A;
291+
interop.ShowShareUIForWindow(Handle);
292+
await t.Task;
293+
dtm.DataRequested -= A;
294+
}
246295
public async Task Save()
247296
{
248297
if (Mat_ != null) await SaveMat(Mat_);
@@ -476,4 +525,11 @@ public void Dispose()
476525
{
477526
MatImage.Dispose();
478527
}
528+
}
529+
[System.Runtime.InteropServices.ComImport, System.Runtime.InteropServices.Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
530+
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
531+
interface IDataTransferManagerInterop
532+
{
533+
IntPtr GetForWindow([System.Runtime.InteropServices.In] IntPtr appWindow, [System.Runtime.InteropServices.In] ref Guid riid);
534+
void ShowShareUIForWindow(IntPtr appWindow);
479535
}

PhotoToys/Custom UI/SimpleUI.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,14 @@ public static UIElement GenerateLIVE(string PageName, string? PageDescription =
179179
{
180180
Children =
181181
{
182-
new StackPanel
182+
new Grid
183183
{
184-
Orientation = Orientation.Horizontal,
184+
ColumnDefinitions =
185+
{
186+
new ColumnDefinition { Width = GridLength.Auto },
187+
new ColumnDefinition(),
188+
new ColumnDefinition { Width = GridLength.Auto },
189+
},
185190
Children =
186191
{
187192
new TextBlock
@@ -192,10 +197,23 @@ public static UIElement GenerateLIVE(string PageName, string? PageDescription =
192197
new Button
193198
{
194199
Margin = new Thickness(10, 0, 0, 0),
195-
Content = "View Image",
200+
Content = new StackPanel
201+
{
202+
Orientation = Orientation.Horizontal,
203+
Children =
204+
{
205+
new SymbolIcon(Symbol.View),
206+
new TextBlock
207+
{
208+
Margin = new Thickness(10, 0, 0, 0),
209+
Text = "View Image"
210+
}
211+
}
212+
},
196213
IsEnabled = false
197214
}.Assign(out var viewbtn).Edit(x =>
198215
{
216+
Grid.SetColumn(x, 2);
199217
x.Click += async delegate
200218
{
201219
await MatDisplayer.MatImage.View();

0 commit comments

Comments
 (0)