コード例 #1
0
        public void LoadPreferences(Preferences prefs, String key, bool appOnly)
        {
            m_DayView.TaskColorIsBackground        = prefs.GetProfileBool("Preferences", "ColorTaskBackground", false);
            m_DayView.ShowParentsAsFolder          = prefs.GetProfileBool("Preferences", "ShowParentsAsFolders", false);
            m_DayView.AutoCalculateDependencyDates = prefs.GetProfileBool("Preferences", "AutoAdjustDependents", false);
            m_DayView.StrikeThruDoneTasks          = prefs.GetProfileBool("Preferences", "StrikethroughDone", true);
            m_DayView.ShowLabelTips = !prefs.GetProfileBool("Preferences", "ShowInfoTips", false);

            m_AllowModifyTimeEstimate = !prefs.GetProfileBool("Preferences", "SyncTimeEstAndDates", false);

            m_WorkWeek.Load(prefs);
            m_DayView.WeekendDays = m_WorkWeek.WeekendDays();

            int gridColor = -1;

            if (prefs.GetProfileBool("Preferences", "SpecifyGridColor", true))
            {
                gridColor = prefs.GetProfileInt("Preferences\\Colors", "GridLines", -1);
            }

            m_DayView.GridlineColor = ((gridColor == -1) ? DefGridColor : DrawingColor.ToColor((UInt32)gridColor));

            if (!appOnly)
            {
                // private settings
                m_PrefsDlg.LoadPreferences(prefs, key);
                UpdateDayViewPreferences();

                SetDaysShowing(prefs.GetProfileInt(key, "DaysShowing", 7));
            }
            else
            {
                UpdateWorkingHourDisplay();
            }
        }
コード例 #2
0
        public void SetUITheme(UITheme theme)
        {
            m_toolbarRenderer.SetUITheme(theme);

            var backColor = theme.GetAppDrawingColor(UITheme.AppColor.ToolbarLight);

            this.BackColor       = backColor;
            MenuBar.BackColor    = SystemColors.Menu;
            ToolBar.BackColor    = backColor;
            FontBar.BackColor    = backColor;
            StatusBar.BackColor  = backColor;
            FormulaBar.BackColor = backColor;

            // Unfocused colours
            var color     = theme.GetAppDrawingColor(UITheme.AppColor.ToolbarHot);
            var gridColor = new unvell.ReoGrid.Graphics.SolidColor(color.A, color.R, color.G, color.B);

            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadSelectedNotFocusedStart, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadSelectedNotFocusedEnd, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadFullSelectedNotFocusedStart, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadFullSelectedNotFocusedEnd, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.RowHeadSelectedNotFocused, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.RowHeadFullSelectedNotFocused, gridColor);

            // Focused colours
            color     = DrawingColor.AdjustLighting(color, -0.15f, false);
            gridColor = new unvell.ReoGrid.Graphics.SolidColor(color.A, color.R, color.G, color.B);

            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadSelectedStart, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadSelectedEnd, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadFullSelectedStart, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.ColHeadFullSelectedEnd, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.RowHeadSelected, gridColor);
            GridControl.ControlStyle.SetColor(ControlAppearanceColors.RowHeadFullSelected, gridColor);
        }
コード例 #3
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            e.DrawBackground();
            e.DrawFocusRectangle();

            if (e.Index > -1)
            {
                ColorScheme scheme = (ColorScheme)Items[e.Index];

                if (scheme != null)
                {
                    Rectangle rect = e.Bounds;
                    rect.Inflate(-2, -2);
                    rect.Width = rect.Height;

                    foreach (Color color in scheme.m_Colors)
                    {
                        using (Brush fill = new SolidBrush(color))
                        {
                            e.Graphics.FillRectangle(fill, rect);
                        }

                        using (Pen border = new Pen(DrawingColor.AdjustLighting(color, -0.2f, true)))
                        {
                            e.Graphics.DrawRectangle(border, rect);
                        }

                        // Next colour
                        rect.Offset(rect.Height + 2, 0);
                    }
                }
            }
        }
