-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
147 lines (123 loc) · 3.38 KB
/
Form1.cs
File metadata and controls
147 lines (123 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.WindowsAPICodePack.Dialogs;
namespace Clock_and_Timer
{
public partial class Clock : Form
{
List<string> filteredFiles;
FolderBrowserDialog pictureFolder = new FolderBrowserDialog();
FolderBrowserDialog musicFolder = new FolderBrowserDialog();
int picCount = -1;
bool picListIsPlaying = false;
int musicCount = -1;
bool musicListIsPlaying = false;
TimeSpan timeSpan = TimeSpan.Zero;
public Clock()
{
InitializeComponent();
countDownTimer.Start();
}
public void Count_down(DateTime now)
{
DateTime nowTime = now;
DateTime endTime = new DateTime(2023, 02, 22, 15, 05, 00);
TimeSpan T = endTime - nowTime;
string remainingTime = string.Format("{0:hh\\:mm\\:ss}", T);
if(T.Hours == 0 && T.Minutes == 0 && T.Seconds == 0)
{
countDownTimer.Stop();
CurrentTimeLabel.Text = "It is 3:00 PM.";
}
else
{
CurrentTimeLabel.Text = remainingTime;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
Count_down(now);
}
private void fullScreenButton_Click(object sender, EventArgs e)
{
if(Clock.ActiveForm.WindowState == FormWindowState.Maximized)
{
fullScreenButton.Text = "Fullscreen";
Clock.ActiveForm.FormBorderStyle = FormBorderStyle.Sizable;
Clock.ActiveForm.WindowState = FormWindowState.Normal;
}
else
{
fullScreenButton.Text = "Restore";
Clock.ActiveForm.FormBorderStyle = FormBorderStyle.None;
Clock.ActiveForm.WindowState = FormWindowState.Maximized;
}
}
private bool dragging = false;
private Point dragCursorPoint;
private Point dragFormPoint;
private void _MouseDown(object sender, MouseEventArgs e)
{
dragging = true;
dragCursorPoint = Cursor.Position;
dragFormPoint = this.Location;
}
private void _MouseMove(object sender, MouseEventArgs e)
{
if(dragging)
{
Point dif = Point.Subtract(Cursor.Position, new Size(dragCursorPoint));
this.Location = Point.Add(dragFormPoint, new Size(dif));
}
}
private void _MouseUp(object sender, MouseEventArgs e)
{
dragging = false;
}
private void exitButton_Click(object sender, EventArgs e)
{
Close();
}
public void SelectFolder(string path)
{
string dirpath = path;
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
if(path == null || path == "")
{
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
}
else if(path == "MyPictures")
{
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
}
else if(path == "MyMusic")
{
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
}
dialog.IsFolderPicker = true;
if(dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
// call respective function here
MessageBox.Show("You selected: " + dialog.FileName);
}
}
private void musicfolder_Click(object sender, EventArgs e)
{
SelectFolder("MyMusic");
}
private void picturefolder_Click(object sender, EventArgs e)
{
picCount = -1;
picListIsPlaying = false;
slideShowTimer.Stop();
SelectFolder("MyPictures");
//DialogResult pictures = FolderBrowser.ShowDialog();
}
private void datetimepicker_Click(object sender, EventArgs e)
{
}
}
}