Skip to content

Commit 803a85d

Browse files
committed
Single cell version
1 parent 00d1e26 commit 803a85d

File tree

47 files changed

+6201
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6201
-48
lines changed

BionicCode.Net/BionicCode.Controls.Net.Framework.Wpf/BionicCalendar/Calendar.cs

Lines changed: 1251 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#region Info
2+
3+
// 2020/11/04 13:25
4+
// Activitytracker
5+
6+
#endregion
7+
8+
#region Usings
9+
10+
#endregion
11+
12+
#region Usings
13+
14+
using System;
15+
using System.Collections.ObjectModel;
16+
17+
#endregion
18+
19+
namespace BionicCode.Controls.Net.Framework.Wpf.BionicCalendar
20+
{
21+
public class CalendarDate : BionicCode.Utilities.Net.Standard.ViewModel.ViewModel, ICalendarDate
22+
{
23+
#region
24+
25+
public DateTime Day { get => this.day; set => TrySetValue(value, ref this.day); }
26+
27+
public string Annotation { get => this.annotation; set => TrySetValue(value, ref this.annotation); }
28+
29+
public bool IsHoliday { get => this.isHoliday; set => TrySetValue(value, ref this.isHoliday); }
30+
public DayOfWeek DayOfWeek { get => this.dayOfWeek; set => TrySetValue(value, ref this.dayOfWeek); }
31+
public int WeekOfYear { get => this.weekOfYear; set => TrySetValue(value, ref this.weekOfYear); }
32+
33+
private bool isToday;
34+
public bool IsToday
35+
{
36+
get => this.isToday;
37+
set => TrySetValue(value, ref this.isToday);
38+
}
39+
40+
#endregion
41+
42+
43+
private string annotation;
44+
private DateTime day;
45+
46+
private DayOfWeek dayOfWeek;
47+
private bool isHoliday;
48+
private int weekOfYear;
49+
}
50+
}
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
#region Info
2+
3+
// 2020/11/07 17:41
4+
// Activitytracker
5+
6+
#endregion
7+
8+
#region Usings
9+
10+
using System;
11+
using System.Windows;
12+
using System.Windows.Controls;
13+
using System.Windows.Controls.Primitives;
14+
using System.Windows.Input;
15+
16+
#endregion
17+
18+
namespace BionicCode.Controls.Net.Framework.Wpf.BionicCalendar
19+
{
20+
public class CalendarDateColumnHeaderItem : Control, ICommandSource
21+
{
22+
public static readonly RoutedEvent SelectedRoutedEvent = EventManager.RegisterRoutedEvent(
23+
"Selected",
24+
RoutingStrategy.Bubble,
25+
typeof(RoutedEventHandler),
26+
typeof(CalendarDateColumnHeaderItem));
27+
28+
public static readonly RoutedEvent PreviewSelectedRoutedEvent = EventManager.RegisterRoutedEvent(
29+
"PreviewSelected",
30+
RoutingStrategy.Tunnel,
31+
typeof(RoutedEventHandler),
32+
typeof(CalendarDateColumnHeaderItem));
33+
34+
public static readonly RoutedEvent UnselectedRoutedEvent = EventManager.RegisterRoutedEvent(
35+
"Unselected",
36+
RoutingStrategy.Bubble,
37+
typeof(RoutedEventHandler),
38+
typeof(CalendarDateColumnHeaderItem));
39+
40+
public static readonly RoutedEvent PreviewUnselectedRoutedEvent = EventManager.RegisterRoutedEvent(
41+
"PreviewUnselected",
42+
RoutingStrategy.Tunnel,
43+
typeof(RoutedEventHandler),
44+
typeof(CalendarDateColumnHeaderItem));
45+
46+
public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
47+
"IsSelected",
48+
typeof(bool),
49+
typeof(CalendarDateColumnHeaderItem),
50+
new PropertyMetadata(default(bool)));
51+
52+
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
53+
"Command",
54+
typeof(ICommand),
55+
typeof(CalendarDateColumnHeaderItem),
56+
new PropertyMetadata(default(ICommand), CalendarDateColumnHeaderItem.OnCommandChanged));
57+
58+
public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register(
59+
"CommandParameter",
60+
typeof(object),
61+
typeof(CalendarDateColumnHeaderItem),
62+
new PropertyMetadata(default(object)));
63+
64+
public static readonly DependencyProperty CommandTargetProperty = DependencyProperty.Register(
65+
"CommandTarget",
66+
typeof(IInputElement),
67+
typeof(CalendarDateColumnHeaderItem),
68+
new PropertyMetadata(default(IInputElement)));
69+
70+
#region Dependency properties
71+
72+
private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
73+
{
74+
var this_ = d as CalendarDateColumnHeaderItem;
75+
if (e.OldValue is ICommand oldCommand)
76+
{
77+
oldCommand.CanExecuteChanged -= this_.OnCanExecuteChanged;
78+
}
79+
80+
if (e.NewValue is ICommand newCommand)
81+
{
82+
newCommand.CanExecuteChanged += this_.OnCanExecuteChanged;
83+
}
84+
}
85+
86+
#endregion
87+
88+
#region
89+
90+
static CalendarDateColumnHeaderItem()
91+
{
92+
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(
93+
typeof(CalendarDateColumnHeaderItem),
94+
new FrameworkPropertyMetadata(typeof(CalendarDateColumnHeaderItem)));
95+
Selector.IsSelectedProperty.OverrideMetadata(
96+
typeof(CalendarDateColumnHeaderItem),
97+
new FrameworkPropertyMetadata(default(bool), CalendarDateColumnHeaderItem.OnIsSelectedChanged));
98+
}
99+
100+
#endregion
101+
102+
#region
103+
104+
/// <inheritdoc />
105+
public ICommand Command
106+
{
107+
get => (ICommand) GetValue(CalendarDateColumnHeaderItem.CommandProperty);
108+
set => SetValue(CalendarDateColumnHeaderItem.CommandProperty, value);
109+
}
110+
111+
/// <inheritdoc />
112+
public object CommandParameter
113+
{
114+
get => GetValue(CalendarDateColumnHeaderItem.CommandParameterProperty);
115+
set => SetValue(CalendarDateColumnHeaderItem.CommandParameterProperty, value);
116+
}
117+
118+
/// <inheritdoc />
119+
public IInputElement CommandTarget
120+
{
121+
get => (IInputElement) GetValue(CalendarDateColumnHeaderItem.CommandTargetProperty);
122+
set => SetValue(CalendarDateColumnHeaderItem.CommandTargetProperty, value);
123+
}
124+
125+
#endregion
126+
127+
private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
128+
{
129+
var this_ = d as CalendarDateColumnHeaderItem;
130+
this_.OnIsSelectedChanged((bool) e.OldValue, (bool) e.NewValue);
131+
}
132+
133+
/// <inheritdoc />
134+
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
135+
{
136+
base.OnPreviewMouseLeftButtonDown(e);
137+
HandleSelection();
138+
ExecuteClickCommand();
139+
}
140+
141+
private void HandleSelection()
142+
{
143+
Selector.SetIsSelected(this, true);
144+
}
145+
146+
private void ExecuteClickCommand()
147+
{
148+
if (this.Command?.CanExecute(this.CommandParameter) ?? false)
149+
{
150+
this.Command.Execute(this.CommandParameter);
151+
}
152+
}
153+
154+
protected virtual void OnCanExecuteChanged(object sender, EventArgs e)
155+
{
156+
}
157+
158+
protected virtual void OnIsSelectedChanged(bool oldValue, bool newValue)
159+
{
160+
this.IsSelected = newValue;
161+
162+
if (newValue)
163+
{
164+
RaiseEvent(new RoutedEventArgs(CalendarDateColumnHeaderItem.PreviewSelectedRoutedEvent, this));
165+
RaiseEvent(new RoutedEventArgs(CalendarDateColumnHeaderItem.SelectedRoutedEvent, this));
166+
RaiseEvent(new RoutedEventArgs(Selector.SelectedEvent, this));
167+
}
168+
else
169+
{
170+
RaiseEvent(new RoutedEventArgs(CalendarDateColumnHeaderItem.PreviewUnselectedRoutedEvent, this));
171+
RaiseEvent(new RoutedEventArgs(CalendarDateColumnHeaderItem.UnselectedRoutedEvent, this));
172+
RaiseEvent(new RoutedEventArgs(Selector.UnselectedEvent, this));
173+
}
174+
}
175+
176+
public event RoutedEventHandler Selected
177+
{
178+
add => AddHandler(CalendarDateColumnHeaderItem.SelectedRoutedEvent, value);
179+
remove => RemoveHandler(CalendarDateColumnHeaderItem.SelectedRoutedEvent, value);
180+
}
181+
182+
public event RoutedEventHandler PreviewSelected
183+
{
184+
add => AddHandler(CalendarDateColumnHeaderItem.PreviewSelectedRoutedEvent, value);
185+
remove => RemoveHandler(CalendarDateColumnHeaderItem.PreviewSelectedRoutedEvent, value);
186+
}
187+
188+
public event RoutedEventHandler Unselected
189+
{
190+
add => AddHandler(CalendarDateColumnHeaderItem.UnselectedRoutedEvent, value);
191+
remove => RemoveHandler(CalendarDateColumnHeaderItem.UnselectedRoutedEvent, value);
192+
}
193+
194+
public event RoutedEventHandler PreviewUnselected
195+
{
196+
add => AddHandler(CalendarDateColumnHeaderItem.PreviewUnselectedRoutedEvent, value);
197+
remove => RemoveHandler(CalendarDateColumnHeaderItem.PreviewUnselectedRoutedEvent, value);
198+
}
199+
200+
public bool IsSelected
201+
{
202+
get => (bool) GetValue(CalendarDateColumnHeaderItem.IsSelectedProperty);
203+
set => SetValue(CalendarDateColumnHeaderItem.IsSelectedProperty, value);
204+
}
205+
}
206+
}

0 commit comments

Comments
 (0)