Beispiel #1
0
        public void CreateControl(out FrameworkElement control)
        {
            var buttonReferenceControl = new AutomatonButtonReference()
            {
                Button = ButtonRef
            };
            var labelWithButton = new LabelWithButton()
            {
                Button = buttonReferenceControl
            };
            var textControl = new FormattedTextBlock()
            {
                Content             = Text,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            var stackPanel = new StackPanel
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(0, 1, 0, 1),
            };

            stackPanel.Children.Add(labelWithButton);
            stackPanel.Children.Add(textControl);

            control = stackPanel;
        }
        protected override void CreateControlInternal(
            out FrameworkElement labelControl,
            out FrameworkElement optionControl)
        {
            labelControl = new FormattedTextBlock()
            {
                Content           = this.Name,
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(0, 7, 0, 0)
            };

            var smallChange = this.StepSize;
            var slider      = new Slider
            {
                Minimum             = this.Minimum,
                Maximum             = this.Maximum,
                SmallChange         = smallChange,
                LargeChange         = smallChange,
                VerticalAlignment   = VerticalAlignment.Center,
                Width               = 200,
                Margin              = new Thickness(-10, 2, 0, -3),
                IsSnapToTickEnabled = true,
                TickFrequency       = smallChange
            };

            this.SetupOptionToControlValueBinding(slider, RangeBase.ValueProperty);

            this.SetupSliderControlTooltip(slider);

            optionControl = slider;
        }
Beispiel #3
0
 public SizeF GetTextSize(SizeF proposedSize, TextParams textParams)
 {
     if (this.isDirty)
     {
         this.isDirty   = false;
         this.TextBlock = TinyHTMLParsers.Parse(textParams);
     }
     return(this.TextBlock.GetTextSize(proposedSize, textParams));
 }
Beispiel #4
0
 public SizeF GetTextSize(TextParams textParams)
 {
     if (this.isDirty)
     {
         this.isDirty   = false;
         this.TextBlock = TinyHTMLParsers.Parse(textParams);
     }
     return(this.TextBlock.GetTextSize(new SizeF(float.MaxValue, float.MaxValue), textParams));
 }
Beispiel #5
0
        private FrameworkElement CreateMessageBoxView(DialogViewModelBase viewModel)
        {
            var textBlock = new FormattedTextBlock();

            textBlock.Margin = new Thickness(4);
            textBlock.SetBinding(FormattedTextBlock.TextProperty, "Message");
            textBlock.TextWrapping = TextWrapping.Wrap;
            return(new OkCancelView(textBlock));
        }
Beispiel #6
0
        protected override void CreateControlInternal(out FrameworkElement control)
        {
            //<DataTemplate DataType="{x:Type options:OptionTextBoxDouble}">
            //    <StackPanel Orientation="Horizontal">
            //    <TextBlock Text="{Binding Label}"
            //               Margin="0,0,10,0"
            //               base:ToolTipServiceExtend.ToolTip="{Binding Tooltip}" />
            //    <TextBox Text="{Binding CurrentValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
            //             Width="75" />
            //    </StackPanel>
            //</DataTemplate>

            var label = new FormattedTextBlock()
            {
                Content           = Label,
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(0, 0, 10, 0)
            };

            if (ToolTip != "")
            {
                ToolTipServiceExtend.SetToolTip(label, ToolTip);
            }

            var textbox = new TextBox()
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Right,
                Width = 100
            };

            SetupOptionToControlValueBinding(textbox, TextBox.TextProperty);


            var mainGrid = new Grid()
            {
                Margin = new Thickness(0, 3, 0, 3)
            };

            mainGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            mainGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(100, GridUnitType.Star)
            });
            mainGrid.Children.Add(label);
            Grid.SetColumn(label, 0);
            mainGrid.Children.Add(textbox);
            Grid.SetColumn(textbox, 1);

            control = mainGrid;
        }
