public FrmGenericSettings(dynamic settingsObject, string title, TitleColor style) { InitializeComponent(); _settings = settingsObject; this.Text = title; gridSettings.SelectedObject = _settings; }
/// <summary> /// Override private render method /// <inheritdoc cref="PlotModel.RenderTitle"/> /// </summary> /// <param name="rc"></param> private void RenderTitle(IRenderContext rc) { OxySize?maxSize = null; if (ClipTitle) { maxSize = new OxySize(TitleArea.Width * TitleClippingLength, double.MaxValue); } var titleSize = rc.MeasureText(Title, ActualTitleFont, TitleFontSize, TitleFontWeight); var x = (TitleArea.Left + TitleArea.Right) * 0.5; var y = TitleArea.Top; if (!string.IsNullOrEmpty(Title)) { rc.SetToolTip(TitleToolTip); rc.DrawMathText( new ScreenPoint(x, y), Title, TitleColor.GetActualColor(TextColor), ActualTitleFont, TitleFontSize, TitleFontWeight, 0, HorizontalAlignment.Center, VerticalAlignment.Top, maxSize); y += titleSize.Height + SubTitleMargin; rc.SetToolTip(null); } if (!string.IsNullOrEmpty(Subtitle)) { rc.DrawMathText( new ScreenPoint(x, y), Subtitle, SubtitleColor.GetActualColor(TextColor), ActualSubtitleFont, SubtitleFontSize, SubtitleFontWeight, 0, HorizontalAlignment.Center, VerticalAlignment.Top, maxSize); } }
/// <summary> /// Synchronize properties in the internal Plot model /// </summary> private void SynchronizeProperties() { var m = internalModel; m.PlotType = PlotType; m.PlotMargins = PlotMargins.ToOxyThickness(); m.Padding = Padding.ToOxyThickness(); m.TitlePadding = TitlePadding; m.Culture = Culture; m.DefaultColors = DefaultColors.Select(c => c.ToOxyColor()).ToArray(); m.DefaultFont = DefaultFont; m.DefaultFontSize = DefaultFontSize; m.Title = Title; m.TitleColor = TitleColor.ToOxyColor(); m.TitleFont = TitleFont; m.TitleFontSize = TitleFontSize; m.TitleFontWeight = (int)TitleFontWeight; m.TitleToolTip = TitleToolTip; m.Subtitle = Subtitle; m.SubtitleColor = SubtitleColor.ToOxyColor(); m.SubtitleFont = SubtitleFont; m.SubtitleFontSize = SubtitleFontSize; m.SubtitleFontWeight = (int)SubtitleFontWeight; m.TextColor = TextColor.ToOxyColor(); m.SelectionColor = SelectionColor.ToOxyColor(); m.RenderingDecorator = RenderingDecorator; m.AxisTierDistance = AxisTierDistance; m.IsLegendVisible = IsLegendVisible; m.PlotAreaBackground = PlotAreaBackground.ToOxyColor(); m.PlotAreaBorderColor = PlotAreaBorderColor.ToOxyColor(); m.PlotAreaBorderThickness = PlotAreaBorderThickness.ToOxyThickness(); }
public override View GetView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = DroidFactory.MainActivity.LayoutInflater.Inflate(Resource.Layout.ab_main_view, parent, false); convertView.Tag = holder = new ViewHolder { Title = convertView.FindViewById <TextView>(Resource.Id.ab_basemaps_title), Subtitle = convertView.FindViewById <TextView>(Resource.Id.ab_basemaps_subtitle), }; } else { holder = (ViewHolder)convertView.Tag; } var titleView = PaneManager.Instance.FromNavContext(Pane.Master, position)?.CurrentView as IView; var title = titleView?.Title; var stack = PaneManager.Instance.FromNavContext(Pane.Detail, position); titleView = stack?.CurrentView as IView; if (titleView != null && stack.FindPane() == Pane.Detail && !string.IsNullOrWhiteSpace(titleView.Title)) { title += " | " + titleView.Title; } holder.Title.Text = string.IsNullOrEmpty(title) ? TabItems.ElementAtOrDefault(position)?.Title ?? Title : title; holder.Subtitle.Text = TabItems.ElementAtOrDefault(position)?.Title ?? string.Empty; if (!TitleColor.IsDefaultColor) { holder.Title.SetTextColor(TitleColor.ToColor()); holder.Subtitle.SetTextColor(TitleColor.ToColor()); } holder.Title.Visibility = string.IsNullOrWhiteSpace(holder.Title.Text) ? ViewStates.Invisible : ViewStates.Visible; holder.Subtitle.Visibility = string.IsNullOrWhiteSpace(holder.Subtitle.Text) ? ViewStates.Gone : ViewStates.Visible; return(convertView); }
/// <summary> /// return a hash code /// </summary> /// <returns>hashcode as <see cref="int" /></returns> public override int GetHashCode() { var hashCode = -2087474320; hashCode = hashCode * -1521134295 + HeaderFullWidth.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderFullHeight.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderFocusWidth.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderFocusHeight.GetHashCode(); hashCode = hashCode * -1521134295 + AvatarShape.GetHashCode(); #if NETSTANDARD2_0 hashCode = hashCode * -1521134295 + BackgroundColor.GetHashCode(); #else hashCode = hashCode * -1521134295 + BackgroundColor.GetHashCode(); #endif hashCode = hashCode * -1521134295 + BodyFont.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderBounds.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderImage.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderImageFocused.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderImageScaled.GetHashCode(); hashCode = hashCode * -1521134295 + HeaderStretch.GetHashCode(); #if NETSTANDARD2_0 hashCode = hashCode * -1521134295 + LinkColor.GetHashCode(); #else hashCode = hashCode * -1521134295 + LinkColor.GetHashCode(); #endif hashCode = hashCode * -1521134295 + ShowAvatar.GetHashCode(); hashCode = hashCode * -1521134295 + ShowDescription.GetHashCode(); hashCode = hashCode * -1521134295 + ShowHeaderImage.GetHashCode(); hashCode = hashCode * -1521134295 + ShowTitle.GetHashCode(); #if NETSTANDARD2_0 hashCode = hashCode * -1521134295 + TitleColor.GetHashCode(); #else hashCode = hashCode * -1521134295 + TitleColor.GetHashCode(); #endif hashCode = hashCode * -1521134295 + TitleFont.GetHashCode(); hashCode = hashCode * -1521134295 + TitleFontWeight.GetHashCode(); return(hashCode); }
/// <summary> /// compare this object with another /// </summary> /// <param name="obj">Object to be equals</param> /// <returns></returns> public override bool Equals(object obj) { return(obj is TrailTheme theme && HeaderFullWidth == theme.HeaderFullWidth && HeaderFullHeight == theme.HeaderFullHeight && HeaderFocusWidth == theme.HeaderFocusWidth && HeaderFocusHeight == theme.HeaderFocusHeight && AvatarShape == theme.AvatarShape && #if NETSTANDARD2_0 BackgroundColor.Equals(theme.BackgroundColor) && #else BackgroundColor == theme.BackgroundColor && #endif BodyFont == theme.BodyFont && HeaderBounds == theme.HeaderBounds && HeaderImage == theme.HeaderImage && HeaderImageFocused == theme.HeaderImageFocused && HeaderImageScaled == theme.HeaderImageScaled && HeaderStretch == theme.HeaderStretch && #if NETSTANDARD2_0 LinkColor.Equals(LinkColor) && #else LinkColor == theme.LinkColor && #endif ShowAvatar == theme.ShowAvatar && ShowDescription == theme.ShowDescription && ShowHeaderImage == theme.ShowHeaderImage && ShowTitle == theme.ShowTitle && #if NETSTANDARD2_0 TitleColor.Equals(TitleColor) && #else TitleColor == theme.TitleColor && #endif TitleFont == theme.TitleFont && TitleFontWeight == theme.TitleFontWeight); }
public override void UpdateSvg(XmlDocument document, IEnumerable items) { try { var elements = (IEnumerable <Tuple <int, string> >)items; var offset = 25; var previousOffset = -1; var previousSpace = -1; var root = document.DocumentElement.GetElementsByTagName("g").Cast <XmlElement>().LastOrDefault(); var donutNode = root.GetElementsByTagName("circle").Cast <XmlElement>() .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "donut-hole"); var donutAttr = donutNode.Attributes; donutAttr["fill"].Value = FillColor.ToHex(); var ringNode = root.GetElementsByTagName("circle").Cast <XmlElement>() .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "donut-ring"); var ringAttr = ringNode.Attributes; ringAttr["stroke-width"].Value = StrokeWidth.ToString(); ringAttr["stroke"].Value = RingColor.ToHex(); var segmentNodeToCopy = root.GetElementsByTagName("circle").Cast <XmlElement>() .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "donut-segment"); var centerTextNode = root.GetElementsByTagName("text").Cast <XmlElement>() .FirstOrDefault(x => x.HasAttribute("class") && x.Attributes["class"].Value == "center-text"); centerTextNode.InnerText = CharTitle; var textAttr = centerTextNode.Attributes; textAttr["fill"].Value = TitleColor.ToHex(); foreach (var el in elements) { if (el.Item1 < 0) { continue; } var newnode = segmentNodeToCopy.CloneNode(true); var attr = newnode.Attributes; attr["stroke-width"].Value = StrokeWidth.ToString(); attr["stroke"].Value = el.Item2; var spaceDash = 100 - el.Item1; attr["stroke-dasharray"].Value = $"{ el.Item1 }, { spaceDash }"; var newOffset = (previousOffset < 0) ? offset : (previousOffset + previousSpace); if (newOffset > 100) { newOffset -= 100; } attr["stroke-dashoffset"].Value = newOffset.ToString(); root.InsertAfter(newnode, root.LastChild); previousOffset = newOffset; previousSpace = spaceDash; } root.RemoveChild(segmentNodeToCopy); } catch (InvalidCastException ex) { throw new ItemsSourceException("ItemsSource for Donut chart must to be a collection of values and colors IEnumerable<Tuple<int,string>>", ex); } }
/// <summary> /// Synchronize properties in the internal Plot model /// </summary> private void SynchronizeProperties() { var m = internalModel; m.PlotType = PlotType; m.PlotMargins = PlotMargins.ToOxyThickness(); m.Padding = Padding.ToOxyThickness(); m.TitlePadding = TitlePadding; m.Culture = Culture; m.DefaultColors = DefaultColors.Select(c => c.ToOxyColor()).ToArray(); m.DefaultFont = DefaultFont; m.DefaultFontSize = DefaultFontSize; m.Title = Title; m.TitleColor = TitleColor.ToOxyColor(); m.TitleFont = TitleFont; m.TitleFontSize = TitleFontSize; m.TitleFontWeight = (int)TitleFontWeight; m.TitleToolTip = TitleToolTip; m.Subtitle = Subtitle; m.SubtitleColor = SubtitleColor.ToOxyColor(); m.SubtitleFont = SubtitleFont; m.SubtitleFontSize = SubtitleFontSize; m.SubtitleFontWeight = (int)SubtitleFontWeight; m.TextColor = TextColor.ToOxyColor(); m.SelectionColor = SelectionColor.ToOxyColor(); m.RenderingDecorator = RenderingDecorator; m.AxisTierDistance = AxisTierDistance; m.IsLegendVisible = IsLegendVisible; m.LegendTextColor = LegendTextColor.ToOxyColor(); m.LegendTitle = LegendTitle; m.LegendTitleColor = LegendTitleColor.ToOxyColor(); m.LegendTitleFont = LegendTitleFont; m.LegendTitleFontSize = LegendTitleFontSize; m.LegendTitleFontWeight = (int)LegendTitleFontWeight; m.LegendFont = LegendFont; m.LegendFontSize = LegendFontSize; m.LegendFontWeight = (int)LegendFontWeight; m.LegendSymbolLength = LegendSymbolLength; m.LegendSymbolMargin = LegendSymbolMargin; m.LegendPadding = LegendPadding; m.LegendColumnSpacing = LegendColumnSpacing; m.LegendItemSpacing = LegendItemSpacing; m.LegendLineSpacing = LegendLineSpacing; m.LegendMargin = LegendMargin; m.LegendMaxHeight = LegendMaxHeight; m.LegendMaxWidth = LegendMaxWidth; m.LegendBackground = LegendBackground.ToOxyColor(); m.LegendBorder = LegendBorder.ToOxyColor(); m.LegendBorderThickness = LegendBorderThickness; m.LegendPlacement = LegendPlacement; m.LegendPosition = LegendPosition; m.LegendOrientation = LegendOrientation; m.LegendItemOrder = LegendItemOrder; m.LegendItemAlignment = LegendItemAlignment.ToHorizontalAlignment(); m.LegendSymbolPlacement = LegendSymbolPlacement; m.PlotAreaBackground = PlotAreaBackground.ToOxyColor(); m.PlotAreaBorderColor = PlotAreaBorderColor.ToOxyColor(); m.PlotAreaBorderThickness = PlotAreaBorderThickness.ToOxyThickness(); }
public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect) { DrawBackground(canvas, rect); LastRect = rect; // 0.65 RadiusAll = Math.Min(rect.Width, rect.Height - textHeight) / 2.0; if (IsTitleOnTop) { Center = new NGraphics.Point(rect.Center.X, rect.Center.Y + textHeight); } else { Center = new NGraphics.Point(rect.Center.X, rect.Center.Y - textHeight); } double pullLength = RadiusAll.Value * PullRatio; double radius = RadiusAll.Value - (RadiusAll.Value * PullRatio); double sumRadian = StartRadian; foreach (var eachSegment in ListItems) { sumRadian = eachSegment.DrawSegment(canvas, rect.Center, radius, sumRadian, pullLength, Font, TextColor, IsNameVisible, PercentColor, IsPercentVisible, ValueColor, IsValueVisible); } Rect rectText; if (IsTitleOnTop) { rectText = new Rect(rect.Center.X, rect.Center.Y - RadiusAll.Value - textHeight / 4.0, 20, 20); } else { rectText = new Rect(rect.Center.X, rect.Center.Y + RadiusAll.Value + textHeight / 4.0, 20, 20); } canvas.DrawText(Title ?? "", rectText, new NGraphics.Font(), NGraphics.TextAlignment.Center, new Pen(TitleColor.ToCross()), new SolidBrush(TitleColor.ToCross())); }
public static void ShowGenericSettingsGUI(dynamic settingsObject, string title, TitleColor style = TitleColor.Pink) { ShowGUI(new FrmGenericSettings(settingsObject, title, style)); }