コード例 #1
0
    public Color GetColor(SchemeColor color)
    {
        switch (color)
        {
        case SchemeColor.mainColor:
            return(currentScheme.mainColor);

        case SchemeColor.effectColor:
            return(currentScheme.effectColor);

        case SchemeColor.backgroundColor:
            return(currentScheme.backgroundColor);

        case SchemeColor.highlightColor:
            return(currentScheme.highlightColor);

        case SchemeColor.negativeHighlightColor:
            return(currentScheme.negativeHighlightColor);

        case SchemeColor.positiveHighlightColor:
            return(currentScheme.positiveHighlightColor);

        default:
            throw new NotImplementedException(color.ToString());
        }
    }
コード例 #2
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
        public static Event BuildButton(this ImGui gui, Rect rect, SchemeColor normal, SchemeColor over, SchemeColor down = SchemeColor.None, uint button = SDL.SDL_BUTTON_LEFT)
        {
            if (button == 0)
            {
                button = (uint)InputSystem.Instance.mouseDownButton;
            }
            switch (gui.action)
            {
            case ImGuiAction.MouseMove:
                var wasOver = gui.IsMouseOver(rect);
                return(gui.ConsumeMouseOver(rect, RenderingUtils.cursorHand) && !wasOver ? Event.MouseOver : Event.None);

            case ImGuiAction.MouseDown:
                return(gui.actionParameter == button && gui.ConsumeMouseDown(rect, button) ? Event.MouseDown : Event.None);

            case ImGuiAction.MouseUp:
                return(gui.actionParameter == button && gui.ConsumeMouseUp(rect, true, button) ? Event.Click : Event.None);

            case ImGuiAction.Build:
                var color = gui.IsMouseOver(rect) ? (down != SchemeColor.None && gui.IsMouseDown(rect, button)) ? down : over : normal;
                gui.DrawRectangle(rect, color);
                return(Event.None);

            default:
                return(Event.None);
            }
        }
コード例 #3
0
 public void DrawRectangle(Rect rect, SchemeColor color, RectangleBorder border = RectangleBorder.None)
 {
     if (action != ImGuiAction.Build)
     {
         return;
     }
     rects.Add(new DrawCommand <RectangleBorder>(rect, border, color));
 }
コード例 #4
0
 public void DrawIcon(Rect rect, Icon icon, SchemeColor color)
 {
     if (action != ImGuiAction.Build || icon == Icon.None)
     {
         return;
     }
     icons.Add(new DrawCommand <Icon>(rect, icon, color));
 }
コード例 #5
0
 public void DrawRenderable(Rect rect, IRenderable renderable, SchemeColor color)
 {
     if (action != ImGuiAction.Build || renderable == null)
     {
         return;
     }
     renderables.Add(new DrawCommand <IRenderable>(rect, renderable, color));
 }
コード例 #6
0
ファイル: WindowUtility.cs プロジェクト: phoenixuprising/yafc
        internal override void DrawIcon(SDL.SDL_Rect position, Icon icon, SchemeColor color)
        {
            var sdlColor    = color.ToSdlColor();
            var iconSurface = IconCollection.GetIconSurface(icon);

            SDL.SDL_SetSurfaceColorMod(iconSurface, sdlColor.r, sdlColor.g, sdlColor.b);
            SDL.SDL_SetSurfaceAlphaMod(iconSurface, sdlColor.a);
            SDL.SDL_BlitScaled(iconSurface, ref IconCollection.IconRect, surface, ref position);
        }
コード例 #7
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
        public static bool BuildButton(this ImGui gui, string text, SchemeColor color = SchemeColor.Primary, Padding?padding = null, bool active = true)
        {
            if (!active)
            {
                color = SchemeColor.Grey;
            }
            using (gui.EnterGroup(padding ?? DefaultButtonPadding, active ? color + 2 : color + 3))
                gui.BuildText(text, Font.text, align: RectAlignment.Middle);

            return(gui.BuildButton(gui.lastRect, color, color + 1) == Event.Click && active);
        }
