2019-09-19 12:34:02 +10:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Runtime.InteropServices.WindowsRuntime;
|
2019-11-20 06:11:57 +11:00
|
|
|
|
using System.Threading.Tasks;
|
2019-09-19 13:36:46 +10:00
|
|
|
|
using UWP_Visual_Asset_Generator.ViewModels;
|
2019-09-19 14:24:58 +10:00
|
|
|
|
using Windows.ApplicationModel.DataTransfer;
|
2019-09-19 12:34:02 +10:00
|
|
|
|
using Windows.Foundation;
|
|
|
|
|
|
using Windows.Foundation.Collections;
|
2019-09-19 14:24:58 +10:00
|
|
|
|
using Windows.Storage;
|
2019-09-19 12:34:02 +10:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
|
using Windows.UI.Xaml.Controls.Primitives;
|
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
|
using Windows.UI.Xaml.Input;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
using Windows.UI.Xaml.Navigation;
|
|
|
|
|
|
|
|
|
|
|
|
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
|
|
|
|
|
|
|
|
namespace UWP_Visual_Asset_Generator.UserControls
|
|
|
|
|
|
{
|
|
|
|
|
|
public sealed partial class SidebarUserControl : UserControl
|
|
|
|
|
|
{
|
2019-09-19 13:36:46 +10:00
|
|
|
|
public MainViewModel mainViewModel { get; set; }
|
|
|
|
|
|
|
2019-09-19 12:34:02 +10:00
|
|
|
|
public SidebarUserControl()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.InitializeComponent();
|
2019-09-19 13:36:46 +10:00
|
|
|
|
mainViewModel = App.mainViewModel;
|
2019-09-19 12:34:02 +10:00
|
|
|
|
}
|
2019-09-19 14:24:58 +10:00
|
|
|
|
|
2020-07-21 08:26:53 +10:00
|
|
|
|
private async void Image_Original_Tapped(object sender, TappedRoutedEventArgs e)
|
2019-09-19 14:24:58 +10:00
|
|
|
|
{
|
2020-07-21 08:26:53 +10:00
|
|
|
|
await mainViewModel.LoadOriginalImageFromFileAsync();
|
2019-09-19 14:24:58 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void Image_Original_Drop(object sender, DragEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.DataView.Contains(StandardDataFormats.StorageItems))
|
|
|
|
|
|
{
|
|
|
|
|
|
var items = await e.DataView.GetStorageItemsAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (items.Count > 0 &&
|
|
|
|
|
|
items[0] is StorageFile &&
|
|
|
|
|
|
((StorageFile)items[0]).FileType.ToLower().Equals(".png"))
|
|
|
|
|
|
{
|
|
|
|
|
|
mainViewModel.LoadOriginalImageFromFileAsync(items[0] as StorageFile);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
mainViewModel.ShowDialog("Information", "Only .PNG files are allowed.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Image_Original_DragOver(object sender, DragEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
e.AcceptedOperation = DataPackageOperation.Link;
|
|
|
|
|
|
|
|
|
|
|
|
e.DragUIOverride.Caption = "Load file"; // Sets custom UI text
|
|
|
|
|
|
//e.DragUIOverride.SetContentFromBitmapImage(null); // Sets a custom glyph
|
|
|
|
|
|
e.DragUIOverride.IsCaptionVisible = true; // Sets if the caption is visible
|
|
|
|
|
|
e.DragUIOverride.IsContentVisible = true; // Sets if the dragged content is visible
|
|
|
|
|
|
e.DragUIOverride.IsGlyphVisible = true; // Sets if the glyph is visibile
|
|
|
|
|
|
}
|
2019-09-19 20:14:34 +10:00
|
|
|
|
|
|
|
|
|
|
private void Btn_OutputFolder_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
mainViewModel.SetOutputFolderAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-11-20 06:11:57 +11:00
|
|
|
|
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var s = sender as ComboBox;
|
|
|
|
|
|
if (s != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetThemeAsync(s.SelectedIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SetThemeAsync(int theme)
|
|
|
|
|
|
{
|
2020-07-21 08:26:53 +10:00
|
|
|
|
if (App.mainPage != null)
|
2019-11-20 06:11:57 +11:00
|
|
|
|
{
|
2020-07-21 08:26:53 +10:00
|
|
|
|
switch (theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 0: App.mainPage.RequestedTheme = ElementTheme.Default; ; break;
|
|
|
|
|
|
case 1: App.mainPage.RequestedTheme = ElementTheme.Light; ; break;
|
|
|
|
|
|
case 2: App.mainPage.RequestedTheme = ElementTheme.Dark; ; break;
|
|
|
|
|
|
}
|
2019-11-20 06:11:57 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-01-26 15:21:06 +11:00
|
|
|
|
|
2020-02-02 15:41:48 -05:00
|
|
|
|
private async void btnSetBackgroundColour_Click(object sender, RoutedEventArgs e)
|
2020-01-26 15:21:06 +11:00
|
|
|
|
{
|
2020-02-02 15:41:48 -05:00
|
|
|
|
var dialog = new BackgroundColorUserControl();
|
|
|
|
|
|
await dialog.ShowAsync();
|
2020-01-26 15:21:06 +11:00
|
|
|
|
}
|
2019-09-19 12:34:02 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|