Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stojcheska Teodora
Programming_Project
Commits
12e59856
Commit
12e59856
authored
Aug 02, 2021
by
Stojcheska Teodora
Browse files
Calendar Class reorganized, added set default working hours option.
parent
b33c6935
Changes
10
Hide whitespace changes
Inline
Side-by-side
Calendar.cs
View file @
12e59856
...
@@ -17,7 +17,7 @@ public class Calendar
...
@@ -17,7 +17,7 @@ public class Calendar
this
.
Days
=
new
List
<
Day
>();
this
.
Days
=
new
List
<
Day
>();
this
.
DefaultWorkingHours
=
8
;
this
.
DefaultWorkingHours
=
8
;
this
.
DefaultWorkingHoursInterval
=
(
9
,
17
);
this
.
DefaultWorkingHoursInterval
=
(
9
,
17
);
Days
.
Add
(
new
Day
(
DateTime
.
Now
,
new
List
<
Task
>(),
DefaultWorkingHoursInterval
,
DefaultWorkingHours
));
Days
.
Add
(
new
Day
(
DateTime
.
Now
,
new
List
<
Task
>(),
DefaultWorkingHoursInterval
));
this
.
CurrentDate
=
DateTime
.
Now
;
// format dd.mm.yyyy hh:mm:ss
this
.
CurrentDate
=
DateTime
.
Now
;
// format dd.mm.yyyy hh:mm:ss
}
}
...
@@ -62,7 +62,7 @@ public class Calendar
...
@@ -62,7 +62,7 @@ public class Calendar
int
daysToAdd
=
numberOfDaysInRange
(
Days
[
Days
.
Count
-
1
].
Date
,
date
);
int
daysToAdd
=
numberOfDaysInRange
(
Days
[
Days
.
Count
-
1
].
Date
,
date
);
for
(
int
i
=
0
;
i
<
daysToAdd
;
++
i
)
for
(
int
i
=
0
;
i
<
daysToAdd
;
++
i
)
{
{
Day
newDay
=
new
Day
(
Days
[
Days
.
Count
-
1
].
Date
.
AddDays
(
1
),
new
List
<
Task
>(),
DefaultWorkingHoursInterval
,
DefaultWorkingHours
);
Day
newDay
=
new
Day
(
Days
[
Days
.
Count
-
1
].
Date
.
AddDays
(
1
),
new
List
<
Task
>(),
DefaultWorkingHoursInterval
);
newDay
.
PrevDay
=
Days
[
Days
.
Count
-
1
];
newDay
.
PrevDay
=
Days
[
Days
.
Count
-
1
];
Days
[
Days
.
Count
-
1
].
NextDay
=
newDay
;
Days
[
Days
.
Count
-
1
].
NextDay
=
newDay
;
Days
.
Add
(
newDay
);
Days
.
Add
(
newDay
);
...
@@ -95,6 +95,21 @@ public class Calendar
...
@@ -95,6 +95,21 @@ public class Calendar
return
validDays
;
return
validDays
;
}
}
public
bool
doesTaskExist
(
Task
t
)
{
foreach
(
Day
day
in
Days
)
{
foreach
(
Task
task
in
day
.
Tasks
)
{
if
(
t
.
Equals
(
task
))
{
return
true
;
}
}
}
return
false
;
}
public
event
ErrorNotify
ErrorInTaskParameters
;
public
event
ErrorNotify
ErrorInTaskParameters
;
/* ----------------------------- Utility for add and delete task ----------------------------- */
/* ----------------------------- Utility for add and delete task ----------------------------- */
...
@@ -106,8 +121,9 @@ public class Calendar
...
@@ -106,8 +121,9 @@ public class Calendar
int
hours
=
hoursToShift
;
int
hours
=
hoursToShift
;
Day
dirDay
=
dir
==
Direction
.
NEXT
?
day
.
NextDay
:
day
.
PrevDay
;
Day
dirDay
=
dir
==
Direction
.
NEXT
?
day
.
NextDay
:
day
.
PrevDay
;
// DateTime.Now > dirDay.Date it cannot go in past
if
(
dirDay
==
null
||
(
dirDay
.
Equals
(
returnPoint
)
&&
dir
==
Direction
.
PREVIOUS
)
||
(
day
.
hoursToShift
<=
0
&&
dir
==
Direction
.
NEXT
))
{
return
;
}
if
(
dirDay
==
null
||
(
dirDay
.
Equals
(
returnPoint
)
&&
dir
==
Direction
.
PREVIOUS
)
||
(
day
.
hoursToShift
<=
0
&&
dir
==
Direction
.
NEXT
))
{
return
;
}
if
(
numberOfDaysInRange
(
DateTime
.
Now
,
dirDay
.
Date
)
<=
0
)
{
return
;
}
List
<
Task
>
tasks
=
new
List
<
Task
>();
List
<
Task
>
tasks
=
new
List
<
Task
>();
...
@@ -175,7 +191,6 @@ public class Calendar
...
@@ -175,7 +191,6 @@ public class Calendar
foreach
(
Task
task
in
tasks
)
{
dirDay
.
addTask
(
task
,
dir
==
Direction
.
NEXT
?
0
:
dirDay
.
Tasks
.
Count
);
}
foreach
(
Task
task
in
tasks
)
{
dirDay
.
addTask
(
task
,
dir
==
Direction
.
NEXT
?
0
:
dirDay
.
Tasks
.
Count
);
}
// for delete only shift fixed hours and for add it chages according to the hours we shifted
reorderCalendar
(
dirDay
,
dir
==
Direction
.
NEXT
?
dirDay
.
hoursToShift
<
0
?
hoursToShift
:
dirDay
.
hoursToShift
:
hoursToShift
,
returnPoint
,
dir
);
reorderCalendar
(
dirDay
,
dir
==
Direction
.
NEXT
?
dirDay
.
hoursToShift
<
0
?
hoursToShift
:
dirDay
.
hoursToShift
:
hoursToShift
,
returnPoint
,
dir
);
}
}
...
@@ -196,7 +211,11 @@ public class Calendar
...
@@ -196,7 +211,11 @@ public class Calendar
}
}
catch
(
NoSpaceForTaskException
exception
)
catch
(
NoSpaceForTaskException
exception
)
{
{
if
(
exception
.
Day
!=
null
)
if
(
task
.
Type
==
Type
.
FIXED
)
{
exception
.
Day
.
removeTask
(
task
);
}
else
if
(
task
.
Type
==
Type
.
NORMAL
&&
exception
.
Day
!=
null
)
{
{
Day
day
=
exception
.
Day
;
Day
day
=
exception
.
Day
;
deleteTask
(
day
,
exception
.
Task
);
deleteTask
(
day
,
exception
.
Task
);
...
@@ -206,7 +225,6 @@ public class Calendar
...
@@ -206,7 +225,6 @@ public class Calendar
reorderCalendar
(
day
,
day
.
hoursToShift
,
null
,
Direction
.
NEXT
);
reorderCalendar
(
day
,
day
.
hoursToShift
,
null
,
Direction
.
NEXT
);
}
}
}
}
ErrorInTaskParameters
?.
Invoke
();
ErrorInTaskParameters
?.
Invoke
();
}
}
}
}
...
@@ -260,6 +278,7 @@ public class Calendar
...
@@ -260,6 +278,7 @@ public class Calendar
return
;
return
;
}
}
}
}
throw
new
NoSpaceForTaskException
(
"There is no space to add the Task"
,
null
,
null
,
0
);
}
}
/* ------------------------------- Delete Task ----------------------------------- */
/* ------------------------------- Delete Task ----------------------------------- */
...
@@ -283,31 +302,51 @@ public class Calendar
...
@@ -283,31 +302,51 @@ public class Calendar
}
}
}
}
/* ------------------------------ Modify Task ---------------------------------- */
public
void
modifyTask
(
Task
task
,
DateTime
newDeadline
,
String
newName
)
{
Task
t
=
task
;
while
(
t
!=
null
)
{
t
.
Name
=
newName
;
t
.
Deadline
=
newDeadline
;
}
t
=
task
.
NextSplitTaskPtr
;
while
(
t
!=
null
)
{
t
.
Name
=
newName
;
t
.
Deadline
=
newDeadline
;
}
}
/* --------------------------- Change Working Hours ------------------------------- */
/* --------------------------- Change Working Hours ------------------------------- */
public
void
changeWorkingHours
(
DateTime
date
,
int
previousWorkingHours
)
public
bool
changeWorkingHours
(
DateTime
date
,
(
int
,
int
)
previousWorkingHours
Interval
)
{
{
Day
day
=
getDayByDate
(
date
);
Day
day
=
getDayByDate
(
date
);
int
previousWorkingHours
=
previousWorkingHoursInterval
.
Item2
-
previousWorkingHoursInterval
.
Item1
;
if
(
previousWorkingHours
-
day
.
WorkingHours
<
0
)
if
(
previousWorkingHours
-
day
.
WorkingHours
<
0
)
{
{
reorderCalendar
(
Days
[
Days
.
Count
-
1
],
Math
.
Abs
(
previousWorkingHours
-
day
.
WorkingHours
),
day
,
Direction
.
PREVIOUS
);
reorderCalendar
(
Days
[
Days
.
Count
-
1
],
Math
.
Abs
(
previousWorkingHours
-
day
.
WorkingHours
),
day
,
Direction
.
PREVIOUS
);
}
}
else
if
(
previousWorkingHours
-
day
.
WorkingHours
>
0
)
else
if
(
previousWorkingHours
-
day
.
WorkingHours
>
0
)
{
{
int
hoursNeeded
=
shouldAddDay
(
previousWorkingHours
-
day
.
WorkingHours
);
int
hoursNeeded
=
shouldAddDay
(
day
.
hoursToShift
);
if
(
hoursNeeded
>
0
)
if
(
hoursNeeded
>
0
)
{
{
int
daysNeeded
=
(
int
)
Math
.
Ceiling
((
double
)
hoursNeeded
/
day
.
WorkingHours
);
int
daysNeeded
=
(
int
)
Math
.
Ceiling
((
double
)
hoursNeeded
/
day
.
WorkingHours
);
addDaysUpToDate
(
Days
[
Days
.
Count
].
Date
.
AddDays
(
daysNeeded
));
addDaysUpToDate
(
Days
[
Days
.
Count
-
1
].
Date
.
AddDays
(
daysNeeded
));
}
}
int
shiftHours
=
day
.
hoursToShift
;
try
try
{
{
reorderCalendar
(
day
,
previousWorkingHours
-
day
.
Working
Hours
,
null
,
Direction
.
NEXT
);
reorderCalendar
(
day
,
shift
Hours
,
null
,
Direction
.
NEXT
);
}
}
catch
(
NoSpaceForTaskException
exception
)
catch
(
NoSpaceForTaskException
exception
)
{
{
int
tryWorkingHours
=
day
.
WorkingHours
;
int
tryWorkingHours
=
day
.
WorkingHours
;
day
.
WorkingHours
=
previousWorkingHours
;
day
.
WorkingHours
Interval
=
previousWorkingHours
Interval
;
if
(
exception
.
Day
!=
null
)
if
(
exception
.
Day
!=
null
)
{
{
...
@@ -315,14 +354,17 @@ public class Calendar
...
@@ -315,14 +354,17 @@ public class Calendar
{
{
reorderCalendar
(
exception
.
Day
,
exception
.
Day
.
hoursToShift
-
(
previousWorkingHours
-
tryWorkingHours
),
null
,
Direction
.
NEXT
);
reorderCalendar
(
exception
.
Day
,
exception
.
Day
.
hoursToShift
-
(
previousWorkingHours
-
tryWorkingHours
),
null
,
Direction
.
NEXT
);
}
}
reorderCalendar
(
exception
.
Day
,
previousWorkingHours
-
tryWorking
Hours
,
day
.
PrevDay
,
Direction
.
PREVIOUS
);
reorderCalendar
(
exception
.
Day
,
shift
Hours
,
day
.
PrevDay
,
Direction
.
PREVIOUS
);
}
}
ErrorInTaskParameters
?.
Invoke
();
ErrorInTaskParameters
?.
Invoke
();
return
false
;
}
}
}
}
return
true
;
}
}
public
void
changeDefaultWorkingHours
((
int
,
int
)
workingHoursInterval
)
public
bool
changeDefaultWorkingHours
((
int
,
int
)
workingHoursInterval
)
{
{
this
.
DefaultWorkingHours
=
workingHoursInterval
.
Item2
-
workingHoursInterval
.
Item1
;
this
.
DefaultWorkingHours
=
workingHoursInterval
.
Item2
-
workingHoursInterval
.
Item1
;
this
.
DefaultWorkingHoursInterval
=
workingHoursInterval
;
this
.
DefaultWorkingHoursInterval
=
workingHoursInterval
;
...
@@ -331,12 +373,21 @@ public class Calendar
...
@@ -331,12 +373,21 @@ public class Calendar
while
(
day
!=
null
)
while
(
day
!=
null
)
{
{
int
previousWorkingHours
=
day
.
WorkingHours
;
(
int
,
int
)
previousWorkingHoursInterval
=
day
.
WorkingHoursInterval
;
day
.
WorkingHours
=
this
.
DefaultWorkingHours
;
day
.
WorkingHoursInterval
=
this
.
DefaultWorkingHoursInterval
;
day
.
WorkingHoursInterval
=
this
.
DefaultWorkingHoursInterval
;
changeWorkingHours
(
day
.
Date
,
previousWorkingHours
);
if
(!
changeWorkingHours
(
day
.
Date
,
previousWorkingHoursInterval
))
{
while
(
day
!=
null
&&
numberOfDaysInRange
(
DateTime
.
Now
,
day
.
Date
)
>
0
)
{
day
.
WorkingHoursInterval
=
previousWorkingHoursInterval
;
reorderCalendar
(
Days
[
Days
.
Count
-
1
],
day
.
hoursToShift
*
-
1
,
day
.
PrevDay
,
Direction
.
PREVIOUS
);
day
=
day
.
PrevDay
;
}
return
false
;
}
day
=
day
.
NextDay
;
day
=
day
.
NextDay
;
}
}
return
true
;
}
}
}
}
\ No newline at end of file
Controls/DatePicker.resx
deleted
100644 → 0
View file @
b33c6935
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema
id=
"root"
xmlns=
""
xmlns:xsd=
"http://www.w3.org/2001/XMLSchema"
xmlns:msdata=
"urn:schemas-microsoft-com:xml-msdata"
>
<xsd:import
namespace=
"http://www.w3.org/XML/1998/namespace"
/>
<xsd:element
name=
"root"
msdata:IsDataSet=
"true"
>
<xsd:complexType>
<xsd:choice
maxOccurs=
"unbounded"
>
<xsd:element
name=
"metadata"
>
<xsd:complexType>
<xsd:sequence>
<xsd:element
name=
"value"
type=
"xsd:string"
minOccurs=
"0"
/>
</xsd:sequence>
<xsd:attribute
name=
"name"
use=
"required"
type=
"xsd:string"
/>
<xsd:attribute
name=
"type"
type=
"xsd:string"
/>
<xsd:attribute
name=
"mimetype"
type=
"xsd:string"
/>
<xsd:attribute
ref=
"xml:space"
/>
</xsd:complexType>
</xsd:element>
<xsd:element
name=
"assembly"
>
<xsd:complexType>
<xsd:attribute
name=
"alias"
type=
"xsd:string"
/>
<xsd:attribute
name=
"name"
type=
"xsd:string"
/>
</xsd:complexType>
</xsd:element>
<xsd:element
name=
"data"
>
<xsd:complexType>
<xsd:sequence>
<xsd:element
name=
"value"
type=
"xsd:string"
minOccurs=
"0"
msdata:Ordinal=
"1"
/>
<xsd:element
name=
"comment"
type=
"xsd:string"
minOccurs=
"0"
msdata:Ordinal=
"2"
/>
</xsd:sequence>
<xsd:attribute
name=
"name"
type=
"xsd:string"
use=
"required"
msdata:Ordinal=
"1"
/>
<xsd:attribute
name=
"type"
type=
"xsd:string"
msdata:Ordinal=
"3"
/>
<xsd:attribute
name=
"mimetype"
type=
"xsd:string"
msdata:Ordinal=
"4"
/>
<xsd:attribute
ref=
"xml:space"
/>
</xsd:complexType>
</xsd:element>
<xsd:element
name=
"resheader"
>
<xsd:complexType>
<xsd:sequence>
<xsd:element
name=
"value"
type=
"xsd:string"
minOccurs=
"0"
msdata:Ordinal=
"1"
/>
</xsd:sequence>
<xsd:attribute
name=
"name"
type=
"xsd:string"
use=
"required"
/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader
name=
"resmimetype"
>
<value>
text/microsoft-resx
</value>
</resheader>
<resheader
name=
"version"
>
<value>
2.0
</value>
</resheader>
<resheader
name=
"reader"
>
<value>
System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader
name=
"writer"
>
<value>
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</value>
</resheader>
</root>
\ No newline at end of file
Controls/HintTextBox.cs
View file @
12e59856
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
/* ------------------------------ Public Variables ------------------------------ */
/* ------------------------------ Public Variables ------------------------------ */
public
bool
IsHintDisplayed
{
get
;
private
set
;
}
=
false
;
public
bool
IsHintDisplayed
{
get
;
private
set
;
}
=
false
;
/* ------------------------------ Private Methods ------------------------------ */
/* ------------------------------ Private Methods ------------------------------ */
private
void
SetStyle
(
TextBoxStyle
style
)
private
void
SetStyle
(
TextBoxStyle
style
)
{
{
...
...
Day.cs
View file @
12e59856
...
@@ -8,18 +8,17 @@ public class Day
...
@@ -8,18 +8,17 @@ public class Day
public
DateTime
Date
{
get
;
set
;
}
public
DateTime
Date
{
get
;
set
;
}
public
List
<
Task
>
Tasks
{
get
;
set
;
}
public
List
<
Task
>
Tasks
{
get
;
set
;
}
public
(
int
,
int
)
WorkingHoursInterval
{
get
;
set
;
}
public
(
int
,
int
)
WorkingHoursInterval
{
get
;
set
;
}
public
int
WorkingHours
{
get
;
set
;
}
public
int
WorkingHours
=>
WorkingHoursInterval
.
Item2
-
WorkingHoursInterval
.
Item1
;
public
Day
NextDay
{
get
;
set
;
}
public
Day
NextDay
{
get
;
set
;
}
public
Day
PrevDay
{
get
;
set
;
}
public
Day
PrevDay
{
get
;
set
;
}
public
Task
this
[
int
i
]
=>
Tasks
[
i
];
public
Task
this
[
int
i
]
=>
Tasks
[
i
];
public
Day
(
DateTime
date
,
List
<
Task
>
tasks
,
(
int
,
int
)
workingHoursInterval
,
int
workingHours
)
public
Day
(
DateTime
date
,
List
<
Task
>
tasks
,
(
int
,
int
)
workingHoursInterval
)
{
{
this
.
Date
=
date
;
this
.
Date
=
date
;
this
.
Tasks
=
tasks
;
this
.
Tasks
=
tasks
;
this
.
WorkingHoursInterval
=
workingHoursInterval
;
this
.
WorkingHoursInterval
=
workingHoursInterval
;
this
.
WorkingHours
=
workingHours
;
this
.
NextDay
=
null
;
this
.
NextDay
=
null
;
this
.
PrevDay
=
null
;
this
.
PrevDay
=
null
;
}
}
...
...
Forms/CalendarView.cs
View file @
12e59856
...
@@ -390,8 +390,9 @@ namespace Scheduler.Forms
...
@@ -390,8 +390,9 @@ namespace Scheduler.Forms
private
void
AddTaskButton_Click
(
object
sender
,
EventArgs
e
)
private
void
AddTaskButton_Click
(
object
sender
,
EventArgs
e
)
{
{
TaskView
createTask
=
new
TaskView
((
t
)
=>
{
TaskView
createTask
=
new
TaskView
((
t
,
oldTask
)
=>
{
Settings
.
MyCalendar
.
addTask
(
t
);
if
(!
Settings
.
MyCalendar
.
doesTaskExist
(
t
))
{
Settings
.
MyCalendar
.
addTask
(
t
);
return
true
;
}
return
false
;
});
});
createTask
.
ShowDialog
();
createTask
.
ShowDialog
();
...
@@ -442,9 +443,14 @@ namespace Scheduler.Forms
...
@@ -442,9 +443,14 @@ namespace Scheduler.Forms
this
.
ItemMenuStrip
=
new
ContextMenuStrip
();
this
.
ItemMenuStrip
=
new
ContextMenuStrip
();
this
.
ItemMenuStrip
.
Items
.
Add
(
"Modify"
,
null
,
(
sender
,
e
)
=>
{
this
.
ItemMenuStrip
.
Items
.
Add
(
"Modify"
,
null
,
(
sender
,
e
)
=>
{
TaskView
view
=
new
TaskView
((
Task
)
TaskList
.
SelectedRows
[
0
].
Tag
,
(
t
)
=>
{
TaskView
view
=
new
TaskView
((
Task
)
TaskList
.
SelectedRows
[
0
].
Tag
,
(
t
,
oldTask
)
=>
{
this
.
CurrentDay
.
removeTask
(
t
);
if
(!
Settings
.
MyCalendar
.
doesTaskExist
(
t
))
Settings
.
MyCalendar
.
addTask
(
t
);
{
Settings
.
MyCalendar
.
deleteTask
(
CurrentDay
,
oldTask
);
Settings
.
MyCalendar
.
addTask
(
t
);
return
true
;
}
return
false
;
});
});
view
.
ShowDialog
();
view
.
ShowDialog
();
LoadTasks
();
LoadTasks
();
...
@@ -498,14 +504,15 @@ namespace Scheduler.Forms
...
@@ -498,14 +504,15 @@ namespace Scheduler.Forms
}
}
SetWorkingHoursView
setWorkingHoursView
=
new
SetWorkingHoursView
((
from
,
to
)
=>
{
SetWorkingHoursView
setWorkingHoursView
=
new
SetWorkingHoursView
((
from
,
to
)
=>
{
(
int
,
int
)
prev
=
CurrentDay
.
WorkingHoursInterval
;
CurrentDay
.
WorkingHoursInterval
=
(
from
,
to
);
CurrentDay
.
WorkingHoursInterval
=
(
from
,
to
);
int
prev
=
CurrentDay
.
WorkingHours
;
CurrentDay
.
WorkingHours
=
to
-
from
;
Settings
.
MyCalendar
.
changeWorkingHours
(
CurrentDay
.
Date
,
prev
);
Settings
.
MyCalendar
.
changeWorkingHours
(
CurrentDay
.
Date
,
prev
);
LoadTasks
();
},
CurrentDay
.
WorkingHoursInterval
);
});
setWorkingHoursView
.
ShowDialog
();
if
(
setWorkingHoursView
.
ShowDialog
()
==
DialogResult
.
OK
)
{
LoadTasks
();
}
}
}
private
void
addTaskToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
private
void
addTaskToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
...
@@ -515,17 +522,7 @@ namespace Scheduler.Forms
...
@@ -515,17 +522,7 @@ namespace Scheduler.Forms
private
void
TaskList_CellDoubleClick
(
object
sender
,
DataGridViewCellEventArgs
e
)
private
void
TaskList_CellDoubleClick
(
object
sender
,
DataGridViewCellEventArgs
e
)
{
{
this
.
ItemMenuStrip
.
Items
[
0
].
PerformClick
();
if
(
e
.
RowIndex
!=
-
1
)
{
TaskView
view
=
new
TaskView
((
Task
)
TaskList
.
Rows
[
e
.
RowIndex
].
Tag
,
(
t
)
=>
{
this
.
CurrentDay
.
removeTask
(
t
);
Settings
.
MyCalendar
.
addTask
(
t
);
});
view
.
ShowDialog
();
LoadTasks
();
}
}
}
}
}
}
}
\ No newline at end of file
Forms/SetWorkingHoursView.cs
View file @
12e59856
...
@@ -10,12 +10,13 @@ namespace Scheduler.Forms
...
@@ -10,12 +10,13 @@ namespace Scheduler.Forms
private
Label
TitleLabel
;
private
Label
TitleLabel
;
private
FlowLayoutPanel
mainFlowPanel
;
private
FlowLayoutPanel
mainFlowPanel
;
private
Label
FromLabel
;
private
Label
FromLabel
;
private
TextBox
from
;
private
Label
ToLabel
;
private
Label
ToLabel
;
private
TextBox
to
;
private
FlowLayoutPanel
buttonsFlowPanel
;
private
FlowLayoutPanel
buttonsFlowPanel
;
private
Button
Set
;
private
Button
Set
;
private
Button
Cancel
;
private
Button
Cancel
;
private
Controls
.
HintTextBox
from
;
private
Controls
.
HintTextBox
to
;
private
Button
setDefault
;
public
delegate
void
setWorkingHoursHandler
(
int
from
,
int
to
);
public
delegate
void
setWorkingHoursHandler
(
int
from
,
int
to
);
public
setWorkingHoursHandler
setWorkingHoursFunc
;
public
setWorkingHoursHandler
setWorkingHoursFunc
;
...
@@ -27,12 +28,13 @@ namespace Scheduler.Forms
...
@@ -27,12 +28,13 @@ namespace Scheduler.Forms
this
.
TitleLabel
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
TitleLabel
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
mainFlowPanel
=
new
System
.
Windows
.
Forms
.
FlowLayoutPanel
();
this
.
mainFlowPanel
=
new
System
.
Windows
.
Forms
.
FlowLayoutPanel
();
this
.
FromLabel
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
FromLabel
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
from
=
new
S
ystem
.
Windows
.
Forms
.
TextBox
();
this
.
from
=
new
S
cheduler
.
Controls
.
Hint
TextBox
();
this
.
ToLabel
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
ToLabel
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
to
=
new
S
ystem
.
Windows
.
Forms
.
TextBox
();
this
.
to
=
new
S
cheduler
.
Controls
.
Hint
TextBox
();
this
.
buttonsFlowPanel
=
new
System
.
Windows
.
Forms
.
FlowLayoutPanel
();
this
.
buttonsFlowPanel
=
new
System
.
Windows
.
Forms
.
FlowLayoutPanel
();
this
.
Set
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
Set
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
Cancel
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
Cancel
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
setDefault
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
MainLayout
.
SuspendLayout
();
this
.
MainLayout
.
SuspendLayout
();
this
.
mainFlowPanel
.
SuspendLayout
();
this
.
mainFlowPanel
.
SuspendLayout
();
this
.
buttonsFlowPanel
.
SuspendLayout
();
this
.
buttonsFlowPanel
.
SuspendLayout
();
...
@@ -52,7 +54,7 @@ namespace Scheduler.Forms
...
@@ -52,7 +54,7 @@ namespace Scheduler.Forms
this
.
MainLayout
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
40F
));
this
.
MainLayout
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
40F
));
this
.
MainLayout
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
100F
));
this
.
MainLayout
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
100F
));
this
.
MainLayout
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
45F
));
this
.
MainLayout
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
45F
));
this
.
MainLayout
.
Size
=
new
System
.
Drawing
.
Size
(
3
44
,
194
);
this
.
MainLayout
.
Size
=
new
System
.
Drawing
.
Size
(
3
61
,
194
);
this
.
MainLayout
.
TabIndex
=
0
;
this
.
MainLayout
.
TabIndex
=
0
;
//
//
// TitleLabel
// TitleLabel
...
@@ -60,7 +62,7 @@ namespace Scheduler.Forms
...
@@ -60,7 +62,7 @@ namespace Scheduler.Forms
this
.
TitleLabel
.
Anchor
=
System
.
Windows
.
Forms
.
AnchorStyles
.
None
;
this
.
TitleLabel
.
Anchor
=
System
.
Windows
.
Forms
.
AnchorStyles
.
None
;
this
.
TitleLabel
.
AutoSize
=
true
;
this
.
TitleLabel
.
AutoSize
=
true
;
this
.
TitleLabel
.
Font
=
new
System
.
Drawing
.
Font
(
"Segoe UI"
,
12F
,
System
.
Drawing
.
FontStyle
.
Bold
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
0
)));
this
.
TitleLabel
.
Font
=
new
System
.
Drawing
.
Font
(
"Segoe UI"
,
12F
,
System
.
Drawing
.
FontStyle
.
Bold
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
0
)));
this
.
TitleLabel
.
Location
=
new
System
.
Drawing
.
Point
(
77
,
6
);
this
.
TitleLabel
.
Location
=
new
System
.
Drawing
.
Point
(
85
,
6
);
this
.
TitleLabel
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
TitleLabel
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
TitleLabel
.
Name
=
"TitleLabel"
;
this
.
TitleLabel
.
Name
=
"TitleLabel"
;
this
.
TitleLabel
.
Size
=
new
System
.
Drawing
.
Size
(
190
,
28
);
this
.
TitleLabel
.
Size
=
new
System
.
Drawing
.
Size
(
190
,
28
);
...
@@ -75,10 +77,10 @@ namespace Scheduler.Forms
...
@@ -75,10 +77,10 @@ namespace Scheduler.Forms
this
.
mainFlowPanel
.
Controls
.
Add
(
this
.
from
);
this
.
mainFlowPanel
.
Controls
.
Add
(
this
.
from
);
this
.
mainFlowPanel
.
Controls
.
Add
(
this
.
ToLabel
);
this
.
mainFlowPanel
.
Controls
.
Add
(
this
.
ToLabel
);
this
.
mainFlowPanel
.
Controls
.
Add
(
this
.
to
);
this
.
mainFlowPanel
.
Controls
.
Add
(
this
.
to
);
this
.
mainFlowPanel
.
Location
=
new
System
.
Drawing
.
Point
(
8
1
,
5
0
);
this
.
mainFlowPanel
.
Location
=
new
System
.
Drawing
.
Point
(
9
1
,
5
4
);
this
.
mainFlowPanel
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
mainFlowPanel
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);