コード例 #8
0
        internal override OpenXmlElement CreateColorElement()
        {
            SchemeColor element = new SchemeColor()
            {
                Val = color
            };

            this.AnnotateOpenXmlElement(element);

            return(element);
        }
コード例 #9
0
ファイル: ImGuiDrag.cs プロジェクト: ShadowGlass0/PyYAFC
        public void SetDraggingArea <T>(Rect rect, T draggingObject, SchemeColor bgColor)
        {
            if (window == null || mouseDownButton == -1)
            {
                return;
            }
            rebuildRequested      = false;
            currentDraggingObject = draggingObject;
            var overlay = window.GetDragOverlay();

            overlay.BeginDrag(this, rect, bgColor);
        }
コード例 #10
0
        public Context EnterGroup(Padding padding, RectAllocator allocator, SchemeColor textColor = SchemeColor.None, float spacing = float.NegativeInfinity)
        {
            state.AllocateSpacing();
            var ctx = new Context(this, padding);

            state.allocator = allocator;
            if (!float.IsNegativeInfinity(spacing))
            {
                state.spacing = spacing;
            }
            if (textColor != SchemeColor.None)
            {
                state.textColor = textColor;
            }
            return(ctx);
        }
コード例 #11
0
        public SchemeColor Build()
        {
            var schemaColor = new SchemeColor();

            schemaColor.Val = this.Options.SchemeColor;

            decimal decTint = this.Options.Tint;

            // we don't have to do anything extra if the tint's zero.
            if (decTint < 0.0m)
            {
                decTint += 1.0m;
                decTint *= 100000m;
                schemaColor.Append(new LuminanceModulation()
                {
                    Val = Convert.ToInt32(decTint)
                });
            }
            else if (decTint > 0.0m)
            {
                decTint *= 100000m;
                decTint  = decimal.Floor(decTint);
                schemaColor.Append(new LuminanceModulation()
                {
                    Val = Convert.ToInt32(100000m - decTint)
                });
                schemaColor.Append(new LuminanceOffset()
                {
                    Val = Convert.ToInt32(decTint)
                });
            }

            var alpha = CalculateAlpha();

            if (alpha < 100000)
            {
                schemaColor.Append(new Alpha()
                {
                    Val = alpha
                });
            }

            return(schemaColor);
        }
コード例 #12
0
 public DrawCommand(Rect rect, T data, SchemeColor color)
 {
     this.rect  = rect;
     this.data  = data;
     this.color = color;
 }
コード例 #13
0
 public Context EnterRow(float spacing = 0.5f, RectAllocator allocator = RectAllocator.LeftRow, SchemeColor textColor = SchemeColor.None) => EnterGroup(default, allocator, textColor, spacing);
コード例 #14
0
 public Context EnterGroup(Padding padding, SchemeColor textColor = SchemeColor.None) => EnterGroup(padding, allocator, textColor);
コード例 #15
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
        public static bool BuildRadioButton(this ImGui gui, string option, bool selected, SchemeColor color = SchemeColor.None)
        {
            using (gui.EnterRow())
            {
                gui.BuildIcon(selected ? Icon.RadioCheck : Icon.RadioEmpty, 1.5f, color);
                gui.BuildText(option, Font.text, color: color, wrap: true);
            }

            return(!selected && gui.OnClick(gui.lastRect));
        }
コード例 #16
0
 public static SDL.SDL_Color ToSdlColor(this SchemeColor color) => SchemeColors[(int)color];