コード例 #4
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        var workbook  = new ExcelFile();
        var worksheet = workbook.Worksheets.Add("Shapes");

        var shape = worksheet.Shapes.Add(ShapeType.Oval, 100, 100, 200, 150, LengthUnit.Point);

        shape.Fill.SetSolid(DrawingColor.FromName(DrawingColorName.GreenYellow));
        shape.Outline.Fill.SetSolid(DrawingColor.FromName(DrawingColorName.DarkBlue));
        shape.Outline.Width = Length.From(3, LengthUnit.Point);

        var roundedRectangle = worksheet.Shapes.Add(ShapeType.RoundedRectangle, "B2", "D4");

        // Radius of the corners is 35% of the rounded rectangle height (since it is smaller than width).
        roundedRectangle.AdjustValues["adj"] = 35000;

        var rightArrow = worksheet.Shapes.Add(ShapeType.RightArrow, "B6", 100, 40, LengthUnit.Point);

        rightArrow.Fill.SetNone();
        rightArrow.Outline.Fill.SetSolid(DrawingColor.FromRgb(250, 30, 20));
        rightArrow.Outline.Width = Length.From(2, LengthUnit.Point);

        var line = worksheet.Shapes.Add(ShapeType.Line, "B12", "B15");

        line.Outline.Width = Length.From(10, LengthUnit.Pixel);

        worksheet.PrintOptions.PrintGridlines = true;
        worksheet.PrintOptions.PrintHeadings  = true;

        workbook.Save("Shapes.xlsx");
    }
コード例 #5
0
        protected void DrawNonWorkHours(PaintEventArgs e, Rectangle rect, DateTime time)
        {
            if (m_Renderer.Theme.HasAppColor(UITheme.AppColor.Weekends) && WeekendDays.Contains(time.DayOfWeek))
            {
                var weekendColor = m_Renderer.Theme.GetAppDrawingColor(UITheme.AppColor.Weekends, 128);

                // If this is also 'today' then convert to gray so it doesn't
                // impose too much when the today colour is laid on top
                if (WantDrawToday(time))
                {
                    weekendColor = DrawingColor.ToGray(weekendColor);
                }

                using (var brush = new SolidBrush(weekendColor))
                    e.Graphics.FillRectangle(brush, rect);
            }
            else if (m_Renderer.Theme.HasAppColor(UITheme.AppColor.NonWorkingHours))
            {
                var nonWorkColor = m_Renderer.Theme.GetAppDrawingColor(UITheme.AppColor.NonWorkingHours, 128);

                // If this is also 'today' then convert to gray so it doesn't
                // impose too much when the today colour is laid on top
                if (WantDrawToday(time))
                {
                    nonWorkColor = DrawingColor.ToGray(nonWorkColor);
                }

                using (SolidBrush brush = new SolidBrush(nonWorkColor))
                {
                    DrawNonWorkHours(e, new HourMin(0, 0), WorkStart, rect, brush);
                    DrawNonWorkHours(e, LunchStart, LunchEnd, rect, brush);
                    DrawNonWorkHours(e, WorkEnd, new HourMin(24, 0), rect, brush);
                }
            }
        }
コード例 #6
0
 public bool Equals(HeaderFooterTemplateItem other)
 {
     return(base.Equals(other) &&
            (WantDivider == other.WantDivider) &&
            (PixelHeight == other.PixelHeight) &&
            DrawingColor.Equals(BackColor, other.BackColor));
 }
