private void InitializeComponentEx() { InitialiseFeatures(); if (DPIScaling.WantScaling()) { int imageSize = DPIScaling.Scale(16); this.ToolBar.ImageScalingSize = new System.Drawing.Size(imageSize, imageSize); this.ContextMenu.ImageScalingSize = new System.Drawing.Size(imageSize, imageSize); } this.ToolbarDock = DockStyle.Top; this.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; this.InnerText = ""; this.TabIndex = 26; this.BorderSize = 0; this.ContentMargin = 5; this.BrowserPanel.Anchor = AnchorStyles.None; // we handle positioning ourselves this.WebBrowser.Document.AttachEventHandler("onfocusout", OnLostFocus); this.WebBrowser.Document.AttachEventHandler("onfocusin", OnGotFocus); // Place this at the end to ensure the toolbar has finished its resize Toolbars.FixupButtonSizes(this.ToolBar); }
private void CreateDayView() { m_DayView = new TDLDayView(new UIExtension.TaskIcon(m_HwndParent), new UIExtension.TaskRecurrences(m_HwndParent), DPIScaling.Scale(5)); m_DayView.NewAppointment += new Calendar.NewAppointmentEventHandler(OnDayViewNewAppointment); m_DayView.SelectionChanged += new Calendar.AppointmentEventHandler(OnDayViewSelectionChanged); m_DayView.AppointmentMove += new Calendar.AppointmentEventHandler(OnDayViewAppointmentChanged); m_DayView.WeekChange += new Calendar.WeekChangeEventHandler(OnDayViewWeekChanged); m_DayView.MouseWheel += new MouseEventHandler(OnDayViewMouseWheel); m_DayView.MouseDoubleClick += new MouseEventHandler(OnDayViewMouseDoubleClick); // Performing icon editing from a 'MouseUp' or 'MouseClick' event // causes the edit icon dialog to fail to correctly get focus but // counter-intuitively it works from 'MouseDown' m_DayView.MouseDown += new MouseEventHandler(OnDayViewMouseClick); m_DayView.StartDate = DateTime.Now; m_DayView.SetFont(FontName, 8); m_WeekLabel.StartDate = m_DayView.StartDate; if (VisualStyleRenderer.IsSupported) { m_DayView.BorderStyle = BorderStyle.FixedSingle; } else { m_DayView.BorderStyle = BorderStyle.Fixed3D; } Controls.Add(m_DayView); }
private void InitialiseToolbars() { // Main toolbar var tbRenderer = new UIThemeToolbarRenderer(); tbRenderer.SetUITheme(new UITheme()); tbRenderer.EnableDrawRowSeparators(true); this.Toolbar.Renderer = tbRenderer; this.Toolbar.BackColor = BackColor; if (DPIScaling.WantScaling()) { int imageSize = DPIScaling.Scale(16); this.Toolbar.ImageScalingSize = new System.Drawing.Size(imageSize, imageSize); } // Place this at the end to ensure the toolbar has finished its resize Toolbars.FixupButtonSizes(this.Toolbar); UpdateToolbar(); // Page toolbars var theme = new UITheme(); theme.SetAppDrawingColor(UITheme.AppColor.AppBackLight, headerPage.BackColor); theme.SetAppDrawingColor(UITheme.AppColor.ToolbarLight, headerPage.BackColor); theme.SetAppDrawingColor(UITheme.AppColor.ToolbarDark, headerPage.BackColor); this.htmlReportHeaderControl.SetUITheme(theme); this.htmlReportTitleControl.SetUITheme(theme); this.htmlReportTasksControl.SetUITheme(theme); this.htmlReportFooterControl.SetUITheme(theme); }
/// <summary> /// Apply theme / language /// </summary> internal void UpdateUI() { // Apply current theme ------------------------------------------------------ OnDpiChanged(); SetColors(Configs.Theme); // Remove white line under tool strip toolPageNav.Renderer = new UI.Renderers.ToolStripRenderer(Configs.Theme.ToolbarBackgroundColor, Configs.Theme.TextInfoColor); toolPageNav.BackgroundImage = Configs.Theme.ToolbarBackgroundImage.Image; toolPageNav.BackColor = Configs.Theme.ToolbarBackgroundColor; toolPageNav.Alignment = ToolbarAlignment.CENTER; // Overflow button and Overflow dropdown toolPageNav.OverflowButton.DropDown.BackColor = Configs.Theme.ToolbarBackgroundColor; toolPageNav.OverflowButton.AutoSize = false; toolPageNav.OverflowButton.Padding = new Padding(DPIScaling.Transform(10)); lblFormTitle.Text = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainPageNav"]; btnNextPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainNextPage"]; btnPreviousPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainPrevPage"]; btnFirstPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainFirstPage"]; btnLastPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainLastPage"]; btnSnapTo.FlatAppearance.MouseOverBackColor = Theme.LightenColor(Configs.Theme.BackgroundColor, 0.1f); btnSnapTo.FlatAppearance.MouseDownBackColor = Theme.DarkenColor(Configs.Theme.BackgroundColor, 0.1f); }
private void OnPreviewLoaded(object sender, WebBrowserDocumentCompletedEventArgs e) { if (m_FirstPreview) // First time only { SetPreviewZoom(DPIScaling.Scale(40)); m_FirstPreview = false; } }
public TaskMatchesListView(IntPtr hwndParent) { m_SelectionRect = new UIExtension.SelectionRect(); m_TaskIcons = new UIExtension.TaskIcon(hwndParent); m_ilItemHeight = new ImageList(); m_ilItemHeight.ImageSize = new Size(1, DPIScaling.Scale(17)); // minimum height }
public TaskMatchesListView(IntPtr hwndParent) { m_TaskIcons = new UIExtension.TaskIcon(hwndParent); m_ilItemHeight = new ImageList(); m_ilItemHeight.ImageSize = new Size(1, DPIScaling.Scale(17)); // minimum height m_LabelTip = new LabelTip(this); }
void InitialiseCombo(ComboBox combo, Label prevLabel, int width) { combo.Font = m_ControlsFont; combo.Width = DPIScaling.Scale(width); combo.Height = DPIScaling.Scale(200); combo.Location = new Point(prevLabel.Right + 5, 4); combo.DropDownStyle = ComboBoxStyle.DropDownList; combo.Sorted = true; }
private void InitialiseToolbars() { this.MenuBar.Renderer = m_toolbarRenderer; this.RowContextMenu.Renderer = m_toolbarRenderer; this.CellContextMenu.Renderer = m_toolbarRenderer; this.HeaderContextMenu.Renderer = m_toolbarRenderer; this.ColumnContextMenu.Renderer = m_toolbarRenderer; this.ToolBar.Renderer = m_toolbarRenderer; this.FontBar.Renderer = m_toolbarRenderer; this.StatusBar.Renderer = m_toolbarRenderer; Toolbars.FixupButtonSizes(this.ToolBar); Toolbars.FixupButtonSizes(this.FontBar); if (m_ControlsFont != null) { this.MenuBar.Font = m_ControlsFont; this.ToolBar.Font = m_ControlsFont; this.StatusBar.Font = m_ControlsFont; this.FontBar.Font = m_ControlsFont; this.FontBar.Items["fontToolStripComboBox"].Font = m_ControlsFont; this.FontBar.Items["fontSizeToolStripComboBox"].Font = m_ControlsFont; this.RowContextMenu.Font = m_ControlsFont; this.CellContextMenu.Font = m_ControlsFont; this.HeaderContextMenu.Font = m_ControlsFont; this.ColumnContextMenu.Font = m_ControlsFont; } if (DPIScaling.WantScaling()) { int imageSize = DPIScaling.Scale(16); var scalingSize = new Size(imageSize, imageSize); this.MenuBar.ImageScalingSize = scalingSize; this.FontBar.ImageScalingSize = scalingSize; this.ToolBar.ImageScalingSize = scalingSize; this.RowContextMenu.ImageScalingSize = scalingSize; this.CellContextMenu.ImageScalingSize = scalingSize; this.HeaderContextMenu.ImageScalingSize = scalingSize; this.ColumnContextMenu.ImageScalingSize = scalingSize; } this.ToolBar.GripStyle = ToolStripGripStyle.Hidden; this.FontBar.GripStyle = ToolStripGripStyle.Hidden; this.StatusBar.SizingGrip = false; // After all resizing has occurred, set menu bar height to // match application and make its top-level items full height this.MenuBar.AutoSize = false; this.MenuBar.Height = Win32.GetSystemMetric(15); // SM_CYMENU this.MenuBar.Padding = new Padding(0); }
void ShowSplitterBar(bool show = true) { int newSplitterWidth = (show ? DPIScaling.Scale(6) : 1); if (newSplitterWidth != m_SplitterWidth) { m_SplitterWidth = newSplitterWidth; OnSizeChanged(new EventArgs()); } }
private void CreateWeekLabel() { m_WeekLabel = new DayViewWeekLabel(m_Trans); m_WeekLabel.Font = new Font(FontName, 14); m_WeekLabel.Location = new Point(m_Toolbar.Right, DPIScaling.Scale(LabelTop)); m_WeekLabel.Size = new Size(DPIScaling.Scale(350), m_Toolbar.Height); m_WeekLabel.TextAlign = ContentAlignment.TopLeft; Controls.Add(m_WeekLabel); }
private void OnDpiChanged() { // Update size of toolbar DPIScaling.TransformToolbar(ref toolPageNav, Constants.TOOLBAR_HEIGHT); // Update toolbar icon according to the new size LoadToolbarIcons(Configs.Theme); // Update window size this.Width = toolPageNav.PreferredSize.Width; this.Height = toolPageNav.PreferredSize.Height + lblPageInfo.Height + btnClose.Height + 30; }
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) { var textColor = e.Item.Selected ? theme.MenuTextHoverColor : theme.MenuTextColor; if (!e.Item.Enabled) { if (theme.MenuBackgroundColor.GetBrightness() > 0.5) //light background color { textColor = Theme.DarkenColor(theme.MenuBackgroundColor, 0.5f); } else //dark background color { textColor = Theme.LightenColor(theme.MenuBackgroundColor, 0.5f); } } using var pen = new Pen(textColor, DPIScaling.Transform <float>(1)); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.DrawLine(pen, e.Item.Width - (5 * e.Item.Height / 8), 3 * e.Item.Height / 8, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2); e.Graphics.DrawLine(pen, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2, e.Item.Width - (5 * e.Item.Height / 8), 5 * e.Item.Height / 8); // Render ShortcutKeyDisplayString for menu item with dropdown if (e.Item is ToolStripMenuItem) { var mnu = e.Item as ToolStripMenuItem; if (!string.IsNullOrWhiteSpace(mnu.ShortcutKeyDisplayString)) { var shortcutSize = e.Graphics.MeasureString(mnu.ShortcutKeyDisplayString, mnu.Font); var shortcutRect = new RectangleF(e.ArrowRectangle.X - shortcutSize.Width - DPIScaling.Transform <float>(13), e.Item.Height / 2 - shortcutSize.Height / 2, shortcutSize.Width, shortcutSize.Height); e.Graphics.DrawString(mnu.ShortcutKeyDisplayString, e.Item.Font, new SolidBrush(textColor), shortcutRect); } } }
private void UpdateDayViewPreferences() { m_DayView.HideParentTasks = m_PrefsDlg.HideParentTasks; m_DayView.HideTasksWithoutTimes = m_PrefsDlg.HideTasksWithoutTimes; m_DayView.HideTasksSpanningWeekends = m_PrefsDlg.HideTasksSpanningWeekends; m_DayView.HideTasksSpanningDays = m_PrefsDlg.HideTasksSpanningDays; m_DayView.SlotsPerHour = (60 / m_PrefsDlg.SlotMinutes); m_DayView.MinSlotHeight = DPIScaling.Scale(m_PrefsDlg.MinSlotHeight); m_DayView.Invalidate(); }
private void CreateToolbar() { var assembly = Assembly.GetExecutingAssembly(); var images = new Bitmap(assembly.GetManifestResourceStream("DayViewUIExtension.toolbar_std.bmp")); m_TBImageList = new ImageList(); m_TBImageList.ImageSize = new System.Drawing.Size(16, 16); m_TBImageList.TransparentColor = Color.Magenta; m_TBImageList.Images.AddStrip(images); m_Toolbar = new ToolStrip(); m_Toolbar.Anchor = AnchorStyles.None; m_Toolbar.GripStyle = ToolStripGripStyle.Hidden; m_Toolbar.ImageList = m_TBImageList; if (DPIScaling.WantScaling()) { int imageSize = DPIScaling.Scale(16); m_Toolbar.ImageScalingSize = new Size(imageSize, imageSize); m_Toolbar.AutoSize = false; m_Toolbar.Height = (imageSize + 10); } m_TBRenderer = new UIThemeToolbarRenderer(); m_Toolbar.Renderer = m_TBRenderer; var btn1 = new ToolStripButton(); btn1.ImageIndex = 0; btn1.Click += new EventHandler(OnGoToToday); btn1.ToolTipText = m_Trans.Translate("Go to Today"); m_Toolbar.Items.Add(btn1); var btn2 = new ToolStripButton(); btn2.ImageIndex = 1; btn2.Click += new EventHandler(OnPreferences); btn2.ToolTipText = m_Trans.Translate("Preferences"); m_Toolbar.Items.Add(btn2); var btn3 = new ToolStripButton(); btn3.ImageIndex = 2; btn3.Click += new EventHandler(OnHelp); btn3.ToolTipText = m_Trans.Translate("Online Help"); m_Toolbar.Items.Add(btn3); Toolbars.FixupButtonSizes(m_Toolbar); Controls.Add(m_Toolbar); }
public TDLDayView(UIExtension.TaskIcon taskIcons, int minSlotHeight) { minHourLabelWidth = DPIScaling.Scale(minHourLabelWidth); hourLabelIndent = DPIScaling.Scale(hourLabelIndent); dayHeadersHeight = DPIScaling.Scale(dayHeadersHeight); longAppointmentSpacing = DPIScaling.Scale(longAppointmentSpacing); dayGripWidth = 1; // to match app styling m_Renderer = new TDLRenderer(Handle, taskIcons); m_Items = new System.Collections.Generic.Dictionary <UInt32, CalendarItem>(); m_UserMinSlotHeight = minSlotHeight; m_LabelTip = new LabelTip(this); InitializeComponent(); }
private void UpdateDayViewPreferences() { m_DayView.HideParentTasks = m_PrefsDlg.HideParentTasks; m_DayView.DisplayTasksContinuous = m_PrefsDlg.DisplayTasksContinuous; m_DayView.HideTasksWithoutTimes = m_PrefsDlg.HideTasksWithoutTimes; m_DayView.HideTasksSpanningWeekends = m_PrefsDlg.HideTasksSpanningWeekends; m_DayView.HideTasksSpanningDays = m_PrefsDlg.HideTasksSpanningDays; m_DayView.ShowFutureOccurrences = m_PrefsDlg.ShowFutureOccurrences; m_DayView.SlotsPerHour = (60 / m_PrefsDlg.SlotMinutes); m_DayView.MinSlotHeight = DPIScaling.Scale(m_PrefsDlg.MinSlotHeight); UpdateWorkingHourDisplay(); m_DayView.Invalidate(); }
// ------------------------------------------------------------- public WordCloudUIExtensionCore(IntPtr hwndParent, Translator trans) { m_HwndParent = hwndParent; m_Trans = trans; m_Attrib = UIExtension.TaskAttribute.Title; m_ExcludedWords = new CommonWords(); // English by default m_ControlsFont = new Font(FontName, 8, FontStyle.Regular); m_Splitting = false; m_InitialSplitPos = -1; m_SplitterColor = Color.Gray; m_SplitterWidth = DPIScaling.Scale(6); InitializeComponent(); }
public TDLDayView(UIExtension.TaskIcon taskIcons, int minSlotHeight) { hourLabelWidth = DPIScaling.Scale(hourLabelWidth); hourLabelIndent = DPIScaling.Scale(hourLabelIndent); dayHeadersHeight = DPIScaling.Scale(dayHeadersHeight); appointmentGripWidth = DPIScaling.Scale(appointmentGripWidth); headerBorder = DPIScaling.Scale(headerBorder); longAppointmentSpacing = DPIScaling.Scale(longAppointmentSpacing); m_Renderer = new TDLRenderer(Handle, taskIcons); m_Items = new System.Collections.Generic.Dictionary <UInt32, CalendarItem>(); m_UserMinSlotHeight = minSlotHeight; InitializeComponent(); RefreshHScrollSize(); }
private void InitialiseToolbar() { m_TBRenderer = new UIThemeToolbarRenderer(); m_TBRenderer.SetUITheme(new UITheme()); m_TBRenderer.EnableDrawRowDividers(true); this.Toolbar.Renderer = m_TBRenderer; if (DPIScaling.WantScaling()) { int imageSize = DPIScaling.Scale(16); this.Toolbar.ImageScalingSize = new System.Drawing.Size(imageSize, imageSize); } // Place this at the end to ensure the toolbar has finished its resize Toolbars.FixupButtonSizes(this.Toolbar); }
// ------------------------------------------------------------- public WordCloudUIExtensionCore(IntPtr hwndParent, Translator trans) { m_HwndParent = hwndParent; m_Trans = trans; m_Attrib = Task.Attribute.Title; m_ExcludedWords = new CommonWords(); // English by default m_ControlsFont = new Font(FontName, 8, FontStyle.Regular); m_Splitting = false; m_InitialSplitPos = -1; m_SplitterColor = Color.Gray; m_SplitterWidth = DPIScaling.Scale(6); InitializeComponent(); RhinoLicensing.LicenseType licType = RhinoLicensing.GetLicense("3BDEF4EA-7B02-41E1-BE65-3E03025E1FFE"); }
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) { var textColor = e.Item.Selected ? theme.MenuTextHoverColor : theme.MenuTextColor; using var pen = new Pen(textColor, DPIScaling.Transform <float>(2)); e.Graphics.DrawLine(pen, (2 * e.Item.Height / 10) + 1, e.Item.Height / 2, (4 * e.Item.Height / 10) + 1, 7 * e.Item.Height / 10); e.Graphics.DrawLine(pen, 4 * e.Item.Height / 10, 7 * e.Item.Height / 10, 8 * e.Item.Height / 10, 3 * e.Item.Height / 10); }
private void CreateDayView() { m_DayView = new TDLDayView(m_TaskIcons, DPIScaling.Scale(5)); m_DayView.NewAppointment += new Calendar.NewAppointmentEventHandler(OnDayViewNewAppointment); m_DayView.SelectionChanged += new Calendar.AppointmentEventHandler(OnDayViewSelectionChanged); m_DayView.AppointmentMove += new Calendar.AppointmentEventHandler(OnDayViewAppointmentChanged); m_DayView.WeekChange += new Calendar.WeekChangeEventHandler(OnDayViewWeekChanged); m_DayView.MouseWheel += new MouseEventHandler(OnDayViewMouseWheel); // Performing icon editing from a 'MouseUp' or 'MouseClick' event // causes the edit icon dialog to fail to correctly get focus but // counter-intuitively it works from 'MouseDown' m_DayView.MouseDown += new MouseEventHandler(OnDayViewMouseClick); m_DayView.StartDate = DateTime.Now; m_DayView.SetFont(FontName, 8); Controls.Add(m_DayView); }
public void SetFont(String fontName, int fontSize) { m_Renderer.SetFont(fontName, fontSize); // Long appt height to match Calendar in core app int fontHeight = 0; if (DPIScaling.WantScaling()) { fontHeight = m_Renderer.BaseFont.Height; } else { fontHeight = Win32.GetPixelHeight(m_Renderer.BaseFont.ToHfont()); } int itemHeight = (fontHeight + 6 - longAppointmentSpacing); LongAppointmentHeight = Math.Max(itemHeight, 17); }
private void InitializeComponent() { InitialiseFeatures(); this.ToolBar.Renderer = m_toolbarRenderer; this.ToolBar.Font = m_ControlsFont; if (DPIScaling.WantScaling()) { int imageSize = DPIScaling.Scale(16); this.ToolBar.ImageScalingSize = new System.Drawing.Size(imageSize, imageSize); this.ContextMenu.ImageScalingSize = new System.Drawing.Size(imageSize, imageSize); } this.ToolbarDock = DockStyle.Top; this.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; this.InnerText = ""; this.TabIndex = 26; this.BorderStyle = System.Windows.Forms.BorderStyle.None; this.BorderSize = 0; this.NavigateAction = MSDN.Html.Editor.NavigateActionOption.NewWindow; this.ContentMargin = 8; this.BrowserPanel.Anchor = AnchorStyles.None; // we handle positioning ourselves m_Trans.Translate(ToolBar.Items); m_Trans.Translate(ContextMenu.Items); m_TextChangeTimer.Tick += new EventHandler(OnTextChangeTimer); m_TextChangeTimer.Interval = 200; m_TextChangeTimer.Start(); // Dynamic tooltip handling this.WebBrowser.Document.MouseOver += new HtmlElementEventHandler(OnDocumentMouseOver); // Place this at the end to ensure the toolbar has finished its resize Toolbars.FixupButtonSizes(this.ToolBar); }
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) { var textColor = e.Item.Selected ? theme.MenuTextHoverColor : theme.MenuTextColor; using var pen = new Pen(textColor, DPIScaling.Transform <float>(1)); e.Graphics.DrawLine(pen, e.Item.Width - (5 * e.Item.Height / 8), 3 * e.Item.Height / 8, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2); e.Graphics.DrawLine(pen, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2, e.Item.Width - (5 * e.Item.Height / 8), 5 * e.Item.Height / 8); // Render ShortcutKeyDisplayString for menu item with dropdown if (e.Item is ToolStripMenuItem) { var mnu = e.Item as ToolStripMenuItem; if (!string.IsNullOrWhiteSpace(mnu.ShortcutKeyDisplayString)) { var shortcutSize = e.Graphics.MeasureString(mnu.ShortcutKeyDisplayString, mnu.Font); var shortcutRect = new RectangleF(e.ArrowRectangle.X - shortcutSize.Width - DPIScaling.Transform <float>(13), e.Item.Height / 2 - shortcutSize.Height / 2, shortcutSize.Width, shortcutSize.Height); e.Graphics.DrawString(mnu.ShortcutKeyDisplayString, e.Item.Font, new SolidBrush(textColor), shortcutRect); } } }
private void DoHighDPIFixups() { if (DPIScaling.WantScaling()) { // LHS this.Toolbar.Width = this.splitContainer.Panel1.Width; this.tabControl.Width = this.splitContainer.Panel1.Width; this.tabControl.Height = this.splitContainer.Panel1.Height - this.tabControl.Top; // RHS this.panel1.Width = this.splitContainer.Panel2.Width - DPIScaling.Scale(3); this.panel1.Height = this.splitContainer.Panel2.Height - this.panel1.Top; this.browserPreview.Width = this.panel1.Width; this.browserPreview.Height = this.panel1.Height - this.browserPreview.Top; this.previewDefaultBrowser.Location = new Point(this.panel1.Width - this.previewDefaultBrowser.Size.Width, 0); this.labelPreview.Width = this.previewDefaultBrowser.Left; this.splitContainer.Panel1.AutoSize = true; this.splitContainer.Panel2.AutoSize = true; this.splitContainer.SplitterDistance = DPIScaling.Scale(this.splitContainer.SplitterDistance); } }
private void CreateMonthYearCombos() { m_MonthCombo = new DayViewMonthComboBox(); m_MonthCombo.Font = m_ControlsFont; m_MonthCombo.Location = new Point(DPIScaling.Scale(0), ComboTop); m_MonthCombo.Size = DPIScaling.Scale(new Size(100, 16)); m_MonthCombo.SelectedMonth = DateTime.Now.Month; m_MonthCombo.SelectedIndexChanged += new EventHandler(OnMonthYearSelChanged); Controls.Add(m_MonthCombo); m_YearCombo = new DayViewYearComboBox(); m_YearCombo.Font = m_ControlsFont; m_YearCombo.Location = new Point(DPIScaling.Scale(105), ComboTop); m_YearCombo.Size = DPIScaling.Scale(new Size(100, 16)); m_YearCombo.SelectedYear = DateTime.Now.Year; m_YearCombo.SelectedIndexChanged += new EventHandler(OnMonthYearSelChanged); Controls.Add(m_YearCombo); }
// Internal ------------------------------------------------------------ override protected int ScaleByDPIFactor(int value) { return(DPIScaling.Scale(value)); }
public override void DrawAppointment(Graphics g, Rectangle rect, Calendar.Appointment appointment, bool isLong, bool isSelected, Rectangle gripRect) { if (appointment == null) { throw new ArgumentNullException("appointment"); } if (g == null) { throw new ArgumentNullException("g"); } if (rect.Width != 0 && rect.Height != 0) { CalendarItem taskItem = (appointment as CalendarItem); UInt32 taskId = taskItem.Id; UInt32 realTaskId = GetRealTaskId(taskItem); bool isFutureItem = (taskId != realTaskId); // Recalculate colours Color textColor = taskItem.TaskTextColor; Color fillColor = DrawingColor.SetLuminance(textColor, 0.95f); if (isFutureItem) { fillColor = SystemColors.Window; float textLum = DrawingColor.GetLuminance(textColor); textColor = DrawingColor.SetLuminance(textColor, Math.Min(textLum + 0.2f, 0.7f)); } Color borderColor = textColor; Color barColor = textColor; if (taskItem.HasTaskTextColor) { if (isSelected) { textColor = DrawingColor.SetLuminance(textColor, 0.3f); } else if (TaskColorIsBackground && !taskItem.IsDoneOrGoodAsDone && !isFutureItem) { barColor = textColor; fillColor = textColor; borderColor = DrawingColor.AdjustLighting(textColor, -0.5f, true); textColor = DrawingColor.GetBestTextColor(textColor); } } // Draw the background of the appointment g.SmoothingMode = SmoothingMode.None; if (isSelected) { if (isLong) { rect.Height++; } if (isFutureItem) { UIExtension.SelectionRect.Draw(m_hWnd, g, rect.Left, rect.Top, rect.Width, rect.Height, UIExtension.SelectionRect.Style.DropHighlighted, false); // opaque } else { UIExtension.SelectionRect.Draw(m_hWnd, g, rect.Left, rect.Top, rect.Width, rect.Height, false); // opaque } } else { using (SolidBrush brush = new SolidBrush(fillColor)) g.FillRectangle(brush, rect); if (taskItem.DrawBorder) { if (!isLong) { rect.Height--; // drawing with pen adds 1 to height rect.Width--; } using (Pen pen = new Pen(borderColor, 1)) { if (isFutureItem) { pen.DashStyle = DashStyle.Dash; } g.DrawRectangle(pen, rect); } } } // Draw appointment icon bool hasIcon = false; taskItem.IconRect = Rectangle.Empty; if (TaskHasIcon(taskItem)) { Rectangle rectIcon; int imageSize = DPIScaling.Scale(16); if (isLong) { int yCentre = ((rect.Top + rect.Bottom + 1) / 2); rectIcon = new Rectangle((rect.Left + TextPadding), (yCentre - (imageSize / 2)), imageSize, imageSize); } else { rectIcon = new Rectangle(rect.Left + TextPadding, rect.Top + TextPadding, imageSize, imageSize); } if (g.IsVisible(rectIcon) && m_TaskIcons.Get(realTaskId)) { if (isLong) { rectIcon.X = (gripRect.Right + TextPadding); } else { gripRect.Y += (imageSize + TextPadding); gripRect.Height -= (imageSize + TextPadding); } var clipRgn = g.Clip; if (rect.Bottom < (rectIcon.Y + imageSize)) { g.Clip = new Region(RectangleF.Intersect(rect, g.ClipBounds)); } m_TaskIcons.Draw(g, rectIcon.X, rectIcon.Y); g.Clip = clipRgn; hasIcon = true; taskItem.IconRect = rectIcon; rect.Width -= (rectIcon.Right - rect.Left); rect.X = rectIcon.Right; } } // Draw gripper bar if (gripRect.Width > 0) { using (SolidBrush brush = new SolidBrush(barColor)) g.FillRectangle(brush, gripRect); if (!isLong) { gripRect.Height--; // drawing with pen adds 1 to height } // Draw gripper border using (Pen pen = new Pen(DrawingColor.AdjustLighting(barColor, -0.5f, true), 1)) g.DrawRectangle(pen, gripRect); if (!hasIcon) { rect.X = gripRect.Right; rect.Width -= (gripRect.Width + (TextPadding * 2)); } } // draw appointment text using (StringFormat format = new StringFormat()) { format.Alignment = StringAlignment.Near; format.LineAlignment = (isLong ? StringAlignment.Center : StringAlignment.Near); rect.Y += 3; if (isLong) { rect.Height = m_BaseFont.Height; } else { rect.Height -= 3; } taskItem.TextRect = rect; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; using (SolidBrush brush = new SolidBrush(textColor)) { if (taskItem.IsDone && StrikeThruDoneTasks) { using (Font font = new Font(this.BaseFont, FontStyle.Strikeout)) { g.DrawString(appointment.Title, font, brush, rect, format); } } else { g.DrawString(appointment.Title, this.BaseFont, brush, rect, format); } } g.TextRenderingHint = TextRenderingHint.SystemDefault; } } }