private void Serialize(PieChart control, DataStore data) { SerializeDefault(control); legend = control.LegendLocation; InnerRadius = control.InnerRadius; chdata = new ChartData(control.Series); ControlDef.Serialize(control); brush.Serialize(control, control.Background, data); Hoverable = control.Hoverable; DataTooltipV = control.DataTooltip.Visibility; PushOut = control.HoverPushOut; LegendFontSize = control.ChartLegend.FontSize; TooltipFontSize = control.DataTooltip.FontSize; disableAnimations = control.DisableAnimations; LegendColor = ((SolidColorBrush)control.ChartLegend.Foreground).Color; LegendBullet = ((DefaultLegend)control.ChartLegend).BulletSize; TooltipBullet = ((DefaultTooltip)control.DataTooltip).BulletSize; if (control.SeriesColors != null) { SeriesColors = control.SeriesColors; } else { SeriesColors = null; } }
private void Serialize(CartesianChart control, DataStore data) { if (control.Series.Count > 0) { if (control.Series[0] is ColumnSeries) { CarType = ChartType.CartesianChart_Type.ColumnChart; } else if (control.Series[0] is StackedAreaSeries) { CarType = ChartType.CartesianChart_Type.StackedAreaChart; } else if (control.Series[0] is LineSeries) { CarType = ChartType.CartesianChart_Type.LineChart; } else if (control.Series[0] is RowSeries) { CarType = ChartType.CartesianChart_Type.RowChart; } else if (control.Series[0] is StackedColumnSeries) { CarType = ChartType.CartesianChart_Type.StackedColumnChart; } else if (control.Series[0] is StackedRowSeries) { CarType = ChartType.CartesianChart_Type.StackedRowChart; } else if (control.Series[0] is StepLineSeries) { CarType = ChartType.CartesianChart_Type.StepLineChart; } } SerializeDefault(control); legend = control.LegendLocation; chdata = new ChartData(control.Series); brush.Serialize(control, control.Background, data); axisSerializer.Serialize(control); Hoverable = control.Hoverable; DataTooltipV = control.DataTooltip.Visibility; LegendFontSize = control.ChartLegend.FontSize; TooltipFontSize = control.DataTooltip.FontSize; disableAnimations = control.DisableAnimations; LegendBullet = ((DefaultLegend)control.ChartLegend).BulletSize; TooltipBullet = ((DefaultTooltip)control.DataTooltip).BulletSize; LegendColor = ((SolidColorBrush)control.ChartLegend.Foreground).Color; if (control.SeriesColors != null) { SeriesColors = control.SeriesColors; } else { SeriesColors = null; } }
public static ColorsCollection ToColorsCollection(this Color[] colors) { ColorsCollection colorsCollection = new ColorsCollection(); Color[] colorArray = colors; colorsCollection.AddRange(colorArray); return colorsCollection; }
public ColorComplexGamePlayViewModel(Difficulty difficulty, ResumeModel resume) : base(GameType.ColourComplex, difficulty, resume) { GameModel = new ComplexColorGame(); Colors = ColorsCollection.ColorsArray(); PlayColors = new ComplexColor[DifficultySetting.MaxSelectable]; for (int i = 0; i < DifficultySetting.MaxSelectable; i++) { PlayColors[i] = Colors[i]; } IsResume(); }
internal static ColorsCollection getColours() { ColorsCollection result = new ColorsCollection(); Color c1 = new Color { A = 255, R = 100, G = 130, B = 185 }; //A1-A3 (Blue tone) Color c2 = new Color { A = 255, R = 180, G = 150, B = 100 }; //A4 (Brown tone) Color c3 = new Color { A = 255, R = 164, G = 180, B = 100 }; //A5 (0) (Yellowish) Color c4 = new Color { A = 255, R = 210, G = 210, B = 60 }; //A5 Global (Bright yellow) Color c5 = new Color { A = 255, R = 150, G = 150, B = 150 }; //B (0) Color c6 = new Color { A = 255, R = 190, G = 88, B = 90 }; //C (Red) Color c7 = new Color { A = 255, R = 200, G = 60, B = 60 }; //C Global (Red) Color c8 = new Color { A = 210, R = 210, G = 205, B = 60 }; //D (Blue) Color c9 = new Color { A = 255, R = 50, G = 50, B = 50 }; //Added Color c10 = new Color { A = 255, R = 160, G = 100, B = 175 }; //Extra result.Add(c1); result.Add(c2); result.Add(c3); result.Add(c4); result.Add(c5); result.Add(c6); result.Add(c7); result.Add(c8); result.Add(c9); result.Add(c10); return(result); }
public MainWindowViewModel() { List <WorkTime> workTimes = new List <WorkTime> { new WorkTime { Date = DateTime.Today.AddDays(-3) , ActualTime = 900 } , new WorkTime { Date = DateTime.Today.AddDays(-3) , ActualTime = 7200 } , new WorkTime { Date = DateTime.Today.AddDays(-2) , ActualTime = 1800 } , new WorkTime { Date = DateTime.Today.AddDays(-2) , ActualTime = 6000 } , new WorkTime { Date = DateTime.Today.AddDays(-2) , ActualTime = 7200 } }; Series = new SeriesCollection(); Series.AddRange(workTimes.GroupBy(x => x.Date) .Select(x => new PieSeries { Title = x.Key.ToString("yyyy/MM/dd") , Values = new ChartValues <int>(new[] { x.Sum(v => v.ActualTime) }) , DataLabels = true , LabelPoint = p => $"{p.SeriesView.Title}{Environment.NewLine} {p.Participation:P}" , FontSize = 18.0d })); SeriesColors = new ColorsCollection(); SeriesColors.AddRange(new[] { "#FFE65100", "#FFEF6C00", "#FFF57C00", "#FFFB8C00", "#FFFF9800" } .Select(System.Windows.Media.ColorConverter.ConvertFromString) .OfType <System.Windows.Media.Color>() .ToList()); }
/// <summary> /// Initializes a new instance of Chart class /// </summary> protected Chart() { Canvas = new Canvas(); Content = Canvas; DrawMargin = new Canvas { ClipToBounds = true }; Canvas.Children.Add(DrawMargin); TooltipTimeoutTimer = new DispatcherTimer(); SetCurrentValue(MinHeightProperty, 50d); SetCurrentValue(MinWidthProperty, 80d); SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(300)); SetCurrentValue(TooltipTimeoutProperty, TimeSpan.FromMilliseconds(800)); SetCurrentValue(AxisXProperty, new AxesCollection()); SetCurrentValue(AxisYProperty, new AxesCollection()); SetCurrentValue(ChartLegendProperty, new DefaultLegend()); SetCurrentValue(DataTooltipProperty, new DefaultTooltip()); var colors = new ColorsCollection { Color.FromRgb(33, 149, 242), Color.FromRgb(243, 67, 54), Color.FromRgb(254, 192, 7), Color.FromRgb(96, 125, 138), Color.FromRgb(0, 187, 211), Color.FromRgb(232, 30, 99), Color.FromRgb(254, 87, 34), Color.FromRgb(63, 81, 180), Color.FromRgb(204, 219, 57), Color.FromRgb(0, 149, 135), Color.FromRgb(76, 174, 80) }; SetCurrentValue(ColorsProperty, colors); SizeChanged += OnSizeChanged; IsVisibleChanged += OnIsVisibleChanged; MouseWheel += MouseWheelOnRoll; Loaded += OnLoaded; TooltipTimeoutTimer.Tick += TooltipTimeoutTimerOnTick; DrawMargin.Background = Brushes.Transparent; // if this line is not set, then it does not detect mouse down event... DrawMargin.MouseDown += OnDraggingStart; DrawMargin.MouseUp += OnDraggingEnd; }
public ColorsCollection getCollection() { ColorsCollection colorsCollection = new ColorsCollection { primary0 = Color.FromArgb(175, 207, 251), primary1 = Color.FromArgb(153, 255, 255), secondaryA0 = Color.FromArgb(255, 204, 0), secondaryA1 = Color.FromArgb(255, 204, 153), secondaryB0 = Color.FromArgb(255, 0, 0), secondaryB1 = Color.FromArgb(255, 153, 153) }; return(colorsCollection); }
//int startMonth = DateTime.Today.Month - 3; public DiagramViewModel() { dateStart = DateTime.Today; dateEnd = DateTime.Today; _viewId = Guid.NewGuid(); db = new DAL.BusStationContext(); ColorCollection = new ColorsCollection(); var Random = new Random(); for (int i = 0; i < db.Route.ToList().Count; i++) { var color = System.Windows.Media.Color.FromRgb(Convert.ToByte(Random.Next(255)), Convert.ToByte(Random.Next(255)), Convert.ToByte(Random.Next(255))); ColorCollection.Add(color); } LabelsX = new string[3]; b = false; /*int count = 0; * for (int i = startMonth; count < 3; i++) * { * if (i==12) * { * i = 0; * } * LabelsX[count] = months[i]; * numMonths[count] = i; * count++; * } * * monthStart = numMonths[0]; * monthEnd = numMonths[2];*/ CreateCharts(); }
void Update() { chart.Series.Clear(); for (int r = 0; r < dt.Rows.Count; r++) { Series CSeries; if (Ctype == ChartType.Chart_Type.PieChart) { CSeries = new PieSeries(); } else if (Ctype == ChartType.Chart_Type.ColumnChart) { CSeries = new ColumnSeries(); } else if (Ctype == ChartType.Chart_Type.RowChart) { CSeries = new RowSeries(); } else if (Ctype == ChartType.Chart_Type.StackedColumnChart) { CSeries = new StackedColumnSeries(); } else if (Ctype == ChartType.Chart_Type.StackedRowChart) { CSeries = new StackedRowSeries(); } else if (Ctype == ChartType.Chart_Type.StackedAreaChart) { CSeries = new StackedAreaSeries(); } else if (Ctype == ChartType.Chart_Type.StepLineChart) { CSeries = new StepLineSeries(); } else { CSeries = new LineSeries(); } CSeries.Values = new ChartValues <double> { }; for (int c = 0; c < dt.Columns.Count; c++) { // Debug.WriteLine(dt.Rows[r].Field<double?>(c)); if (dt.Rows[r].Field <double?>(c) != null) { CSeries.Values.Add(dt.Rows[r].Field <double>(c)); } }//columns if (r < ListBox_Customization.Items.Count) { StackPanel panel = (StackPanel)ListBox_Customization.Items[r]; CSeries.Title = ((TextBox)panel.Children[0]).Text; CSeries.DataLabels = (((CheckBox)panel.Children[1]).IsChecked == true); double size = 10; if (double.TryParse(((TextBox)panel.Children[2]).Text, out size) == false) { size = 10; } CSeries.FontSize = size; CSeries.Stroke = ((Rectangle)((StackPanel)panel.Children[3]).Children[0]).Fill; double sth = 0; if (double.TryParse(((TextBox)panel.Children[4]).Text, out sth)) { CSeries.StrokeThickness = sth; } /* * if ((((CheckBox)panel.Children[4]).IsChecked == true)) * CSeries.Fill = ((Rectangle)((StackPanel)panel.Children[5]).Children[0]).Fill; * else * CSeries.Fill = null;*/ } else { CSeries.Title = "R" + r; CSeries.DataLabels = true; } chart.Series.Add(CSeries); }//rows if (RB_CusColors.IsChecked == true) { ColorsCollection colorsCollection = new ColorsCollection(); for (int i = 0; i < ListBox_Colors.Items.Count; i++) { StackPanel stack = (StackPanel)ListBox_Colors.Items[i]; colorsCollection.Add(((SolidColorBrush)((Rectangle)stack.Children[0]).Fill).Color); } chart.SeriesColors = colorsCollection; } else { chart.SeriesColors = null; } }
public PaletteManager() { Stream palStream = new MemoryStream(Properties.Resources.JA2PAL); string palFile = Path.Combine(Application.StartupPath, "JA2PAL.DAT"); if (File.Exists(palFile)) { palStream = new FileStream("JA2PAL.DAT", FileMode.Open); } using (BinaryReader Ja2PalReader = new BinaryReader(palStream)) { colorsTypeCount = Ja2PalReader.ReadInt16(); Ja2PalReader.ReadBytes(2); // 00 00 что-то непонятное typeLengths = new int[colorsTypeCount]; for (int i = 0; i < colorsTypeCount; i++) { typeLengths[i] = Ja2PalReader.ReadByte(); } Ja2PalReader.ReadBytes(2); // F5 FA что-то непонятное typeShifts = new int[colorsTypeCount]; for (int i = 0; i < colorsTypeCount; i++) { typeShifts[i] = Ja2PalReader.ReadByte(); } Ja2PalReader.ReadBytes(2); // DC EA что-то непонятное int headerLength = Ja2PalReader.ReadByte(); Ja2PalReader.ReadBytes(4); // 00 00 00 00 что-то непонятное // в файле какие-то неправильные и переставленные сдвиги:205, 219, 235, 244. // Должны быть такие. вроде как. typeShifts = new int[] { 245, 205, 235, 220 }; for (int i = 0; i < colorsTypeCount; i++) { for (int j = 0; j < typeLengths[i]; j++) { byte[] header = Ja2PalReader.ReadBytes(headerLength); string name = ""; int index = 0; while (header[index] != 0) { name += Convert.ToChar(header[index]); index++; } Ja2PalReader.ReadBytes(2); int colorsCount = Ja2PalReader.ReadByte(); ColorList colorList = new ColorList(name, typeShifts[i], colorsCount, i); for (int k = 0; k < colorsCount; k++) { colorList.Colors[k] = Color.FromArgb (255, Math.Min((int)(Ja2PalReader.ReadByte() * 350 / 255), 255), Math.Min((int)(Ja2PalReader.ReadByte() * 350 / 255), 255), Math.Min((int)(Ja2PalReader.ReadByte() * 350 / 255), 255)); } ColorsCollection.Add(name, colorList); // Разделитель(?) после последнего набора не стоит. if (i < colorsTypeCount - 1 || j < typeLengths[i] - 1) { Ja2PalReader.ReadByte(); // 00 } } } } }