コード例 #7
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");

        var workbook  = new ExcelFile();
        var worksheet = workbook.Worksheets.Add("Text Boxes");

        // Create the first shape.
        var shape = worksheet.Shapes.Add(ShapeType.Rectangle, "B2", "D8");

        // Get the shape's text content.
        var textBox = shape.Text;

        // Create the first paragraph with bold, red run element.
        var run = textBox.Paragraphs.Add().Elements.AddRun("Shows how to use text boxes with GemBox.Spreadsheet component.");

        run.Format.Bold = true;
        run.Format.Fill.SetSolid(DrawingColor.FromName(DrawingColorName.Orange));

        // Create an empty paragraph.
        textBox.Paragraphs.Add();

        // Create a right-aligned (multi-line) paragraph.
        var paragraph = textBox.Paragraphs.Add();

        paragraph.Format.Alignment = HorizontalAlignment.Right;

        // Create and add a run element.
        run = paragraph.Elements.AddRun("This is a ...");
        var lineBreak = paragraph.Elements.AddLineBreak();

        run = paragraph.Elements.AddRun("... multi-line paragraph.");

        // Create the second shape.
        shape = worksheet.Shapes.Add(ShapeType.Oval, 200, 50, 150, 150, LengthUnit.Point);
        shape.Fill.SetSolid(DrawingColor.FromName(DrawingColorName.DarkOliveGreen));
        shape.Outline.Fill.SetNone();
        textBox = shape.Text;
        textBox.Format.VerticalAlignment = VerticalAlignment.Middle;

        // Create a list.
        paragraph = textBox.Paragraphs.Add();
        paragraph.Elements.AddRun("This is a paragraph list:");

        paragraph = textBox.Paragraphs.Add();
        paragraph.Format.List.NumberType = ListNumberType.DecimalPeriod;
        run = paragraph.Elements.AddRun("First list item");

        paragraph = textBox.Paragraphs.Add();
        paragraph.Format.List.NumberType = ListNumberType.DecimalPeriod;
        run = paragraph.Elements.AddRun("Second list item");

        paragraph = textBox.Paragraphs.Add();
        paragraph.Format.List.NumberType = ListNumberType.DecimalPeriod;
        run = paragraph.Elements.AddRun("Third list item");

        workbook.Save("Text Boxes.xlsx");
    }
コード例 #8
0
        void DrawPos(int pos, DrawingColor color)
        {
            ClearPos(pos);
            RectangleF rect  = GetPosRect(pos);
            SolidBrush brush = new SolidBrush(DrawingStyler.GetColor(arrayToDraw, pos, color));

            graph.FillRectangle(brush, rect);
        }
コード例 #9
0
 public static void SaveColor(DrawingColor drawingColor)
 {
     Properties.Settings settings = Properties.Settings.Default;
     settings.R = drawingColor.R;
     settings.G = drawingColor.G;
     settings.B = drawingColor.B;
     settings.Save();
 }
コード例 #10
0
        public void SetUITheme(UITheme theme)
        {
            var color = theme.GetAppDrawingColor(UITheme.AppColor.AppLinesDark);

            // Make sure it's dark enough
            color = DrawingColor.SetLuminance(color, 0.6f);

            m_MindMap.ConnectionColor = color;
        }
コード例 #11
0
 /// <summary>
 /// Zamienia DrawingColor na parametr, ktory moze byc wykorzystany przez InkCanvas.
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public static Color ToColor(this DrawingColor color)
 {
     return(new Color()
     {
         A = 255,
         R = color.R,
         G = color.G,
         B = color.B
     });
 }
コード例 #12
0
        public void SetUITheme(UITheme theme)
        {
            BackColor = theme.GetAppDrawingColor(UITheme.AppColor.AppBackLight);

            // Connection colour
            var color = theme.GetAppDrawingColor(UITheme.AppColor.AppLinesDark);

            // Make sure it's dark enough
            m_MindMap.ConnectionColor = DrawingColor.SetLuminance(color, 0.6f);
        }
コード例 #13
0
        private void DrawEmphasizedBackground(LayoutItem layoutItem)
        {
            Color color     = GetPresudoRandomColorFromPalette(layoutItem);
            Color backColor = DrawingColor.SetLuminance(color, 0.8f);

            using (Brush brush = new SolidBrush(backColor))
            {
                Rectangle rect = Rectangle.Inflate(Rectangle.Round(layoutItem.Rectangle), -1, -1);
                m_Graphics.FillRectangle(brush, rect);
            }
        }
コード例 #14
0
        private void DrawEmphasizedText(LayoutItem layoutItem, bool selected)
        {
            AdjustTextRenderHint(layoutItem);

            Color color     = GetPresudoRandomColorFromPalette(layoutItem);
            Color textColor = DrawingColor.SetLuminance(color, 0.3f);
            Font  font      = GetFont(layoutItem.Word);

            using (Brush brush = new SolidBrush(textColor))
            {
                m_Graphics.DrawString(layoutItem.Word.Text, font, brush, layoutItem.Rectangle.X, layoutItem.Rectangle.Y);
            }
        }
