static GlobalData() { try { XmlDocument settings = new XmlDocument(); settings.Load("settings.xml"); CoefficientUndergroundTransfersWithinSameLine = double.Parse(settings.GetElementsByTagName("CoefficientUndergroundTransfersWithinSameLine")?[0].InnerText); CoefficientUndergroundTransfersWithinDifferentLines = double.Parse(settings.GetElementsByTagName("CoefficientUndergroundTransfersWithinDifferentLines")?[0].InnerText); CoefficientUndergroundToSurfaceTransfer = double.Parse(settings.GetElementsByTagName("CoefficientUndergroundToSurfaceTransfer")?[0].InnerText); MaximalDurationOfTransfer = int.Parse(settings.GetElementsByTagName("MaximalDurationOfTransfer")?[0].InnerText); AverageWalkingSpeed = double.Parse(settings.GetElementsByTagName("AverageWalkingSpeed")?[0].InnerText); } catch { CoefficientUndergroundTransfersWithinSameLine = 0.5; CoefficientUndergroundTransfersWithinDifferentLines = 2; CoefficientUndergroundToSurfaceTransfer = 3; MaximalDurationOfTransfer = 600; AverageWalkingSpeed = 0.9; DefaultBusColor = CPColor.FromHtml("#4A90E2"); DefaultTramColor = CPColor.FromHtml("#8B572A"); DefaultCableCarColor = CPColor.FromHtml("#FF8C00"); DefaultRailColor = CPColor.FromHtml("#006600"); DefaultSubwayColor = CPColor.FromHtml("#FFFF00"); DefaultShipColor = CPColor.FromHtml("#0033CC"); } }
public RouteInfoBasic(int id, string label, MeanOfTransport type, CPColor c, CPColor tc) { ID = id; Label = label; MeanOfTransport = type; Color = c; TextColor = tc; }
public virtual void Draw(Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor) { bool is_themecolor = backColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb() || backColor == Color.Empty ? true : false; CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor(backColor); Pen pen; switch (state) { case ButtonThemeState.Normal: case ButtonThemeState.Entered: case ButtonThemeState.Disabled: pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen(cpcolor.LightLight); g.DrawLine(pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2); g.DrawLine(pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y); pen = is_themecolor ? SystemPens.Control : ResPool.GetPen(backColor); g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3); g.DrawLine(pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1); pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen(cpcolor.Dark); g.DrawLine(pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2); g.DrawLine(pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3); pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen(cpcolor.DarkDark); g.DrawLine(pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1); g.DrawLine(pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2); break; case ButtonThemeState.Pressed: g.DrawRectangle(ResPool.GetPen(foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); bounds.Inflate(-1, -1); pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen(cpcolor.Dark); g.DrawRectangle(pen, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); break; case ButtonThemeState.Default: g.DrawRectangle(ResPool.GetPen(foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); bounds.Inflate(-1, -1); pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen(cpcolor.LightLight); g.DrawLine(pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2); g.DrawLine(pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y); pen = is_themecolor ? SystemPens.Control : ResPool.GetPen(backColor); g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3); g.DrawLine(pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1); pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen(cpcolor.Dark); g.DrawLine(pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2); g.DrawLine(pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3); pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen(cpcolor.DarkDark); g.DrawLine(pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1); g.DrawLine(pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2); break; } }
/// <summary> /// Initializes object. /// </summary> /// <param name="id">Route Info ID.</param> /// <param name="shortName">Short Name.</param> /// <param name="longName">Long Name.</param> /// <param name="type">Mean Of The Transport.</param> /// <param name="color">Color.</param> /// <param name="textColor">Text color.</param> public RouteInfo(int id, string shortName, string longName, RouteType type, string color, string textColor) { ID = id; ShortName = shortName; LongName = longName; Type = type; if (color == "") { switch (type) { case RouteType.Bus: Color = GlobalData.DefaultBusColor; break; case RouteType.CableCar: case RouteType.Funicular: case RouteType.Gondola: Color = GlobalData.DefaultCableCarColor; break; case RouteType.Rail: Color = GlobalData.DefaultRailColor; break; case RouteType.Ship: Color = GlobalData.DefaultShipColor; break; case RouteType.Subway: Color = GlobalData.DefaultSubwayColor; break; case RouteType.Tram: Color = GlobalData.DefaultTramColor; break; default: Color = CPColor.FromHtml("#000000"); break; } } else { Color = CPColor.FromHtml(color[0] == '#' ? color : "#" + color); } if (textColor == "") { TextColor = CPColor.White; } else { TextColor = CPColor.FromHtml(textColor[0] == '#' ? textColor : "#" + textColor); } }
private void DrawPolyline(IEnumerable <StopsBasic.StopBasic> stops, CPColor color) { Polyline line = new Polyline { StrokeColor = new Color((double)color.R / 255, (double)color.G / 255, (double)color.B / 255), StrokeWidth = 4 }; foreach (var stop in stops) { line.Positions.Add(new Xamarin.Forms.GoogleMaps.Position(stop.Latitude, stop.Longitude)); } map.Polylines.Add(line); }
public Departure(int stopID, bool outdated, string headsign, string lineLabel, string lineName, ulong lineColor, ulong lineTextColor, int meanOfTransport, ulong departureDateTime, List <KeyValuePair <ulong, int> > intStops) { StopID = stopID; Outdated = outdated; Headsign = headsign; LineLabel = lineLabel; LineName = lineName; LineColor = CPColor.FromHtml("#" + lineColor.ToString("X")); LineTextColor = CPColor.FromHtml("#" + lineTextColor.ToString("X")); MeanOfTransport = (MeanOfTransport)meanOfTransport; DepartureDateTime = new DateTime(1970, 1, 1).AddSeconds(departureDateTime); IntermediateStops = new List <IntermediateStop>(); foreach (var x in intStops) { IntermediateStops.Add(new IntermediateStop(new DateTime(1970, 1, 1).AddSeconds(x.Key), x.Value)); } }
public static string CreateSimplePolyline(this IEnumerable <StopsBasic.StopBasic> stops, JavascriptVariable <JavascriptObject> map, double strokeWeight, CPColor strokeColor, bool strokeDashed = false, int index = 0) { var arr = new JavascriptArray <JavascriptObject.Anonymous>(stops.Select(s => new JavascriptObject.Anonymous( new KeyValuePair <string, object>("lat", s.Latitude), new KeyValuePair <string, object>("lng", s.Longitude)))); var coordinates = new JavascriptVariable <JavascriptArray <JavascriptObject.Anonymous> >($"coordinates{ index }", arr); var lineSymbol = new JavascriptVariable <JavascriptObject.Anonymous>($"lineSymbol{ index }", new JavascriptObject.Anonymous( new KeyValuePair <string, object>("path", new JavascriptString("M 0,-1 0,1")), new KeyValuePair <string, object>("strokeOpacity", 1), new KeyValuePair <string, object>("scale", 4))); var polyline = strokeDashed ? new JavascriptVariable <JavascriptObject>($"polyline{ index }", new JavascriptObject("google.maps.Polyline", new JavascriptObject.Anonymous( new KeyValuePair <string, object>("path", coordinates.Name), new KeyValuePair <string, object>("strokeColor", new JavascriptString("#" + strokeColor.R.ToString("X2") + strokeColor.G.ToString("X2") + strokeColor.B.ToString("X2"))), new KeyValuePair <string, object>("strokeOpacity", 0), new KeyValuePair <string, object>("icons", new JavascriptArray <JavascriptObject.Anonymous> { new JavascriptObject.Anonymous( new KeyValuePair <string, object>("icon", lineSymbol.Name), new KeyValuePair <string, object>("offset", new JavascriptString("0")), new KeyValuePair <string, object>("repeat", new JavascriptString("20px"))) })))) : new JavascriptVariable <JavascriptObject>($"polyline{ index }", new JavascriptObject("google.maps.Polyline", new JavascriptObject.Anonymous( new KeyValuePair <string, object>("path", coordinates.Name), new KeyValuePair <string, object>("strokeColor", new JavascriptString("#" + strokeColor.R.ToString("X2") + strokeColor.G.ToString("X2") + strokeColor.B.ToString("X2"))), new KeyValuePair <string, object>("strokeOpacity", 1.0), new KeyValuePair <string, object>("strokeWeight", strokeWeight)))); return(coordinates.VariableAssignment() + Environment.NewLine + (strokeDashed ? (lineSymbol.VariableAssignment() + Environment.NewLine) : string.Empty) + polyline.VariableAssignment() + Environment.NewLine + polyline.Call(new JavascriptFunction.Call("setMap", map.Name))); }
public RoutesInfoBasic(System.IO.StreamReader sr) { var count = int.Parse(sr.ReadLine()); Items = new RouteInfoBasic[count]; var tokens = sr.ReadLine().Split(';'); // This could take some time but files are usually small. for (int i = 0; i < count; i++) { Items[i] = new RouteInfoBasic(int.Parse(tokens[5 * i]), tokens[5 * i + 1], (MeanOfTransport)int.Parse(tokens[5 * i + 2]), CPColor.FromHtml(tokens[5 * i + 3]), CPColor.FromHtml(tokens[5 * i + 4])); } sr.Dispose(); }
protected virtual int DrawTab(Graphics dc, System.Windows.Forms.TabPage page, System.Windows.Forms.TabControl tab, Rectangle bounds, bool is_selected) { Rectangle interior; int res = bounds.Width; dc.FillRectangle(ResPool.GetSolidBrush(tab.BackColor), bounds); if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) { // Separators if (tab.Appearance == TabAppearance.FlatButtons) { int width = bounds.Width; bounds.Width += (flatButtonSpacing - 2); res = bounds.Width; if (tab.Alignment == TabAlignment.Top || tab.Alignment == TabAlignment.Bottom) { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Etched, Border3DSide.Right); } else { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Etched, Border3DSide.Top); } bounds.Width = width; } if (is_selected) { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom); } else if (tab.Appearance != TabAppearance.FlatButtons) { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom); } } else { CPColor cpcolor = ResPool.GetCPColor(tab.BackColor); Pen light = ResPool.GetPen(cpcolor.LightLight); switch (tab.Alignment) { case TabAlignment.Top: dc.DrawLine(light, bounds.Left, bounds.Bottom - 1, bounds.Left, bounds.Top + 3); dc.DrawLine(light, bounds.Left, bounds.Top + 3, bounds.Left + 2, bounds.Top); dc.DrawLine(light, bounds.Left + 2, bounds.Top, bounds.Right - 3, bounds.Top); dc.DrawLine(SystemPens.ControlDark, bounds.Right - 2, bounds.Top + 1, bounds.Right - 2, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 2, bounds.Top + 1, bounds.Right - 1, bounds.Top + 2); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 1); break; case TabAlignment.Bottom: dc.DrawLine(light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 2); dc.DrawLine(light, bounds.Left, bounds.Bottom - 2, bounds.Left + 3, bounds.Bottom); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom); dc.DrawLine(SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDark, bounds.Right - 2, bounds.Bottom - 1, bounds.Right - 2, bounds.Top + 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 2, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 2); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Top + 1); break; case TabAlignment.Left: dc.DrawLine(light, bounds.Left - 2, bounds.Top, bounds.Right, bounds.Top); dc.DrawLine(light, bounds.Left, bounds.Top + 2, bounds.Left - 2, bounds.Top); dc.DrawLine(light, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - 2); dc.DrawLine(SystemPens.ControlDark, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDark, bounds.Left + 2, bounds.Bottom - 1, bounds.Right, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Right, bounds.Bottom); break; default: // TabAlignment.Right dc.DrawLine(light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top); dc.DrawLine(light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3); dc.DrawLine(SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom); break; } } interior = new Rectangle(bounds.Left + focusRectSpacing.X + borderThickness.Left, bounds.Top + focusRectSpacing.Y + +borderThickness.Top, bounds.Width - (focusRectSpacing.X * 2) - borderThickness.Width + 1, bounds.Height - (focusRectSpacing.Y * 2) - borderThickness.Height); if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) { if (tab.Alignment == TabAlignment.Left) { dc.TranslateTransform(bounds.Left, bounds.Bottom); dc.RotateTransform(-90); dc.DrawString(page.Text, page.Font, SystemBrushes.ControlText, tab.Padding.X - 2, // drawstring adds some extra unwanted leading spaces, so trimming tab.Padding.Y, defaultFormatting); dc.ResetTransform(); } else if (tab.Alignment == TabAlignment.Right) { dc.TranslateTransform(bounds.Right, bounds.Top); dc.RotateTransform(90); dc.DrawString(page.Text, page.Font, SystemBrushes.ControlText, tab.Padding.X - 2, // drawstring adds some extra unwanted leading spaces, so trimming tab.Padding.Y, defaultFormatting); dc.ResetTransform(); } else { Rectangle str_rect = interior; if (tab.ImageList != null && page.ImageIndex >= 0 && page.ImageIndex < tab.ImageList.Images.Count) { int image_y = interior.Y + (interior.Height - tab.ImageList.ImageSize.Height) / 2; tab.ImageList.Draw(dc, new Point(interior.X, image_y), page.ImageIndex); str_rect.X += tab.ImageList.ImageSize.Width + 2; str_rect.Width -= tab.ImageList.ImageSize.Width + 2; } dc.DrawString(page.Text, page.Font, SystemBrushes.ControlText, str_rect, defaultFormatting); } } else if (page.Text != null) { DrawItemState state = DrawItemState.None; if (page == tab.SelectedTab) { state |= DrawItemState.Selected; } DrawItemEventArgs e = new DrawItemEventArgs(dc, tab.Font, bounds, tab.IndexForTabPage(page), state, page.ForeColor, page.BackColor); tab.OnDrawItemInternal(e); return(res); } if (page.Parent.Focused && is_selected && tab.ShowFocusCues) { interior.Width -= 1; ThemeEngine.Current.CPDrawFocusRectangle(dc, interior, tab.ForeColor, tab.BackColor); } return(res); }
protected virtual int DrawTab(Graphics dc, System.Windows.Forms.TabPage page, System.Windows.Forms.TabControl tab, Rectangle_ bounds, bool is_selected) { Rectangle_ interior; int res = bounds.Width; dc.FillRectangle(ResPool.GetSolidBrush(tab.BackColor), bounds); if (tab.Appearance == TabAppearance.Buttons || tab.Appearance == TabAppearance.FlatButtons) { // Separators if (tab.Appearance == TabAppearance.FlatButtons) { int width = bounds.Width; bounds.Width += (flatButtonSpacing - 2); res = bounds.Width; if (tab.Alignment == TabAlignment.Top || tab.Alignment == TabAlignment.Bottom) { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Etched, Border3DSide.Right); } else { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Etched, Border3DSide.Top); } bounds.Width = width; } if (is_selected) { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Sunken, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom); } else if (tab.Appearance != TabAppearance.FlatButtons) { ThemeEngine.Current.CPDrawBorder3D(dc, bounds, Border3DStyle.Raised, Border3DSide.Left | Border3DSide.Right | Border3DSide.Top | Border3DSide.Bottom); } } else { CPColor cpcolor = ResPool.GetCPColor(tab.BackColor); Pen light = ResPool.GetPen(cpcolor.LightLight); switch (tab.Alignment) { case TabAlignment.Top: dc.DrawLine(light, bounds.Left, bounds.Bottom - 1, bounds.Left, bounds.Top + 3); dc.DrawLine(light, bounds.Left, bounds.Top + 3, bounds.Left + 2, bounds.Top); dc.DrawLine(light, bounds.Left + 2, bounds.Top, bounds.Right - 3, bounds.Top); dc.DrawLine(SystemPens.ControlDark, bounds.Right - 2, bounds.Top + 1, bounds.Right - 2, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 2, bounds.Top + 1, bounds.Right - 1, bounds.Top + 2); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top + 2, bounds.Right - 1, bounds.Bottom - 1); break; case TabAlignment.Bottom: dc.DrawLine(light, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom - 2); dc.DrawLine(light, bounds.Left, bounds.Bottom - 2, bounds.Left + 3, bounds.Bottom); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Left + 3, bounds.Bottom, bounds.Right - 3, bounds.Bottom); dc.DrawLine(SystemPens.ControlDark, bounds.Left + 3, bounds.Bottom - 1, bounds.Right - 3, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDark, bounds.Right - 2, bounds.Bottom - 1, bounds.Right - 2, bounds.Top + 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 2, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 2); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Bottom - 2, bounds.Right - 1, bounds.Top + 1); break; case TabAlignment.Left: dc.DrawLine(light, bounds.Left - 2, bounds.Top, bounds.Right, bounds.Top); dc.DrawLine(light, bounds.Left, bounds.Top + 2, bounds.Left - 2, bounds.Top); dc.DrawLine(light, bounds.Left, bounds.Top + 2, bounds.Left, bounds.Bottom - 2); dc.DrawLine(SystemPens.ControlDark, bounds.Left, bounds.Bottom - 2, bounds.Left + 2, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDark, bounds.Left + 2, bounds.Bottom - 1, bounds.Right, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Left + 2, bounds.Bottom, bounds.Right, bounds.Bottom); break; default: // TabAlignment.Right dc.DrawLine(light, bounds.Left, bounds.Top, bounds.Right - 3, bounds.Top); dc.DrawLine(light, bounds.Right - 3, bounds.Top, bounds.Right, bounds.Top + 3); dc.DrawLine(SystemPens.ControlDark, bounds.Right - 1, bounds.Top + 1, bounds.Right - 1, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDark, bounds.Left, bounds.Bottom - 1, bounds.Right - 2, bounds.Bottom - 1); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Right, bounds.Top + 3, bounds.Right, bounds.Bottom - 3); dc.DrawLine(SystemPens.ControlDarkDark, bounds.Left, bounds.Bottom, bounds.Right - 3, bounds.Bottom); break; } } Point_ padding = tab.Padding; interior = new Rectangle_(bounds.Left + padding.X - 1, // substract a little offset bounds.Top + padding.Y, bounds.Width - (padding.X * 2), bounds.Height - (padding.Y * 2)); if (tab.DrawMode == TabDrawMode.Normal && page.Text != null) { if (tab.Alignment == TabAlignment.Left) { dc.TranslateTransform(bounds.Left, bounds.Bottom); dc.RotateTransform(-90); dc.DrawString(page.Text, tab.Font, SystemBrushes.ControlText, tab.Padding.X - 2, // drawstring adds some extra unwanted leading spaces, so trimming tab.Padding.Y, defaultFormatting); dc.ResetTransform(); } else if (tab.Alignment == TabAlignment.Right) { dc.TranslateTransform(bounds.Right, bounds.Top); dc.RotateTransform(90); dc.DrawString(page.Text, tab.Font, SystemBrushes.ControlText, tab.Padding.X - 2, // drawstring adds some extra unwanted leading spaces, so trimming tab.Padding.Y, defaultFormatting); dc.ResetTransform(); } else { Rectangle_ str_rect = interior; if (is_selected) { // Reduce the interior Size_ to match the inner Size_ of non-selected tabs str_rect.X += selectedTabDelta.X; str_rect.Y += selectedTabDelta.Y; str_rect.Width -= selectedTabDelta.Width; str_rect.Height -= selectedTabDelta.Height; str_rect.Y -= selectedTabDelta.Y; // Move up the text / image of the selected tab } if (tab.ImageList != null && page.ImageIndex >= 0 && page.ImageIndex < tab.ImageList.Images.Count) { int image_x; if (tab.SizeMode != TabSizeMode.Fixed) { image_x = str_rect.X; } else { image_x = str_rect.X + (str_rect.Width - tab.ImageList.ImageSize.Width) / 2; if (page.Text != null) { SizeF_ textSize = dc.MeasureString(page.Text, page.Font, str_rect.Size); image_x -= (int)(textSize.Width / 2); } } int image_y = str_rect.Y + (str_rect.Height - tab.ImageList.ImageSize.Height) / 2; tab.ImageList.Draw(dc, new Point_(image_x, image_y), page.ImageIndex); str_rect.X += tab.ImageList.ImageSize.Width + 2; str_rect.Width -= tab.ImageList.ImageSize.Width + 2; } dc.DrawString(page.Text, tab.Font, SystemBrushes.ControlText, str_rect, defaultFormatting); } } else if (page.Text != null) { DrawItemState state = DrawItemState.None; if (page == tab.SelectedTab) { state |= DrawItemState.Selected; } DrawItemEventArgs e = new DrawItemEventArgs(dc, tab.Font, bounds, tab.IndexForTabPage(page), state, page.ForeColor, page.BackColor); tab.OnDrawItemInternal(e); return(res); } // TabControl ignores the value of ShowFocusCues if (page.Parent.Focused && is_selected) { Rectangle_ focus_rect = bounds; focus_rect.Inflate(-2, -2); ThemeEngine.Current.CPDrawFocusRectangle(dc, focus_rect, tab.BackColor, tab.ForeColor); } return(res); }
public virtual void DrawFlat(Graphics g, Rectangle bounds, ButtonThemeState state, Color backColor, Color foreColor, FlatButtonAppearance appearance) { bool is_themecolor = backColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb() || backColor == Color.Empty ? true : false; CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor(backColor); Pen pen; switch (state) { case ButtonThemeState.Normal: case ButtonThemeState.Disabled: // This will just use the BackColor break; case ButtonThemeState.Entered: case ButtonThemeState.Default | ButtonThemeState.Entered: if (appearance.MouseOverBackColor != Color.Empty) { g.FillRectangle(ResPool.GetSolidBrush(appearance.MouseOverBackColor), bounds); } else { g.FillRectangle(ResPool.GetSolidBrush(ChangeIntensity(backColor, .9F)), bounds); } break; case ButtonThemeState.Pressed: if (appearance.MouseDownBackColor != Color.Empty) { g.FillRectangle(ResPool.GetSolidBrush(appearance.MouseDownBackColor), bounds); } else { g.FillRectangle(ResPool.GetSolidBrush(ChangeIntensity(backColor, .95F)), bounds); } break; case ButtonThemeState.Default: if (appearance.CheckedBackColor != Color.Empty) { g.FillRectangle(ResPool.GetSolidBrush(appearance.CheckedBackColor), bounds); } break; } if (appearance.BorderColor == Color.Empty) { pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetSizedPen(cpcolor.DarkDark, appearance.BorderSize); } else { pen = ResPool.GetSizedPen(appearance.BorderColor, appearance.BorderSize); } bounds.Width -= 1; bounds.Height -= 1; if (appearance.BorderSize > 0) { g.DrawRectangle(pen, bounds); } }
public virtual bool CanSellCP(CPTier tier, CPColor color) { return(false); }
public virtual bool HasUnlockedTier(CPTier tier, CPColor color) { return(false); }