Beispiel #7
0
        public void CreateControl(out FrameworkElement control)
        {
            var textControl = new FormattedTextBlock()
            {
                Content             = Text,
                HorizontalAlignment = HorizontalAlignment.Center,
                FontSize            = FontSize,
            };

            control = textControl;
        }
Beispiel #8
0
        public SizeF GetTextSize(TextParams textParams)
        {
            if (this.isDirty)
            {
                this.isDirty   = false;
                this.TextBlock = TinyHTMLParsers.Parse(textParams);
            }

            SizeF proposedSize = new SizeF(float.MaxValue, float.MaxValue);
            SizeF textSize     = this.TextBlock.GetTextSize(proposedSize, textParams);

            return(textSize);
        }
Beispiel #9
0
        protected override void CreateControlInternal(out FrameworkElement control)
        {
            //<DataTemplate DataType="{x:Type options:OptionTextBoxDouble}">
            //    <StackPanel Orientation="Horizontal">
            //    <TextBlock Text="{Binding Label}"
            //               Margin="0,0,10,0"
            //               base:ToolTipServiceExtend.ToolTip="{Binding Tooltip}" />
            //    <TextBox Text="{Binding CurrentValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
            //             Width="75" />
            //    </StackPanel>
            //</DataTemplate>

            var label = new FormattedTextBlock()
            {
                Content           = Label,
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(0, 0, 10, 0)
            };

            if (ToolTip != "")
            {
                ToolTipServiceExtend.SetToolTip(label, ToolTip);
            }

            var textbox = new TextBox()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Width             = 75
            };

            SetupOptionToControlValueBinding(textbox, TextBox.TextProperty);

            var stackPanel = new StackPanel()
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(0, 5, 0, 5)
            };

            stackPanel.Children.Add(label);
            stackPanel.Children.Add(textbox);

            control = stackPanel;
        }
        protected override void CreateControlInternal(
            out FrameworkElement labelControl,
            out FrameworkElement optionControl)
        {
            labelControl = new FormattedTextBlock()
            {
                Content           = this.Name,
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(0, 9, 0, 0)
            };

            var checkbox = new CheckBox()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(0, 12, 0, 0)
            };

            this.SetupOptionToControlValueBinding(checkbox, ToggleButton.IsCheckedProperty);
            optionControl = checkbox;
        }