コード例 #15
0
        public bool Copy(HeaderFooterTemplateItem other)
        {
            if (!base.Copy(other))
            {
                return(false);
            }

            WantDivider = other.WantDivider;
            PixelHeight = other.PixelHeight;
            BackColor   = DrawingColor.Copy(other.BackColor);

            return(true);
        }
コード例 #16
0
        public void SetGlobalSetting(string key, DrawingColor value)
        {
            if (!IsOpen())
            {
                return;
            }

            Setting setting = SettingRepository.Find(s => s.SettingName == key);

            if (setting == null)
            {
                setting = new Setting();
            }

            Set(setting, key, value.ToARGBString());
        }
コード例 #17
0
        public bool Copy(HtmlReportTemplate other)
        {
            if (other == null)
            {
                return(false);
            }

            BackImage = String.Copy(other.BackImage);
            BackColor = DrawingColor.Copy(other.BackColor);

            Header.Copy(other.Header);
            Title.Copy(other.Title);
            Task.Copy(other.Task);
            Footer.Copy(other.Footer);

            return(true);
        }
コード例 #18
0
        protected override void OnPaint(PaintEventArgs e)
        {
            // border around Word cloud and Task match list
            Rectangle border = new Rectangle(ClientRectangle.Left, ControlTop, ClientRectangle.Width, (ClientRectangle.Height - ControlTop));

            ControlPaint.DrawBorder(e.Graphics, border, Color.DarkGray, ButtonBorderStyle.Solid);

            // Splitter bar
            Rectangle splitterRect = SplitterRect();
            Color     fillColor    = m_SplitterColor;
            Color     borderColor  = DrawingColor.AdjustLighting(m_SplitterColor, -0.2f, true);

            if (m_SplitterWidth == 1)
            {
                fillColor = borderColor;
            }

            using (var brush = new SolidBrush(fillColor))
                e.Graphics.FillRectangle(brush, splitterRect);

            // draw drag marker (2 x 20)
            if (m_SplitterWidth > 2)
            {
                ControlPaint.DrawBorder(e.Graphics, splitterRect, borderColor, ButtonBorderStyle.Solid);

                Point     splitCentre = SplitterCentre();
                Rectangle markerRect  = new Rectangle((splitCentre.X - 1), (splitCentre.Y - 10), 2, 20);

                // use the splitter colour luminance to decide whether
                // to draw the marker lighter or darker
                Color markerColor;

                if (m_SplitterColor.GetBrightness() > 0.5f)
                {
                    markerColor = DrawingColor.AdjustLighting(m_SplitterColor, -0.3f, true);
                }
                else
                {
                    markerColor = DrawingColor.AdjustLighting(m_SplitterColor, 0.3f, true);
                }

                using (var brush = new SolidBrush(markerColor))
                    e.Graphics.FillRectangle(brush, markerRect);
            }
        }
コード例 #19
0
        public static Color GetColor(SortingArray array, int pos, DrawingColor color)
        {
            switch (color)
            {
            case DrawingColor.Default:
                return(GetDefaultColor(array, pos));

            case DrawingColor.Selected:
                return(GetSelectedColor(array, pos));

            case DrawingColor.Swapped:
                return(GetSwappedColor(array, pos));

            case DrawingColor.Special:
                return(GetSpecialColor(array, pos));
            }
            return(Color.WhiteSmoke);
        }
コード例 #20
0
        public System.Drawing.Color GetTextColor(Boolean isSelected, Boolean taskColorIsBkgnd)
        {
            if (!taskTextColor.IsEmpty)
            {
                if (isSelected)
                {
                    return(DrawingColor.SetLuminance(TextColor, 0.3f));
                }

                if (taskColorIsBkgnd && !IsDone(true))
                {
                    return(DrawingColor.GetBestTextColor(TextColor));
                }
            }
            else
            {
                return(System.Drawing.SystemColors.WindowText);
            }

            return(TextColor);
        }
