Class MainWindow #Region "Window Movement" Private isDown As Boolean Private offset As Point Private Sub Grid_MouseLeftButtonDown_1 (sender As Object, e As MouseButtonEventArgs) offset = e.GetPosition(Me) isDown = True End Sub Private Sub Grid_MouseMove_1(sender As Object, e As MouseEventArgs) If isDown Then Dim pos = PointToScreen(e.GetPosition(Me) - offset) Me.Left = pos.X Me.Top = pos.Y End If End Sub Private Sub Grid_MouseLeftButtonUp_1 (sender As Object, e As MouseButtonEventArgs) isDown = False End Sub #End Region Private SON As New SON Public Shared Main As MainWindow Private HasOptimized As Boolean = False Private HasOptimized2 As Boolean = False Event Reset(target As String) Sub LoadData(Optional ByVal for_expectation As Boolean = False) With My.Settings If Not for_expectation Then Fe.Text = .SON_Fe Si.Text = .SON_Si Mn.Text = .SON_Mn P.Text = .SON_P S.Text = .SON_S C.Text = .SON_C Else Fe_expect.pc.Text = .SON_Fe & "%" Si_expect.pc.Text = .SON_Si & "%" Mn_expect.pc.Text = .SON_Mn & "%" P_expect.pc.Text = .SON_P & "%" S_expect.pc.Text = .SON_S & "%" C_expect.pc.Text = .SON_C & "%" End If End With Dim Mfa As Double = Math.Abs(((Mst * (X_prime - X_not) + (DualValueDisplay.ExactValue(RefineScrap.Text) * (Xn - X_not))) * R_prime) / (X_not - (Xm * R_not))) Hidden_StepMum_For_Level2.Text = Mfa & "kg" CType(FindName(String.Format("Fe{0}_Result", element)), TextBox).Text = Mfa & "kg" CType(FindName("Level2_C_" & element), DualValueDisplay).pc.Text = Level2_C.pc.Text CType(FindName("Level2_C_" & element), DualValueDisplay).kg.Text = Level2_C.kg.Text CType(FindName("Level2_Fe_" & element), DualValueDisplay).pc.Text = Level2_Fe.pc.Text CType(FindName("Level2_Fe_" & element), DualValueDisplay).kg.Text = Level2_Fe.kg.Text Select Case element Case "Mn" Level2_Si.pc.Text = "0.00%" Case Else Level2_Mn.pc.Text = "0.00%" End Select RaiseEvent UpdateDataFields(False) HasOptimized = True End Sub Private Sub Level3_Btn_Click (sender As Object, e As RoutedEventArgs) Handles Level3_Btn.Click Dim element As String = Level3_Element.SelectedItem.Content.ToString.Split(" ")(0) Dim Mst As Double = DualValueDisplay.ExactValue(jScrap.Text) + DualValueDisplay.ExactValue(Heel_kg.Text) + FindName("Level2_" & element & "_Mn").GetKg + FindName("Level2_" & element & "_Si").GetKg + DualValueDisplay.ExactValue(RefineScrap.Text) Dim R_not As Double = Element_Recovery(element) Dim X_not As Double = Element_SON(element) Dim Xj As Double = DualValueDisplay.ExactValue(CType(FindName("Level3_" & element), TextBox).Text) Dim X_star As Double = DualValueDisplay.ExactValue(FindName(element & "_Melt").Text) Dim M_Ad As Double = ((X_not - X_star) * Mst) / (Xj * R_not) CType(FindName(element & "_Result"), TextBox).Text = M_Ad & "kg" HasOptimized = True End Sub Private Sub Resultant_Click (sender As Object, e As RoutedEventArgs) Handles Resultant.Click Try Dim elements = sender.Tag.ToString.Split(",") For Each element In elements Dim Mst As Double = (DualValueDisplay.ExactValue(jScrap.Text)) + DualValueDisplay.ExactValue(Heel_kg.Text) Dim R_not As Double = Element_Recovery(element) Dim X_not As Double = Element_SON(element) Dim X_prime As Double = Pcent_Element_Comp_In_Melt(element) Dim Xn As Double= Pcent_Element_Comp_In_Incoming_Scrap(element) Dim Msc As Double=DualValueDisplay.ExactValue(RefineScrap.Text) Dim Pcentage_Element_Composition As Double = ((Mst * X_prime) + (Msc * Xn * R_not)) / (Mst + Msc) Dispatcher.BeginInvoke(Sub() CType(FindName(element & "_Melt"), TextBox).Text = Pcentage_Element_Composition & "%" End Sub) Next Catch ex As Exception End Try End Sub Private Sub Level2_Resultant_Click (sender As Object, e As RoutedEventArgs) Handles Level2_Resultant.Click Try Dim elements = sender.Tag.ToString.Split(",") For Each element In elements Dim Mst As Double = (DualValueDisplay.ExactValue(jScrap.Text)) + DualValueDisplay.ExactValue(Heel_kg.Text) Dim R_not As Double = Element_Recovery(element) Dim X_not As Double = Element_SON(element) Dim X_prime As Double = Pcent_Element_Comp_In_Melt(element) Dim Xn As Double = Pcent_Element_Comp_In_Incoming_Scrap(element) Dim Mfa As Double = Mass_Of_Element_In_Incoming_FerroAlloy(element, Level2_Element.SelectedItem.Content.ToString.Split(" ")(0).Replace("Fe", "")) Dim Xm As Double = Pcent_Element_Comp_In_Incoming_FerroAlloy(element, Level2_Element.SelectedItem.Content.ToString.Split(" ")(0).Replace("Fe", "")) Dim Msc As Double = DualValueDisplay.ExactValue(RefineScrap.Text) Dim Pcentage_Element_Composition As Double = ((Mst * X_prime) + (Msc * Xn * R_not) + (Mfa * (Xm * R_not))) / (Mst + Msc + Mfa) Dispatcher.BeginInvoke(Sub() CType(FindName(element & "_Melt"), TextBox).Text = Pcentage_Element_Composition & "%" End Sub) Next Catch ex As Exception End Try End Sub Private Sub Level3_Resultant_Click (sender As Object, e As RoutedEventArgs) Handles Level3_Resultant.Click Try Dim elements = sender.Tag.ToString.Split(",") For Each element In elements Dim Mst As Double = (DualValueDisplay.ExactValue(jScrap.Text))+ DualValueDisplay.ExactValue(Heel_kg.Text) Dim R_not As Double = Element_Recovery(element) Dim X_not As Double = Element_SON(element) Dim X_prime As Double = Pcent_Element_Comp_In_Melt(element) Dim Xn As Double = Pcent_Element_Comp_In_Incoming_Scrap(element) Dim Mfa1 As Double = DualValueDisplay.ExactValue(FeMn_Result.Text) Dim Mfa2 As Double = DualValueDisplay.ExactValue(FeSi_Result.Text) Dim Xm1 As Double = Pcent_Element_Comp_In_Incoming_FerroAlloy(element, "Mn") Dim Xm2 As Double = Pcent_Element_Comp_In_Incoming_FerroAlloy(element, "Si") Dim Mad As Double = DualValueDisplay.ExactValue(CType(FindName(element & "_Result"), TextBox).Text) Dim Xj As Double = Pcent_Element_Comp_In_Incoming_Additive(element) Dim Msc As Double = DualValueDisplay.ExactValue(RefineScrap.Text) M_Xn = 0 Else M_Xn = R_not Next End Try End Sub
Write, Run & Share C# code online using OneCompiler's C# online compiler for free. It's one of the robust, feature-rich online compilers for C# language, running on the latest version 8.0. Getting started with the OneCompiler's C# compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C#
and start coding.
OneCompiler's C# online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
using System;
namespace Sample
{
class Test
{
public static void Main(string[] args)
{
string name;
name = Console.ReadLine();
Console.WriteLine("Hello {0} ", name);
}
}
}
C# is a general purpose object-oriented programming language by Microsoft. Though initially it was developed as part of .net but later it was approved by ECMA and ISO standards.
You can use C# to create variety of applications, like web, windows, mobile, console applications and much more using Visual studio.
Data Type | Description | Range | size |
---|---|---|---|
int | To store integers | -2,147,483,648 to 2,147,483,647 | 4 bytes |
double | to store large floating point numbers with decimals | can store 15 decimal digits | 8 bytes |
float | to store floating point numbers with decimals | can store upto 7 decimal digits | 4 bytes |
char | to store single characters | - | 2 bytes |
string | to stores text | - | 2 bytes per character |
bool | to stores either true or false | - | 1 bit |
datatype variable-name = value;
When ever you want to perform a set of operations based on a condition or set of few conditions IF-ELSE is used.
if(conditional-expression) {
// code
}
else {
// code
}
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
Switch is an alternative to If-Else-If ladder.
switch(conditional-expression) {
case value1:
// code
break; // optional
case value2:
// code
break; // optional
...
default:
// code to be executed when all the above cases are not matched;
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement) {
// code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while(condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Array is a collection of similar data which is stored in continuous memory addresses. Array values can be fetched using index. Index starts from 0 to size-1.
data-type[] array-name;
Method is a set of statements which gets executed only when they are called. Call the method name in the main function to execute the method.
static void method-name()
{
// code to be executed
}