コード例 #17
0
 public void ReadThemeSchemeColor(SchemeColor schemeColor)
 {
     if (schemeColor.Val == "bg1")
     {
         Light1Color light1Color = slide.SlideLayoutPart.SlideMasterPart.
                                   ThemePart.Theme.ThemeElements.ColorScheme.Light1Color;
         if (light1Color.RgbColorModelHex != null)
         {
             FontColor = "#" + light1Color.RgbColorModelHex.Val.Value;
         }
         else if (light1Color.SystemColor != null)
         {
             FontColor = "#" + light1Color.SystemColor.LastColor.Value;
         }
     }
     else if (schemeColor.Val == "bg2")
     {
         Light2Color light2Color = slide.SlideLayoutPart.SlideMasterPart.
                                   ThemePart.Theme.ThemeElements.ColorScheme.Light2Color;
         if (light2Color.RgbColorModelHex != null)
         {
             FontColor = "#" + light2Color.RgbColorModelHex.Val.Value;
         }
         else if (light2Color.SystemColor != null)
         {
             FontColor = "#" + light2Color.SystemColor.LastColor.Value;
         }
     }
     else if (schemeColor.Val == "tx1")
     {
         Dark1Color dark1Color = slide.SlideLayoutPart.SlideMasterPart.
                                 ThemePart.Theme.ThemeElements.ColorScheme.Dark1Color;
         if (dark1Color.RgbColorModelHex != null)
         {
             FontColor = "#" + dark1Color.RgbColorModelHex.Val.Value;
         }
         else if (dark1Color.SystemColor != null)
         {
             FontColor = "#" + dark1Color.SystemColor.LastColor.Value;
         }
     }
     else if (schemeColor.Val == "tx2")
     {
         Dark2Color dark2Color = slide.SlideLayoutPart.SlideMasterPart.
                                 ThemePart.Theme.ThemeElements.ColorScheme.Dark2Color;
         if (dark2Color.RgbColorModelHex != null)
         {
             FontColor = "#" + dark2Color.RgbColorModelHex.Val.Value;
         }
         else if (dark2Color.SystemColor != null)
         {
             FontColor = "#" + dark2Color.SystemColor.LastColor.Value;
         }
     }
     else if (schemeColor.Val == "hlink")
     {
         Hyperlink HyperLink = slide.SlideLayoutPart.SlideMasterPart.
                               ThemePart.Theme.ThemeElements.ColorScheme.Hyperlink;
         if (HyperLink.RgbColorModelHex != null)
         {
             FontColor = "#" + HyperLink.RgbColorModelHex.Val.Value;
         }
     }
     else if (schemeColor.Val == "folHlink")
     {
         FollowedHyperlinkColor folHyperLink = slide.SlideLayoutPart.SlideMasterPart.
                                               ThemePart.Theme.ThemeElements.ColorScheme.FollowedHyperlinkColor;
         if (folHyperLink.RgbColorModelHex != null)
         {
             FontColor = "#" + folHyperLink.RgbColorModelHex.Val.Value;
         }
     }
     this.ReadAccentSchemeColors(schemeColor);
 }