コード例 #21
0
        public bool Equals(HtmlReportTemplate other)
        {
            if (other == null)
            {
                return(false);
            }

            if (!BackImage.Equals(other.BackImage))
            {
                return(false);
            }

            if (!DrawingColor.Equals(BackColor, other.BackColor))
            {
                return(false);
            }

            if (!Header.Equals(other.Header))
            {
                return(false);
            }

            if (!Title.Equals(other.Title))
            {
                return(false);
            }

            if (!Task.Equals(other.Task))
            {
                return(false);
            }

            if (!Footer.Equals(other.Footer))
            {
                return(false);
            }

            return(true);
        }
コード例 #22
0
        public TValueType GetGlobalSetting <TValueType>(string key, TValueType defaultValue)
        {
            if (!IsOpen())
            {
                return(defaultValue);
            }
            if (defaultValue == null)
            {
                return(default(TValueType));
            }

            Setting setting = SettingRepository.Find(s => s.SettingName == key);

            if (setting == null)
            {
                return(defaultValue);
            }

            if (defaultValue.GetType() == typeof(bool))
            {
                return((TValueType)((object)bool.Parse(setting.SettingValue)));
            }
            if (defaultValue.GetType() == typeof(int))
            {
                return((TValueType)((object)int.Parse(setting.SettingValue)));
            }
            if (defaultValue.GetType() == typeof(DrawingColor))
            {
                return((TValueType)((object)DrawingColor.Parse(setting.SettingValue)));
            }
            if (defaultValue.GetType() == typeof(string))
            {
                return((TValueType)((object)setting.SettingValue));
            }

            return(defaultValue);
        }
コード例 #23
0
 /// <summary>
 /// Converts a System.Drawing.Color struct into a System.Windows.Media.Color object.
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public static MediaColor ToMediaColor(this DrawingColor color)
 {
     return(MediaColor.FromArgb(color.A, color.R, color.G, color.B));
 }
コード例 #24
0
        /// <summary>
        /// Replaces any pixel with a zero alpha value with the specified transparency key.
        /// </summary>
        /// <param name="bmpData">The bitmap data in which to perform the operation.</param>
        /// <param name="transKey">The transparency color. This color is rendered transparent
        /// by the DragDropHelper.</param>
        /// <remarks>
        /// This function only supports 32-bit pixel formats for now.
        /// </remarks>
        private static void ReplaceTransparentPixelsWithTransparentKey(BitmapData bmpData, DrawingColor transKey)
        {
            DrawingPixelFormat pxFormat = bmpData.PixelFormat;

            if (DrawingPixelFormat.Format32bppArgb == pxFormat
                || DrawingPixelFormat.Format32bppPArgb == pxFormat)
            {
                int transKeyArgb = transKey.ToArgb();

                // We will just iterate over the data... we don't care about pixel location,
                // just that every pixel is checked.
                unsafe
                {
                    byte* pscan = (byte*)bmpData.Scan0.ToPointer();
                    {
                        for (int y = 0; y < bmpData.Height; ++y, pscan += bmpData.Stride)
                        {
                            int* prgb = (int*)pscan;
                            for (int x = 0; x < bmpData.Width; ++x, ++prgb)
                            {
                                // If the alpha value is zero, replace this pixel's color
                                // with the transparency key.
                                if ((*prgb & 0xFF000000L) == 0L)
                                    *prgb = transKeyArgb;
                            }
                        }
                    }
                }
            }
            else
            {
                // If it is anything else, we aren't supporting it, but we
                // won't throw, cause it isn't an error
                System.Diagnostics.Trace.TraceWarning("Not converting transparent colors to transparency key.");
                return;
            }
        }
