private void FillGrid() { // fill grid solutions gridSolutions.Rows.Clear(); // border DevAge.Drawing.BorderLine border = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1); DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border); // views CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); viewNormal.Border = cellBorder; CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White); viewNormalCheck.Border = cellBorder; // column header view SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader(); DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader(); backHeader.BackColor = Color.LightGray; backHeader.Border = DevAge.Drawing.RectangleBorder.NoBorder; viewColumnHeader.Background = backHeader; viewColumnHeader.ForeColor = Color.White; viewColumnHeader.Font = new Font("Arial", 10, FontStyle.Bold); viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None; // create the grid gridSolutions.BorderStyle = BorderStyle.FixedSingle; gridSolutions.ColumnsCount = 8; gridSolutions.FixedRows = 1; gridSolutions.Rows.Insert(0); // header SourceGrid.Cells.ColumnHeader columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_INDEX); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 0] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYOUT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 1] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETCOUNT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 2] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 3] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 4] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LOADWEIGHT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 5] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LOADHEIGHT); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 6] = columnHeader; columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED); columnHeader.AutomaticSortEnabled = false; columnHeader.View = viewColumnHeader; gridSolutions[0, 7] = columnHeader; // handling check box click SourceGrid.Cells.Controllers.CustomEvents solCheckboxClickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); solCheckboxClickEvent.Click += new EventHandler(clickEvent_Click); // data rows int iIndex = 0; foreach (TruckSolution sol in _truckAnalysis.Solutions) { ++iIndex; gridSolutions.Rows.Insert(iIndex); // index gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex)); // Layout { Graphics2DImage graphics = new Graphics2DImage(new Size(300, 30)); TruckSolutionViewer sv = new TruckSolutionViewer(sol); sv.Draw(graphics); gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap); } // Pallet count gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.PalletCount)); // Case count gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.BoxCount)); // Efficiency gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.Efficiency)); // Load gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.LoadWeight)); // Load height gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.LoadHeight)); // Selected gridSolutions[iIndex, 7] = new SourceGrid.Cells.CheckBox(null, _truckAnalysis.HasSolutionSelected(iIndex-1)); gridSolutions[iIndex, 0].View = viewNormal; gridSolutions[iIndex, 1].View = viewNormal; gridSolutions[iIndex, 2].View = viewNormal; gridSolutions[iIndex, 3].View = viewNormal; gridSolutions[iIndex, 4].View = viewNormal; gridSolutions[iIndex, 5].View = viewNormal; gridSolutions[iIndex, 6].View = viewNormal; gridSolutions[iIndex, 7].View = viewNormalCheck; gridSolutions[iIndex, 7].AddController(solCheckboxClickEvent); } gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution gridSolutions.Selection.SelectRow(1, true); if (_truckAnalysis.Solutions.Count > 0) _sol = _truckAnalysis.Solutions[0]; graphCtrlSolution.Invalidate(); }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { TruckProperties truckProp = _sol.ParentTruckAnalysis.TruckProperties; graphics.AddDimensions(new DimensionCube(_sol.LoadBoundingBox, Color.Red, false)); graphics.AddDimensions(new DimensionCube(Vector3D.Zero, truckProp.Length, truckProp.Width, truckProp.Height, Color.Black, true)); // draw solution TruckSolutionViewer sv = new TruckSolutionViewer(_sol); sv.Draw(graphics); }
private void AppendTruckSolutionElement(ReportData inputData, XmlElement elemTruckAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; CasePalletSolution palletSolution = inputData.CasePalletSolution; TruckAnalysis truckAnalysis = inputData.SelSolution.TruckAnalyses[0]; // retrieve selected truckSolution TruckSolution truckSolution = truckAnalysis.SelectedSolution; if (null == truckSolution) return; // create "truckSolution" element XmlElement elemTruckSolution = xmlDoc.CreateElement("truckSolution", ns); elemTruckAnalysis.AppendChild(elemTruckSolution); if (!string.IsNullOrEmpty(truckSolution.Title)) { // title XmlElement elemTitle = xmlDoc.CreateElement("title", ns); elemTitle.InnerText = truckSolution.Title; elemTruckSolution.AppendChild(elemTitle); } // palletCount XmlElement elemPalletCount = xmlDoc.CreateElement("palletCount", ns); elemPalletCount.InnerText = string.Format("{0}", truckSolution.PalletCount); elemTruckSolution.AppendChild(elemPalletCount); // boxCount XmlElement elemBoxCount = xmlDoc.CreateElement("caseCount", ns); elemBoxCount.InnerText = string.Format("{0}", truckSolution.BoxCount); elemTruckSolution.AppendChild(elemBoxCount); double loadWeight = truckSolution.PalletCount * inputData.ActualPalletWeight; AppendElementValue(xmlDoc, elemTruckSolution, "loadWeight", UnitsManager.UnitType.UT_MASS, loadWeight); // loadEfficiency XmlElement elemLoadEfficiency = xmlDoc.CreateElement("loadEfficiency", ns); elemLoadEfficiency.InnerText = string.Format("{0:F}", 100.0 * loadWeight / truckAnalysis.TruckProperties.AdmissibleLoadWeight); elemTruckSolution.AppendChild(elemLoadEfficiency); // volumeEfficiency XmlElement elemVolumeEfficiency = xmlDoc.CreateElement("volumeEfficiency", ns); elemVolumeEfficiency.InnerText = string.Format("{0:F}", truckSolution.Efficiency); elemTruckSolution.AppendChild(elemVolumeEfficiency); // --- truck images for (int i = 0; i < 2; ++i) { // initialize drawing values string viewName = string.Empty; Vector3D cameraPos = Vector3D.Zero; int imageWidth = ImageSizeWide; switch (i) { case 0: viewName = "view_trucksolution_top"; cameraPos = Graphics3D.Top; imageWidth = ImageSizeWide; break; case 1: viewName = "view_trucksolution_iso"; cameraPos = Graphics3D.Corner_0; imageWidth = ImageSizeWide; break; default: break; } // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(new Size(imageWidth, imageWidth)); // set camera position graphics.CameraPosition = cameraPos; // dimensions if (1 == i) { TruckProperties truckProp = truckSolution.ParentTruckAnalysis.TruckProperties; graphics.AddDimensions(new DimensionCube(truckSolution.LoadBoundingBox, Color.Red, false)); graphics.AddDimensions(new DimensionCube(Vector3D.Zero, truckProp.Length, truckProp.Width, truckProp.Height, Color.Black, true)); } // instantiate solution viewer TruckSolutionViewer sv = new TruckSolutionViewer(truckSolution); sv.Draw(graphics); graphics.Flush(); // --- XmlElement elemImage = xmlDoc.CreateElement(viewName, ns); TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style"); styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 3, graphics.Bitmap.Height / 3); elemImage.Attributes.Append(styleAttribute); elemTruckSolution.AppendChild(elemImage); // Save image ? SaveImageAs(graphics.Bitmap, viewName + ".png"); } }