Beispiel #11
0
        public void CreateControl(out FrameworkElement control)
        {
            var separatorControl1 = new Control()
            {
                Style = Api.Client.UI.GetApplicationResource <Style>("ControlHorizontalSeparator")
            };

            var titleControl = new FormattedTextBlock()
            {
                Content             = Title,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            var separatorControl2 = new Control()
            {
                Style = Api.Client.UI.GetApplicationResource <Style>("ControlHorizontalSeparator")
            };

            var mainGrid = new Grid();

            mainGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            mainGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            mainGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            mainGrid.Children.Add(separatorControl1);
            Grid.SetRow(separatorControl1, 0);
            mainGrid.Children.Add(titleControl);
            Grid.SetRow(titleControl, 1);
            mainGrid.Children.Add(separatorControl2);
            Grid.SetRow(separatorControl2, 2);

            control = mainGrid;
        }
        protected override void CreateControlInternal(
            out FrameworkElement labelControl,
            out FrameworkElement optionControl)
        {
            labelControl = new FormattedTextBlock()
            {
                Content           = this.Name,
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(0, 7, 0, 0)
            };

            var combobox = new ComboBox()
            {
                VerticalAlignment = VerticalAlignment.Center,
                Width             = 200,
                Margin            = new Thickness(0, 10, 0, 0)
            };

            var viewModelsDictionary = this.viewModels.Value;

            combobox.ItemsSource       = viewModelsDictionary.Values.ToArray();
            combobox.DisplayMemberPath = "Description";
            // TODO: rewrite this as soon as NoesisGUI will support value binding for combobox
            // see http://bugs.noesisengine.com/view.php?id=1132
            //combobox.SelectedValuePath = "Value"; // and use Selector.SelectedValueProperty
            //this.SetupOptionToControlValueBinding(combobox, Selector.SelectedItemProperty);

            // use custom binding with converter
            combobox.SetBinding(
                Selector.SelectedItemProperty,
                new Binding("Value")
            {
                Converter = new ConverterEnumToViewModel(viewModelsDictionary)
            });
            combobox.DataContext = this.InternalOptionValueHolder;

            optionControl = combobox;
        }
Beispiel #13
0
        public static void ShowUpdateDialog(string modName, string oldVersion, string newVersion, RssFeedEntry latestRelease)
        {
            if (modListPanel == null)
            {
                modListPanel = new StackPanel()
                {
                    Orientation = Orientation.Vertical
                };
            }

            string text = string.Format("[*] [b]{0}[/b]    v{1} -> v{2}    [url={5}]update[/url]",
                                        modName,
                                        oldVersion,
                                        newVersion,
                                        latestRelease.Date.ToString(),
                                        latestRelease.Description,
                                        latestRelease.Url);

            var textBlock = new FormattedTextBlock()
            {
                Content      = text,
                TextWrapping = TextWrapping.Wrap
            };

            modListPanel.Children.Add(textBlock);

            if (dialogWindowInstance != null)
            {
                dialogWindowInstance.Close(DialogResult.OK);
            }

            dialogWindowInstance = DialogWindow.ShowDialog(
                "New version of mods was found",
                modListPanel,
                () => { },
                cancelAction: null,
                closeByEscapeKey: true);
        }
Beispiel #14
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);
                }
            }
        }
        public virtual UIElement CreateControl()
        {
            var options = this.Options.Where(o => !o.IsHidden).ToList();

            if (options.Count <= 0)
            {
                return(new TextBlock()
                {
                    // ReSharper disable once CanExtractXamlLocalizableStringCSharp
                    Text = "This category has no options",
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center
                });
            }

            var tableControl = new TableControl()
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            tableControl.Loaded
                += (_, e) =>
                {
                if (!tableControl.IsEmpty)
                {
                    return;
                }

                // populate options
                tableControl.Clear();

                // local helper method for getting option order
                IEnumerable <IProtoOption> GetOptionOrder(IProtoOption tab)
                {
                    if (tab.OrderAfterOption is not null)
                    {
                        yield return(tab.OrderAfterOption);
                    }
                }

                foreach (var option in options.OrderBy(o => o.ShortId)
                         .TopologicalSort(GetOptionOrder)
                         .Where(o => !o.IsHidden))
                {
                    option.CreateControl(out var labelControl, out var optionControl);
                    optionControl.Focusable = false;

                    if (!string.IsNullOrEmpty(option.Description))
                    {
                        // wrap into a stackpanel with an info tooltip control
                        var controlInfoPoint = new Control
                        {
                            Style = Api.Client.UI.GetApplicationResource <Style>(
                                "ControlInfoQuestionPointStyle"),
                            VerticalAlignment = VerticalAlignment.Bottom,
                            Margin            = new Thickness(0, 0, 0, 3)
                        };

                        var stackPanel = new StackPanel
                        {
                            Orientation = Orientation.Horizontal,
                            Background  = Brushes.Transparent
                        };

                        stackPanel.Children.Add(optionControl);
                        stackPanel.Children.Add(controlInfoPoint);
                        optionControl = stackPanel;

                        var tooltipContent = new FormattedTextBlock()
                        {
                            Content  = option.Description,
                            MaxWidth = 300
                        };

                        ToolTipServiceExtend.SetToolTip(stackPanel, tooltipContent);
                        ToolTipServiceExtend.SetToolTip(labelControl, tooltipContent);
                    }

                    tableControl.Add(labelControl, optionControl);
                }
                };

            return(new ScrollViewer()
            {
                Content = tableControl,
                VerticalScrollBarVisibility = ScrollBarVisibility.Visible
            });
        }