Created
April 14, 2013 21:18
-
-
Save Cellane/5384241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using System.Globalization; | |
using System.Windows.Forms; | |
namespace SixthTask | |
{ | |
public partial class MainForm : Form | |
{ | |
public MainForm() | |
{ | |
InitializeComponent(); | |
} | |
private void nudColor_ValueChanged(object sender, EventArgs e) | |
{ | |
var numericUpDown = (NumericUpDown) sender; | |
var backgroundColor = Color.FromArgb((int) nudRed.Value, (int) nudGreen.Value, (int) nudBlue.Value); | |
var foregroundColor = Color.FromArgb(255 - (int) nudRed.Value, 255 - (int) nudGreen.Value, | |
255 - (int) nudBlue.Value); | |
BackColor = backgroundColor; | |
lblName.ForeColor = foregroundColor; | |
if ((string) numericUpDown.Tag == "red") | |
{ | |
Text = numericUpDown.Value.ToString(CultureInfo.CurrentCulture); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace SixthTask | |
{ | |
partial class MainForm | |
{ | |
/// <summary> | |
/// Required designer variable. | |
/// </summary> | |
private System.ComponentModel.IContainer components = null; | |
/// <summary> | |
/// Clean up any resources being used. | |
/// </summary> | |
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> | |
protected override void Dispose(bool disposing) | |
{ | |
if (disposing && (components != null)) | |
{ | |
components.Dispose(); | |
} | |
base.Dispose(disposing); | |
} | |
#region Windows Form Designer generated code | |
/// <summary> | |
/// Required method for Designer support - do not modify | |
/// the contents of this method with the code editor. | |
/// </summary> | |
private void InitializeComponent() | |
{ | |
this.label1 = new System.Windows.Forms.Label(); | |
this.nudRed = new System.Windows.Forms.NumericUpDown(); | |
this.label2 = new System.Windows.Forms.Label(); | |
this.nudGreen = new System.Windows.Forms.NumericUpDown(); | |
this.label3 = new System.Windows.Forms.Label(); | |
this.nudBlue = new System.Windows.Forms.NumericUpDown(); | |
this.lblName = new System.Windows.Forms.Label(); | |
((System.ComponentModel.ISupportInitialize)(this.nudRed)).BeginInit(); | |
((System.ComponentModel.ISupportInitialize)(this.nudGreen)).BeginInit(); | |
((System.ComponentModel.ISupportInitialize)(this.nudBlue)).BeginInit(); | |
this.SuspendLayout(); | |
// | |
// label1 | |
// | |
this.label1.AutoSize = true; | |
this.label1.Location = new System.Drawing.Point(12, 14); | |
this.label1.Name = "label1"; | |
this.label1.Size = new System.Drawing.Size(30, 13); | |
this.label1.TabIndex = 0; | |
this.label1.Text = "Red:"; | |
// | |
// nudRed | |
// | |
this.nudRed.Location = new System.Drawing.Point(57, 12); | |
this.nudRed.Maximum = new decimal(new int[] { | |
255, | |
0, | |
0, | |
0}); | |
this.nudRed.Name = "nudRed"; | |
this.nudRed.Size = new System.Drawing.Size(120, 20); | |
this.nudRed.TabIndex = 1; | |
this.nudRed.Tag = "red"; | |
this.nudRed.ValueChanged += new System.EventHandler(this.nudColor_ValueChanged); | |
// | |
// label2 | |
// | |
this.label2.AutoSize = true; | |
this.label2.Location = new System.Drawing.Point(12, 40); | |
this.label2.Name = "label2"; | |
this.label2.Size = new System.Drawing.Size(39, 13); | |
this.label2.TabIndex = 2; | |
this.label2.Text = "Green:"; | |
// | |
// nudGreen | |
// | |
this.nudGreen.Location = new System.Drawing.Point(57, 38); | |
this.nudGreen.Maximum = new decimal(new int[] { | |
255, | |
0, | |
0, | |
0}); | |
this.nudGreen.Name = "nudGreen"; | |
this.nudGreen.Size = new System.Drawing.Size(120, 20); | |
this.nudGreen.TabIndex = 3; | |
this.nudGreen.Tag = "green"; | |
this.nudGreen.ValueChanged += new System.EventHandler(this.nudColor_ValueChanged); | |
// | |
// label3 | |
// | |
this.label3.AutoSize = true; | |
this.label3.Location = new System.Drawing.Point(12, 66); | |
this.label3.Name = "label3"; | |
this.label3.Size = new System.Drawing.Size(31, 13); | |
this.label3.TabIndex = 4; | |
this.label3.Text = "Blue:"; | |
// | |
// nudBlue | |
// | |
this.nudBlue.Location = new System.Drawing.Point(57, 64); | |
this.nudBlue.Maximum = new decimal(new int[] { | |
255, | |
0, | |
0, | |
0}); | |
this.nudBlue.Name = "nudBlue"; | |
this.nudBlue.Size = new System.Drawing.Size(120, 20); | |
this.nudBlue.TabIndex = 5; | |
this.nudBlue.Tag = "blue"; | |
this.nudBlue.ValueChanged += new System.EventHandler(this.nudColor_ValueChanged); | |
// | |
// lblName | |
// | |
this.lblName.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); | |
this.lblName.Location = new System.Drawing.Point(15, 87); | |
this.lblName.Name = "lblName"; | |
this.lblName.Size = new System.Drawing.Size(162, 42); | |
this.lblName.TabIndex = 6; | |
this.lblName.Text = "Milan Vít"; | |
this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; | |
// | |
// MainForm | |
// | |
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); | |
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | |
this.ClientSize = new System.Drawing.Size(189, 138); | |
this.Controls.Add(this.lblName); | |
this.Controls.Add(this.nudBlue); | |
this.Controls.Add(this.label3); | |
this.Controls.Add(this.nudGreen); | |
this.Controls.Add(this.label2); | |
this.Controls.Add(this.nudRed); | |
this.Controls.Add(this.label1); | |
this.MaximizeBox = false; | |
this.MinimizeBox = false; | |
this.Name = "MainForm"; | |
this.Text = "Sixth Task"; | |
((System.ComponentModel.ISupportInitialize)(this.nudRed)).EndInit(); | |
((System.ComponentModel.ISupportInitialize)(this.nudGreen)).EndInit(); | |
((System.ComponentModel.ISupportInitialize)(this.nudBlue)).EndInit(); | |
this.ResumeLayout(false); | |
this.PerformLayout(); | |
} | |
#endregion | |
private System.Windows.Forms.Label label1; | |
private System.Windows.Forms.NumericUpDown nudRed; | |
private System.Windows.Forms.Label label2; | |
private System.Windows.Forms.NumericUpDown nudGreen; | |
private System.Windows.Forms.Label label3; | |
private System.Windows.Forms.NumericUpDown nudBlue; | |
private System.Windows.Forms.Label lblName; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows.Forms; | |
namespace SixthTask | |
{ | |
static class Program | |
{ | |
/// <summary> | |
/// The main entry point for the application. | |
/// </summary> | |
[STAThread] | |
static void Main() | |
{ | |
Application.EnableVisualStyles(); | |
Application.SetCompatibleTextRenderingDefault(false); | |
Application.Run(new MainForm()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment