I am very new to C sharp programming. I have the design like as shown below attached image.
My concept is i have to set some volume in “Transfer volume” text box (for example 100) and then press “set” button. It automatically sets the scale of picture box, it is working fine.
Now i want to fill the picture box with colors when i click “Regenerate” button. The percentage of color to be filled in picture box should be the number in the TextBox of that regarding color or liquid.
for example
if i set GasPhase =5 ; Hydrocarbon Liquid =5; Water= 5; Oil Based Mud =5; Water Based Mud =5 ; Not Identified = 75.
then the picture has to fill with 75 % with “Not Identified” color and GasPhase color with 5 % e.t.c.
I have the written some code as shown below.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txtTransferVolume_TextChanged(object sender, EventArgs e)
{
}
private void txtTransferSet_Click(object sender, EventArgs e)
{
string value = txtTransferVolume.Text;
double midvalue = Convert.ToDouble(value);
lblTransferBottleMax.Text = value;
lblTransferBottleMid.Text = (midvalue / 2).ToString();
}
private void chkTransferManual_CheckedChanged(object sender, EventArgs e)
{
}
private void btnTransferBottleRegenerate_Click(object sender, EventArgs e)
{
}
}
}
Please help me how to fill as i want.
This can be achieved quite easily by drawing directly on the picturebox control or creating a bitmap in memory and show in the picturebox.
Example:
Of course you have to check that both arrays are the same length, etc. I just want to give you the basic idea of how to do this.
Here’s a concept of how to get your data in arrays and pass them to the function. Since you are using a different textbox for each value, it’s hard to iterate over them, so right now I’m showing you how to do it using the 6 values you have now.
If your percentages don’t always sum to 100, you could use a third parameter that specifies the sum and change the value
100fto this value in theDrawPercentagesmethod.