Question

Using C# Language

Develop a Visual C# .NET application that performs a colour control operation. The main form contains a reset button and sets the form's background colour according to the colour values indicated by the colour control objects. Each colour control object is controlled by a corresponding colour control form which provides a progress bar to show the value (in the range 0 to 255) of the corresponding colour control object. The user can click the increase (+) or decrease (-) button to change the value in the corresponding colour control object. When the user clicks the Reset button on the main form, the colour control objects are reset to their initial values (128).

Program Requirements

The main form should have an appropriate title. The colour control form should be named ColourControlForm. The colour control class should be named ColourControl. Make sure to use the property and event names as specified in the colour control class (including case). Local variables and class fields must follow the camel case naming convention. Variable names must be meaningful. The project name must be valid and descriptive. Each form and class filename must match its corresponding form class name and class name. The program must adhere to the following requirements:

The Main Form

Main FormClick for more options

  • The Reset button should always remain at the top of the form and always be the width of the form as it is resized (you can use the Dock property or the Anchor property).
  • When the form is initialized, three ColourControl objects should be created as class fields (so they can be used from multiple event procedures).
  • When the program first runs, it should create three ColourControlForm objects (these do not need to be class fields) passing the three colour control objects to their respective constructors along with a word indicating the colour that that control form controls (i.e., "Red", "Green", or "Blue"). Show all three forms modelessly. Specify this form as the owner form. E.g.
    form.Show(this)
  • When the program first runs, the background colour (BackColor) of the form should be set to the colour made from the three colour controls. Use the Color.FromArgb method to set the colour. E.g.
    Color color = Color.FromArgb(red value, green value, blue value)
  • When the user clicks the Reset button, the program will reset the value in all three colour control objects by calling each ColourControl object's ResetValue method.
  • Whenever the value changes in any of the colour control objects, the program must update the form background colour (again, using the Color.FromArgb method). Respond to the colour control objects' ValueChanged events.

The Colour Control Form

Colour Control FormClick for more options

  • The form should not be resizable (see the FormBorderStyle property of the form). Also, the form's MinimizeBox, MaximizeBox, and ControlBox should all be disabled.
  • The constructor for the form should take a string parameter for the colour name and a ColourControl object. The colour name (e.g. Red, Green, or Blue) should be included in the form title (as shown to the right). The colour control object should be stored into a class field.
  • The form has a progress bar and two buttons.
  • The limits of the progress bar should be 0 to 255.
  • When the form loads, the value of the colour control object should be assigned to the progress bar's value.
  • When the user clicks the + button, the program will increase the colour control's value by calling the colour control's IncreaseValue method.
  • When the user clicks the - button, the program will decrease the colour control's value by calling the colour control's DecreaseValue method.
  • Whenever the value changes in the colour control object, the form must update the progress bar's Value to the Value of the colour control object.

The ColourControl Class

  • The class should be public.
  • The class defines a read-only or private set public property named Value of type int.
  • The class defines a public event named ValueChanged whose delegate type is void with two parameters, object sender and EventArgs e.
  • The public constructor for the class is a default constructor (i.e., takes no parameters). The constructor sets the Value property to 128.
  • The class defines a public void method named IncreaseValue. The method increases Value by 5. If after adding 5 the value is greater than 255, then Value should be set to 255 instead. The ValueChanged event should be raised only if the value has changed.
  • The class defines a public void method named DecreaseValue. The method decreases Value by 5. If after subtracting 5 the value is less than 0, then Value should be set to 0 instead. The ValueChanged event should be raised only if the value has changed.
  • The class defines a public void method named ResetValue. The method sets Value to 128. The ValueChanged event should be raised only if the value has changed.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ColorControl
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
this.BackColor = Color.FromArgb(128, 128, 128);


}

public MainForm(int R , int G , int B)
{
this.BackColor = Color.FromArgb(R, G, B);
}

private void reset(int red , int yellow , int green)
{
ButtonRed1.Text = "128";
ButtonGreen1.Text = "128";
ButtonBlack1.Text = "128";
  
int R = Convert.ToInt32(ButtonRed1.Text);
int G = Convert.ToInt32(ButtonGreen1.Text);
int B = Convert.ToInt32(ButtonBlack1.Text);
new MainForm( R ,G ,B);   
}

private void ButtonRed_Click(object sender, EventArgs e)
{
Rpanel.Show();
Bpanel.Hide();
Gpanel.Hide();   
DoneButton.Show();
}

private void ButtonRed1_Click(object sender, EventArgs e)
{
Rpanel.Show();
Bpanel.Hide();
Gpanel.Hide();
DoneButton.Show();
}

