public override void OnUpdate() { base.OnUpdate(); if (spooler_connection.CopyPrinterList(ref printer_list)) { return; } PrinterGrid.Clear(); var num = 0; foreach (PrinterInfo printer in printer_list) { var buttonWidget1 = new ButtonWidget(1064 + num, null); ImageResourceMapping.PixelCoordinate pixelCoordinate = ImageResourceMapping.PrinterColorPosition(printer.serial_number.ToString()); buttonWidget1.Init(host, "extendedcontrols", pixelCoordinate.u0, pixelCoordinate.v0, pixelCoordinate.u1, pixelCoordinate.v1, pixelCoordinate.u0, pixelCoordinate.v0, pixelCoordinate.u1, pixelCoordinate.v1, pixelCoordinate.u0, pixelCoordinate.v0, pixelCoordinate.u1, pixelCoordinate.v1); buttonWidget1.DontMove = true; buttonWidget1.Text = GetPrinterLabelText(printer); buttonWidget1.Color = new Color4(0.0f, 0.5f, 1f, 1f); buttonWidget1.Size = FontSize.Small; buttonWidget1.VAlignment = TextVerticalAlignment.Bottom; buttonWidget1.Data = printer; buttonWidget1.SetCallback(new ButtonCallback(MyButtonCallback)); buttonWidget1.ToolTipMessage = " " + printer.Status.ToString(); ButtonWidget buttonWidget2 = buttonWidget1; buttonWidget2.ToolTipMessage = buttonWidget2.ToolTipMessage + "\n Gantry clips removed: " + (printer.persistantData.GantryClipsRemoved ? "yes" : "no") + " "; ButtonWidget buttonWidget3 = buttonWidget1; buttonWidget3.ToolTipMessage = buttonWidget3.ToolTipMessage + "\n Has Valid Z: " + (printer.extruder.Z_Valid ? "yes" : "no") + " "; ButtonWidget buttonWidget4 = buttonWidget1; buttonWidget4.ToolTipMessage = buttonWidget4.ToolTipMessage + "\n Has Valid Calibration: " + (printer.calibration.Calibration_Valid ? "yes" : "no") + " "; PrinterGrid.AddChildElement(buttonWidget1); ++num; } }
public void Show(GUIHost host, GridLayout LibraryGrid, string filter) { LibraryGrid.Clear(); Sprite.pixel_perfect = false; QueryResults <RecentPrintsHistory.PrintHistory> queryResults = recentPrintsHistory.QuereyRecords(filter); if (queryResults == null) { return; } var num = 0; foreach (RecentPrintsHistory.PrintHistory record in queryResults.records) { var buttonWidget = new ButtonWidget(1064 + num, null); if (string.IsNullOrEmpty(record.iconfilename) || !File.Exists(record.iconfilename)) { buttonWidget.Init(host, "null.png"); } else { buttonWidget.Init(host, record.iconfilename); } buttonWidget.DontMove = true; var str1 = record.ToString(); if (str1.Length > 30) { var str2 = str1.Substring(0, 15); var str3 = str1.Substring(str1.Length - 15, 15); var str4 = " ... "; var str5 = str3; str1 = str2 + str4 + str5; } buttonWidget.Text = str1; buttonWidget.Color = new Color4(0.0f, 0.5f, 1f, 1f); buttonWidget.Size = FontSize.Small; buttonWidget.VAlignment = TextVerticalAlignment.Bottom; buttonWidget.Data = record; buttonWidget.SetCallback(new ButtonCallback(MyButtonCallback)); buttonWidget.SetFullyDraggable(); LibraryGrid.AddChildElement(buttonWidget); ++num; } host.Refresh(); }