protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); MultilineLabel multilineLabel = (MultilineLabel)Element; if (multilineLabel != null && multilineLabel.Lines != -1) { Control.SetSingleLine(false); Control.SetLines(multilineLabel.Lines); } }
public AboutModsPanel(Panel containingPanel, IModManager modManager, int desiredHeight = 500, int desiredWidth = 750) { _modManager = modManager; ModListBox = new ListBox(containingPanel.Manager); ModListBox.Init(); ModListBox.Top = ModListBox.Margins.Top; ModListBox.Left = ModListBox.Margins.Left; ModListBox.Width = 250; ModListBox.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModListBox.Top - ModListBox.Margins.Bottom; ModListBox.HideSelection = false; ModListBox.c81fb310624c15a101535d14adc9ec383.Add("Gnomodia"); ModListBox.ItemIndexChanged += ModListBoxOnItemIndexChanged; foreach (var modMetadata in modManager.ModMetadata) { ModListBox.c81fb310624c15a101535d14adc9ec383.Add(modMetadata.Name); } containingPanel.Add(ModListBox); ModInfoPanel = new LoweredPanel(containingPanel.Manager); ModInfoPanel.Init(); ModInfoPanel.Left = ModListBox.Left + ModListBox.Width + ModListBox.Margins.Right + ModInfoPanel.Margins.Left; ModInfoPanel.Top = ModInfoPanel.Margins.Top; ModInfoPanel.Width = desiredWidth - ModInfoPanel.Left - ModInfoPanel.Margins.Right; ModInfoPanel.Height = desiredHeight - containingPanel.ClientMargins.Vertical - ModInfoPanel.Top - ModInfoPanel.Margins.Bottom; ModInfoPanel.AutoScroll = true; ModInfoPanel.HorizontalScrollBarEnabled = false; ModInfoPanel.VerticalScrollBarShow = true; containingPanel.Add(this.ModInfoPanel); _titleLabel = new Label(containingPanel.Manager); _titleLabel.Init(); _titleLabel.Top = _titleLabel.Margins.Top; _titleLabel.Left = _titleLabel.Margins.Left; _titleLabel.Height = 14; _titleLabel.Width = ModInfoPanel.ClientWidth - _titleLabel.Margins.Horizontal; _titleLabel.Text = ""; ModInfoPanel.Add(_titleLabel); _versionLabel = new Label(containingPanel.Manager); _versionLabel.Init(); _versionLabel.Left = _versionLabel.Margins.Left; _versionLabel.Height = 14; _versionLabel.Width = ModInfoPanel.Width - _versionLabel.Margins.Horizontal; _versionLabel.Top = _titleLabel.Top + _titleLabel.Height + _titleLabel.Margins.Bottom + _versionLabel.Margins.Top; _versionLabel.Text = ""; ModInfoPanel.Add(_versionLabel); _authorLabel = new Label(containingPanel.Manager); _authorLabel.Init(); _authorLabel.Left = _authorLabel.Margins.Left; _authorLabel.Height = 14; _authorLabel.Width = ModInfoPanel.Width - _authorLabel.Margins.Horizontal; _authorLabel.Top = _versionLabel.Top + _versionLabel.Height + _versionLabel.Margins.Bottom + _authorLabel.Margins.Top; _authorLabel.Text = ""; ModInfoPanel.Add(_authorLabel); _infoLabel = new MultilineLabel(containingPanel.Manager); _infoLabel.Left = _infoLabel.Margins.Left; _infoLabel.Height = 0; _infoLabel.Top = _authorLabel.Top + _authorLabel.Height + _authorLabel.Margins.Bottom + _infoLabel.Margins.Top; _infoLabel.Width = ModInfoPanel.ClientWidth - _infoLabel.Margins.Horizontal; _infoLabel.Anchor = Anchors.Top | Anchors.Left | Anchors.Right; _infoLabel.Alignment = Alignment.TopLeft; ModInfoPanel.Add(_infoLabel); ModListBox.ItemIndex = 0; }
public List <BaseWidget> CreateWindow(dynamic Utility) { this.Text = new List <string>(); foreach (object o in Utility.ParamAsArray("choices")) { this.Text.Add((string)o); } if (this.Text.Count < 8) { this.Text.AddRange(new string[8 - this.Text.Count]); } this.Conditions = Utility.HasParam("conditions") ? Utility.ParamAsArray("conditions") : new List <dynamic>(); DisallowCancel = Utility.ParamIsString("cancel") && Utility.ParamAsString("cancel") == ":disallow"; BranchCancel = Utility.ParamIsString("cancel") && Utility.ParamAsString("cancel") == ":branch"; ChoiceCancel = Utility.ParamIsInt("cancel") ? Utility.ParamAsInt("cancel") : -1; TabView = new TabView("tabview"); TabView.X = 1; TabView.Y = 24; TabView.Width = 345; TabView.Height = 306; SimpleContainer = TabView.NewTab("Simple"); SimpleTooAdvancedLabel = new MultilineLabel("tooadvanced", SimpleContainer); SimpleTooAdvancedLabel.X = 30; SimpleTooAdvancedLabel.Y = 105; SimpleTooAdvancedLabel.Width = 285; SimpleTooAdvancedLabel.Text = "There are active options in the Advanced tab. Please disable the advanced features, or use the Advanced tab."; SimpleTooAdvancedLabel.Visible = false; SimpleCancelLabel = new Label("simplecancellabel", SimpleContainer); SimpleCancelLabel.X = 252; SimpleCancelLabel.Y = 4; SimpleCancelLabel.Text = "On Cancel:"; SimpleDisallowButton = new RadioButton("simpledisallow", SimpleContainer); SimpleDisallowButton.X = 252; SimpleDisallowButton.Y = 21; SimpleDisallowButton.Text = "Disallow"; SimpleDisallowButton.OnSelectionChanged += delegate() { if (SimpleDisallowButton.Selected) { DisallowCancel = true; BranchCancel = false; ChoiceCancel = -1; return(Sync(Utility)); } return(Refresh()); }; SimpleBranchButton = new RadioButton("simplebranch", SimpleContainer); SimpleBranchButton.X = 252; SimpleBranchButton.Y = 41; SimpleBranchButton.Text = "Branch"; SimpleBranchButton.OnSelectionChanged += delegate() { if (SimpleBranchButton.Selected) { DisallowCancel = false; BranchCancel = true; ChoiceCancel = -1; return(Sync(Utility)); } return(Refresh()); }; this.SimpleChoiceLabels = new List <Label>(); this.SimpleChoiceTextBoxes = new List <TextBox>(); this.SimpleChoiceButtons = new List <RadioButton>(); List <object> choices = Utility.ParamAsArray("choices"); for (int i = 0; i < 8; i++) { Label label = new Label($"choice{i + 1}label", SimpleContainer); TextBox textbox = new TextBox($"choice{i + 1}text", SimpleContainer); RadioButton choice = new RadioButton($"choice{i + 1}button", SimpleContainer); label.X = 18; label.Y = 14 + 33 * i; label.Text = $"Choice {i + 1}:"; SimpleChoiceLabels.Add(label); textbox.X = 77; textbox.Y = 9 + 33 * i; textbox.Width = 150; textbox.Height = 27; textbox.OnTextChanged += delegate() { choice.Enabled = !string.IsNullOrEmpty(textbox.Text); this.Text[SimpleChoiceTextBoxes.IndexOf(textbox)] = textbox.Text; int index = SimpleChoiceTextBoxes.IndexOf(textbox); if (string.IsNullOrEmpty(textbox.Text)) { this.Text.RemoveAt(index); if (index < this.Conditions.Count) { this.Conditions.RemoveAt(index); } } return(Refresh(choice, Sync(Utility))); }; SimpleChoiceTextBoxes.Add(textbox); choice.X = 252; choice.Y = 61 + 20 * i; choice.Text = $"Choice {i + 1}"; choice.OnSelectionChanged += delegate() { if (choice.Selected) { DisallowCancel = false; BranchCancel = false; ChoiceCancel = SimpleChoiceButtons.IndexOf(choice); return(Sync(Utility)); } return(Refresh()); }; SimpleChoiceButtons.Add(choice); } AdvContainer = TabView.NewTab("Advanced"); AdvChoiceLabel = new Label("choiceslabel", AdvContainer); AdvChoiceLabel.X = 11; AdvChoiceLabel.Text = "Choices:"; AdvList = new List("choicelist", AdvContainer); AdvList.X = 8; AdvList.Y = 17; AdvList.Width = 141; AdvList.Height = 121; AdvList.OnSelectionChanged += delegate() { return(UpdateSelection()); }; for (int i = 0; i < choices.Count; i++) { AdvList.Items.Add((string)choices[i]); } AdvAddButton = new Button("add", AdvContainer); AdvAddButton.X = 4; AdvAddButton.Y = 138; AdvAddButton.Width = 74; AdvAddButton.Height = 31; AdvAddButton.Text = "Add"; AdvRemoveButton = new Button("remove", AdvContainer); AdvRemoveButton.X = 78; AdvRemoveButton.Y = 138; AdvRemoveButton.Width = 74; AdvRemoveButton.Height = 31; AdvRemoveButton.Text = "Remove"; AdvEntryTextLabel = new Label("textlabel", AdvContainer); AdvEntryTextLabel.X = 157; AdvEntryTextLabel.Y = 22; AdvEntryTextLabel.Text = "Text:"; AdvEntryTextLabel.Enabled = false; AdvEntryTextBox = new TextBox("textbox", AdvContainer); AdvEntryTextBox.X = 187; AdvEntryTextBox.Y = 17; AdvEntryTextBox.Width = 150; AdvEntryTextBox.Height = 27; AdvEntryTextBox.Enabled = false; AdvEntryTextBox.OnTextChanged += delegate() { if (AdvList.Index == -1) { return(Refresh()); } AdvList.Items[AdvList.Index] = AdvEntryTextBox.Text; AdvTreatAsChoiceBox.Items = AdvList.Items; this.Text[AdvList.Index] = AdvEntryTextBox.Text; return(Refresh(AdvList, AdvTreatAsChoiceBox, Sync(Utility))); }; AdvShowIfButton = new CheckBox("showif", AdvContainer); AdvShowIfButton.X = 158; AdvShowIfButton.Y = 49; AdvShowIfButton.Text = "Show if:"; AdvShowIfButton.Enabled = false; AdvShowIfButton.OnCheckChanged += delegate() { AdvConditions.Enabled = AdvShowIfButton.Checked; if (!AdvShowIfButton.Checked) { AdvConditions.Conditions = null; if (AdvList.Index < this.Conditions.Count) { this.Conditions[AdvList.Index] = null; } } AdvEditConditionsButton.Enabled = AdvShowIfButton.Checked; return(Refresh(AdvConditions, AdvEditConditionsButton, Sync(Utility))); }; AdvConditions = new ConditionBox("conditions", AdvContainer); AdvConditions.X = 178; AdvConditions.Y = 68; AdvConditions.Width = 159; AdvConditions.Height = 65; AdvConditions.Enabled = false; AdvConditions.OnConditionsChanged += delegate() { if (AdvConditions.Conditions.Count == 0) { AdvShowIfButton.Checked = false; if (AdvList.Index < Conditions.Count) { Conditions[AdvList.Index] = null; } } else { if (AdvList.Index < Conditions.Count) { Conditions[AdvList.Index] = AdvConditions.Conditions; } else { for (int i = Conditions.Count; i < AdvList.Index; i++) { Conditions.Add(null); } Conditions.Add(AdvConditions.Conditions); } } return(Refresh(AdvShowIfButton, Sync(Utility))); }; AdvEditConditionsButton = new Button("editconditions", AdvContainer); AdvEditConditionsButton.X = 282; AdvEditConditionsButton.Y = 133; AdvEditConditionsButton.Width = 59; AdvEditConditionsButton.Height = 31; AdvEditConditionsButton.Text = "Edit"; AdvEditConditionsButton.Enabled = false; AdvEditConditionsButton.OnPressed += delegate() { AdvConditions.Open(); return(Refresh()); }; AdvCancelLabel = new Label("advcancellabel", AdvContainer); AdvCancelLabel.X = 8; AdvCancelLabel.Y = 172; AdvCancelLabel.Text = "When cancelled:"; AdvDisallowButton = new RadioButton("advdisallow", AdvContainer); AdvDisallowButton.X = 9; AdvDisallowButton.Y = 192; AdvDisallowButton.Text = "Disallow"; AdvDisallowButton.OnSelectionChanged += delegate() { if (AdvDisallowButton.Selected) { DisallowCancel = true; BranchCancel = false; ChoiceCancel = -1; return(Sync(Utility)); } return(Refresh()); }; AdvBranchButton = new RadioButton("advbranch", AdvContainer); AdvBranchButton.X = 9; AdvBranchButton.Y = 212; AdvBranchButton.Text = "Branch"; AdvBranchButton.OnSelectionChanged += delegate() { if (AdvBranchButton.Selected) { DisallowCancel = false; BranchCancel = true; ChoiceCancel = -1; return(Sync(Utility)); } return(Refresh()); }; AdvTreatAsChoiceButton = new RadioButton("advtreataschoice", AdvContainer); AdvTreatAsChoiceButton.X = 9; AdvTreatAsChoiceButton.Y = 232; AdvTreatAsChoiceButton.Text = "Treat as choice"; AdvTreatAsChoiceButton.OnSelectionChanged += delegate() { if (AdvTreatAsChoiceButton.Selected) { DisallowCancel = false; BranchCancel = false; ChoiceCancel = 0; return(Sync(Utility)); } return(Refresh()); }; AdvTreatAsChoiceBox = new Dropdown("advchoicebox", AdvContainer); AdvTreatAsChoiceBox.X = 30; AdvTreatAsChoiceBox.Y = 251; AdvTreatAsChoiceBox.Width = 123; AdvTreatAsChoiceBox.Height = 25; AdvTreatAsChoiceBox.Items = AdvList.Items; AdvOutcomeLabel = new Label("outcome", AdvContainer); AdvOutcomeLabel.X = 172; AdvOutcomeLabel.Y = 195; AdvOutcomeLabel.Text = "Outcome:"; AdvBranchCommandButton = new CheckBox("branchcommand", AdvContainer); AdvBranchCommandButton.X = 173; AdvBranchCommandButton.Y = 212; AdvBranchCommandButton.Text = "Branch this command"; AdvBranchCommandButton.Checked = true; AdvBranchCommandButton.OnCheckChanged += delegate() { return(Sync(Utility)); }; if (Utility.HasParam("branch") && !Utility.ParamAsBool("branch")) { AdvBranchCommandButton.Checked = false; } AdvStoreInVariableButton = new CheckBox("storeinvar", AdvContainer); AdvStoreInVariableButton.X = 173; AdvStoreInVariableButton.Y = 232; AdvStoreInVariableButton.Text = "Store in Game Variable"; if (Utility.HasParam("variable") && Utility.ParamIsHash("variable")) { AdvStoreInVariableButton.Checked = true; } AdvStoreInVariableButton.OnCheckChanged += delegate() { AdvVariablePicker.Enabled = AdvStoreInVariableButton.Checked; return(Sync(Utility)); }; AdvVariablePicker = new VariablePicker("variablepicker", AdvContainer); AdvVariablePicker.X = 194; AdvVariablePicker.Y = 251; AdvVariablePicker.Width = 143; AdvVariablePicker.Height = 25; AdvVariablePicker.Enabled = false; if (AdvStoreInVariableButton.Checked) { AdvVariablePicker.GroupID = (int)Utility.ParamAsHash("variable")[":group_id"]; AdvVariablePicker.VariableID = (int)Utility.ParamAsHash("variable")[":variable_id"]; AdvVariablePicker.Enabled = true; } return(Refresh(TabView, SimpleContainer, SimpleTooAdvancedLabel, SimpleCancelLabel, SimpleDisallowButton, SimpleBranchButton, SimpleChoiceLabels, SimpleChoiceTextBoxes, SimpleChoiceButtons, AdvContainer, AdvChoiceLabel, AdvAddButton, AdvRemoveButton, AdvEntryTextLabel, AdvShowIfButton, AdvConditions, AdvEditConditionsButton, AdvCancelLabel, AdvOutcomeLabel, AdvBranchCommandButton, AdvStoreInVariableButton, AdvVariablePicker, Sync(Utility))); }
public List <BaseWidget> CreateReadOnly() { SwitchLabel = new MultilineLabel("switchlabel"); SwitchLabel.Parse = true; return(Refresh(SwitchLabel)); }