// -------------------------------------------------------------

        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();
        }
Exemple #2
0
        public TDLDayView(UIExtension.TaskIcon taskIcons, int minSlotHeight)
        {
            hourLabelWidth         = DPIScaling.Scale(hourLabelWidth);
            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();
            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);
        }
Exemple #4
0
        // -------------------------------------------------------------

        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");
        }
        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);
        }
        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);
        }
        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);
            }
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        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;
                }
            }
        }
        // Internal ------------------------------------------------------------

        override protected int ScaleByDPIFactor(int value)
        {
            return(DPIScaling.Scale(value));
        }
Exemple #11
0
        private void CreateToolbar()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var images   = new Bitmap(assembly.GetManifestResourceStream("DayViewUIExtension.toolbar_std.bmp"));

            m_TBImageList                  = new ImageList();
            m_TBImageList.ColorDepth       = ColorDepth.Depth32Bit;
            m_TBImageList.ImageSize        = new System.Drawing.Size(16, 16);
            m_TBImageList.TransparentColor = Color.Magenta;
            m_TBImageList.Images.AddStrip(images);

            m_Toolbar           = new IIControls.ToolStripEx();
            m_Toolbar.Anchor    = AnchorStyles.None;
            m_Toolbar.GripStyle = ToolStripGripStyle.Hidden;
            m_Toolbar.ImageList = m_TBImageList;

            int imageSize = DPIScaling.Scale(16);

            m_Toolbar.ImageScalingSize = new Size(imageSize, imageSize);
            m_Toolbar.Height           = (imageSize + 7); // MFC

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

            m_Toolbar.Items.Add(new ToolStripSeparator());

            var btn2 = new ToolStripButton();

            btn2.Name        = "Show1DayView";
            btn2.ImageIndex  = 1;
            btn2.Click      += new EventHandler(OnShow1DayView);
            btn2.ToolTipText = m_Trans.Translate("1 Day View");
            m_Toolbar.Items.Add(btn2);

            var btn3 = new ToolStripButton();

            btn3.Name        = "Show3DayView";
            btn3.ImageIndex  = 2;
            btn3.Click      += new EventHandler(OnShow3DayView);
            btn3.ToolTipText = m_Trans.Translate("3 Day View");
            m_Toolbar.Items.Add(btn3);

            var btn4 = new ToolStripButton();

            btn4.Name        = "Show7DayView";
            btn4.ImageIndex  = 3;
            btn4.Click      += new EventHandler(OnShow7DayView);
            btn4.ToolTipText = m_Trans.Translate("7 Day View");
            m_Toolbar.Items.Add(btn4);

            var btn5 = new ToolStripButton();

            btn5.Name        = "Show14DayView";
            btn5.ImageIndex  = 4;
            btn5.Click      += new EventHandler(OnShow14DayView);
            btn5.ToolTipText = m_Trans.Translate("14 Day View");
            m_Toolbar.Items.Add(btn5);

            var btn6 = new ToolStripButton();

            btn6.Name        = "Show28DayView";
            btn6.ImageIndex  = 5;
            btn6.Click      += new EventHandler(OnShow28DayView);
            btn6.ToolTipText = m_Trans.Translate("28 Day View");
            m_Toolbar.Items.Add(btn6);

            m_Toolbar.Items.Add(new ToolStripSeparator());

            var btn9 = new ToolStripButton();

            btn9.ImageIndex  = 6;
            btn9.Click      += new EventHandler(OnPreferences);
            btn9.ToolTipText = m_Trans.Translate("Preferences");
            m_Toolbar.Items.Add(btn9);

            var btn10 = new ToolStripButton();

            btn10.ImageIndex  = 7;
            btn10.Click      += new EventHandler(OnHelp);
            btn10.ToolTipText = m_Trans.Translate("Online Help");
            m_Toolbar.Items.Add(btn10);

            Toolbars.FixupButtonSizes(m_Toolbar);

            Controls.Add(m_Toolbar);
        }
        public override void DrawAppointment(System.Drawing.Graphics g, System.Drawing.Rectangle rect, Calendar.Appointment appointment, bool isSelected, System.Drawing.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);
                bool         longAppt = taskItem.IsLongAppt();

                if (!longAppt && (taskItem.StartDate.TimeOfDay.TotalHours == 0.0))
                {
                    rect.Y++;
                    rect.Height--;
                }

                rect.Width--;

                // Recalculate colours
                Color textColor   = taskItem.TaskTextColor;
                Color borderColor = taskItem.TaskTextColor;
                Color fillColor   = DrawingColor.SetLuminance(taskItem.TaskTextColor, 0.95f);
                Color barColor    = taskItem.TaskTextColor;

                if (taskItem.HasTaskTextColor)
                {
                    if (isSelected)
                    {
                        textColor = DrawingColor.SetLuminance(taskItem.TaskTextColor, 0.3f);
                    }
                    else if (m_TaskColorIsBkgnd && !taskItem.IsDone)
                    {
                        textColor   = DrawingColor.GetBestTextColor(taskItem.TaskTextColor);
                        borderColor = DrawingColor.AdjustLighting(taskItem.TaskTextColor, -0.5f, true);
                        barColor    = taskItem.TaskTextColor;
                        fillColor   = taskItem.TaskTextColor;
                    }
                }

                using (StringFormat format = new StringFormat())
                {
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = (longAppt ? StringAlignment.Center : StringAlignment.Near);

                    // Draw the background of the appointment
                    if (isSelected)
                    {
                        m_SelectionRect.Draw(m_hWnd, g, rect.Left, rect.Top, rect.Width, rect.Height);
                    }
                    else
                    {
                        using (SolidBrush brush = new SolidBrush(fillColor))
                            g.FillRectangle(brush, rect);
                    }

                    //  Draw appointment border if needed
                    if (!isSelected && taskItem.DrawBorder)
                    {
                        using (Pen pen = new Pen(borderColor, 1))
                            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 (taskItem.IsLongAppt())
                        {
                            int yCentre = ((rect.Top + rect.Bottom + 1) / 2);
                            rectIcon = new Rectangle((rect.Left + 2), (yCentre - (imageSize / 2)), imageSize, imageSize);
                        }
                        else
                        {
                            rectIcon = new Rectangle(rect.Left + 2, rect.Top + 2, imageSize, imageSize);
                        }

                        if (Rectangle.Round(g.VisibleClipBounds).Contains(rectIcon) && m_TaskIcons.Get(taskItem.Id))
                        {
                            if (longAppt)
                            {
                                rectIcon.X = (gripRect.Right + 2);
                            }
                            else
                            {
                                gripRect.Y      += (imageSize + 2);
                                gripRect.Height -= (imageSize + 2);
                            }

                            m_TaskIcons.Draw(g, rectIcon.X, rectIcon.Y);

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

                        // 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 + 4);
                        }
                    }

                    // draw appointment text
                    rect.Y += 3;

                    if (longAppt)
                    {
                        rect.Height = m_BaseFont.Height;
                    }
                    else
                    {
                        rect.Height -= 3;
                    }

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    using (SolidBrush brush = new SolidBrush(textColor))
                        g.DrawString(appointment.Title, this.BaseFont, brush, rect, format);

                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }
        }