예제 #1
0
        private static void PopulateKeys(TableControl tableControl)
        {
            tableControl.Clear();
            tableControl.FontSize = 14;

            var categories = ClientInputManager.GetKnownButtons()
                             .GroupBy(pair => pair.Value.Category)
                             .OrderBy(category => category.Key);

            var isFirstCategory = true;

            foreach (var category in categories)
            {
                var textHeader = category.Key;
                if (string.IsNullOrEmpty(textHeader))
                {
                    textHeader = TitleGeneralControlsCategory;
                }

                // add category header
                var marginTop = isFirstCategory ? 0 : 8;
                isFirstCategory = false;
                var categoryHeader = new TextBlock()
                {
                    Text                = textHeader,
                    FontWeight          = FontWeights.Bold,
                    FontSize            = 16,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Margin              = new Thickness(0, marginTop, 0, 5)
                };

                Grid.SetColumnSpan(categoryHeader, 3);
                tableControl.Add(categoryHeader, null);

                // add keys for this category
                foreach (var pair in category)
                {
                    var button = pair.Key;
                    var info   = pair.Value;

                    var labelControl = new FormattedTextBlock
                    {
                        // ReSharper disable once CanExtractXamlLocalizableStringCSharp
                        Content              = info.Title,
                        TextWrapping         = TextWrapping.Wrap,
                        FontSize             = 12,
                        LineHeight           = 13,
                        LineStackingStrategy = LineStackingStrategy.BlockLineHeight,
                        MaxWidth             = 150,
                        Margin              = new Thickness(0, 0, 0, 6),
                        TextAlignment       = TextAlignment.Right,
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Center
                    };

                    //ToolTipServiceExtend.SetToolTip(
                    //    labelControl,
                    //    new TextBlock()
                    //    {
                    //        Text = info.Description ?? info.Name,
                    //        TextWrapping = TextWrapping.Wrap,
                    //        MaxWidth = 200,
                    //        VerticalAlignment = VerticalAlignment.Center
                    //    });

                    var inputMappingControl = GetInputMappingControl(button, info);
                    tableControl.Add(labelControl, inputMappingControl);
                }
            }
        }