142 lines
5.2 KiB
C#
142 lines
5.2 KiB
C#
///
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using Config.Entities;
|
|
using Config.CalendarEvent;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.UI.Calendar
|
|
{
|
|
internal partial class EventDetailsForm : Form
|
|
{
|
|
private ICalendarEvent evnt;
|
|
private ICalendarEvent newEvnt;
|
|
|
|
public ICalendarEvent Event
|
|
{
|
|
get { return evnt; }
|
|
set
|
|
{
|
|
evnt = value;
|
|
FillValues();
|
|
}
|
|
}
|
|
|
|
public ICalendarEvent NewEvent
|
|
{
|
|
get { return newEvnt; }
|
|
}
|
|
|
|
|
|
public EventDetailsForm()
|
|
{
|
|
InitializeComponent();
|
|
Text = Strings.Event_details;
|
|
for (Frequency f = Frequency.Once; f < Frequency.Count; f++)
|
|
{
|
|
cbRecurringFrequency.Items.Add(Config.CalendarEvent.Utils.Freq2String(f));
|
|
}
|
|
|
|
for (AutoAction a = AutoAction.None; a < AutoAction.Count; a++)
|
|
{
|
|
autoActionComboBox.Items.Add(Config.CalendarEvent.Utils.Action2String(a));
|
|
}
|
|
|
|
string[] times = { Strings.All_day,
|
|
"00:00", "00:30", "01:00", "01:30", "02:00", "02:30", "03:00", "03:30", "04:00", "04:30", "05:00", "05:30",
|
|
"06:00", "06:30", "07:00", "07:30", "08:00", "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30",
|
|
"12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "17:30",
|
|
"18:00", "18:30", "19:00", "19:30", "20:00", "20:30", "21:00", "21:30", "22:00", "22:30", "23:00", "23:30" };
|
|
|
|
foreach (var s in times) timeComboBox.Items.Add(s);
|
|
}
|
|
|
|
private void EventDetailsLoad(object sender, EventArgs e)
|
|
{
|
|
if (evnt == null)
|
|
{
|
|
DateTime now = DateTime.Now;
|
|
Event = newEvnt = new Config.Entities.CustomEvent(new DateTime(now.Year, now.Month, now.Day, now.Hour, 30 * (now.Minute / 30), 0), Strings.New_event);
|
|
}
|
|
else
|
|
{
|
|
newEvnt = (CustomEvent)evnt.Clone();
|
|
}
|
|
}
|
|
|
|
private void FillValues()
|
|
{
|
|
txtEventTitle.Text = evnt.Title;
|
|
txtEventSource.Text = evnt.Source;
|
|
dateTimePicker.Value = evnt.Date;
|
|
timeComboBox.Text = evnt.AllDay ? Strings.All_day : evnt.Date.ToString("HH:mm");
|
|
cbRecurringFrequency.SelectedItem = Config.CalendarEvent.Utils.Freq2String(evnt.Frequency);
|
|
chkTriggerOnExactDayOnly.Checked = evnt.TriggerOnExactDayOnly;
|
|
chkHidden.Checked = evnt.Hidden;
|
|
autoActionComboBox.SelectedItem = Config.CalendarEvent.Utils.Action2String(evnt.AutoAction);
|
|
parametersTextBox.Text = evnt.Parameters;
|
|
pnlEventColor.BackColor = System.Drawing.Color.FromArgb(evnt.BackColor);
|
|
pnlTextColor.BackColor = System.Drawing.Color.FromArgb(evnt.TextColor);
|
|
chkEnableTooltip.Checked = evnt.TooltipEnabled;
|
|
}
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
|
{
|
|
newEvnt.Title = txtEventTitle.Text;
|
|
newEvnt.Source = txtEventSource.Text;
|
|
newEvnt.Date = dateTimePicker.Value;
|
|
|
|
DateTime timeOnly;
|
|
if (timeComboBox.Text == Strings.All_day)
|
|
{
|
|
newEvnt.AllDay = true;
|
|
}
|
|
else if (DateTime.TryParse(timeComboBox.Text, out timeOnly))
|
|
{
|
|
newEvnt.AllDay = false;
|
|
newEvnt.Date = new DateTime(newEvnt.Date.Year, newEvnt.Date.Month, newEvnt.Date.Day, timeOnly.Hour, timeOnly.Minute, 0);
|
|
}
|
|
|
|
newEvnt.Hidden = chkHidden.Checked;
|
|
newEvnt.Frequency = Config.CalendarEvent.Utils.String2Freq(cbRecurringFrequency.SelectedItem.ToString());
|
|
newEvnt.TriggerOnExactDayOnly = chkTriggerOnExactDayOnly.Checked;
|
|
newEvnt.TooltipEnabled = chkEnableTooltip.Checked;
|
|
newEvnt.AutoAction = Config.CalendarEvent.Utils.String2Action(autoActionComboBox.SelectedItem.ToString());
|
|
newEvnt.Parameters = parametersTextBox.Text;
|
|
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
|
|
private void cancelButton_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
}
|
|
|
|
private void PnlEventColorDoubleClick(object sender, EventArgs e)
|
|
{
|
|
colorDialog1.Color = System.Drawing.Color.FromArgb(newEvnt.BackColor);
|
|
|
|
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
|
{
|
|
pnlEventColor.BackColor = colorDialog1.Color;
|
|
newEvnt.BackColor = colorDialog1.Color.ToArgb();
|
|
}
|
|
}
|
|
|
|
private void PnlTextColorDoubleClick(object sender, EventArgs e)
|
|
{
|
|
colorDialog1.Color = System.Drawing.Color.FromArgb(newEvnt.BackColor);
|
|
|
|
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
|
{
|
|
pnlTextColor.BackColor = colorDialog1.Color;
|
|
newEvnt.TextColor = colorDialog1.Color.ToArgb();
|
|
}
|
|
}
|
|
}
|
|
}
|