コード例 #25
0
ファイル: OnScreenDrawing.cs プロジェクト: don100/Unity-A-Z
    //tools events
    public void ToolsEvents(GameObject toolOb)
    {
        if (toolOb == null)
        {
            return;
        }

        string toolName              = toolOb.name;
        string obTag                 = toolOb.tag;
        bool   checkSelectedTool     = false;
        bool   checkFontSize         = false;
        bool   checkPrevColor        = false;
        bool   checkDrawResizerColor = false;

        if (toolName == "small-size-circle (Drawing Level)")
        {
            fontSize              = FontSize.SMALL;
            checkFontSize         = true;
            checkDrawResizerColor = true;
        }
        else if (toolName == "med-size-circle (Drawing Level)")
        {
            fontSize              = FontSize.MEDIUM;
            checkFontSize         = true;
            checkDrawResizerColor = true;
        }
        else if (toolName == "larg-size-circle (Drawing Level)")
        {
            fontSize              = FontSize.LARGE;
            checkFontSize         = true;
            checkDrawResizerColor = true;
        }
        else if (toolName == "trash (Drawing Level)")
        {
            ClearBoard();
            colorsWheelControllerComp.ScrollingRelease(360, 0);
        }
        else if (obTag == "WheelColor")
        {
            checkDrawResizerColor = true;
            checkPrevColor        = true;
            drawingColorComp      = toolOb.GetComponent <DrawingColor> ();
            lineColor             = drawingColorComp.color;
            drawingMaterial       = drawingColorComp.drawingMaterial;
            previousMaterial      = drawingMaterial;
            if (DrawingLevel.isEraserSelected)
            {
                checkSelectedTool = true;
                checkFontSize     = true;
                fontSizeType      = FontSizeType.PEN;
                selectedTool      = SelectedTool.PEN;
            }
        }
        else if (toolName == "eraser (Drawing Level)")
        {
            DrawingLevel.isEraserSelected = true;
            selectedTool          = SelectedTool.DELETE;
            checkDrawResizerColor = true;
            checkSelectedTool     = true;
            lineColor             = Color.white;
            drawingMaterial       = DrawingColor.whiteMaterial;
        }
        else if (toolName == "pencil (Drawing Level)")
        {
            DrawingLevel.isEraserSelected = false;
            selectedTool          = SelectedTool.PEN;
            checkDrawResizerColor = true;
            checkSelectedTool     = true;
            checkFontSize         = true;
            fontSizeType          = FontSizeType.PEN;
            lineColor             = prevColor;
            drawingMaterial       = previousMaterial;
        }
        else if (toolName == "brush (Drawing Level)")
        {
            DrawingLevel.isEraserSelected = false;
            selectedTool          = SelectedTool.BRUSH;
            checkDrawResizerColor = true;
            checkSelectedTool     = true;
            checkFontSize         = true;
            fontSizeType          = FontSizeType.BRUSH;
            lineColor             = prevColor;
            drawingMaterial       = previousMaterial;
        }

        if (checkDrawResizerColor)
        {
            if (checkPrevColor)
            {
                prevColor = lineColor;
            }
            SetDrawResizerColor();
        }

        if (checkSelectedTool)
        {
            SetSelectedTool();
        }

        if (checkFontSize)
        {
            SetFontSize();
        }
    }
コード例 #26
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;
                }
            }
        }
コード例 #27
0
 internal static string Colorized(this string str, DrawingColor color) => str.Pastel(color);
コード例 #28
0
 internal static string Colorized(this string str, DrawingColor foregroundColor, DrawingColor backgroundColor) => str.Pastel(foregroundColor).PastelBg(backgroundColor);
