private void textBoxColorHTML_Validated(object sender, EventArgs e) { _ignoreHTMLBoxClick = false; String text = textBoxColorHTML.Text.Trim().ToUpperInvariant(); if (text.Length == 7 && text.Substring(0, 1) == "#") { // ignore the leading char '#' text = text.Substring(1); } if (text.Length == 6) { try { decimal red = Int32.Parse(text.Substring(0, 2), NumberStyles.AllowHexSpecifier); decimal green = Int32.Parse(text.Substring(2, 2), NumberStyles.AllowHexSpecifier); decimal blue = Int32.Parse(text.Substring(4, 2), NumberStyles.AllowHexSpecifier); _ignoreNumericUpDownEvent = true; numericUpDownTintRed.Value = red; numericUpDownTintGreen.Value = green; numericUpDownTintBlue.Value = blue; _ignoreNumericUpDownEvent = false; ApplyUpDownColors(); } catch { } } textBoxColorHTML.Text = SpriteEditor.GetHTMLFromColor(this.AnimatedSprite.Tint); }
private void AnimatedSpriteEditor_Load(object sender, EventArgs e) { this.ZoomBox = new ZoomBox(); this.ZoomBox.SetToolStripButtomZoomIn(toolStripButtonZoomIn); this.ZoomBox.SetToolStripButtomZoomOut(toolStripButtonZoomOut); this.ZoomBox.SetToolStripButtomZoomNormal(toolStripButtonZoomNormal); this.ZoomBox.Camera.Pivot = new Vector2(0.5f); this.ZoomBox.Camera.IsPivotRelative = true; if (this.AnimatedSprite.Material != null) { labelTextureName.Text = this.AnimatedSprite.Material.ToString(); } // hack around designer bug that resize the control labelTextureName.Size = new Size(labelTextureName.Size.Width, 22); // load all the Blending Type values in the combo box for (int i = 0; i < (int)DrawingBlendingType.EnumSize; i++) { comboBoxBlendingType.Items.Add(((DrawingBlendingType)i).ToString()); } comboBoxBlendingType.SelectedIndex = (int)this.AnimatedSprite.BlendingType; pictureBoxTint.BackColor = MilkshakeForm.GetGDIColor(this.AnimatedSprite.Tint); _ignoreNumericUpDownEvent = true; numericUpDownTintRed.Value = this.AnimatedSprite.Tint.R; numericUpDownTintGreen.Value = this.AnimatedSprite.Tint.G; numericUpDownTintBlue.Value = this.AnimatedSprite.Tint.B; textBoxColorHTML.Text = SpriteEditor.GetHTMLFromColor(this.AnimatedSprite.Tint); _ignoreNumericUpDownEvent = false; sceneItemPreviewControl.SceneItem = this.AnimatedSprite; sceneItemPreviewControl.Camera = this.ZoomBox.Camera; RefreshAreaComboList(); LoadAnimationsList(); }
private void ApplyUpDownColors() { if (_ignoreNumericUpDownEvent == false) { Color color = Color.FromArgb((int)numericUpDownTintRed.Value, (int)numericUpDownTintGreen.Value, (int)numericUpDownTintBlue.Value); pictureBoxTint.BackColor = color; this.AnimatedSprite.Tint = new XnaColor(color.R, color.G, color.B, this.AnimatedSprite.Tint.A); textBoxColorHTML.Text = SpriteEditor.GetHTMLFromColor(this.AnimatedSprite.Tint); } }