public UiEncodingLabeledNumber(string label, int width, int minValue, int maxValue, RoutedPropertyChangedEventHandler <object> onValueChanged) { _onValueChanged = onValueChanged; ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); ColumnDefinitions.Add(new ColumnDefinition()); Margin = new Thickness(5); UiTextBlock labelControl = UiTextBlockFactory.Create(label); { labelControl.Margin = new Thickness(5, 5, 2, 5); labelControl.VerticalAlignment = VerticalAlignment.Center; AddUiElement(labelControl, 0, 0); } NumberControl = UiIntegerUpDownFactory.Create(minValue, maxValue); { NumberControl.Width = width; NumberControl.Margin = new Thickness(2, 5, 5, 5); NumberControl.ValueChanged += OnValueChanged; AddUiElement(NumberControl, 0, 1); } }
public UiTextInput() { _textBlock = new UiTextBlock(); _textBlock.SetCaret(); base.AddChild(_textBlock); }
public UiProgressWindow(string title) { #region Construct Height = 72; Width = 320; WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStyle = WindowStyle.None; UiGrid root = UiGridFactory.Create(3, 1); root.SetRowsHeight(GridLength.Auto); root.Margin = new Thickness(5); UiTextBlock titleTextBlock = UiTextBlockFactory.Create(title); { titleTextBlock.VerticalAlignment = VerticalAlignment.Center; titleTextBlock.HorizontalAlignment = HorizontalAlignment.Center; root.AddUiElement(titleTextBlock, 0, 0); } _progressBar = UiProgressBarFactory.Create(); { root.AddUiElement(_progressBar, 1, 0); } _progressTextBlock = UiTextBlockFactory.Create("100%"); { _progressTextBlock.VerticalAlignment = VerticalAlignment.Center; _progressTextBlock.HorizontalAlignment = HorizontalAlignment.Center; root.AddUiElement(_progressTextBlock, 1, 0); } _elapsedTextBlock = UiTextBlockFactory.Create(Lang.Measurement.Elapsed + ": 00:00"); { _elapsedTextBlock.HorizontalAlignment = HorizontalAlignment.Left; root.AddUiElement(_elapsedTextBlock, 2, 0); } _processedTextBlock = UiTextBlockFactory.Create("0 / 0"); { _processedTextBlock.HorizontalAlignment = HorizontalAlignment.Center; root.AddUiElement(_processedTextBlock, 2, 0); } _remainingTextBlock = UiTextBlockFactory.Create(Lang.Measurement.Remaining + ": 00:00"); { _remainingTextBlock.HorizontalAlignment = HorizontalAlignment.Right; root.AddUiElement(_remainingTextBlock, 2, 0); } Content = root; #endregion Loaded += OnLoaded; Closing += OnClosing; _timer = new System.Timers.Timer(500); _timer.Elapsed += OnTimer; }
public UiAudioPlayer() { Orientation = System.Windows.Controls.Orientation.Horizontal; Thickness margin = new Thickness(3); _playbackButton = AddUiElement(new UiImageButton { ImageSource = Icons.PlayIcon, Margin = margin }); _stopButton = AddUiElement(new UiImageButton { ImageSource = Icons.StopIcon, Margin = margin }); _timeTextBlock = AddUiElement(UiTextBlockFactory.Create("00:00 / 00:00")); _timeTextBlock.Margin = margin; _timeTextBlock.VerticalAlignment = VerticalAlignment.Center; _timer = new System.Timers.Timer(1000); _timer.Elapsed += OnTimerTick; _playbackButton.Click += Playback; _stopButton.Click += Stop; ChangeAudioSettings(InteractionService.AudioSettings.Provide()); InteractionService.AudioSettings.InfoProvided += ChangeAudioSettings; }
public UiEncodingLabeledWatermark(string label, string watermark, int width, TextChangedEventHandler onValueChanged) { ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); ColumnDefinitions.Add(new ColumnDefinition()); Margin = new Thickness(5); UiTextBlock labelControl = UiTextBlockFactory.Create(label); { labelControl.Margin = new Thickness(5, 5, 2, 5); labelControl.VerticalAlignment = VerticalAlignment.Center; AddUiElement(labelControl, 0, 0); } _textControl = UiWatermarkTextBoxFactory.Create(watermark); { _textControl.Width = width; _textControl.Margin = new Thickness(2, 5, 5, 5); _textControl.TextChanged += onValueChanged; AddUiElement(_textControl, 0, 1); } }
public static UiTextBlock Create(String text) { UiTextBlock textBlock = new UiTextBlock { Text = text }; return(textBlock); }
public static UiTextBlock Create(string text) { Exceptions.CheckArgumentNull(text, "text"); UiTextBlock textBlock = new UiTextBlock { Text = text }; return(textBlock); }
public UiAdvertListing(Advert advert, ISettings apiSettings) { AdStatus = UiTextBlock.Paragraph(advert.Status.ToString()); AdTitle = UiTextBlock.Emphasis(advert.Title); AdId = UiTextBlock.Paragraph(advert.AdvertReference); AdType = UiTextBlock.Paragraph("Standard"); AdPrice = UiTextBlock.Paragraph(String.Format("{0:C}", advert.EditingData.Price)); AdDateTimeCreated = UiTextBlock.Paragraph(advert.DateCreated.GetHumanReadableDate()); }
private static void SpawnColorItem(Color color, UiSpacer spacer, out UiColumn colorSquare, out UiTextBlock colorText) { colorSquare = new UiColumn(); var colorSquare1 = new UiTexture2D(graphics => Helpers.GetTexture(graphics)); colorSquare1.SetColor(color); colorSquare.AddChild(UiSpacer.GetSpacer(0, 5)); colorSquare.AddChild(colorSquare1); colorText = new UiTextBlock(); colorText.SetString($"{color.R:X2}{color.G:X2}{color.B:X2}"); }
public UiAudioPlayer() { Orientation = System.Windows.Controls.Orientation.Horizontal; Thickness margin = new Thickness(3); _playbackButton = AddUiElement(new UiImageButton {ImageSource = Icons.PlayIcon, Margin = margin}); _stopButton = AddUiElement(new UiImageButton {ImageSource = Icons.StopIcon, Margin = margin}); _timeTextBlock = AddUiElement(UiTextBlockFactory.Create("00:00 / 00:00")); _timeTextBlock.Margin = margin; _timeTextBlock.VerticalAlignment = VerticalAlignment.Center; _timer = new System.Timers.Timer(1000); _timer.Elapsed += OnTimerTick; _playbackButton.Click += Playback; _stopButton.Click += Stop; ChangeAudioSettings(InteractionService.AudioSettings.Provide()); InteractionService.AudioSettings.InfoProvided += ChangeAudioSettings; }
public ModOptionsEvent() { _window = new UiWindow(); _window.Container.SetBackground("mods/Fox Core V3/Staxel/UI/Backgrounds/Dark/DarkBackground.json"); _window.Container.SetMinWidth(250); _window.Container.SetMinHeight(250); var selectable = new UiSelectable(); selectable.SetActiveBackgroundColor(Color.Green); selectable.SetActiveTextColor(Color.Red); selectable.SetBackground("mods/Fox Core V3/Staxel/UI/Backgrounds/Dark/DarkBackground.json"); var text = new UiTextBlock(); text.SetString("Hello World"); _window.AddChild(selectable); selectable.AddChild(text); _window.OnShow += () => { ClientContext.WebOverlayRenderer.AcquireInputControl(); }; _window.OnHide += () => { ClientContext.WebOverlayRenderer.ReleaseInputControl(); }; _window.OnClose += () => { ClientContext.WebOverlayRenderer.ReleaseInputControl(); }; _window.Show(); }
public UiEncodingMainCharacterControl() { Orientation = Orientation.Horizontal; VerticalAlignment = VerticalAlignment.Center; #region Construct _indexLabel = UiTextBlockFactory.Create("#"); { _indexLabel.Margin = new Thickness(5); _indexLabel.VerticalAlignment = VerticalAlignment.Center; Children.Add(_indexLabel); } _ox = AddUiElement(new UiEncodingLabeledNumber("OX:", 60, 0, short.MaxValue, OXChanged)); _oy = AddUiElement(new UiEncodingLabeledNumber("OY:", 60, 0, short.MaxValue, OYChanged)); _before = AddUiElement(new UiEncodingLabeledNumber(Lang.EncodingEditor.Main.Before, 50, sbyte.MinValue, sbyte.MaxValue, BeforeChanged)); _width = AddUiElement(new UiEncodingLabeledNumber(Lang.EncodingEditor.Main.Width, 50, 0, sbyte.MaxValue, WidthChanged)); _after = AddUiElement(new UiEncodingLabeledNumber(Lang.EncodingEditor.Main.After, 50, sbyte.MinValue, sbyte.MaxValue, AfterChanged)); _output = AddUiElement(new UiEncodingLabeledWatermark(Lang.EncodingEditor.Main.ToText, "0x31->\"1\"", 50, OnOutputTextChanged)); _input = AddUiElement(new UiEncodingLabeledWatermark(Lang.EncodingEditor.Main.FromText, "0x31<-\"1\"", 70, OnInputTextChanged)); #endregion }
public UiNumberInput() { _textInput = new UiTextInput(); _textInput.SetBackground(Constants.Backgrounds.TextInput); _textInput.SetTextColor(Color.Black); _textInput.SetActiveTextColor(Color.Black); _textInput.InputCheck += ch => { switch (ch) { default: return(false); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': return(true); } }; _textInput.OnChange += text => { if (float.TryParse(text, out var value)) { SetValue(value, true); } }; _displayRow = new UiRow(); var downButton = new UiButton(); downButton.SetBackground(Constants.Backgrounds.Button); downButton.OnHold += () => { SetValue(_value - _itterations, true); }; downButton.SetTextColor(Color.Black); downButton.SetActiveTextColor(Color.Black); var downText = new UiTextBlock(); downText.SetString("-"); downButton.AddChild(downText); var spacer = UiSpacer.GetSpacer(5, 5); _displayRow.AddChild(downButton); _displayRow.AddChild(spacer); base.AddChild(_displayRow); var upButton = new UiButton(); upButton.SetBackground(Constants.Backgrounds.Button); upButton.OnHold += () => { SetValue(_value + _itterations, true); }; var inputColumn = new UiColumn(); inputColumn.AddChild(spacer); inputColumn.AddChild(_textInput); inputColumn.AddChild(spacer); _displayRow.AddChild(inputColumn); _displayRow.AddChild(spacer); _displayRow.AddChild(upButton); upButton.SetTextColor(Color.Black); upButton.SetActiveTextColor(Color.Black); var upText = new UiTextBlock(); upText.SetString("+"); upButton.AddChild(upText); SetSize(60, 30); }
private static void SpawnInputTextWindow(UiWindow window, UiSpacer spacer, string labelText, string titleText, Func <string, bool> validationAndSuccess, string errorTitle, string errorMessage, Action onClose) { var textInputWindow = new UiWindow(); textInputWindow.Container.SetBackground(Constants.Backgrounds.Dark); textInputWindow.ListenForEscape(true); textInputWindow.OnClose += () => { onClose(); }; var title = new UiTextBlock(); title.SetColor(Color.Orange); title.SetFont(Constants.Fonts.MyFirstCrush36); title.SetString(titleText); textInputWindow.AddChild(title); textInputWindow.AddChild(spacer); var inputRow = new UiRow(); textInputWindow.AddChild(inputRow); textInputWindow.AddChild(spacer); var label = new UiTextBlock(); label.SetString(labelText); inputRow.AddChild(label); inputRow.AddChild(spacer); var input = new UiTextInput(); input.SetBackgroundColor(new Color(237, 207, 154)); input.SetTextColor(Color.Black); input.SetActiveTextColor(Color.Black); input.SetBackground(Constants.Backgrounds.TextInput); inputRow.AddChild(input); input.SetSize(300); input.SetLimit(25); var buttonRow = new UiRow(); textInputWindow.AddChild(buttonRow); var createButton = new UiButton(); buttonRow.AddChild(createButton); buttonRow.AddChild(spacer); var createText = new UiTextBlock(); createText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.create")); createButton.AddChild(createText); createButton.OnClick += () => { if (validationAndSuccess(input.GetValue())) { textInputWindow.Dispose(); } else { var errorWindow = new UiWindow(); errorWindow.Container.SetBackground(Constants.Backgrounds.Dark); var errorTitleText = new UiTextBlock(); errorTitleText.SetColor(Color.Orange); errorTitleText.SetFont(Constants.Fonts.MyFirstCrush36); errorTitleText.SetString(errorTitle); errorWindow.AddChild(errorTitleText); errorWindow.AddChild(spacer); var message = new UiTextBlock(); message.SetString(errorMessage); message.SetColor(Color.Red); errorWindow.AddChild(message); errorWindow.AddChild(spacer); var okButton = new UiButton(); var okText = new UiTextBlock(); okText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.ok")); okButton.AddChild(okText); okButton.OnClick += () => { textInputWindow.StartUpdateCalls(); errorWindow.Dispose(); }; errorWindow.AddChild(okButton); textInputWindow.AddChildWindow(errorWindow); textInputWindow.ListenForEscape(false); textInputWindow.StopUpdateCalls(); errorWindow.ListenForEscape(true); errorWindow.OnClose += () => { textInputWindow.ListenForEscape(true); textInputWindow.StartUpdateCalls(); }; errorWindow.Show(); } }; var cancelButton = new UiButton(); buttonRow.AddChild(cancelButton); var cancelText = new UiTextBlock(); cancelButton.AddChild(cancelText); cancelText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.cancel")); cancelButton.OnClick += () => { textInputWindow.Dispose(); }; window.Hide(); window.ListenForEscape(false); window.AddChildWindow(textInputWindow); window.StopUpdateCalls(); textInputWindow.Show(); }
private static UiElement SpawnFolderItem(UiWindow window, UiWindow parent, UiSpacer spacer, Action <Color> setColor, string folder, Func <string, bool> onClick, Action <UiWindow, UiSpacer, Action <Color> > renew) { var itemRow = new UiRow(); var itemButton = new UiButton(); itemRow.AddChild(itemButton); var itemText = new UiTextBlock(); itemText.SetString(folder); itemButton.AddChild(itemText); itemRow.AddChild(spacer); itemButton.OnClick += () => { if (onClick(folder)) { parent.Dispose(); } }; var deleteButton = new UiButton(); itemRow.AddChild(deleteButton); var deleteIcon = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.delete.text"); deleteButton.AddChild(deleteIcon); deleteButton.OnClick += () => { var confirmWindow = new UiWindow(); confirmWindow.Container.SetBackground(Constants.Backgrounds.Dark); parent.AddChildWindow(confirmWindow); var confirmTitle = new UiTextBlock(); confirmWindow.AddChild(confirmTitle); confirmTitle.SetFont(Constants.Fonts.MyFirstCrush36); confirmTitle.SetColor(Color.Orange); confirmTitle.SetString(string.Format(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.deleteTitle"), folder)); confirmWindow.AddChild(spacer); var confirmMessage = new UiTextBlock(); confirmWindow.AddChild(confirmMessage); confirmMessage.SetString(string.Format(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.deleteMessage"), folder)); confirmWindow.AddChild(spacer); var buttonRow = new UiRow(); confirmWindow.AddChild(buttonRow); var confirmButton = new UiButton(); buttonRow.AddChild(confirmButton); var confirmButtonText = new UiTextBlock(); confirmButton.AddChild(confirmButtonText); confirmButtonText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.delete")); buttonRow.AddChild(spacer); confirmButton.OnClick += () => { if (_favDir.FileExists(folder)) { _favDir.DeleteFile(folder); } parent.Dispose(); renew(window, spacer, setColor); }; confirmWindow.OnClose += () => { parent.ListenForEscape(true); parent.Show(); parent.StartUpdateCalls(); }; var cancelButton = new UiButton(); buttonRow.AddChild(cancelButton); var cancelText = new UiTextBlock(); cancelButton.AddChild(cancelText); cancelText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.cancel")); cancelButton.OnClick += () => { confirmWindow.Dispose(); }; parent.Hide(); parent.ListenForEscape(false); parent.StopUpdateCalls(); confirmWindow.Show(); }; return(itemRow); }
private static void SpawnHistoryColorItem(UiWindow window, UiWindow parentwindow, Color color, UiSpacer spacer, Action <Color> setColor, Action <UiWindow, UiSpacer, Action <Color> > renew, Action <Color> remove, bool showAddFav, out UiColumn colorSquare, out UiTextBlock colorText, out UiRow buttons) { SpawnColorItem(color, spacer, out colorSquare, out colorText); var buttonSpacer = UiSpacer.GetSpacer(5, 5); buttons = new UiRow(); if (showAddFav) { var addToFavButton = new UiButton(); addToFavButton.SetBackground(Constants.Backgrounds.Button); var addToFavePic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.addFavorite"); addToFavButton.AddChild(addToFavePic); buttons.AddChild(addToFavButton); buttons.AddChild(buttonSpacer); addToFavButton.OnClick += () => { _historyColor = color; SpawnAddToFavFromHistoryMenu(parentwindow, spacer, setColor); }; } var setButton = new UiButton(); setButton.SetBackground(Constants.Backgrounds.Button); var setPic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.set"); setButton.AddChild(setPic); setButton.OnClick += () => { setColor(color); parentwindow.Dispose(); }; buttons.AddChild(setButton); buttons.AddChild(buttonSpacer); var deleteButton = new UiButton(); deleteButton.SetBackground(Constants.Backgrounds.Button); var deletePic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.delete"); deleteButton.AddChild(deletePic); deleteButton.OnClick += () => { remove(color); parentwindow.Dispose(); renew(window, spacer, setColor); }; buttons.AddChild(deleteButton); }
public UiAdvertListings(string title, List <UiAdvertListing> advertListings) { Title = UiTextBlock.SectionTitle(title); AdvertListings = advertListings; }
private static void SpawnFavoriteFolderMenuContent(UiWindow window, UiWindow favFolderMenuWindow, UiSpacer spacer, Action <Color> setColor) { var scrollable = new UiScrollableContainer(); scrollable.SetDimensions(400, 500); var favFolderMenuTitle = new UiTextBlock(); favFolderMenuTitle.SetFont(Constants.Fonts.MyFirstCrush36); favFolderMenuTitle.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.favorites")); favFolderMenuTitle.SetColor(Color.Orange); favFolderMenuWindow.AddChild(favFolderMenuTitle); favFolderMenuWindow.AddChild(spacer); favFolderMenuWindow.AddChild(scrollable); var newFolderButton = new UiButton(); var newFolderText = new UiTextBlock(); newFolderText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder")); newFolderButton.OnClick += () => { favFolderMenuWindow.Dispose(); SpawnInputTextWindow(window, spacer, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.name") + ":", ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder"), value => { if (_favDir.Files .Any(x => x.ToLower() == value.ToLower())) { return(false); } using (var stream = _favDir .ObtainFileStream(value, FileMode.Create, FileAccess.ReadWrite)) { stream.Seek(0L, SeekOrigin.Begin); } return(true); }, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists"), ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists.message"), () => { SpawnFavoriteFolderMenu(window, spacer, setColor); }); }; newFolderButton.AddChild(newFolderText); scrollable.AddChild(newFolderButton); scrollable.AddChild(spacer); var files = _favDir.Files; if (files.Any()) { foreach (var file in files) { scrollable.AddChild(SpawnFolderItem(window, favFolderMenuWindow, spacer, setColor, file, (folder) => { SpawnFolderColorWindow(favFolderMenuWindow, spacer, setColor, folder); return(false); }, SpawnFavoriteFolderMenu)); scrollable.AddChild(spacer); } } var closeButton = new UiButton(); closeButton.SetBackground(Constants.Backgrounds.Button); var closeText = new UiTextBlock(); closeText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.close")); closeButton.AddChild(closeText); favFolderMenuWindow.AddChild(closeButton); closeButton.OnClick += favFolderMenuWindow.Dispose; }
private static void SpawnAddToFavFromHistoryMenuContent(UiWindow window, UiWindow favFolderMenuWindow, UiSpacer spacer, Action <Color> setColor) { var scrollable = new UiScrollableContainer(); scrollable.SetDimensions(400, 500); var favFolderMenuTitle = new UiTextBlock(); favFolderMenuTitle.SetFont(Constants.Fonts.MyFirstCrush36); favFolderMenuTitle.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.favorites")); favFolderMenuTitle.SetColor(Color.Orange); favFolderMenuWindow.AddChild(favFolderMenuTitle); favFolderMenuWindow.AddChild(spacer); favFolderMenuWindow.AddChild(scrollable); var newFolderButton = new UiButton(); var newFolderText = new UiTextBlock(); newFolderText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder")); newFolderButton.OnClick += () => { favFolderMenuWindow.StopUpdateCalls(); favFolderMenuWindow.Dispose(); SpawnInputTextWindow(window, spacer, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.name") + ":", ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.newFolder"), value => { if (_favDir.Files.Any(x => x.ToLower() == value.ToLower())) { return(false); } using (var stream = _favDir .ObtainFileStream(value, FileMode.Create, FileAccess.ReadWrite)) { stream.Seek(0L, SeekOrigin.Begin); } return(true); }, ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists"), ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.folderExists.message"), () => { SpawnAddToFavFromHistoryMenu(window, spacer, setColor); }); }; newFolderButton.AddChild(newFolderText); scrollable.AddChild(newFolderButton); scrollable.AddChild(spacer); var files = _favDir.Files; if (files.Any()) { foreach (var file in files) { scrollable.AddChild(SpawnFolderItem(window, favFolderMenuWindow, spacer, setColor, file, (folder) => { var values = new List <string>(); if (_favDir.FileExists(folder)) { values.AddRange( File.ReadAllLines( Path.Combine(_favDir.GetPath(Path.DirectorySeparatorChar), folder))); } if (!values.Contains($"{_historyColor.R:X2}{_historyColor.G:X2}{_historyColor.B:X2}")) { values.Add($"{_historyColor.R:X2}{_historyColor.G:X2}{_historyColor.B:X2}"); } File.WriteAllLines(Path.Combine(_favDir.GetPath(Path.DirectorySeparatorChar), folder), values); return(true); }, SpawnAddToFavFromHistoryMenu)); scrollable.AddChild(spacer); } } var closeButton = new UiButton(); closeButton.SetBackground(Constants.Backgrounds.Button); var closeText = new UiTextBlock(); closeText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.close")); closeButton.AddChild(closeText); scrollable.AddChild(closeButton); closeButton.OnClick += () => { favFolderMenuWindow.Dispose(); window.ListenForEscape(true); window.Show(); window.StartUpdateCalls(); }; }
private static void SpawnColorWindowContent(UiWindow window, UiWindow historyWindow, UiSpacer spacer, Action <Color> setColor, Action <UiWindow, UiSpacer, Action <Color> > renew, Action <Color> remove, List <Color> colors, string title, string noColorText, bool showAddToFav = false) { var historyTitle = new UiTextBlock(); historyTitle.SetString(title); historyTitle.SetColor(Color.Orange); historyTitle.SetFont(Constants.Fonts.MyFirstCrush36); historyWindow.AddChild(historyTitle); historyWindow.AddChild(spacer); if (!colors.Any()) { var historyText = new UiTextBlock(); historyText.SetString(noColorText); historyWindow.AddChild(historyText); } else { var column1 = new UiRow(); var column1Squares = new UiColumn(); var column1Text = new UiColumn(); var column1Buttons = new UiColumn(); column1.AddChild(column1Squares); column1.AddChild(UiSpacer.GetSpacer()); column1.AddChild(column1Text); column1.AddChild(UiSpacer.GetSpacer()); column1.AddChild(column1Buttons); var column2 = new UiRow(); var column2Squares = new UiColumn(); var column2Text = new UiColumn(); var column2Buttons = new UiColumn(); column2.AddChild(column2Squares); column2.AddChild(UiSpacer.GetSpacer()); column2.AddChild(column2Text); column2.AddChild(UiSpacer.GetSpacer()); column2.AddChild(column2Buttons); var column = 1; var count = 0; foreach (var color in colors) { SpawnHistoryColorItem(window, historyWindow, color, spacer, setColor, renew, remove, showAddToFav, out var colorSquare, out var colorText, out var buttons); if (count >= 2) { if (column == 1) { column1Squares.AddChild(UiSpacer.GetSpacer(0, 20)); column1Text.AddChild(UiSpacer.GetSpacer(0, 12)); column1Buttons.AddChild(UiSpacer.GetSpacer(0, 15)); } else { column2Squares.AddChild(UiSpacer.GetSpacer(0, 20)); column2Text.AddChild(UiSpacer.GetSpacer(0, 12)); column2Buttons.AddChild(UiSpacer.GetSpacer(0, 15)); } } if (column == 1) { column1Squares.AddChild(colorSquare); column1Text.AddChild(colorText); column1Buttons.AddChild(buttons); column = 2; } else { column2Squares.AddChild(colorSquare); column2Text.AddChild(colorText); column2Buttons.AddChild(buttons); column = 1; } count++; } var columnRow = new UiRow(); columnRow.AddChild(column1); if (colors.Count >= 2) { columnRow.AddChild(UiSpacer.GetSpacer(10, 0)); columnRow.AddChild(column2); } var scrollable = new UiScrollableContainer(); scrollable.AddChild(columnRow); scrollable.SetDimensions(600, 400); historyWindow.AddChild(scrollable); } historyWindow.AddChild(spacer); var closeButton = new UiButton(); closeButton.SetBackground(Constants.Backgrounds.Button); var closeText = new UiTextBlock(); closeText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.close")); closeButton.AddChild(closeText); historyWindow.AddChild(closeButton); closeButton.OnClick += historyWindow.Dispose; }
public ColorPickerWindow(Color?_default = null) { if (_default != null) { _color = _default.Value; } _current = new UiWindow(); _current.ListenForEscape(true); _current.Container.SetBackground(Constants.Backgrounds.Dark); var picker = new UiColorPicker(); var currentColor = new UiTexture2D(context => Helpers.GetTexture(context)); var hoverColor = new UiTexture2D(context => Helpers.GetTexture(context)); var selectedColor = new UiTexture2D(context => Helpers.GetTexture(context)); selectedColor.SetColor(_color); currentColor.SetColor(_color); var row = new UiRow(); row.AddChild(picker); var column = new UiColumn(); var spacer = new UiSpacer(); spacer.SetHeight(20); spacer.SetWidth(20); row.AddChild(spacer); var mouseText = new UiTextBlock(); mouseText.SetColor(Color.White); mouseText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.mouse")); column.AddChild(mouseText); column.AddChild(hoverColor); column.AddChild(spacer); var selectedText = new UiTextBlock(); selectedText.SetColor(Color.White); selectedText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.selected")); column.AddChild(selectedText); column.AddChild(selectedColor); column.AddChild(spacer); var currentText = new UiTextBlock(); currentText.SetColor(Color.White); currentText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.current")); column.AddChild(currentText); column.AddChild(currentColor); row.AddChild(column); _current.AddChild(row); _current.AddChild(spacer); var colorRow = new UiRow(); UiTextInput colorHex = null; var colorR = new UiNumberInput(); colorR.SetItteration(1.0f); colorR.SetMin(0); colorR.SetMax(255); colorR.SetValue(_color.R); colorR.SetBackgroundColors(Color.Red, Color.Pink); colorR.OnChange += value => { if (byte.TryParse(value.ToString(), out var val)) { _color.R = val; colorHex?.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}"); selectedColor.SetColor(_color); } }; var colorG = new UiNumberInput(); colorG.SetItteration(1.0f); colorG.SetMin(0); colorG.SetMax(255); colorG.SetValue(_color.G); colorG.SetBackgroundColors(Color.Green, Color.LimeGreen); colorG.OnChange += value => { if (byte.TryParse(value.ToString(), out var val)) { _color.G = val; colorHex?.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}"); selectedColor.SetColor(_color); } }; var colorB = new UiNumberInput(); colorB.SetItteration(1.0f); colorB.SetMin(0); colorB.SetMax(255); colorB.SetValue(_color.B); colorB.SetBackgroundColors(Color.Blue, Color.LightBlue); colorB.SetTextColors(Color.White, Color.Black); colorB.OnChange += value => { if (byte.TryParse(value.ToString(), out var val)) { _color.B = val; colorHex?.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}"); selectedColor.SetColor(_color); } }; var colorHexRow = new UiRow(); var hex = new UiTextBlock(); hex.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.hex")); colorHex = new UiTextInput(); colorHex.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}"); colorHex.SetBackgroundColor(new Color(237, 207, 154)); colorHex.SetTextColor(Color.Black); colorHex.SetActiveTextColor(Color.Black); colorHex.SetBackground(Constants.Backgrounds.TextInput); colorHex.SetLimit(6); colorHex.InputCheck += key => { switch (key.ToString().ToUpper()) { default: return(false); case "A": case "B": case "C": case "D": case "E": case "F": case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": return(true); } }; colorHex.OnChange += text => { if (text.IsNullOrEmpty()) { _color = Color.Black; } else { _color = ColorMath.ParseString(text); } selectedColor.SetColor(_color); colorR.ForceSetValue(_color.R); colorG.ForceSetValue(_color.G); colorB.ForceSetValue(_color.B); }; picker.ColorClick += color => { selectedColor.SetColor(color); _color = color; colorR.ForceSetValue(_color.R); colorG.ForceSetValue(_color.G); colorB.ForceSetValue(_color.B); colorHex.ForceSetValue($"{_color.R:X2}{_color.G:X2}{_color.B:X2}"); }; colorRow.AddChild(colorR); colorRow.AddChild(spacer); colorRow.AddChild(colorG); colorRow.AddChild(spacer); colorRow.AddChild(colorB); _current.AddChild(colorRow); _current.AddChild(spacer); colorHexRow.AddChild(hex); colorHexRow.AddChild(colorHex); _current.AddChild(colorHexRow); _current.AddChild(spacer); var confirmButton = new UiButton(); confirmButton.SetBackground(Constants.Backgrounds.Button); var confirmText = new UiTextBlock(); confirmText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.setColor")); confirmButton.AddChild(confirmText); confirmButton.OnClick += () => { OnColorSet?.Invoke(_color); if (_colorHistory.Contains(_color)) { _colorHistory.Remove(_color); } _colorHistory.Add(_color); _current.Dispose(); }; var cancelButton = new UiButton(); cancelButton.SetBackground(Constants.Backgrounds.Button); var cancelText = new UiTextBlock(); cancelText.SetString(ClientContext.LanguageDatabase.GetTranslationString("nimbusfox.foxcore.text.cancel")); cancelButton.AddChild(cancelText); cancelButton.OnClick += () => { _current.Dispose(); }; var buttonRow = new UiRow(); buttonRow.AddChild(confirmButton); buttonRow.AddChild(spacer); buttonRow.AddChild(cancelButton); buttonRow.AddChild(spacer); var favButton = new UiButton(); favButton.SetBackground(Constants.Backgrounds.Button); var favPic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.favorites"); favButton.AddChild(favPic); buttonRow.AddChild(favButton); buttonRow.AddChild(spacer); favButton.OnClick += () => { SpawnFavoriteFolderMenu(_current, spacer, color => { colorHex.ForceSetValue($"{color.R:X2}{color.G:X2}{color.B:X2}", true); }); }; var historyButton = new UiButton(); historyButton.SetBackground(Constants.Backgrounds.Button); var historyPic = FoxUIHook.Instance.GetPicture("nimbusfox.ui.images.history"); historyButton.AddChild(historyPic); buttonRow.AddChild(historyButton); historyButton.OnClick += () => { SpawnHistoryWindow(_current, spacer, color => { colorHex.ForceSetValue($"{color.R:X2}{color.G:X2}{color.B:X2}", true); }); }; _current.AddChild(buttonRow); picker.ColorHover += color => { hoverColor.SetColor(color); }; _current.OnClose += () => { OnClose?.Invoke(); }; }
public UiAdvertListDetails(string advertSummary) { AdvertSummary = UiTextBlock.SectionSubtitle(advertSummary); CreateAdBtn = UiControlButton.Primary("manage-ad", "Create ad", new UiActionNavigate("https://www.carsales.com.au/sell-my-car")); }
public UiGameFileCommanderSettingsWindow(bool isExtracting) { #region Construct SizeToContent = SizeToContent.WidthAndHeight; WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStyle = WindowStyle.None; UiGrid root = UiGridFactory.Create(3, 1); { Thickness margin = new Thickness(3); UiStackPanel maskPanel = UiStackPanelFactory.Create(Orientation.Horizontal); { UiTextBlock maskLabel = UiTextBlockFactory.Create("Маска: "); { maskLabel.Margin = margin; maskLabel.VerticalAlignment = VerticalAlignment.Center; maskPanel.AddUiElement(maskLabel); } _wildcardBox = UiTextBoxFactory.Create("*"); { _wildcardBox.Width = 300; _wildcardBox.Margin = margin; maskPanel.AddUiElement(_wildcardBox); } root.AddUiElement(maskPanel, 0, 0); } UiStackPanel settingsPanel = UiStackPanelFactory.Create(Orientation.Horizontal); { if (!isExtracting) { _compressBox = UiCheckBoxFactory.Create("Сжать", false); { _compressBox.Margin = margin; _compressBox.IsThreeState = true; _compressBox.IsChecked = null; settingsPanel.AddUiElement(_compressBox); } } _convertBox = UiCheckBoxFactory.Create("Конвертировать", false); { _convertBox.Margin = margin; _convertBox.IsThreeState = true; _convertBox.IsChecked = null; settingsPanel.AddUiElement(_convertBox); } root.AddUiElement(settingsPanel, 1, 0); } UiStackPanel buttonsPanel = UiStackPanelFactory.Create(Orientation.Horizontal); { buttonsPanel.HorizontalAlignment = HorizontalAlignment.Right; UiButton okButton = UiButtonFactory.Create("OK"); { okButton.Width = 100; okButton.Margin = margin; okButton.Click += OnOkButtonClick; buttonsPanel.AddUiElement(okButton); } UiButton cancelButton = UiButtonFactory.Create("Отмена"); { cancelButton.Width = 100; cancelButton.Margin = margin; cancelButton.Click += OnCancelButtonClick; buttonsPanel.AddUiElement(cancelButton); } root.AddUiElement(buttonsPanel, 2, 0); } } Content = root; #endregion }
public UiEncodingAdditionalCharacterControl() { Orientation = Orientation.Horizontal; VerticalAlignment = VerticalAlignment.Center; #region Construct _indexLabel = UiTextBlockFactory.Create("#"); { _indexLabel.Margin = new Thickness(5); _indexLabel.VerticalAlignment = VerticalAlignment.Center; Children.Add(_indexLabel); } UiTextBlock rowLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.Row); { rowLabel.Margin = new Thickness(5, 5, 2, 5); rowLabel.VerticalAlignment = VerticalAlignment.Center; Children.Add(rowLabel); } _rowNumber = UiIntegerUpDownFactory.Create(0, byte.MaxValue); { _rowNumber.Width = 50; _rowNumber.Margin = new Thickness(2, 5, 5, 5); _rowNumber.ValueChanged += OnRowValueChanged; Children.Add(_rowNumber); } UiTextBlock colLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.Column); { colLabel.Margin = new Thickness(5, 5, 2, 5); colLabel.VerticalAlignment = VerticalAlignment.Center; Children.Add(colLabel); } _colNumber = UiIntegerUpDownFactory.Create(0, byte.MaxValue); { _colNumber.Width = 50; _colNumber.Margin = new Thickness(2, 5, 5, 5); _colNumber.ValueChanged += OnColValueChanged; Children.Add(_colNumber); } UiTextBlock outputLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.ToText); { outputLabel.Margin = new Thickness(5, 5, 2, 5); outputLabel.VerticalAlignment = VerticalAlignment.Center; Children.Add(outputLabel); } _output = UiWatermarkTextBoxFactory.Create("0x31->\"1\""); { _output.Width = 60; _output.Margin = new Thickness(2, 5, 5, 5); _output.TextChanged += OnOutputTextChanged; Children.Add(_output); } UiTextBlock inputLabel = UiTextBlockFactory.Create(Lang.EncodingEditor.Extra.FromText); { inputLabel.Margin = new Thickness(5, 5, 2, 5); inputLabel.VerticalAlignment = VerticalAlignment.Center; Children.Add(inputLabel); } _input = UiWatermarkTextBoxFactory.Create("0x31<-\"1\""); { _input.Width = 100; _input.Margin = new Thickness(2, 5, 5, 5); _input.TextChanged += OnInputTextChanged; Children.Add(_input); } #endregion }
public DonationControl() { SetCols(2); SetRows(5); Width = 250; VerticalAlignment = VerticalAlignment.Top; HorizontalAlignment = HorizontalAlignment.Left; Margin = new Thickness(5); DataContext = this; ColumnDefinitions[0].Width = GridLength.Auto; LinearGradientBrush backgroundStroke = new LinearGradientBrush { EndPoint = new Point(0.5, 1), StartPoint = new Point(0.5, 0), RelativeTransform = new RotateTransform(115, 0.5, 0.5), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xff, 0x61, 0x61, 0x61), 0), new GradientStop(Color.FromArgb(0xff, 0xF2, 0xF2, 0xF2), 0.504), new GradientStop(Color.FromArgb(0xff, 0xAE, 0xB1, 0xB1), 1) } }; backgroundStroke.Freeze(); LinearGradientBrush backgroundFill = new LinearGradientBrush { MappingMode = BrushMappingMode.RelativeToBoundingBox, StartPoint = new Point(0.5, 1.0), EndPoint = new Point(0.5, -0.4), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xBB, 0x44, 0x71, 0xc1), 0), new GradientStop(Color.FromArgb(0xBB, 0x28, 0x36, 0x65), 1) } }; backgroundFill.Freeze(); Rectangle backround = AddUiElement(new Rectangle { Stroke = backgroundStroke, Fill = backgroundFill, StrokeThickness = 5 }, 0, 0, 9, 2); UiTextBlock title = AddUiElement(UiTextBlockFactory.Create("Пожертвования"), 0, 0, 0, 2); title.FontSize = 18; title.HorizontalAlignment = HorizontalAlignment.Center; title.Margin = new Thickness(0, 4, 0, 0); AddUiElement(UiTextBoxFactory.Create("Яндекс: "), 1, 0); AddUiElement(UiTextBoxFactory.Create("410013254932482"), 1, 1); AddUiElement(UiTextBoxFactory.Create("WMR: "), 2, 0); AddUiElement(UiTextBoxFactory.Create("R255847965836"), 2, 1); AddUiElement(UiTextBoxFactory.Create("WMZ: "), 3, 0); AddUiElement(UiTextBoxFactory.Create("Z321220468886 "), 3, 1); AddUiElement(UiTextBoxFactory.Create("WME: "), 4, 0); AddUiElement(UiTextBoxFactory.Create("E223137827385"), 4, 1).Margin = new Thickness(0, 0, 0, 5); foreach (FrameworkElement child in Children) { if (!ReferenceEquals(child, backround)) { child.Margin = GetColumn(child) == 0 ? new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right, child.Margin.Bottom) : new Thickness(child.Margin.Left, child.Margin.Top, child.Margin.Right + 8, child.Margin.Bottom); } TextBlock textBlock = child as TextBlock; if (textBlock != null) { textBlock.Foreground = Brushes.WhiteSmoke; textBlock.FontWeight = FontWeight.FromOpenTypeWeight(500); continue; } TextBox textBox = child as TextBox; if (textBox != null) { textBox.Foreground = Brushes.WhiteSmoke; textBox.FontWeight = FontWeight.FromOpenTypeWeight(500); textBox.Background = Brushes.Transparent; textBox.BorderThickness = new Thickness(0); textBox.IsReadOnly = true; } } }