private void ButtonGreen_Click(object sender, EventArgs e)
{
Rpanel.Hide();
Bpanel.Hide();
Gpanel.Show();
DoneButton.Show();
}

private void ButtonGreen1_Click(object sender, EventArgs e)
{
Rpanel.Hide();
Bpanel.Hide();
Gpanel.Show();
DoneButton.Show();
}

private void ButtonBlack_Click(object sender, EventArgs e)
{
Rpanel.Hide();
Bpanel.Show();
Gpanel.Hide();
DoneButton.Show();
}

private void ButtonBlack1_Click(object sender, EventArgs e)
{
Rpanel.Hide();
Bpanel.Show();
Gpanel.Hide();
DoneButton.Show();
}

private void MainForm_Load(object sender, EventArgs e)
{
//miscoded
}

private void button1_Click(object sender, EventArgs e)
{
new MainForm();   
}

private void DoneButton_Click(object sender, EventArgs e)
{
Rpanel.Hide();
Bpanel.Hide();
Gpanel.Hide();
new MainForm();
DoneButton.Hide();
}
}
}

Add a comment
Know the answer?
Add Answer to:
Using C# Language Develop a Visual C# .NET application that performs a colour control operation. The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Language The ColourControl Class The class should be public. The class defines a read-only or...

    C# Language The ColourControl Class The class should be public. The class defines a read-only or private set public property named Value of type int. The class defines a public event named ValueChanged whose delegate type is void with two parameters, object sender and EventArgs e. The public constructor for the class is a default constructor (i.e., takes no parameters). The constructor sets the Value property to 128. The class defines a public void method named IncreaseValue. The method increases...

  • What am I doing wrong? I get this error: "The name 'LoginPasswordUserControl' does not exist in...

    What am I doing wrong? I get this error: "The name 'LoginPasswordUserControl' does not exist in the current context" I have a user control, here is the code: using System.Windows.Forms; //Define the namespace to make the user control. //namespace to hold the application namespace LoginPasswordUser { //Define the class to make the user control.   //Class to define the control   public partial class LoginPasswordUserControl : UserControl { //Define the read-only properties to get the username and the password from the user...

  • How do you do this using visual studio on a Mac? You are tasked with creating...

    How do you do this using visual studio on a Mac? You are tasked with creating an application with five PictureBox controls. In the Poker Large folder, you will find JPEG image files for a complete deck of poker cards. Feel free to choose any card image that you like or be creative with this application. Each PictureBox should display a different card from the set of images. When the user clicks any of the PictureBox controls, the name of...

  • Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb...

    Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb Public Class frmNewItem Public InvItem As InvItem Private Sub frmNewItem_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.LoadComboBox() End Sub Private Sub LoadComboBox() cboSizeOrManufacturer.Items.Clear() If rdoPlant.Checked Then cboSizeOrManufacturer.Items.Add("1 gallon") cboSizeOrManufacturer.Items.Add("5 gallon") cboSizeOrManufacturer.Items.Add("15 gallon") cboSizeOrManufacturer.Items.Add("24-inch box") cboSizeOrManufacturer.Items.Add("36-inch box") Else cboSizeOrManufacturer.Items.Add("Bayer") cboSizeOrManufacturer.Items.Add("Jobe's") cboSizeOrManufacturer.Items.Add("Ortho") cboSizeOrManufacturer.Items.Add("Roundup") cboSizeOrManufacturer.Items.Add("Scotts") End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click If IsValidData() Then InvItem = New InvItem(CInt(txtItemNo.Text),...

  • USING VISUAL BASIC STUDIO PLEASE PROVIDE THE CODE IN C# LANGUAGE SELECT CONSOLE APPLICATION You are...

    USING VISUAL BASIC STUDIO PLEASE PROVIDE THE CODE IN C# LANGUAGE SELECT CONSOLE APPLICATION You are to create a House with 2 rooms in the house. The following is an example of C++ code for the basic classes: **in C#, it may be written differently** class Room { private: double L; double W; public: //functions go here. } class House { private: Room room1; Room room2; public: //functions go here } The code above is C++ version. In C#, you...

  • This has to be extremely precise, thank you for your time. ols Window Help U +...

    This has to be extremely precise, thank you for your time. ols Window Help U + 1 /write a class meeting the following specifications: 3 //The class is declared as public. 4 //The class is named Country. 5 //The class has a field of type String named anger. 6 //The class has a field of type int named stretch. 7 //The class has a field of type double named film. 8 //The class has a exactly one constructor. 9 //The...

  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT