clock gadget
This commit is contained in:
9
PacticeSolution/ClockGadget/App.xaml
Normal file
9
PacticeSolution/ClockGadget/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="ClockGadget.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:ClockGadget"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
17
PacticeSolution/ClockGadget/App.xaml.cs
Normal file
17
PacticeSolution/ClockGadget/App.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ClockGadget
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
10
PacticeSolution/ClockGadget/AssemblyInfo.cs
Normal file
10
PacticeSolution/ClockGadget/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
10
PacticeSolution/ClockGadget/ClockGadget.csproj
Normal file
10
PacticeSolution/ClockGadget/ClockGadget.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
45
PacticeSolution/ClockGadget/MainWindow.xaml
Normal file
45
PacticeSolution/ClockGadget/MainWindow.xaml
Normal file
@@ -0,0 +1,45 @@
|
||||
<Window x:Class="ClockGadget.MainWindow"
|
||||
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:local="clr-namespace:ClockGadget"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="200" Width="200"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Ellipse Grid.RowSpan="7" Fill="White" Opacity="0.6"
|
||||
MouseDown="Ellipse_MouseDown"/>
|
||||
<TextBlock x:Name="tbDate"
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="0000-00-00"/>
|
||||
<TextBlock x:Name="tbTime"
|
||||
Grid.Row="3"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="AM 00:00:00"/>
|
||||
<Button x:Name="btnClose"
|
||||
Grid.Row="5"
|
||||
Width="100"
|
||||
BorderBrush="Transparent"
|
||||
Background="Transparent"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Content="Close"
|
||||
Click="btnClose_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
63
PacticeSolution/ClockGadget/MainWindow.xaml.cs
Normal file
63
PacticeSolution/ClockGadget/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ClockGadget
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private DispatcherTimer _timer;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void SetDateTime()
|
||||
{
|
||||
tbDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
tbTime.Text = DateTime.Now.ToString("tt hh:mm:ss");
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SetDateTime();
|
||||
|
||||
_timer = new DispatcherTimer();
|
||||
_timer.Interval = TimeSpan.FromSeconds(1);
|
||||
_timer.Tick += On_timer_Tick;
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
private void On_timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
SetDateTime();
|
||||
}
|
||||
|
||||
private void Ellipse_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
this.DragMove();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user