コード例 #29
0
        protected override void DrawNodeLabel(Graphics graphics, String label, Rectangle rect,
                                              NodeDrawState nodeState, NodeDrawPos nodePos,
                                              Font nodeFont, Object itemData)
        {
            var taskItem = (itemData as MindMapTaskItem);
            var realItem = GetRealTaskItem(taskItem);

            bool      isSelected = (nodeState != NodeDrawState.None);
            Rectangle iconRect   = Rectangle.Empty;

            if (taskItem.IsTask) // not root
            {
                // Checkbox
                Rectangle checkRect = CalcCheckboxRect(rect);

                if (m_ShowCompletionCheckboxes)
                {
                    CheckBoxRenderer.DrawCheckBox(graphics, checkRect.Location, GetItemCheckboxState(realItem));
                }

                // Task icon
                if (TaskHasIcon(realItem))
                {
                    iconRect = CalcIconRect(rect);

                    if (m_TaskIcons.Get(realItem.ID))
                    {
                        m_TaskIcons.Draw(graphics, iconRect.X, iconRect.Y);
                    }

                    rect.Width = (rect.Right - iconRect.Right - 2);
                    rect.X     = iconRect.Right + 2;
                }
                else if (m_ShowCompletionCheckboxes)
                {
                    rect.Width = (rect.Right - checkRect.Right - 2);
                    rect.X     = checkRect.Right + 2;
                }
            }

            // Text Colour
            Color textColor = SystemColors.WindowText;

            if (!taskItem.TextColor.IsEmpty)
            {
                if (m_TaskColorIsBkgnd && !isSelected && !realItem.IsDone(true))
                {
                    textColor = DrawingColor.GetBestTextColor(taskItem.TextColor);
                }
                else if (isSelected)
                {
                    textColor = DrawingColor.SetLuminance(taskItem.TextColor, 0.3f);
                }
                else
                {
                    textColor = taskItem.TextColor;
                }
            }

            switch (nodeState)
            {
            case NodeDrawState.Selected:
                UIExtension.SelectionRect.Draw(this.Handle, graphics, rect.X, rect.Y, rect.Width, rect.Height, this.Focused, false);     // opaque
                break;

            case NodeDrawState.DropTarget:
                UIExtension.SelectionRect.Draw(this.Handle, graphics, rect.X, rect.Y, rect.Width, rect.Height, false, false);     // opaque
                break;

            case NodeDrawState.None:
                if (DebugMode())
                {
                    graphics.DrawRectangle(new Pen(Color.Green), rect);
                }
                break;
            }

            // Text
            var format = DefaultLabelFormat(nodePos, isSelected);

            graphics.DrawString(label, nodeFont, new SolidBrush(textColor), rect, format);

            // Draw Windows shortcut icon if task is a reference
            if (taskItem.IsReference)
            {
                if (iconRect == Rectangle.Empty)
                {
                    iconRect = rect;
                }
                else
                {
                    iconRect.Y = (rect.Bottom - iconRect.Height);                     // don't want shortcut icon centred vertically
                }
                UIExtension.ShortcutOverlay.Draw(graphics, iconRect.X, iconRect.Y, iconRect.Width, iconRect.Height);
            }
        }
コード例 #30
0
		//tools events
		public void ToolsEvents (GameObject toolOb)
		{
				if (toolOb == null) {
						return;
				}

				string toolName = toolOb.name;
				string obTag = toolOb.tag;
				bool checkSelectedTool = false;
				bool checkFontSize = false;
				bool checkPrevColor = false;
				bool checkDrawResizerColor = false;

				if (toolName == "small-size-circle (Drawing Level)") {
						fontSize = FontSize.SMALL;
						checkFontSize = true;
						checkDrawResizerColor = true;
				} else if (toolName == "med-size-circle (Drawing Level)") {
						fontSize = FontSize.MEDIUM;
						checkFontSize = true;
						checkDrawResizerColor = true;
				} else if (toolName == "larg-size-circle (Drawing Level)") {
						fontSize = FontSize.LARGE;
						checkFontSize = true;
						checkDrawResizerColor = true;
				} else if (toolName == "trash (Drawing Level)") {
						ClearBoard ();
						colorsWheelControllerComp.ScrollingRelease (360, 0);
				} else if (obTag == "WheelColor") {
						checkDrawResizerColor = true;
						checkPrevColor = true;
						drawingColorComp = toolOb.GetComponent<DrawingColor> ();
						lineColor = drawingColorComp.color;
						drawingMaterial = drawingColorComp.drawingMaterial;
						previousMaterial = drawingMaterial;
						if (DrawingLevel.isEraserSelected) {
								checkSelectedTool = true;
								checkFontSize = true;
								fontSizeType = FontSizeType.PEN;
								selectedTool = SelectedTool.PEN;
						}
				} else if (toolName == "eraser (Drawing Level)") {
						DrawingLevel.isEraserSelected = true;
						selectedTool = SelectedTool.DELETE;
						checkDrawResizerColor = true;
						checkSelectedTool = true;
						lineColor = Color.white;
						drawingMaterial = DrawingColor.whiteMaterial;
				} else if (toolName == "pencil (Drawing Level)") {
						DrawingLevel.isEraserSelected = false;
						selectedTool = SelectedTool.PEN;
						checkDrawResizerColor = true;
						checkSelectedTool = true;
						checkFontSize = true;
						fontSizeType = FontSizeType.PEN;
						lineColor = prevColor;
						drawingMaterial = previousMaterial;
				} else if (toolName == "brush (Drawing Level)") {
						DrawingLevel.isEraserSelected = false;
						selectedTool = SelectedTool.BRUSH;
						checkDrawResizerColor = true;
						checkSelectedTool = true;
						checkFontSize = true;
						fontSizeType = FontSizeType.BRUSH;
						lineColor = prevColor;
						drawingMaterial = previousMaterial;
				}

				if (checkDrawResizerColor) {
						if (checkPrevColor) {
								prevColor = lineColor;
						}
						SetDrawResizerColor ();
				} 

				if (checkSelectedTool) {
						SetSelectedTool ();
				}

				if (checkFontSize) {
						SetFontSize ();
				}
		}
