//////////////////////////////////////////////////////////////// // // InspectWindow.q // //////////////////////////////////////////////////////////////// (Export InspectWindow) (DefClass InspectWindow content (: Window) (Def (InspectWindow x) (Local alist) (Setq alist (InspectList x)) (Setq content (InspectWindowScrollViewer alist)) (Setq this.Content content) (Setq this.Title (Unparse x)) (Setq this.SizeToContent "WidthAndHeight") (Show) (When (> this.Height Screen.PrimaryScreen.Bounds.Height) (Setq this.SizeToContent "Manual") (Setq this.Height (Round Screen.PrimaryScreen.Bounds.Height 2))) (When (> this.Width Screen.PrimaryScreen.Bounds.Width) (Setq this.SizeToContent "Manual") (Setq this.Width (Round Screen.PrimaryScreen.Bounds.Width 2)))) ) (Def (InspectWindowScrollViewer alist) (Local grid answer) (Setq grid (InspectWindowGrid alist)) (Setq answer (New ScrollViewer)) (Setq answer.Content grid) (Return answer) ) (Def (InspectWindowGrid alist) (Local nrows ncolumns columndef rowdef bucket name value cell answer) (Setq answer (New Grid)) (Setq nrows (Length alist)) (Setq ncolumns 2) (For (i 1 ncolumns 1) (Setq columndef (New ColumnDefinition)) (Setq columndef.Width (New GridLength (Float i) GridUnitType.Star)) (answer.ColumnDefinitions.Add columndef)) (For (i 1 nrows 1) (Setq rowdef (New RowDefinition)) (Setq rowdef.Height (New GridLength 1.0 GridUnitType.Star)) (answer.RowDefinitions.Add rowdef)) (For (i 0 (+ nrows -1) 1) (Setq bucket (Elt alist i)) (Setq [name value] bucket) (Setq cell (New TextBox)) // NOTE: name will be a String already. (Setq cell.Foreground "White") (Setq cell.Background "ForestGreen") (Setq cell.Text name) (Grid.SetRow cell i) (Grid.SetColumn cell 0) (answer.Children.Add cell) (Setq cell (New TextBox)) (Setq cell.Text (Unparse value)) (Grid.SetRow cell i) (Grid.SetColumn cell 1) (answer.Children.Add cell)) (Return answer) )