private void Add3D(ChartArea chartArea) { ChartArea3DStyle area3D = new ChartArea3DStyle(); area3D.Enable3D = true; if (chartSize.CompareTo("BigScreen") == 0) { area3D.PointDepth = 70; area3D.Rotation = 20; area3D.Inclination = 30; area3D.Perspective = 20; } else //torta { area3D.PointDepth = 70; area3D.Rotation = 20; area3D.Inclination = 40; area3D.Perspective = 10; } area3D.IsRightAngleAxes = false; area3D.WallWidth = 0; area3D.IsClustered = false; chartArea.Area3DStyle = area3D; }
//------------------------------------------------------ //------------------------------------------------------ private void Applique3DStyle(CChart3DStyle f, ChartArea3DStyle ms) { ms.Enable3D = f.Enable3D; ms.Inclination = f.Inclination; ms.IsClustered = f.IsClustered; ms.IsRightAngleAxes = f.IsRightAngleAxes; ms.LightStyle = CConvertisseurChartEnumToMSEnum.GetMSLightStyle(f.LightStyle); ms.Perspective = f.Perspective; ms.PointDepth = f.PointDepth; ms.PointGapDepth = f.PointGapDepth; ms.Rotation = f.Rotation; ms.WallWidth = f.WallWidth; }
public Histograma(PgmImg img) { InitializeComponent(); chart1.Legends[0].Alignment = System.Drawing.StringAlignment.Near; chart1.Series["Series1"].ChartType = SeriesChartType.Column; chart1.Series["Series1"].Color = System.Drawing.Color.Goldenrod; chart1.Series["Series1"].YValueType = ChartValueType.Int32; chart1.Series["Series1"].Color = Color.Blue; chart1.Titles.Add("Qtd. Colors"); var chartArea3DStyle = new ChartArea3DStyle(); chartArea3DStyle.Enable3D = true; chartArea3DStyle.LightStyle = LightStyle.Realistic; chartArea3DStyle.Rotation = 5; chartArea3DStyle.Inclination = 40; chartArea3DStyle.PointDepth = 50; chart1.ChartAreas[0].Area3DStyle = chartArea3DStyle; chart1.Series[0].Points.Clear(); for (int i = 0; i < 256; i++) { chart1.Series[0].Points.Add(img.Pallete[i]); } chart2.Legends[0].Alignment = System.Drawing.StringAlignment.Near; chart2.Series["Series1"].ChartType = SeriesChartType.Column; chart2.Series["Series1"].Color = System.Drawing.Color.Goldenrod; chart2.Series["Series1"].YValueType = ChartValueType.Int32; chart2.Series["Series1"].Color = Color.Red; chart2.Titles.Add("Qtd. Colors"); var chartArea3DStyle2 = new ChartArea3DStyle(); chartArea3DStyle2.Enable3D = true; chartArea3DStyle2.LightStyle = LightStyle.Realistic; chartArea3DStyle2.Rotation = 5; chartArea3DStyle2.Inclination = 40; chartArea3DStyle2.PointDepth = 50; chart2.ChartAreas[0].Area3DStyle = chartArea3DStyle2; chart2.Series[0].Points.Clear(); var cumulate = img.CumulativePallete(); for (int i = 0; i < 256; i++) { chart2.Series[0].Points.Add(cumulate[i]); } }
private void button1_Click(object sender, EventArgs e) { Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle); Chart chart1 = new Chart(); chart1.Size = new Size(screenRectangle.Size.Width - 10, screenRectangle.Size.Height / 2 - 10); chart1.Location = new Point(30, 30); chart1.Top = 10; double[] yValues = { 15, 60, 12, 13 }; string[] xValues = { "September", "October", "November", "December" }; Series series = new Series("Default"); series.ChartType = SeriesChartType.Pie; series["PieLabelStyle"] = "Disabled"; chart1.Series.Add(series); // Define the chart area ChartArea chartArea = new ChartArea(); ChartArea3DStyle areaStyle = new ChartArea3DStyle(chartArea); areaStyle.Rotation = 0; Axis yAxis = new Axis(chartArea, AxisName.Y); Axis xAxis = new Axis(chartArea, AxisName.X); // Bind the data to the chart chart1.Series["Default"].Points.DataBindXY(xValues, yValues); chart1.ChartAreas.Add(chartArea); Panel One = new Panel(); One.BackColor = Color.White; One.Name = "One"; One.Location = new Point(5, 30); One.Size = new Size(screenRectangle.Size.Width, screenRectangle.Size.Height); Controls.Add(One); One.Controls.Add(chart1); }
public Chart ReportPieChartGeneration() { Chart chart = new Chart(); Series series = new Series("Default"); series.ChartType = SeriesChartType.Pie; //series["PieLabelStyle"] = "Disabled"; chart.Series.Add(series); ChartArea chartArea = new ChartArea(); chart.ChartAreas.Add(chartArea); ChartArea3DStyle areaStyle = new ChartArea3DStyle(chartArea); areaStyle.Rotation = 0; Axis yAxis = new Axis(chartArea, AxisName.Y); Axis xAxis = new Axis(chartArea, AxisName.X); return(chart); }
public void UpdateChart() { if (_chartTemp == null) { return; } if ((Lvd.SelectedNetworkDevice != null) && (Lvd.SelectedNetworkIndex >= 0)) { _chartTemp.ChartAreas.Clear(); _chartTemp.Series.Clear(); _chartTemp.Titles.Clear(); Lvd.UpdateTemp(Lvd.SelectedNetworkIndex, Lvd.SelectedNetworkDevice.infoDev.SerialRFID); int nbPointToDraw = Lvd.ListTempBottle[Lvd.SelectedNetworkIndex].Count; if (nbPointToDraw == 0) { return; } double?currentTemp = (double?)Lvd.ListTempBottle[Lvd.SelectedNetworkIndex][nbPointToDraw - 1]; if (currentTemp != null) { labelCurrentTemp.Text = string.Format(ResStrings.FridgeTempFrm_UpdateChart_currenttemp, DateTime.Now.ToLongTimeString(), Lvd.SelectedNetworkDevice.infoDev.DeviceName, currentTemp.Value.ToString("0.00°")); } else { labelCurrentTemp.Text = DateTime.Now.ToLongTimeString() + " : " + Lvd.SelectedNetworkDevice.infoDev.DeviceName; } if (nbPointToDraw > 0) { ChartArea3DStyle chartArea3DStyle = new ChartArea3DStyle(); chartArea3DStyle.Enable3D = true; chartArea3DStyle.LightStyle = LightStyle.Simplistic; chartArea3DStyle.Rotation = 30; chartArea3DStyle.Inclination = 45; chartArea3DStyle.PointDepth = 100; chartArea3DStyle.Perspective = 30; chartArea3DStyle.WallWidth = 10; chartArea3DStyle.IsRightAngleAxes = true; _chartTemp.BackColor = Color.WhiteSmoke; _chartTemp.BackGradientStyle = GradientStyle.None; _chartTemp.BorderlineColor = Color.FromArgb(64, 0, 64); _chartTemp.BorderlineDashStyle = ChartDashStyle.Solid; _chartTemp.BorderlineWidth = 2; _chartTemp.AntiAliasing = AntiAliasingStyles.All; _chartTemp.ChartAreas.Add("Main"); // chartTemp.ChartAreas["Main"].Area3DStyle = chartArea3DStyle; int nbInterval = 20; //chartTemp.ChartAreas["Main"].AxisX.Interval = 10; _chartTemp.ChartAreas["Main"].AxisX.Interval = (nbPointToDraw / Lvd.MaxTemp) * nbInterval; _chartTemp.ChartAreas["Main"].AxisX.LabelStyle.Angle = -90; _chartTemp.ChartAreas["Main"].AxisX.LabelStyle.Font = new Font("Verdana", 8.0f, FontStyle.Bold); _chartTemp.ChartAreas["Main"].AxisY.LabelStyle.Font = new Font("Verdana", 10.0f, FontStyle.Bold); _chartTemp.ChartAreas["Main"].BackColor = Color.WhiteSmoke; _chartTemp.ChartAreas["Main"].BackGradientStyle = GradientStyle.VerticalCenter; _chartTemp.ChartAreas["Main"].BackSecondaryColor = Color.WhiteSmoke; _chartTemp.ChartAreas["Main"].BorderColor = Color.FromArgb(64, 0, 64); _chartTemp.ChartAreas["Main"].BorderDashStyle = ChartDashStyle.Solid; _chartTemp.ChartAreas["Main"].BorderWidth = 2; _chartTemp.ChartAreas["Main"].ShadowOffset = 3; _chartTemp.ChartAreas["Main"].ShadowColor = Color.FromArgb(128, 0, 0); _chartTemp.ChartAreas["Main"].AxisX.TitleForeColor = Color.Blue; _chartTemp.ChartAreas["Main"].AxisY.TitleForeColor = Color.Blue; _chartTemp.ChartAreas["Main"].AxisY.Title = "T°"; _chartTemp.ChartAreas["Main"].AxisY.TextOrientation = TextOrientation.Rotated270; _chartTemp.ChartAreas["Main"].AxisY.TitleFont = new Font("Verdana", 12.0f, FontStyle.Italic); _chartTemp.Titles.Add("Temperature"); _chartTemp.ChartAreas["Main"].AxisX.Title = "Time (min)"; _chartTemp.ChartAreas["Main"].AxisX.TextOrientation = TextOrientation.Horizontal; _chartTemp.ChartAreas["Main"].AxisX.TitleFont = new Font("Verdana", 12.0f, FontStyle.Italic); _chartTemp.Titles[0].Font = new Font("Verdana", 16.0f, FontStyle.Underline); _chartTemp.Titles[0].ForeColor = Color.Blue; _chartTemp.Series.Add("T° Alarm High"); _chartTemp.Series["T° Alarm High"].ChartType = SeriesChartType.Line; _chartTemp.Series["T° Alarm High"].YValueType = ChartValueType.Double; _chartTemp.Series["T° Alarm High"].IsValueShownAsLabel = false; _chartTemp.Series["T° Alarm High"].ToolTip = "#VALX : #VALY"; _chartTemp.Series["T° Alarm High"].BackGradientStyle = GradientStyle.VerticalCenter; _chartTemp.Series["T° Alarm High"].ShadowOffset = 0; _chartTemp.Series["T° Alarm High"].BackSecondaryColor = Color.White; _chartTemp.Series["T° Alarm High"].ShadowColor = Color.FromArgb(128, 0, 0); _chartTemp.Series["T° Alarm High"].Color = Color.Red; _chartTemp.Series["T° Alarm High"].BorderWidth = 3; _chartTemp.Series.Add("T° Alarm Low"); _chartTemp.Series["T° Alarm Low"].ChartType = SeriesChartType.Line; _chartTemp.Series["T° Alarm Low"].YValueType = ChartValueType.Double; _chartTemp.Series["T° Alarm Low"].IsValueShownAsLabel = false; _chartTemp.Series["T° Alarm Low"].ToolTip = "#VALX : #VALY"; _chartTemp.Series["T° Alarm Low"].BackGradientStyle = GradientStyle.VerticalCenter; _chartTemp.Series["T° Alarm Low"].ShadowOffset = 0; _chartTemp.Series["T° Alarm Low"].BackSecondaryColor = Color.White; _chartTemp.Series["T° Alarm Low"].ShadowColor = Color.FromArgb(128, 0, 0); _chartTemp.Series["T° Alarm Low"].Color = Color.Red; _chartTemp.Series["T° Alarm Low"].BorderWidth = 3; _chartTemp.Series.Add("T° Bottle"); _chartTemp.Series["T° Bottle"].ChartType = SeriesChartType.Line; _chartTemp.Series["T° Bottle"].YValueType = ChartValueType.Double; _chartTemp.Series["T° Bottle"].IsValueShownAsLabel = false; _chartTemp.Series["T° Bottle"].ToolTip = "#VALX : #VALY"; _chartTemp.Series["T° Bottle"].BackGradientStyle = GradientStyle.VerticalCenter; _chartTemp.Series["T° Bottle"].ShadowOffset = 0; _chartTemp.Series["T° Bottle"].BackSecondaryColor = Color.White; _chartTemp.Series["T° Bottle"].ShadowColor = Color.FromArgb(128, 0, 0); _chartTemp.Series["T° Bottle"].Color = Color.DodgerBlue; _chartTemp.Series["T° Bottle"].BorderWidth = 3; _chartTemp.Series.Add("T° Chamber"); _chartTemp.Series["T° Chamber"].ChartType = SeriesChartType.Line; _chartTemp.Series["T° Chamber"].YValueType = ChartValueType.Double; _chartTemp.Series["T° Chamber"].IsValueShownAsLabel = false; _chartTemp.Series["T° Chamber"].ToolTip = "#VALX : #VALY"; _chartTemp.Series["T° Chamber"].BackGradientStyle = GradientStyle.VerticalCenter; _chartTemp.Series["T° Chamber"].ShadowOffset = 0; _chartTemp.Series["T° Chamber"].BackSecondaryColor = Color.White; _chartTemp.Series["T° Chamber"].ShadowColor = Color.FromArgb(128, 0, 0); _chartTemp.Series["T° Chamber"].Color = Color.Orange; _chartTemp.Series["T° Chamber"].BorderWidth = 3; Font ft = new Font("Verdana", 12.0f, FontStyle.Bold); _chartTemp.Series["T° Bottle"].Font = ft; _chartTemp.Series["T° Chamber"].Font = ft; int rgPt = -nbPointToDraw + 1; for (int loop = 0; loop < nbPointToDraw; loop++) { _chartTemp.Series["T° Alarm High"].Points.AddXY(rgPt, (double?)Lvd.MaxTempFridgeValue); _chartTemp.Series["T° Alarm Low"].Points.AddXY(rgPt, (double?)(Lvd.MaxTempFridgeValue - 5.0)); if (loop >= Lvd.ListTempBottle[Lvd.SelectedNetworkIndex].Count) { break; } if ((double?)Lvd.ListTempBottle[Lvd.SelectedNetworkIndex][loop] == null) { DataPoint point = new DataPoint(rgPt, 0); point.IsEmpty = true; _chartTemp.Series["T° Bottle"].Points.Add(point); } else { _chartTemp.Series["T° Bottle"].Points.AddXY(rgPt, (double?)Lvd.ListTempBottle[Lvd.SelectedNetworkIndex][loop]); } rgPt++; } } else { labelCurrentTemp.Text = "Info : Temperature unavailable"; } } }
public MatrixDataGraphWindow() : base() { EnableExtension = false; int ylinenum = 0; int readstart = 0; int xelementnum = 1; int yelementnum = 1; Area3DStyle = chart.ChartAreas["ChartArea1"].Area3DStyle; foreach (string line in File.ReadLines("feffdat/BTmat.dat", BTMainForm.CharEncode)) { if (line.IndexOf("----") > 0 && readstart == 0) { readstart = 1; continue; } if (readstart == 1) { string[] s = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); xelementnum = int.Parse(s[0]); yelementnum = int.Parse(s[1]); readstart++; continue; } if (readstart == 2) { string[] d = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (d.Count() < 5) { break; } else { for (int i = 0; i < d.Count(); i++) { if (i == ylinenum) { Z.Add(0); } else { Z.Add(double.Parse(d[i])); } } ylinenum++; } } } chart.Series.Clear(); chart.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; for (int y = 0; y < yelementnum; y++) { Series temp = new Series(); temp.ChartArea = "ChartArea1"; temp.ChartType = SeriesChartType.Column; chart.Series.Add(temp); Area3DStyle.Inclination = 30; Area3DStyle.Rotation = 30; Area3DStyle.WallWidth = 5; Area3DStyle.PointGapDepth = 10; AxisX.Interval = 1; for (int x = 0; x < xelementnum; x++) { DataPoint dp = new DataPoint(x, Math.Abs(Z[x + y * xelementnum])); if (Z[x + y * xelementnum] >= 0) { dp.Color = Color.FromArgb(255, 255, 0, 0); } else { dp.Color = Color.FromArgb(255, 0, 0, 255); } chart.Series.Last().Points.Add(dp); } } // } chart.Legends.Clear(); //凡例を非表示に }
public Chart GenChart(string modulecode) { var list = instance.GetListByWhere(string.Format(" AND CM_Module='{0}'", modulecode)); if (list.Count == 0) { return(null); } var charModel = list[0]; Chart Chart1 = new Chart(); try { #region Step1. 設定 Chart Title //Title ChartTitle = new Title(); //System.Drawing.Font font = new System.Drawing.Font("黑体", 20, FontStyle.Bold); ////字体设置 //ChartTitle.Font = font; //ChartTitle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#6B8E23"); ////图表名称 //ChartTitle.Text = charModel.CM_Title; ////新增至Chart Control //Chart1.Titles.Add(ChartTitle); #endregion #region Step2. 產生工作區塊(Area1) ChartArea cArea1 = new ChartArea(charModel.CM_ChartAreas); Chart1.Width = charModel.CM_Width; Chart1.Height = charModel.CM_Height; //設定Area1的X,Y軸標題 // cArea1.AxisX.Title = charModel.CM_XTitle; // cArea1.AxisY.Title = charModel.CM_YTitle; //X,Y軸刻度區間 if (!string.IsNullOrEmpty(charModel.CM_XInterval)) { cArea1.AxisX.Interval = double.Parse(charModel.CM_XInterval); } if (!string.IsNullOrEmpty(charModel.CM_YInterval)) { cArea1.AxisY.Interval = double.Parse(charModel.CM_YInterval); } // Chart1.BackColor = System.Drawing.Color.AliceBlue; // Chart1.BackGradientStyle = GradientStyle.TopBottom; // Set Border Width // Chart1.BorderWidth = 2; // Chart Image Mode // Chart1.BackImageWrapMode = ChartImageWrapMode.TileFlipX; Chart1.ChartAreas.Add(cArea1); #endregion #region 样式设置 var c = new BorderSkin(); c.SkinStyle = BorderSkinStyle.Emboss; Chart1.BorderSkin = c; cArea1.BorderDashStyle = ChartDashStyle.Solid; cArea1.BorderWidth = 1; cArea1.BorderColor = colorHx16toRGB("#AAB6C5"); cArea1.BackColor = colorHx16toRGB("#e3e3e3"); cArea1.BackSecondaryColor = Color.White; cArea1.BackGradientStyle = GradientStyle.TopBottom; cArea1.AxisX.TitleFont = new Font("微软雅黑", 12); cArea1.AxisY.TitleFont = new Font("微软雅黑", 12); cArea1.AxisX.LineColor = colorHx16toRGB("#AAB6C5"); cArea1.AxisX.LineWidth = 1; cArea1.AxisY.LineColor = colorHx16toRGB("#AAB6C5"); cArea1.AxisY.LineWidth = 1; //---- var l = new LabelStyle(); l.Font = new Font("微软雅黑", 20, FontStyle.Bold); l.ForeColor = colorHx16toRGB("#404040"); cArea1.AxisX.LabelStyle = l; var ly = new LabelStyle(); ly.Font = new Font("微软雅黑", 20, FontStyle.Bold); ly.ForeColor = colorHx16toRGB("#404040"); cArea1.AxisY.LabelStyle = ly; cArea1.AxisX.MajorGrid.LineColor = colorHx16toRGB("#AAB6C5"); cArea1.AxisY.MajorGrid.LineColor = colorHx16toRGB("#AAB6C5"); Chart1.BackColor = colorHx16toRGB("#e3e3e3"); Chart1.BackSecondaryColor = Color.White; Chart1.BackGradientStyle = GradientStyle.TopBottom; var d = new ChartArea3DStyle(); d.Rotation = 10; d.Perspective = 10; d.IsRightAngleAxes = false; d.WallWidth = 0; d.IsClustered = false; d.LightStyle = LightStyle.Realistic; cArea1.Area3DStyle = d; #endregion } catch (Exception ex) { return(null); } return(Chart1); }
private void addNewTable(Car car) { Table tbl = new Table(); tbl.Width = new Unit("100%"); tbl.Height = new Unit("100%"); //------------------row----------------------- TableRow rw = new TableRow(); //---------------------cell-------------- TableCell cell = new TableCell(); cell.Width = 300; LinkButton carTitle = new LinkButton(); carTitle.Font.Size = 20; carTitle.Text = car.getCarBrand() + " " + car.getCarModel(); carTitle.Click += new EventHandler(LinkButton1_Click); carTitle.ID = "Title" + car.getId().ToString(); carTitle.CssClass = "linkbtn"; cell.Controls.Add(carTitle); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); Panel div = new Panel(); div.Style.Add("float", "right"); Button btnEdit = new Button(); btnEdit.Click += new EventHandler(btnAddFuel_Click); btnEdit.Text = "Редактирай"; btnEdit.Style.Add("margin-left", "15px"); btnEdit.Style.Add("margin-right", "15px"); btnEdit.ID = "Edit" + car.getId().ToString(); btnEdit.CssClass = "btn"; div.Controls.Add(btnEdit); cell.Controls.Add(div); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); Panel div2 = new Panel(); div.Style.Add("float", "left"); Button btnDel = new Button(); btnDel.Click += new EventHandler(btnDel_Click); btnDel.Text = "Изтрий"; btnDel.Style.Add("margin-left", "15px"); btnDel.Style.Add("margin-right", "15px"); btnDel.ID = "Delete" + car.getId().ToString(); btnDel.CssClass = "btn"; div2.Controls.Add(btnDel); cell.Controls.Add(div2); rw.Cells.Add(cell); tbl.Controls.Add(rw); //------------------row----------------------- rw = new TableRow(); //---------------------cell-------------- cell = new TableCell(); cell.RowSpan = 5; cell.Width = 300; ImageButton img = new ImageButton(); img.ImageUrl = car.getCarImage(); img.Width = 300; img.Height = 150; img.Style.Add("min-height", "150px"); img.Style.Add("min-width", "100px"); img.ID = "Img" + car.getId().ToString(); img.ToolTip = "Виж история на автомобила"; img.Click += new ImageClickEventHandler(img_Click); cell.Controls.Add(img); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.ColumnSpan = 2; cell.Style.Add("height", "10px"); Label carInfo = new Label(); carInfo.Font.Size = 10; carInfo.Text = car.getCarFuel() + ", " + car.getCarEngine() + ", " + car.getCarHPowers() + " к.с., " + car.getCarYear(); cell.Controls.Add(carInfo); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.ColumnSpan = 4; cell.RowSpan = 3; List<Tuple<Double, DateTime>> list = db.getTotalCostPerMonth(car.getId()); List<Double> total_cost = new List<double>(); List<DateTime> period = new List<DateTime>(); foreach (Tuple<Double, DateTime> item in list) { total_cost.Add(item.Item1); period.Add(item.Item2); } List<String> sPeriod = new List<string>(); foreach (DateTime item in period) { sPeriod.Add(item.ToString("MM/yyyy")); } if (total_cost.Count > 0) { Chart chart = new Chart(); Series series = new Series("Default"); series.ChartType = SeriesChartType.Spline; series["PieLabelStyle"] = "Disabled"; chart.Series.Add(series); ChartArea chartArea = new ChartArea(); ChartArea3DStyle areaStyle = new ChartArea3DStyle(chartArea); areaStyle.Rotation = 0; Axis yAxis = new Axis(chartArea, AxisName.Y); Axis xAxis = new Axis(chartArea, AxisName.X); chart.ChartAreas.Add(chartArea); // Bind the data to the chart chart.Series["Default"].Points.DataBindXY(sPeriod, total_cost); chart.Width = new System.Web.UI.WebControls.Unit(600, System.Web.UI.WebControls.UnitType.Pixel); chart.Height = new System.Web.UI.WebControls.Unit(200, System.Web.UI.WebControls.UnitType.Pixel); //string filename = Server.MapPath("~") + "/Chart.png"; //chart.SaveImage(filename, ChartImageFormat.Png); chart.Legends.Add(new Legend("Legend1")); chart.Series["Default"].LegendText = "Обща сума в лв."; cell.Controls.Add(chart); } rw.Cells.Add(cell); tbl.Controls.Add(rw); //------------------row----------------------- rw = new TableRow(); //---------------------cell-------------- cell = new TableCell(); cell.ColumnSpan = 2; Label averageCons = new Label(); averageCons.Font.Bold = true; averageCons.Font.Size = 35; averageCons.Style.Add("margin-left", "10px"); double average = db.getAvgCons(car.getId()); if (average == 0) { averageCons.Text = "---"; } else { averageCons.Text = average.ToString("0.##"); } cell.Controls.Add(averageCons); rw.Cells.Add(cell); tbl.Controls.Add(rw); //------------------row----------------------- rw = new TableRow(); //---------------------cell-------------- cell = new TableCell(); cell.ColumnSpan = 2; Label averageConsInfo = new Label(); averageConsInfo.Font.Size = 10; averageConsInfo.Style.Add("margin-left", "10px"); if (car.getCarFuel().Equals("Електричество")) { averageConsInfo.Text = "кВч/100км " + car.getCarFuel(); } else averageConsInfo.Text = "л./100км " + car.getCarFuel(); cell.Controls.Add(averageConsInfo); rw.Cells.Add(cell); tbl.Controls.Add(rw); //------------------row----------------------- rw = new TableRow(); //---------------------cell-------------- cell = new TableCell(); Label fillUps = new Label(); fillUps.Font.Size = 11; fillUps.Font.Bold = true; fillUps.Style.Add("margin-left", "10px"); fillUps.Style.Add("text-align", "center"); fillUps.Width = new Unit("100%"); int numFillUps = db.getFillUps(car.getId()); if (numFillUps == 0) fillUps.Text = "-"; else fillUps.Text = numFillUps.ToString(); cell.Controls.Add(fillUps); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); Label minCons = new Label(); minCons.Font.Size = 11; minCons.Font.Bold = true; minCons.Style.Add("margin-left", "10px"); minCons.Style.Add("text-align", "center"); minCons.Width = new Unit("100%"); double minConsDB = db.getMinCons(car.getId()); if (minConsDB == 0) minCons.Text = "-"; else minCons.Text = minConsDB.ToString("0.##"); cell.Controls.Add(minCons); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); Label km = new Label(); km.Font.Size = 11; km.Font.Bold = true; km.Style.Add("margin-left", "10px"); km.Style.Add("text-align", "center"); km.Width = new Unit("100%"); int kmDB = db.getKM(car.getId()); if (kmDB == 0) km.Text = "-"; else km.Text = kmDB.ToString("0.##"); cell.Controls.Add(km); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); Label pricePerKm = new Label(); pricePerKm.Font.Size = 11; pricePerKm.Font.Bold = true; pricePerKm.Style.Add("margin-left", "10px"); pricePerKm.Style.Add("text-align", "center"); pricePerKm.Width = new Unit("100%"); double price = db.getTotalPrice(car.getId()); if (price != 0 && kmDB != 0) pricePerKm.Text = (price / kmDB).ToString("0.##"); else pricePerKm.Text = "-"; cell.Controls.Add(pricePerKm); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); rw.Cells.Add(cell); tbl.Controls.Add(rw); //------------------row----------------------- rw = new TableRow(); //---------------------cell-------------- cell = new TableCell(); cell.Width = new Unit("15%"); Label fillUpsInfo = new Label(); fillUpsInfo.Font.Size = 9; fillUpsInfo.Style.Add("margin-left", "10px"); fillUpsInfo.Style.Add("text-align", "center"); fillUpsInfo.Width = new Unit("100%"); fillUpsInfo.Text = "зареждания"; cell.Controls.Add(fillUpsInfo); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.Width = new Unit("15%"); Label minConsInfo = new Label(); minConsInfo.Font.Size = 9; minConsInfo.Style.Add("margin-left", "10px"); minConsInfo.Style.Add("text-align", "center"); minConsInfo.Width = new Unit("100%"); if (car.getCarFuel().Equals("Електричество")) minConsInfo.Text = "мин кВч/100 км"; else minConsInfo.Text = "мин л./100 км"; cell.Controls.Add(minConsInfo); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.Width = new Unit("15%"); Label kmInfo = new Label(); kmInfo.Font.Size = 9; kmInfo.Style.Add("margin-left", "10px"); kmInfo.Style.Add("text-align", "center"); kmInfo.Width = new Unit("100%"); kmInfo.Text = "изминати км"; cell.Controls.Add(kmInfo); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.Width = new Unit("15%"); Label pricePerKmInfo = new Label(); pricePerKmInfo.Font.Size = 9; pricePerKmInfo.Style.Add("margin-left", "10px"); pricePerKmInfo.Style.Add("text-align", "center"); pricePerKmInfo.Width = new Unit("100%"); pricePerKmInfo.Text = "цена на км"; cell.Controls.Add(pricePerKmInfo); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.Width = new Unit("20%"); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.Width = new Unit("20%"); rw.Cells.Add(cell); tbl.Controls.Add(rw); //------------------row----------------------- rw = new TableRow(); //---------------------cell-------------- cell = new TableCell(); rw.Cells.Add(cell); tbl.Controls.Add(rw); //------------------row----------------------- rw = new TableRow(); //---------------------cell-------------- cell = new TableCell(); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.ColumnSpan = 2; Button buttonAddFuel = new Button(); buttonAddFuel.Click += new EventHandler(btnAddFuel_Click); buttonAddFuel.Width = new Unit("75%"); buttonAddFuel.Text = "Добави гориво"; buttonAddFuel.Style.Add("margin-left", "15px"); buttonAddFuel.Style.Add("margin-right", "15px"); buttonAddFuel.ID = "Fuel" + car.getId().ToString(); buttonAddFuel.CssClass = "btn"; //buttonAddFuel cell.Controls.Add(buttonAddFuel); rw.Cells.Add(cell); //---------------------cell-------------- cell = new TableCell(); cell.ColumnSpan = 2; Button buttonAddOtherCost = new Button(); buttonAddOtherCost.Click += new EventHandler(btnAddFuel_Click); buttonAddOtherCost.Width = new Unit("75%"); buttonAddOtherCost.Text = "Добави друг разход"; buttonAddOtherCost.Style.Add("margin-left", "15px"); buttonAddOtherCost.Style.Add("margin-right", "15px"); buttonAddOtherCost.ID = "Other" + car.getId().ToString(); buttonAddOtherCost.CssClass = "btn"; cell.Controls.Add(buttonAddOtherCost); rw.Cells.Add(cell); tbl.Controls.Add(rw); Panel1.Controls.Add(tbl); Panel1.Controls.Add(new LiteralControl("<br />")); Panel1.Controls.Add(new LiteralControl("<hr />")); }