コード例 #31
0
        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;
                }
            }
        }
コード例 #32
0
        protected override void DrawNodeLabel(Graphics graphics, String label, Rectangle rect,
                                              NodeDrawState nodeState, NodeDrawPos nodePos,
                                              Font nodeFont, Object itemData)
        {
            var  taskItem   = (itemData as MindMapTaskItem);
            bool isSelected = (nodeState != NodeDrawState.None);

            if (taskItem.IsTask) // real task
            {
                // Checkbox
                Rectangle checkRect = CalcCheckboxRect(rect);

                if (m_ShowCompletionCheckboxes)
                {
                    CheckBoxRenderer.DrawCheckBox(graphics, checkRect.Location, GetItemCheckboxState(taskItem));
                }

                // Task icon
                if (TaskHasIcon(taskItem))
                {
                    Rectangle iconRect = CalcIconRect(rect);

                    if (m_TaskIcons.Get(taskItem.ID))
                    {
                        m_TaskIcons.Draw(graphics, iconRect.X, iconRect.Y);
                    }

                    rect.Width = (rect.Right - iconRect.Right - 2);
                    rect.X     = iconRect.Right + 2;
                }
                else if (m_ShowCompletionCheckboxes)
                {
                    rect.Width = (rect.Right - checkRect.Right - 2);
                    rect.X     = checkRect.Right + 2;
                }
            }

            // Text background
            Brush textColor = SystemBrushes.WindowText;
            Brush backColor = null;
            Color taskColor = taskItem.TextColor;

            if (!taskColor.IsEmpty)
            {
                if (m_TaskColorIsBkgnd && !isSelected && !taskItem.IsDone(true))
                {
                    backColor = new SolidBrush(taskColor);
                    textColor = new SolidBrush(DrawingColor.GetBestTextColor(taskColor));
                }
                else
                {
                    if (nodeState != MindMapControl.NodeDrawState.None)
                    {
                        taskColor = DrawingColor.SetLuminance(taskColor, 0.3f);
                    }

                    textColor = new SolidBrush(taskColor);
                }
            }

            switch (nodeState)
            {
            case NodeDrawState.Selected:
                m_SelectionRect.Draw(graphics, rect.X, rect.Y, rect.Width, rect.Height, this.Focused);
                break;

            case NodeDrawState.DropTarget:
                m_SelectionRect.Draw(graphics, rect.X, rect.Y, rect.Width, rect.Height, false);
                break;

            case NodeDrawState.None:
            {
                if (backColor != null)
                {
                    var prevSmoothing = graphics.SmoothingMode;
                    graphics.SmoothingMode = SmoothingMode.None;

                    graphics.FillRectangle(backColor, rect);
                    graphics.SmoothingMode = prevSmoothing;
                }

                if (DebugMode())
                {
                    graphics.DrawRectangle(new Pen(Color.Green), rect);
                }
            }
            break;
            }

            // Text
            var format = DefaultLabelFormat(nodePos, isSelected);

            graphics.DrawString(label, nodeFont, textColor, rect, format);
        }