コード例 #18
0
        /// <summary>
        /// Design settings for Y axis.
        /// </summary>
        public ValueAxis SetGanttValueAxis(PlotArea plotArea, TimeSpan minSpan, TimeSpan maxSpan)
        {
            MajorGridlines       majorGridlines1       = new MajorGridlines();
            ChartShapeProperties chartShapeProperties2 = new ChartShapeProperties();
            Outline     outline2     = new Outline();
            SolidFill   solidFill2   = new SolidFill();
            SchemeColor schemeColor2 = new SchemeColor()
            {
                Val = SchemeColorValues.Accent1
            };
            Alpha alpha1 = new Alpha()
            {
                Val = 10000
            };

            schemeColor2.Append(alpha1);
            solidFill2.Append(schemeColor2);
            outline2.Append(solidFill2);
            chartShapeProperties2.Append(outline2);
            majorGridlines1.Append(chartShapeProperties2);

            return(plotArea.AppendChild <ValueAxis>(new ValueAxis(new AxisId()
            {
                Val = new UInt32Value(48672768u)
            },
                                                                  new Scaling(new Orientation()
            {
                Val = new EnumValue <DocumentFormat.OpenXml.Drawing.Charts.OrientationValues>(
                    DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax)
            }, new MinAxisValue()
            {
                Val = 0
            }, new MaxAxisValue()
            {
                Val = 0.99
            }),
                                                                  new Delete()
            {
                Val = false
            },
                                                                  new AxisPosition()
            {
                Val = new EnumValue <AxisPositionValues>(AxisPositionValues.Left)
            },
                                                                  majorGridlines1,
                                                                  new MajorTickMark()
            {
                Val = TickMarkValues.None
            },
                                                                  new MinorTickMark()
            {
                Val = TickMarkValues.None
            },
                                                                  new MajorUnit()
            {
                Val = 4.1666666666666713E-2D
            },
                                                                  new DocumentFormat.OpenXml.Drawing.Charts.NumberingFormat()
            {
                FormatCode = "h:mm;@", SourceLinked = false
            },
                                                                  new TickLabelPosition()
            {
                Val = new EnumValue <TickLabelPositionValues>
                          (TickLabelPositionValues.NextTo)
            }, new CrossingAxis()
            {
                Val = new UInt32Value(48650112U)
            },
                                                                  new Crosses()
            {
                Val = new EnumValue <CrossesValues>(CrossesValues.AutoZero)
            },
                                                                  new CrossBetween()
            {
                Val = new EnumValue <CrossBetweenValues>(CrossBetweenValues.Between)
            })));
        }
コード例 #19
0
        public ValueAxis Build()
        {
            var valueAxis = new ValueAxis();

            valueAxis.AxisId = new AxisId {
                Val = this.Options.Id
            };

            valueAxis.Scaling = new Scaling();

            valueAxis.Scaling.Orientation = new Orientation {
                Val = this.Options.Orientation
            };

            if (this.Options.MinMaxBounds.HasValue)
            {
                var minAxisValue = new MinAxisValue {
                    Val = this.Options.MinMaxBounds.Value.MinValue
                };

                var maxAxisValue = new MaxAxisValue {
                    Val = this.Options.MinMaxBounds.Value.MaxValue
                };

                valueAxis.Scaling.Append(minAxisValue);

                valueAxis.Scaling.Append(maxAxisValue);
            }

            if (this.Options.MinMaxUnits.HasValue)
            {
                var minorUnit = new MinorUnit {
                    Val = this.Options.MinMaxUnits.Value.MinValue
                };

                var majorUnit = new MajorUnit {
                    Val = this.Options.MinMaxUnits.Value.MaxValue
                };

                valueAxis.Append(minorUnit);

                valueAxis.Append(majorUnit);
            }

            valueAxis.Delete = new Delete {
                Val = false
            };

            valueAxis.AxisPosition = new AxisPosition {
                Val = this.Options.AxisPosition
            };

            if (this.Options.ShowMajorGridlines)
            {
                var majorGridlinesBuilder = new MajorGridlinesBuilder(this.Options.MajorGridlinesOptions);

                valueAxis.MajorGridlines = majorGridlinesBuilder.Build();
            }

            if (this.Options.HasNumberingFormat)
            {
                valueAxis.NumberingFormat = new NumberingFormat
                {
                    FormatCode   = this.Options.FormatCode,
                    SourceLinked = this.Options.SourceLinked
                };
            }

            valueAxis.MajorTickMark = new MajorTickMark {
                Val = this.Options.MajorTickMark
            };

            valueAxis.MinorTickMark = new MinorTickMark {
                Val = this.Options.MinorTickMark
            };

            valueAxis.TickLabelPosition = new TickLabelPosition {
                Val = this.Options.TickLabelPosition
            };

            if (this.Options.HasChartShapeProperties)
            {
                var chartShapePropertiesBuilder = new ChartShapePropertiesBuilder(this.Options.ChartShapePropertiesOptions);

                valueAxis.ChartShapeProperties = chartShapePropertiesBuilder.Build();
            }

            if (this.Options.IsTextStylish)
            {
                valueAxis.TextProperties = new TextProperties();
                valueAxis.TextProperties.BodyProperties = new BodyProperties()
                {
                    Rotation            = -60000000,
                    UseParagraphSpacing = true,
                    VerticalOverflow    = TextVerticalOverflowValues.Ellipsis,
                    Vertical            = TextVerticalValues.Horizontal,
                    Wrap         = TextWrappingValues.Square,
                    Anchor       = TextAnchoringTypeValues.Center,
                    AnchorCenter = true
                };
                valueAxis.TextProperties.ListStyle = new ListStyle();

                var para = new Paragraph();
                para.ParagraphProperties = new ParagraphProperties();

                var defrunprops = new DefaultRunProperties();
                defrunprops.FontSize  = 900;
                defrunprops.Bold      = false;
                defrunprops.Italic    = false;
                defrunprops.Underline = TextUnderlineValues.None;
                defrunprops.Strike    = TextStrikeValues.NoStrike;
                defrunprops.Kerning   = 1200;
                defrunprops.Baseline  = 0;

                var schclr = new SchemeColor()
                {
                    Val = SchemeColorValues.Text1
                };
                schclr.Append(new LuminanceModulation()
                {
                    Val = 65000
                });
                schclr.Append(new LuminanceOffset()
                {
                    Val = 35000
                });
                defrunprops.Append(new SolidFill()
                {
                    SchemeColor = schclr
                });

                defrunprops.Append(new LatinFont()
                {
                    Typeface = "+mn-lt"
                });
                defrunprops.Append(new EastAsianFont()
                {
                    Typeface = "+mn-ea"
                });
                defrunprops.Append(new ComplexScriptFont()
                {
                    Typeface = "+mn-cs"
                });

                para.ParagraphProperties.Append(defrunprops);
                para.Append(new EndParagraphRunProperties()
                {
                    Language = System.Globalization.CultureInfo.CurrentCulture.Name
                });

                valueAxis.TextProperties.Append(para);
            }

            valueAxis.CrossingAxis = new CrossingAxis {
                Val = this.Options.CrossingAxisVal
            };

            if (this.Options.Crosses.HasValue)
            {
                valueAxis.Append(new Crosses {
                    Val = this.Options.Crosses
                });
            }
            else if (this.Options.CrossesAtVal.HasValue)
            {
                valueAxis.Append(new CrossesAt()
                {
                    Val = this.Options.CrossesAtVal
                });
            }

            valueAxis.Append(new CrossBetween {
                Val = this.Options.CrossBetween
            });

            return(valueAxis);
        }
