-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added "DateBlock" properties UI (#63)
- Loading branch information
1 parent
d2e36ca
commit 9f6cbc1
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<UserControl x:Class="Datalya.UserControls.DateBlockPropertiesUI" | ||
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:Datalya.UserControls" | ||
xmlns:lang="clr-namespace:Datalya.Properties" | ||
FontFamily="..\Fonts\#Montserrat" Foreground="{Binding Source={StaticResource Foreground1}}" | ||
mc:Ignorable="d" | ||
Height="450" Width="300"> | ||
<Grid d:Background="#fff"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
<StackPanel> | ||
<StackPanel Orientation="Horizontal" Margin="10"> | ||
<TextBlock Text="" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Margin="0 0 10 0" FontSize="24" VerticalAlignment="Center"/> | ||
<TextBlock Text="{x:Static lang:Resources.Date}" FontWeight="Bold" FontSize="16" VerticalAlignment="Center"/> | ||
</StackPanel> | ||
|
||
<TextBlock Text="{x:Static lang:Resources.Name}" FontWeight="Bold" Margin="10,0,0,0"/> | ||
<TextBox x:Name="NameTxt" Style="{DynamicResource RegularTextBoxStyle}" Padding="7" Margin="10,5,10,15" BorderThickness="0" Background="{Binding Source={StaticResource Background2}}" Foreground="{Binding Source={StaticResource Foreground1}}" Text="{x:Static lang:Resources.Input}" FontWeight="Bold" TextAlignment="Center"/> | ||
|
||
<TextBlock Text="{x:Static lang:Resources.DateDefaultValue}" FontWeight="Bold" Margin="10,0,0,0"/> | ||
<CheckBox Foreground="{Binding Source={StaticResource Foreground1}}" Background="{Binding Source={StaticResource Background1}}" x:Name="UseDefaultDateChk" BorderThickness="2" Content="{x:Static lang:Resources.UseDefaultDate}" FontWeight="Bold" Margin="10 2" Style="{DynamicResource CheckBoxStyle1}" VerticalContentAlignment="Center" FontSize="10"/> | ||
|
||
<TextBlock Text="{x:Static lang:Resources.Date}" FontWeight="Bold" Margin="10,0,0,0"/> | ||
<DatePicker x:Name="DefaultDatePicker" Margin="10 2"></DatePicker> | ||
</StackPanel> | ||
|
||
<Button x:Name="SaveBtn" Grid.Row="1" Click="SaveBtn_Click" Padding="5" Margin="10" HorizontalAlignment="Center" Style="{DynamicResource TabButtonStyle}" Background="{Binding Source={StaticResource AccentColor}}" Foreground="{Binding Source={StaticResource WindowButtonsHoverForeground1}}" BorderThickness="0" Cursor="Hand"> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Margin="0,0,10,0" VerticalAlignment="Center"/> | ||
<TextBlock Text="{x:Static lang:Resources.Save}" FontWeight="Bold" VerticalAlignment="Center"/> | ||
</StackPanel> | ||
</Button> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
MIT License | ||
Copyright (c) Léo Corporation | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
using Datalya.Classes; | ||
using LeoCorpLibrary; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace Datalya.UserControls; | ||
/// <summary> | ||
/// Interaction logic for DateBlockPropertiesUI.xaml | ||
/// </summary> | ||
public partial class DateBlockPropertiesUI : UserControl | ||
{ | ||
private DateBlockCreatorUI ParentElement { get; init; } | ||
internal DateBlock DateBlock { get; set; } | ||
|
||
public DateBlockPropertiesUI(DateBlockCreatorUI dateBlockCreatorUI, DateBlock dateBlock) | ||
{ | ||
InitializeComponent(); | ||
DateBlock = dateBlock; // Set | ||
ParentElement = dateBlockCreatorUI; // Set | ||
|
||
if (dateBlock is not null) | ||
{ | ||
NameTxt.Text = dateBlock.Name; // Set text | ||
UseDefaultDateChk.IsChecked = dateBlock.UseDefaultDate; // Set the check state | ||
DefaultDatePicker.DisplayDate = Env.UnixTimeToDateTime(dateBlock.DefaultDate ?? Env.UnixTime); // Set the date | ||
} | ||
} | ||
|
||
private void SaveBtn_Click(object sender, RoutedEventArgs e) | ||
{ | ||
if (!string.IsNullOrEmpty(NameTxt.Text) && !string.IsNullOrWhiteSpace(NameTxt.Text)) | ||
{ | ||
DateBlock = new() { Name = NameTxt.Text, UseDefaultDate = UseDefaultDateChk.IsChecked.Value, DefaultDate = DefaultDatePicker.DisplayDate.Second }; | ||
ParentElement.NameTxt.Text = DateBlock.Name; // Set name | ||
ParentElement.Date = InputBlock; // Set | ||
Global.CreatorPage.SaveChanges(); // Save | ||
} | ||
} | ||
} |