寻求有关简单 C# 日历应用程序设计的帮助
作为一个个人项目,我正在整理一个 C# WPF 日历。
我一直在对日历屏幕进行编码,特别是 5x7 的日期网格。
我首先尝试使用面板、标签和按钮等元素对其进行编码。我觉得这样太麻烦了。
然后我决定使用 GDI 自己绘制日历。我现在有了一个很棒的布局 - 但我不确定如何处理日历的交互式区域。 (比如说,上个月/下个月,单击任何特定的一天...)
渲染日历屏幕后,我是否应该为所有这些任务创建按钮对象,并为它们分配 onClick 处理程序?
或者有其他解决方案吗?
提前致谢。
-弗拉迪斯拉夫
As a personal project, I'm putting together a C# WPF calendar.
I'm stuck on coding the calendar screen - specifically, the 5x7 grid of days.
I've first tried to code it using elements like Panels, Labels, and Buttons. I've decided that was too cumbersome.
I've then decided to use GDI to draw the calendar myself. I now have a wonderful layout - but I'm not sure how to handle interactive regions of the calendar. (Say, Previous/Next month, clicking on any particular day...)
After rendering the calendar screen, should I be creating button objects for all those tasks, and assigning onClick handlers to them?
Or is there an alternative solution?
Thanks in advance.
-Vladislav
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该将控件放置在手绘面板上;这会带来麻烦。
相反,您应该将按钮的边界存储为 Rectangle,并在鼠标事件中自行跟踪它们。
然而,最好在 WPF 中使用网格和一些按钮来实现所有内容。
You should not place controls on your hand-drawn panel; that's a recipe for trouble.
Instead, you should store the bounds of the buttons as
Rectangle
s, and track them yourself in mouse events.However, it would be better to implement everything in WPF, using a Grid and some Buttons.