コード例 #20
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
        public static bool DoListReordering <T>(this ImGui gui, Rect moveHandle, Rect contents, T index, out T moveFrom, SchemeColor backgroundColor = SchemeColor.PureBackground, bool updateDraggingObject = true)
        {
            var result = false;

            moveFrom = index;
            if (!gui.InitiateDrag(moveHandle, contents, index, backgroundColor) && gui.action == ImGuiAction.MouseDrag && gui.ConsumeDrag(contents.Center, index))
            {
                moveFrom = gui.GetDraggingObject <T>();
                if (updateDraggingObject)
                {
                    gui.UpdateDraggingObject(index);
                }
                result = true;
            }
            return(result);
        }
コード例 #21
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
 public static bool BuildButton(this ImGui gui, Icon icon, SchemeColor normal = SchemeColor.None, SchemeColor over = SchemeColor.Grey, SchemeColor down = SchemeColor.None, float size = 1.5f)
 {
     using (gui.EnterGroup(new Padding(0.3f)))
         gui.BuildIcon(icon, size);
     return(gui.BuildButton(gui.lastRect, normal, over, down) == Event.Click);
 }
コード例 #22
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
        public static bool BuildRadioGroup(this ImGui gui, IReadOnlyList <string> options, int selected, out int newSelected, SchemeColor color = SchemeColor.None)
        {
            newSelected = selected;
            for (var i = 0; i < options.Count; i++)
            {
                if (BuildRadioButton(gui, options[i], selected == i, color))
                {
                    newSelected = i;
                }
            }

            return(newSelected != selected);
        }
