protected virtual Control CreateControlForDetailPage() { SLabel c = new SLabel(); c.CssClass = "formFieldValue"; return(c); }
public MainWindow() { this.InitializeComponent(); Transaction.RunVoid(() => { DiscreteCellLoop <int> value = new DiscreteCellLoop <int>(); SLabel lblValue = new SLabel(value.Map(i => i.ToString())); SButton plus = new SButton { Content = "+", Width = 25, Margin = new Thickness(5, 0, 0, 0) }; SButton minus = new SButton { Content = "-", Width = 25, Margin = new Thickness(5, 0, 0, 0) }; this.Container.Children.Add(lblValue); this.Container.Children.Add(plus); this.Container.Children.Add(minus); Stream <int> sPlusDelta = plus.SClicked.Map(_ => 1); Stream <int> sMinusDelta = minus.SClicked.Map(_ => - 1); Stream <int> sDelta = sPlusDelta.OrElse(sMinusDelta); Stream <int> sUpdate = sDelta.Snapshot(value, (d, v) => v + d).Filter(n => n >= 0); value.Loop(sUpdate.Hold(0)); }); }
public void Start() { if (Instance?.GUI == null) { return; } Color color = Colors[LogType]; GUIMessage = new SButton(LogMessageFormatted) { Parent = Instance.GUI, Border = Vector2.zero, Background = new Color(0, 0, 0, 0), Foreground = color, OnClick = delegate(SButton button) { IsStacktraceShown = !IsStacktraceShown; Instance.GUI.UpdateStyle(); }, With = { new SFadeInAnimation() } }; GUIStacktrace = new SLabel(Stacktace) { Parent = Instance.GUI, Foreground = color, OnUpdateStyle = delegate(SElement elem) { elem.Size.y = IsStacktraceShown ? elem.Size.y : 0f; elem.Visible = IsStacktraceShown; } }; }
public void PrintLine(string txt, bool log = false, Color?color = null) { var outputbox = OutputBox; //if (outputbox.Children.Count == 0) { var label = new SLabel(txt); if (color.HasValue) { label.Foreground = color.Value; } outputbox.Children.Add(label); // return; //} else { // var elem = outputbox.Children[outputbox.Children.Count - 1]; // if (elem is SLabel) ((SLabel)elem).Text += txt; // else outputbox.Children.Add(new SLabel(txt)); //} outputbox.ScrollPosition = new Vector2(0, outputbox.ContentSize.y); outputbox.UpdateStyle(); // SGUI BUG! without this scroll breaks with labels with a lot of newlines if (log) { Logger.InfoPretty(txt); } }
public MainWindow() { this.InitializeComponent(); Transaction.RunVoid(() => { // 책의 자바 예제와 다른점은 CellLoop를 사용 CellLoop <int> value = new CellLoop <int>(); // UI요소 생성 및 등록 부분 SLabel lblValue = new SLabel(value.Map(i => i.ToString())); SButton plus = new SButton { Content = "+", Width = 25, Margin = new Thickness(5, 0, 0, 0) }; SButton minus = new SButton { Content = "-", Width = 25, Margin = new Thickness(5, 0, 0, 0) }; this.Container.Children.Add(lblValue); this.Container.Children.Add(plus); this.Container.Children.Add(minus); // 각 버튼의 기능 스트림과 표시에 대한 스냅샷 연결 Stream <int> sPlusDelta = plus.SClicked.Map(_ => 1); Stream <int> sMinusDelta = minus.SClicked.Map(_ => - 1); Stream <int> sDelta = sPlusDelta.OrElse(sMinusDelta); Stream <int> sUpdate = sDelta.Snapshot(value, (d, v) => v + d); value.Loop(sUpdate.Hold(0)); }); }
public MainWindow() { this.InitializeComponent(); IReadOnlyList <Tuple <Grid, Grid> > emailAndValidationPlaceholders = new[] { Tuple.Create(this.Email1Placeholder, this.Email1ValidationPlaceholder), Tuple.Create(this.Email2Placeholder, this.Email2ValidationPlaceholder), Tuple.Create(this.Email3Placeholder, this.Email3ValidationPlaceholder), Tuple.Create(this.Email4Placeholder, this.Email4ValidationPlaceholder) }; int maxEmails = emailAndValidationPlaceholders.Count; STextBox name = new STextBox(string.Empty) { Width = 200 }; this.NamePlaceholder.Children.Add(name); Cell <string> nameValidationError = name.Text.Map(t => string.IsNullOrEmpty(t.Trim()) ? "<-- enter something" : t.Trim().IndexOf(' ') < 0 ? "<-- must contain space" : string.Empty); Cell <bool> isNameValid = nameValidationError.Map(string.IsNullOrEmpty); SLabel validName = new SLabel(nameValidationError); this.NameValidationPlaceholder.Children.Add(validName); SSpinner number = SSpinner.Create(1); this.NumberOfEmailAddressesPlaceholder.Children.Add(number); Cell <string> numberOfEmailAddressesValidationError = number.Value.Map(n => n <1 || n> maxEmails ? "<-- must be 1 to " + maxEmails : string.Empty); Cell <bool> isNumberOfEmailAddressesValid = numberOfEmailAddressesValidationError.Map(string.IsNullOrEmpty); SLabel validNumber = new SLabel(numberOfEmailAddressesValidationError); this.NumberOfEmailAddressesValidationPlaceholder.Children.Add(validNumber); IReadOnlyList <Cell <bool> > validEmails = emailAndValidationPlaceholders.Select((p, i) => { Cell <bool> enabled = number.Value.Map(n => i < n); STextBox email = new STextBox(string.Empty, enabled) { Width = 200 }; p.Item1.Children.Add(email); Cell <string> validText = email.Text.Lift(number.Value, (e, n) => i >= n ? string.Empty : string.IsNullOrEmpty(e.Trim()) ? "<-- enter something" : e.IndexOf('@') < 0 ? "<-- must contain @" : string.Empty); SLabel validEmail = new SLabel(validText); p.Item2.Children.Add(validEmail); return(validText.Map(string.IsNullOrEmpty)); }).ToArray(); Cell <bool> allValid = validEmails.Concat(new[] { isNameValid, isNumberOfEmailAddressesValid }).Lift(vv => vv.All(v => v)); SButton ok = new SButton(allValid) { Content = "OK", Width = 75 }; this.ButtonPlaceholder.Children.Add(ok); }
public static void LogPlain(object msg, Color32?col = null) { Color color = Color.white; if (col != null) { color = col.Value; } SLabel label = new SLabel(msg.ToString()); label.Colors[0] = color; ETGModConsole.Instance.GUI[0].Children.Add(label); }
public void SetupDebugText() { Logger.Debug("SetupDebugText()"); _DebugGroup = new SGroup { AutoLayout = (self) => self.AutoLayoutVertical, Visible = true, OnUpdateStyle = (elem) => { elem.Fill(0); }, Background = new Color(0.0f, 0.0f, 0.0f, 0.0f) }; _DebugGroup.Children.Add(_VersionLabel = new SLabel($"ModUntitled v{VERSION}")); _DebugGroup.Children.Add(_FPSLabel = new SLabel("?? FPS")); }
public MainWindow() { this.InitializeComponent(); STextBox msg = new STextBox("Hello") { Width = 150 }; SLabel lbl = new SLabel(msg.Text) { Width = 150, Margin = new Thickness(5, 0, 0, 0) }; this.Container.Children.Add(msg); this.Container.Children.Add(lbl); }
public MainWindow() { this.InitializeComponent(); STextBox msg = new STextBox("Hello") { Width = 150 }; Cell <string> reversed = msg.Text.Map(t => new string(t.Reverse().ToArray())); SLabel lbl = new SLabel(reversed) { Width = 150, Margin = new Thickness(5, 0, 0, 0) }; this.Container.Children.Add(msg); this.Container.Children.Add(lbl); }
public MainWindow() { this.InitializeComponent(); STextBox english = new STextBox("I like FRP") { Width = 150 }; this.TextBoxPlaceholder.Children.Add(english); Stream <string> sLatin = this.TranslateButton.SClicked.Snapshot(english.Text, (u, t) => Regex.Replace(t.Trim(), " |$", "us ")); Cell <string> latin = sLatin.Hold(string.Empty); SLabel lblLatin = new SLabel(latin); this.TextPlaceholder.Children.Add(lblLatin); }
public MainWindow() { this.InitializeComponent(); STextBox txtA = new STextBox("5") { Width = 100 }; STextBox txtB = new STextBox("10") { Width = 100 }; DiscreteCell <int> a = txtA.Text.Map(ParseInt); DiscreteCell <int> b = txtB.Text.Map(ParseInt); DiscreteCell <int> sum = a.Lift(b, (x, y) => x + y); SLabel lblSum = new SLabel(sum.Map(i => i.ToString())); this.Container.Children.Add(txtA); this.Container.Children.Add(txtB); this.Container.Children.Add(lblSum); }
public MainWindow() { this.InitializeComponent(); SButton red = new SButton { Content = "red", Width = 75 }; SButton green = new SButton { Content = "green", Width = 75, Margin = new Thickness(5, 0, 0, 0) }; Stream <string> sRed = red.SClicked.Map(_ => "red"); Stream <string> sGreen = green.SClicked.Map(_ => "green"); Stream <string> sColor = sRed.OrElse(sGreen); Cell <string> color = sColor.Hold(string.Empty); SLabel lbl = new SLabel(color) { Width = 75, Margin = new Thickness(5, 0, 0, 0) }; this.Container.Children.Add(red); this.Container.Children.Add(green); this.Container.Children.Add(lbl); }
public override void Init() { Instance = this; new SGroup() { Parent = ModGUI.HelpGroup, Background = new Color(0f, 0f, 0f, 0f), AutoLayout = elem => elem.AutoLayoutVertical, AutoLayoutVerticalStretch = false, AutoLayoutPadding = 0f, OnUpdateStyle = ModGUI.SegmentGroupUpdateStyle, Children = { new SLabel("Magic Camera™:") { Background = ModGUI.HeaderBackground, Foreground = ModGUI.HeaderForeground }, new SLabel("Special thanks to Shesez (Boundary Break)!") { Background = ModGUI.HeaderBackground, Foreground = ModGUI.HeaderForeground }, new SLabel("Controller:") { Background = ModGUI.HeaderBackground, Foreground = ModGUI.HeaderForeground }, new SLabel("Press L3 and R3 (into the two sticks) at the same time."), new SLabel("Movement:") { Background = ModGUI.Header2Background, Foreground = ModGUI.Header2Foreground }, new SLabel("Left stick: First person movement"), new SLabel("Right stick: Rotate camera"), new SLabel("LB / L1: Move straight down"), new SLabel("RB / R1: Move straight up"), new SLabel("Speed manipulation:") { Background = ModGUI.Header2Background, Foreground = ModGUI.Header2Foreground }, new SLabel("LT / L2: Reduce move speed"), new SLabel("RT / R2: Increase move speed"), new SLabel("LT + RT / L2 + R2: Reset move speed"), new SLabel("DPad left: Freeze game"), new SLabel("DPad right: Reset game speed"), new SLabel("LT + RT / L2 + R2: Reset move speed"), new SLabel("Other:") { Background = ModGUI.Header2Background, Foreground = ModGUI.Header2Foreground }, new SLabel("B / Circle: Toggle info in bottom-right corner"), new SLabel("X / Square: Toggle game GUI / HUD"), new SLabel("Y / Triangle: Toggle neutral lighting"), new SLabel("Keyboard:") { Background = ModGUI.HeaderBackground, Foreground = ModGUI.HeaderForeground }, new SLabel("Press F12."), new SLabel("Movement:") { Background = ModGUI.Header2Background, Foreground = ModGUI.Header2Foreground }, new SLabel("WASD: First person movement"), new SLabel("R / F: Move straight down"), new SLabel("Q / E: Move straight up"), new SLabel("Mouse: Rotate camera"), new SLabel("Shift: Run"), new SLabel("Speed manipulation:") { Background = ModGUI.Header2Background, Foreground = ModGUI.Header2Foreground }, new SLabel("1 / Scroll up: Reduce move* speed"), new SLabel("2 / Scroll down: Increase move* speed"), new SLabel("3 / Middle mouse button: Reset move* speed"), new SLabel("Hold control + scroll = modify game speed"), new SLabel("4: Reduce game speed"), new SLabel("5: Increase game speed"), new SLabel("6: Reset game speed"), new SLabel("7: Freeze game"), new SLabel("Other:") { Background = ModGUI.Header2Background, Foreground = ModGUI.Header2Foreground }, new SLabel("F3: Toggle info in bottom-right corner"), new SLabel("F4: Toggle neutral lighting") } }; GUISettingsGroup = new SGroup() { Parent = ModGUI.SettingsGroup, Background = new Color(0f, 0f, 0f, 0f), AutoLayout = elem => elem.AutoLayoutVertical, OnUpdateStyle = ModGUI.SegmentGroupUpdateStyle, Children = { new SLabel("Magic Camera™:") { Background = ModGUI.HeaderBackground, Foreground = ModGUI.HeaderForeground }, new SButton("Show Camera Info") { Alignment = TextAnchor.MiddleLeft, With = { new SCheckboxModifier() { GetValue = b => IsGUIVisible, SetValue = (b, v) => IsGUIVisible = v } } }, new SButton("Neutral Ambient Lighting") { Alignment = TextAnchor.MiddleLeft, With = { new SCheckboxModifier() { GetValue = b => IsFullBright, SetValue = (b, v) => IsFullBright = v } } } } }; GUIInfoGroup = new SGroup() { ScrollDirection = SGroup.EDirection.Vertical, AutoLayout = elem => elem.AutoLayoutVertical, AutoLayoutPadding = 0f, OnUpdateStyle = elem => { elem.Size = new Vector2(256, elem.Backend.LineHeight * elem.Children.Count); elem.Position = elem.Root.Size - elem.Size; }, Children = { new SLabel("MAGIC CAMERA™") { Background = ModGUI.HeaderBackground, Foreground = ModGUI.HeaderForeground }, new SLabel("Press F1 to view controls."), new SLabel(), (GUIInfoGameSpeed = new SLabel()), (GUIInfoMoveSpeed = new SLabel()), new SLabel(), (GUIInfoSceneName = new SLabel()), (GUIInfoPosition = new SLabel()), (GUIInfoRotation = new SLabel()), } }; ModInput.ButtonMap["FreeCam Toggle"] = input => Input.GetKey(KeyCode.F12) || (ModInput.GetButton("LS") && ModInput.GetButton("RS")); ModInput.ButtonMap["FreeCam GUI Toggle"] = input => Input.GetKey(KeyCode.F3) || ModInput.GetButton("B"); ModInput.ButtonMap["FreeCam Game GUI Toggle Ext"] = input => ModInput.GetButton("X"); ModInput.ButtonMap["FreeCam Light Toggle"] = input => Input.GetKey(KeyCode.F4) || ModInput.GetButton("Y"); ModInput.ButtonMap["FreeCam Run"] = input => Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); ModInput.ButtonMap["FreeCam Internal Speed Switch"] = input => Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); ModInput.ButtonMap["FreeCam Internal Speed Reset"] = input => Input.GetMouseButton(2) || (ModInput.GetButton("LT") && ModInput.GetButton("RT")); ModInput.ButtonMap["FreeCam Move Speed Reset"] = input => Input.GetKey(KeyCode.Alpha3) || (!ModInput.GetButton("FreeCam Internal Speed Switch") && ModInput.GetButton("FreeCam Internal Speed Reset")); ModInput.ButtonMap["FreeCam Game Speed Reset"] = input => Input.GetKey(KeyCode.Alpha6) || ModInput.GetButton("DPadRight") || (ModInput.GetButton("FreeCam Internal Speed Switch") && ModInput.GetButton("FreeCam Internal Speed Reset")); ModInput.ButtonMap["FreeCam Game Speed Freeze"] = input => Input.GetKey(KeyCode.Alpha7) || ModInput.GetButton("DPadLeft"); ModInput.AxisMap["FreeCam Y Movement"] = input => Input.GetKey(KeyCode.F) || Input.GetKey(KeyCode.Q) || ModInput.GetButton("LB") ? -1f : Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.E) || ModInput.GetButton("RB") ? 1f : 0f; ModInput.AxisMap["FreeCam Internal Speed"] = input => Input.mouseScrollDelta.y + (ModInput.GetButton("LT") ? -0.4f : ModInput.GetButton("RT") ? 0.4f : 0f); ModInput.AxisMap["FreeCam Move Speed"] = input => (Input.GetKey(KeyCode.Alpha1) ? -0.4f : Input.GetKey(KeyCode.Alpha2) ? 0.4f : 0f) + (!ModInput.GetButton("FreeCam Internal Speed Switch") ? ModInput.GetAxis("FreeCam Internal Speed") : 0f); ModInput.AxisMap["FreeCam Game Speed"] = input => (ModInput.GetButton("DPadUp") ? 0.4f : ModInput.GetButton("DPadDown") ? -0.4f : 0f) + (Input.GetKey(KeyCode.Alpha4) ? -0.4f : Input.GetKey(KeyCode.Alpha5) ? 0.4f : 0f) + (ModInput.GetButton("FreeCam Internal Speed Switch") ? ModInput.GetAxis("FreeCam Internal Speed") : 0f); SceneManager.activeSceneChanged += (sceneA, sceneB) => { WasFullBright = IsFullBright = false; }; ModEvents.OnUpdate += Update; // Only make the game use the player input when the free cam is disabled. ModEvents.OnPlayerInputUpdate += input => !IsEnabled; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.panel1 = new System.Windows.Forms.Panel(); this.pictureBox3 = new System.Windows.Forms.PictureBox(); this.lArtist = new System.Windows.Forms.LinkLabel(); this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.lName = new SpotifySmallLabel(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.lTime = new SpotifySmallLabel(); this.sLabel1 = new SLabel(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // panel1 // this.panel1.Controls.Add(this.sLabel1); this.panel1.Controls.Add(this.pictureBox3); this.panel1.Controls.Add(this.lArtist); this.panel1.Controls.Add(this.pictureBox2); this.panel1.Controls.Add(this.lName); this.panel1.Controls.Add(this.pictureBox1); this.panel1.Controls.Add(this.lTime); this.panel1.Location = new System.Drawing.Point(1, 2); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(516, 25); this.panel1.TabIndex = 1; this.panel1.Visible = false; // // pictureBox3 // this.pictureBox3.BackgroundImage = global::Spofity.Properties.Resources.play; this.pictureBox3.Location = new System.Drawing.Point(44, 4); this.pictureBox3.Name = "pictureBox3"; this.pictureBox3.Size = new System.Drawing.Size(20, 16); this.pictureBox3.TabIndex = 16; this.pictureBox3.TabStop = false; this.pictureBox3.Visible = false; // // lArtist // this.lArtist.AutoSize = true; this.lArtist.ForeColor = System.Drawing.SystemColors.ControlDarkDark; this.lArtist.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline; this.lArtist.LinkColor = System.Drawing.Color.Silver; this.lArtist.Location = new System.Drawing.Point(478, -9); this.lArtist.Name = "lArtist"; this.lArtist.Size = new System.Drawing.Size(0, 13); this.lArtist.TabIndex = 11; // // pictureBox2 // this.pictureBox2.BackgroundImage = global::Spofity.Properties.Resources.buy; this.pictureBox2.Location = new System.Drawing.Point(332, 3); this.pictureBox2.Name = "pictureBox2"; this.pictureBox2.Size = new System.Drawing.Size(47, 18); this.pictureBox2.TabIndex = 15; this.pictureBox2.TabStop = false; this.pictureBox2.Visible = false; // // lName // this.lName.AutoSize = true; this.lName.Font = new System.Drawing.Font("Tahoma", 8.25F); this.lName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); this.lName.Location = new System.Drawing.Point(105, 5); this.lName.Name = "lName"; this.lName.Size = new System.Drawing.Size(34, 13); this.lName.TabIndex = 13; // // pictureBox1 // this.pictureBox1.BackgroundImage = global::Spofity.Properties.Resources.rate; this.pictureBox1.Location = new System.Drawing.Point(434, 3); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(45, 16); this.pictureBox1.TabIndex = 14; this.pictureBox1.TabStop = false; // // lTime // this.lTime.AutoSize = true; this.lTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lTime.ForeColor = System.Drawing.Color.Gray; this.lTime.Location = new System.Drawing.Point(400, 5); this.lTime.Name = "lTime"; this.lTime.Size = new System.Drawing.Size(28, 13); this.lTime.TabIndex = 12; // // sLabel1 // this.sLabel1.Location = new System.Drawing.Point(385, 3); this.sLabel1.Name = "sLabel1"; this.sLabel1.Size = new System.Drawing.Size(43, 19); this.sLabel1.TabIndex = 17; // // spotiEntry // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.Controls.Add(this.panel1); this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Name = "spotiEntry"; this.Size = new System.Drawing.Size(519, 28); this.Load += new System.EventHandler(this.spotiEntry_Load); this.DoubleClick += new System.EventHandler(this.spotiEntry_DoubleClick); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.spotiEntry_KeyDown); this.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.spotiEntry_MouseDoubleClick); this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.spotiEntry_MouseDown); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); }
public void AddRow() { Array.Resize <STextBox>(ref tbBarcode, tbBarcode.Length + 1); int i = tbBarcode.Length - 1; tbBarcode[i] = new STextBox(); if (i == 0) { tbBarcode[i].Location = new Point(MessageLabel("BARCODE").Left, MessageLabel("BARCODE").Top + MessageLabel("BARCODE").Height + 10); } else { tbBarcode[i].Location = new Point(MessageLabel("BARCODE").Left, tbBarcode[i - 1].Top + tbBarcode[i - 1].Height + 5); } tbBarcode[i].Width = MessageLabel("DESC").Left - MessageLabel("BARCODE").Left - 2; tbBarcode[i].BorderStyle = BorderStyle.None; tbBarcode[i].KeyDown += new KeyEventHandler(BarcodeKeyDown); tbBarcode[i].GotFocus += new EventHandler(BarcodeGotFocus); tbBarcode[i].nRowNum = i; this.Controls.Add(tbBarcode[i]); Array.Resize <SLabel>(ref lblLineNo, lblLineNo.Length + 1); lblLineNo[i] = new SLabel(); lblLineNo[i].Location = new Point(10, tbBarcode[i].Top); lblLineNo[i].Width = 20; lblLineNo[i].BackColor = Color.Transparent; lblLineNo[i].ForeColor = Color.White; lblLineNo[i].nRowNum = i; lblLineNo[i].Text = (i + 1).ToString(); this.Controls.Add(lblLineNo[i]); Array.Resize <SLabel>(ref lblDesc, lblDesc.Length + 1); lblDesc[i] = new SLabel(); lblDesc[i].Location = new Point(MessageLabel("DESC").Left, tbBarcode[i].Top); lblDesc[i].Width = MessageLabel("QTY").Left - MessageLabel("DESC").Left - 2; lblDesc[i].BackColor = Color.Transparent; lblDesc[i].ForeColor = Color.White; lblDesc[i].nRowNum = i; this.Controls.Add(lblDesc[i]); Array.Resize <STextBox>(ref tbQty, tbQty.Length + 1); tbQty[i] = new STextBox(); tbQty[i].Location = new Point(MessageLabel("QTY").Left, tbBarcode[i].Top); tbQty[i].Width = MessageLabel("MORR").Left - MessageLabel("QTY").Left - 2; tbQty[i].BorderStyle = BorderStyle.None; tbQty[i].KeyDown += new KeyEventHandler(QtyKeyDown); tbQty[i].GotFocus += new EventHandler(QtyGotFocus); tbQty[i].nRowNum = i; this.Controls.Add(tbQty[i]); Array.Resize <SLabel>(ref lblRRPEach, lblRRPEach.Length + 1); lblRRPEach[i] = new SLabel(); lblRRPEach[i].Location = new Point(MessageLabel("RRP").Left, tbBarcode[i].Top); lblRRPEach[i].Width = MessageLabel("FMARGIN").Left - MessageLabel("RRP").Left - 2; lblRRPEach[i].BackColor = Color.Transparent; lblRRPEach[i].ForeColor = Color.White; lblRRPEach[i].BorderStyle = BorderStyle.None; lblRRPEach[i].nRowNum = i; this.Controls.Add(lblRRPEach[i]); Array.Resize <SLabel>(ref lblFullMargin, lblFullMargin.Length + 1); lblFullMargin[i] = new SLabel(); lblFullMargin[i].Location = new Point(MessageLabel("FMARGIN").Left, tbBarcode[i].Top); lblFullMargin[i].Width = MessageLabel("T-MARGIN").Left - MessageLabel("FMARGIN").Left - 2; lblFullMargin[i].BorderStyle = BorderStyle.None; lblFullMargin[i].BackColor = Color.Transparent; lblFullMargin[i].ForeColor = Color.White; lblFullMargin[i].nRowNum = i; this.Controls.Add(lblFullMargin[i]); Array.Resize <STextBox>(ref tbMarginOrRRP, tbMarginOrRRP.Length + 1); tbMarginOrRRP[i] = new STextBox(); tbMarginOrRRP[i].Location = new Point(MessageLabel("MORR").Left, tbBarcode[i].Top); tbMarginOrRRP[i].Width = 50; tbMarginOrRRP[i].BorderStyle = BorderStyle.None; tbMarginOrRRP[i].KeyDown += new KeyEventHandler(MarginOrRRPKeyDown); tbMarginOrRRP[i].nRowNum = i; this.Controls.Add(tbMarginOrRRP[i]); Array.Resize <STextBox>(ref tbTargetMargin, tbTargetMargin.Length + 1); tbTargetMargin[i] = new STextBox(); tbTargetMargin[i].Location = new Point(MessageLabel("T-MARGIN").Left, tbBarcode[i].Top); tbTargetMargin[i].Width = 100; tbTargetMargin[i].BorderStyle = BorderStyle.None; tbTargetMargin[i].KeyDown += new KeyEventHandler(TargetMarginKeyDown); tbTargetMargin[i].nRowNum = i; this.Controls.Add(tbTargetMargin[i]); Array.Resize <SLabel>(ref lblFinalLinePrice, lblFinalLinePrice.Length + 1); lblFinalLinePrice[i] = new SLabel(); lblFinalLinePrice[i].Location = new Point(800, tbBarcode[i].Top); lblFinalLinePrice[i].BackColor = Color.Transparent; lblFinalLinePrice[i].ForeColor = Color.White; lblFinalLinePrice[i].Width = 100; lblFinalLinePrice[i].nRowNum = i; this.Controls.Add(lblFinalLinePrice[i]); Array.Resize <SLabel>(ref lblFinalLineMargin, lblFinalLineMargin.Length + 1); lblFinalLineMargin[i] = new SLabel(); lblFinalLineMargin[i].Location = new Point(900, tbBarcode[i].Top); lblFinalLineMargin[i].BackColor = Color.Transparent; lblFinalLineMargin[i].ForeColor = Color.White; lblFinalLineMargin[i].Width = 100; lblFinalLineMargin[i].nRowNum = i; this.Controls.Add(lblFinalLineMargin[i]); this.Refresh(); }
/// <summary> /// used to log buttons, buttons can run certain code when pressed. /// do SButton button = YourLogCode. /// then button.OnClick += myMethod; /// </summary> /// <param name="msg">the object or string you want to log</param> /// <param name="col">text color you want</param> /// <param name="HaveModName">whether your log messege will have the mod name at the front</param> /// <param name="HaveModIcon">whether your logged messege will have your mod icon at the front</param> public static SButton LogButton(object msg, Color32?col = null, string UpdatedTextOnClick = null, bool HaveModName = false, bool HaveModIcon = false) { SButton btn; Color color = Color.white; if (col != null) { color = col.Value; } if (HaveModIcon == false) { if (HaveModName == false) { btn = new SButton($"{msg}"); btn.Background = Color.clear; btn.Colors[0] = color; ETGModConsole.Instance.GUI[0].Children.Add(btn); } else { btn = new SButton($"{Initialisation.metadata.Name}: {msg}"); btn.Background = Color.clear; btn.Colors[0] = color; ETGModConsole.Instance.GUI[0].Children.Add(btn); } } else { if (HaveModName == false) { btn = new SButton($"{msg}"); btn.Background = Color.clear; btn.Colors[0] = color; if (File.Exists(Initialisation.metadata.Archive)) { btn.Icon = Initialisation.metadata.Icon; } ETGModConsole.Instance.GUI[0].Children.Add(btn); } else { btn = new SButton($"{Initialisation.metadata.Name}: {msg}"); btn.Background = Color.clear; btn.Colors[0] = color; if (File.Exists(Initialisation.metadata.Archive)) { btn.Icon = Initialisation.metadata.Icon; } ETGModConsole.Instance.GUI[0].Children.Add(btn); } } bool ShowAlt = false; if (!string.IsNullOrEmpty(UpdatedTextOnClick)) { var i = new SLabel(UpdatedTextOnClick); btn.OnClick += (obj) => { ShowAlt = !ShowAlt; ETGModConsole.Instance.GUI[0].UpdateStyle(); }; i.Colors[0] = color; i.Background = Color.clear; i.OnUpdateStyle = delegate(SElement elem) { elem.Size.y = ShowAlt ? elem.Size.y : 0f; elem.Visible = ShowAlt; ((SGroup)ETGModConsole.Instance.GUI[0]).ContentSize.y = 0; }; ETGModConsole.Instance.GUI[0].Children.Add(i); } return(btn); }
public GridValidForm() { InitializeComponent(); Transaction.RunVoid(() => { STextBox nameBox = new STextBox(); Cell <string> nameLabel = nameBox.CText.Map(t => { if (string.IsNullOrWhiteSpace(t)) { return("입력해라"); } else if (t.Trim().IndexOf(" ") < 0) { return("성씨가 뭐냐 스페이스바를 넣어라."); } else { return(string.Empty); } }); SLabel nameCheckLabel = new SLabel(nameLabel); this.nameBox.Children.Add(nameBox); this.nameValidateLabel.Children.Add(nameCheckLabel); Sspinner emailCounter = new Sspinner(1); Cell <string> emailCountLabel = emailCounter.Value.Map(v => v <1 || v> maxEmails ? "이메일은 1개부터 4개다잉~ 잘해라잉" : string.Empty); SLabel CounterCheckLabel = new SLabel(emailCountLabel); this.spinner.Children.Add(emailCounter); this.numberValidateLabel.Children.Add(CounterCheckLabel); var emailLists = new List <Tuple <Grid, Grid> >() { new Tuple <Grid, Grid>(this.eMailBox1, this.eMailValidateLabel1), new Tuple <Grid, Grid>(this.eMailBox2, this.eMailValidateLabel2), new Tuple <Grid, Grid>(this.eMailBox3, this.eMailValidateLabel3), new Tuple <Grid, Grid>(this.eMailBox4, this.eMailValidateLabel4), }; var emailValids = emailLists.Select((t, i) => { Cell <bool> enabled = emailCounter.Value.Map(v => v > i); var emailBox = new STextBox(string.Empty, enabled); Cell <string> emailLabel = enabled.Lift(emailBox.CText.Map(t_ => { if (string.IsNullOrWhiteSpace(t_)) { return("입력해라"); } else if (t_.Trim().IndexOf("@") < 0) { return("골뱅이 어따 팔아먹었냐~ 넣지??"); } else { return(string.Empty); } }), (_1, _2) => _1 ? _2 : string.Empty); var emailCheckLabel = new SLabel(emailLabel); t.Item1.Children.Add(emailBox); t.Item2.Children.Add(emailCheckLabel); return(emailLabel); }); var allOk = emailValids.Concat(new [] { nameLabel, emailCountLabel }).Lift(v => v.All(string.IsNullOrWhiteSpace)); var OkButton = new SButton(allOk) { Content = "확인" }; this.okButton.Children.Add(OkButton); }); }