views:

93

answers:

2

Just wondering if we have access to the PocketOutlook DaysOfWeek control/editor, or if anybody else has made their own for free usage.

I'm looking for something exactly like what's in the Outlook Calendar appointment reoccurring pattern editor.

  1. Open Calendar
  2. Create a new Appointment
  3. Click on "Occurs", then "< Edit Pattern... >"
  4. Click "Next"
  5. The control that has SMTWTFS, where you can tap on the square for the day to enable/disable, or use the hardware keys to navigate.

--UPDATE------------------------

Ah well, I just rolled my own Control.

Not too difficult, I just used 7 LinkLabels w/ click handlers. Actually the hardest part was getting a border around it (using manual positioning to place the white linklabel just inside a black panel). It's ridiculous that somehow the .NET CF designers thought that we wouldn't need BORDERS.

I exposed the DaysOfWeek value with a Value property, and a ValueChanged event. Presto, a DaysOfWeek control!

+1  A: 

Those are just checkbox controls.

Tom Anderson
+1  A: 

Here's some code snippets for my homebrewed control:

public partial class DaysOfWeekPicker : UserControl
{
 public event EventHandler ValueChanged;

 private DaysOfWeek myValue;

 [DefaultValue (0)]
 public DaysOfWeek Value
 {
  get { return myValue; }
  set { myValue = value; RefreshData (); }
 }

 public DaysOfWeekPicker ()
 {
  InitializeComponent ();
 }

 private void DayOfWeekClick (object sender, EventArgs e)
 {
  if (Object.ReferenceEquals (sender, g_l_Sunday))
  {
   this.Value = this.Value ^ DaysOfWeek.Sunday;
  }
  else if (Object.ReferenceEquals (sender, g_l_Monday))
  {
   this.Value = this.Value ^ DaysOfWeek.Monday;
  }
  else if (Object.ReferenceEquals (sender, g_l_Tuesday))
  {
   this.Value = this.Value ^ DaysOfWeek.Tuesday;
  }
  else if (Object.ReferenceEquals (sender, g_l_Wednesday))
  {
   this.Value = this.Value ^ DaysOfWeek.Wednesday;
  }
  else if (Object.ReferenceEquals (sender, g_l_Thursday))
  {
   this.Value = this.Value ^ DaysOfWeek.Thursday;
  }
  else if (Object.ReferenceEquals (sender, g_l_Friday))
  {
   this.Value = this.Value ^ DaysOfWeek.Friday;
  }
  else if (Object.ReferenceEquals (sender, g_l_Saturday))
  {
   this.Value = this.Value ^ DaysOfWeek.Saturday;
  }
 }

 private void RefreshData ()
 {
  SetLabelDisplay (g_l_Sunday, (this.Value & DaysOfWeek.Sunday) == DaysOfWeek.Sunday);
  SetLabelDisplay (g_l_Monday, (this.Value & DaysOfWeek.Monday) == DaysOfWeek.Monday);
  SetLabelDisplay (g_l_Tuesday, (this.Value & DaysOfWeek.Tuesday) == DaysOfWeek.Tuesday);
  SetLabelDisplay (g_l_Wednesday, (this.Value & DaysOfWeek.Wednesday) == DaysOfWeek.Wednesday);
  SetLabelDisplay (g_l_Thursday, (this.Value & DaysOfWeek.Thursday) == DaysOfWeek.Thursday);
  SetLabelDisplay (g_l_Friday, (this.Value & DaysOfWeek.Friday) == DaysOfWeek.Friday);
  SetLabelDisplay (g_l_Saturday, (this.Value & DaysOfWeek.Saturday) == DaysOfWeek.Saturday);

  if (this.ValueChanged != null) this.ValueChanged (this, EventArgs.Empty);
 }

 private void SetLabelDisplay (LinkLabel label, bool enabled)
 {
  if (enabled)
  {
   label.BackColor = Color.Black;
   label.ForeColor = Color.White;
  }
  else
  {
   label.BackColor = Color.White;
   label.ForeColor = Color.Black;
  }
 }
}

There may be a better way to do the value comparisons, but this is just what I came up with very quickly.

As far as the designer part of it goes, I won't put it in here because of its verbosity, but it's rather simple. Each day is represented by a LinkLabel with the click event set to DayOfWeekClick. Each LinkLabel is at (1,1) and is 2 pixels smaller in both dimensions from is parent Panel. Each parent Panel has a black ForeColor, giving a border effect. Each Panel is set to DockStyle.Left, and the overall control size is equivalent to panel.Width * 7, panel.Height.

ZaijiaN