コード例 #23
0
 public void Deconstruct(out Rect rect, out T data, out SchemeColor color)
 {
     rect  = this.rect;
     data  = this.data;
     color = this.color;
 }
コード例 #24
0
 public static SchemeColor GetTextColorFromBackgroundColor(SchemeColor color) => (SchemeColor)((int)color & ~3) + 2;
コード例 #25
0
        private void ReadAccentSchemeColors(SchemeColor schemeColor)
        {
            for (int i = 1; i <= 6; i++)
            {
                if (schemeColor.Val == "accent" + i)
                {
                    switch (i)
                    {
                    case 1:
                    {
                        Accent1Color c = slide.SlideLayoutPart.SlideMasterPart.
                                         ThemePart.Theme.ThemeElements.ColorScheme.Accent1Color;
                        if (c.RgbColorModelHex != null)
                        {
                            FontColor = "#" + c.RgbColorModelHex.Val.Value;
                        }
                    } break;

                    case 2:
                    {
                        Accent2Color c = slide.SlideLayoutPart.SlideMasterPart.
                                         ThemePart.Theme.ThemeElements.ColorScheme.Accent2Color;
                        if (c.RgbColorModelHex != null)
                        {
                            FontColor = "#" + c.RgbColorModelHex.Val.Value;
                        }
                    } break;

                    case 3:
                    {
                        Accent3Color c = slide.SlideLayoutPart.SlideMasterPart.
                                         ThemePart.Theme.ThemeElements.ColorScheme.Accent3Color;
                        if (c.RgbColorModelHex != null)
                        {
                            FontColor = "#" + c.RgbColorModelHex.Val.Value;
                        }
                    } break;

                    case 4:
                    {
                        Accent4Color c = slide.SlideLayoutPart.SlideMasterPart.
                                         ThemePart.Theme.ThemeElements.ColorScheme.Accent4Color;
                        if (c.RgbColorModelHex != null)
                        {
                            FontColor = "#" + c.RgbColorModelHex.Val.Value;
                        }
                    } break;

                    case 5:
                    {
                        Accent5Color c = slide.SlideLayoutPart.SlideMasterPart.
                                         ThemePart.Theme.ThemeElements.ColorScheme.Accent5Color;
                        if (c.RgbColorModelHex != null)
                        {
                            FontColor = "#" + c.RgbColorModelHex.Val.Value;
                        }
                    } break;

                    case 6:
                    {
                        Accent6Color c = slide.SlideLayoutPart.SlideMasterPart.
                                         ThemePart.Theme.ThemeElements.ColorScheme.Accent6Color;
                        if (c.RgbColorModelHex != null)
                        {
                            FontColor = "#" + c.RgbColorModelHex.Val.Value;
                        }
                    } break;

                    default: { } break;
                    }
                }
            }
        }
