반응형
MainWindow.xaml
0.00MB
MainWindow.xaml.cs
0.00MB
소스 코드
MainWindow.xaml
<Window x:Class="시계_가젯.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:시계_가젯"
mc:Ignorable="d"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
Loaded="Window_Loaded"
Title="MainWindow" Height="200" Width="150">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Ellipse
MouseDown="Ellipse_MouseDown"
Opacity="0.2"
Grid.RowSpan="6"
Fill="Cyan"/>
<TextBlock
Name="tb_eh"
Foreground="Red"
FontWeight="Heavy"
HorizontalAlignment="Center"
Text="http://ehpub.co.kr"
Grid.Row="1"/>
<TextBlock
Name="tb_date"
HorizontalAlignment="Center"
Text="0000-00-00"
Grid.Row="2"/>
<TextBlock
Name="tb_time"
HorizontalAlignment="Center"
Text="오전 00:00:00"
Grid.Row="3"/>
<Button
Click="Button_Click"
Grid.Row="4"
Width="100"
Content="닫기"/>
</Grid>
</Window>
MainWindow.cs
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
namespace 시계_가젯
{
/// <summary>
/// MainWindow.xaml에 대한 상호 작용 논리
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Ellipse_MouseDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
SetDateTime();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
timer.Start();
}
private void SetDateTime()
{
tb_date.Text = DateTime.Now.ToShortDateString();
tb_time.Text = DateTime.Now.ToLongTimeString();
}
private void Timer_Tick(object sender, EventArgs e)
{
SetDateTime();
}
}
}
시계 Gadget 만들기 [언제나 WPF] – 언제나 휴일
안녕하세요. 언제나 휴일, 언휴예요. 이번에는 작은 기능을 수행하는 도구인 Gadget을 만들어 봅시다. Gadget(가젯)은 Widget, Winget, Webget, Appget 등의 여러가지 형태로 불리죠. 암튼 작은 기능을 수행하는 도구예요. 그림에 보시는 것처럼 가젯은 보통 타이틀 바가 없는 형태로 많이 만들죠. 그리고 딱딱한 사각형보다 타원이나 별 등의 모양 등으로 만든 것들도 있고요. 먼저 “WPF 앱 ” 프로젝트를 생성하세요. 윈도우에 타이
ehpub.co.kr
반응형
'.NET > WPF' 카테고리의 다른 글
WPF에서 WebBrowser 컨트롤 스크립트 오류 없애기 (0) | 2020.07.31 |
---|---|
Grid 패널에 배치하기 – CS 코드로 작성하기 [언제나 WPF] (0) | 2020.07.08 |
Grid 패널에 배치하기 [언제나 WPF] (0) | 2020.05.28 |
Kakao API를 이용한 위치 검색 프로그램 만들기 [WPF] (0) | 2020.04.27 |