Ejemplo n.º 1
0
        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();
        }