コード例 #26
0
        public static bool BuildFactorioObjectButton(this ImGui gui, Rect rect, FactorioObject obj, SchemeColor bgColor = SchemeColor.None, bool extendHeader = false)
        {
            var overColor = bgColor == SchemeColor.None ? SchemeColor.Grey : bgColor + 1;
            var evt       = gui.BuildButton(rect, bgColor, overColor, button: 0);

            if (evt == ImGuiUtils.Event.MouseOver && obj != null)
            {
                MainScreen.Instance.ShowTooltip(obj, gui, rect, extendHeader);
            }
            else if (evt == ImGuiUtils.Event.Click)
            {
                if (gui.actionParameter == SDL.SDL_BUTTON_MIDDLE && obj != null)
                {
                    if (obj is Goods goods && obj.IsAccessible())
                    {
                        NeverEnoughItemsPanel.Show(goods, null);
                    }
                    else
                    {
                        DependencyExplorer.Show(obj);
                    }
                }
                else if (gui.actionParameter == SDL.SDL_BUTTON_LEFT)
                {
                    return(true);
                }
            }
コード例 #27
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
 public static bool InitiateDrag <T>(this ImGui gui, Rect moveHandle, Rect contents, T index, SchemeColor backgroundColor = SchemeColor.PureBackground)
 {
     if (gui.action == ImGuiAction.MouseDown)
     {
         gui.ConsumeMouseDown(moveHandle);
     }
     if (gui.ShouldEnterDrag(moveHandle) || (gui.action == ImGuiAction.Build && gui.IsDragging(index)))
     {
         gui.SetDraggingArea(contents, index, backgroundColor);
         return(true);
     }
     return(false);
 }
コード例 #28
0
ファイル: ImGuiUtils.cs プロジェクト: andreybetty/yafc
        public static bool BuildCheckBox(this ImGui gui, string text, bool value, out bool newValue, SchemeColor color = SchemeColor.None)
        {
            using (gui.EnterRow())
            {
                gui.BuildIcon(value ? Icon.CheckBoxCheck : Icon.CheckBoxEmpty, 1.5f, color);
                gui.BuildText(text, Font.text, color: color);
            }

            if (gui.OnClick(gui.lastRect))
            {
                newValue = !value;
                return(true);
            }

            newValue = value;
            return(false);
        }
コード例 #29
0
        public bool BuildTextInput(string text, out string newText, string placeholder, FontFile.FontSize fontSize, bool delayed, Icon icon, Padding padding, RectAlignment alignment, SchemeColor color)
        {
            newText = text;
            Rect textRect, realTextRect;

            using (gui.EnterGroup(padding, RectAllocator.LeftRow))
            {
                var lineSize = gui.PixelsToUnits(fontSize.lineSize);
                if (icon != Icon.None)
                {
                    gui.BuildIcon(icon, lineSize, color + 3);
                }
                textRect = gui.RemainingRow(0.3f).AllocateRect(0, lineSize, RectAlignment.MiddleFullRow);
            }
            var boundingRect = gui.lastRect;
            var focused      = rect == boundingRect;

            if (focused && this.text == null)
            {
                this.text = text ?? "";
                SetCaret(0, this.text.Length);
            }

            switch (gui.action)
            {
            case ImGuiAction.MouseDown:
                if (gui.actionParameter != SDL.SDL_BUTTON_LEFT)
                {
                    break;
                }
                if (gui.ConsumeMouseDown(boundingRect))
                {
                    SetFocus(boundingRect, text ?? "");
                    GetTextParameters(this.text, textRect, fontSize, alignment, out _, out _, out _, out realTextRect);
                    SetCaret(FindCaretIndex(text, gui.mousePosition.X - realTextRect.X, fontSize, textRect.Width));
                }
                break;

            case ImGuiAction.MouseMove:
                if (focused && gui.actionParameter == SDL.SDL_BUTTON_LEFT)
                {
                    GetTextParameters(this.text, textRect, fontSize, alignment, out _, out _, out _, out realTextRect);
                    SetCaret(caret, FindCaretIndex(this.text, gui.mousePosition.X - realTextRect.X, fontSize, textRect.Width));
                }
                gui.ConsumeMouseOver(boundingRect, RenderingUtils.cursorCaret, false);
                break;

            case ImGuiAction.Build:
                var    textColor = color + 2;
                string textToBuild;
                if (focused)
                {
                    textToBuild = this.text;
                }
                else if (string.IsNullOrEmpty(text))
                {
                    textToBuild = placeholder;
                    textColor   = color + 3;
                }
                else
                {
                    textToBuild = text;
                }

                GetTextParameters(textToBuild, textRect, fontSize, alignment, out var cachedText, out var scale, out var textWidth, out realTextRect);
                if (cachedText != null)
                {
                    gui.DrawRenderable(realTextRect, cachedText, textColor);
                }

                if (focused)
                {
                    if (selectionAnchor != caret)
                    {
                        var left  = GetCharacterPosition(Math.Min(selectionAnchor, caret), fontSize, textWidth) * scale;
                        var right = GetCharacterPosition(Math.Max(selectionAnchor, caret), fontSize, textWidth) * scale;
                        gui.DrawRectangle(new Rect(left + realTextRect.X, realTextRect.Y, right - left, realTextRect.Height), SchemeColor.TextSelection);
                    }
                    else
                    {
                        if (nextCaretTimer <= Ui.time)
                        {
                            nextCaretTimer = Ui.time + 500;
                            caretVisible   = !caretVisible;
                        }
                        gui.SetNextRebuild(nextCaretTimer);
                        if (caretVisible)
                        {
                            var caretPosition = GetCharacterPosition(caret, fontSize, textWidth) * scale;
                            gui.DrawRectangle(new Rect(caretPosition + realTextRect.X - 0.05f, realTextRect.Y, 0.1f, realTextRect.Height), color + 2);
                        }
                    }
                }
                gui.DrawRectangle(boundingRect, color);
                break;
            }

            if (boundingRect == prevRect)
            {
                var changed = text != prevText;
                if (changed)
                {
                    newText = prevText;
                }
                prevRect = default;
                prevText = null;
                return(changed);
            }

            if (focused && !delayed && this.text != text)
            {
                newText = this.text;
                return(true);
            }

            return(false);
        }
コード例 #30
0
        /// <summary>
        /// Design settings for Y axis.
        /// </summary>
        public virtual ValueAxis SetValueAxis(PlotArea plotArea)
        {
            // Postavljanje Gridline-a.
            MajorGridlines       majorGridlines       = new MajorGridlines();
            ChartShapeProperties chartShapeProperties = new ChartShapeProperties();
            Outline     outline     = new Outline();
            SolidFill   solidFill   = new SolidFill();
            SchemeColor schemeColor = new SchemeColor()
            {
                Val = SchemeColorValues.Accent1
            };
            Alpha alpha = new Alpha()
            {
                Val = 10000
            };

            schemeColor.Append(alpha);
            solidFill.Append(schemeColor);
            outline.Append(solidFill);
            chartShapeProperties.Append(outline);
            majorGridlines.Append(chartShapeProperties);

            var valueAxis = plotArea.AppendChild <ValueAxis>(new ValueAxis(
                                                                 new AxisId()
            {
                Val = new UInt32Value(48672768u)
            },
                                                                 new Scaling(new Orientation()
            {
                Val = new EnumValue <DocumentFormat.OpenXml.Drawing.Charts.OrientationValues>(
                    DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax)
            }),
                                                                 new Delete()
            {
                Val = !ChartProperties.AxisY
            },
                                                                 new AxisPosition()
            {
                Val = new EnumValue <AxisPositionValues>(AxisPositionValues.Left)
            },
                                                                 majorGridlines,
                                                                 SetTitle(ChartProperties.AxisYTitle),
                                                                 new NumberingFormat()
            {
                FormatCode   = ChartProperties.AxisYFormatCode,
                SourceLinked = new BooleanValue(true)
            },
                                                                 new MajorTickMark()
            {
                Val = TickMarkValues.None
            },
                                                                 new MinorTickMark()
            {
                Val = TickMarkValues.None
            },
                                                                 new TickLabelPosition()
            {
                Val = new EnumValue <TickLabelPositionValues>
                          (TickLabelPositionValues.NextTo)
            }, new CrossingAxis()
            {
                Val = new UInt32Value(48650112U)
            },
                                                                 new Crosses()
            {
                Val = new EnumValue <CrossesValues>(CrossesValues.AutoZero)
            },
                                                                 new CrossBetween()
            {
                Val = new EnumValue <CrossBetweenValues>(CrossBetweenValues.Between)
            }));

            if (ChartProperties.AxisYFormatCategory == "Time")
            {
                valueAxis.Append(new MajorUnit()
                {
                    Val = getMajorUnitFromSeconds((int)yAxisValue)
                });
            }

            return(valueAxis);
        }