我们可以访问可重复使用的DaysOfWeek控件吗?

时间:2009-01-07 05:57:47

标签: c# winforms windows-mobile

只是想知道我们是否可以访问PocketOutlook DaysOfWeek控件/编辑器,或者是否有其他人自己使用它们。

我正在寻找与Outlook日历约会重复出现的模式编辑器完全相同的东西。

  1. 打开日历
  2. 创建新的约会
  3. 点击“发生”,然后点击“<编辑模式......>”
  4. 点击“下一步”
  5. 具有SMTWTFS的控件,您可以点按当天的方块来启用/禁用,或使用硬件键进行导航。
  6. - UPDATE ------------------------

    好吧,我刚刚推出了自己的Control。

    不太难,我只使用了7个LinkLabels w /点击处理程序。实际上最难的部分是围绕它的边界(使用手动定位将白色链接标签放在黑色面板内)。令人遗憾的是,.NET CF设计者认为我们不需要BORDERS。

    我使用Value属性和ValueChanged事件公开了DaysOfWeek值。 Presto,一个DaysOfWeek控制!

2 个答案:

答案 0 :(得分:1)

这些只是复选框控件。

答案 1 :(得分:1)

以下是我的自制控件的一些代码片段:

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;
        }
    }
}

可能有更好的方法进行价值比较,但这正是我提出的非常快。

就其设计师的部分而言,由于它的冗长,我不会把它放在这里,但它相当简单。每天都由LinkLabel表示,点击事件设置为DayOfWeekClick。每个LinkLabel位于(1,1),并且在父级面板的两个维度上都小2像素。每个父面板都有一个黑色ForeColor,给出边框效果。每个Panel都设置为DockStyle.Left,整体控件大小相当于panel.Width * 7,panel.Height。