0% found this document useful (0 votes)
25 views5 pages

Solution File

hh

Uploaded by

bc210420793mma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views5 pages

Solution File

hh

Uploaded by

bc210420793mma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CS411 – Visual Programming

Total Marks: 20
Assignment No. 02
Semester: Spring 2024 Due Date: June 24, 2024

Output:

//Put screenshot of output here


1. Pressing "Add" button

2. Pressing "Multiply" button

1
CS411 – Visual Programming
Total Marks: 20
Assignment No. 02
Semester: Spring 2024 Due Date: June 24, 2024

//Put your XAML code (code of the MainWindow.xaml file) here

<Window x:Class="BC210420793.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="292" Width="500">
<Grid Background="#FFD1E4D1">
<Label Content="VU ID: BC210420793 " HorizontalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="16"
Background="#FFDCA518" Padding="10,5" Margin="0,10,0,0" Width="497" FontWeight="Bold"/>
<Label Content="Enter First Number" HorizontalAlignment="Left"
VerticalAlignment="Top" Margin="30,60,0,0" FontSize="14" FontWeight="Bold"/>
<TextBox x:Name="frttxtbx" HorizontalAlignment="Left" VerticalAlignment="Top"
Width="202" Margin="206,60,0,0" Height="29" FontSize="14" FontWeight="Bold"/>

<Label Content="Enter Second Number" HorizontalAlignment="Left"


VerticalAlignment="Top" Margin="30,100,0,0" FontSize="14" FontWeight="Bold"/>
<TextBox x:Name="sndtxtbx" HorizontalAlignment="Left" VerticalAlignment="Top"
Width="202" Margin="206,100,0,0" Height="29" FontSize="14" FontWeight="Bold"/>

<Button Content="Add" HorizontalAlignment="Left" VerticalAlignment="Top" Width="80"


Margin="128,161,0,0" Click="sumbtn_Click" FontSize="14" FontWeight="Bold">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="0.127"/>
</LinearGradientBrush>
</Button.Background>
</Button>
<Button Content="Multiply" HorizontalAlignment="Left" VerticalAlignment="Top"
Width="80" Margin="228,161,0,0" Click="mulbtn_Click" FontSize="14" FontWeight="Bold">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="0.078"/>
</LinearGradientBrush>

2
CS411 – Visual Programming
Total Marks: 20
Assignment No. 02
Semester: Spring 2024 Due Date: June 24, 2024

</Button.Background>
</Button>
<Button Content="Clear" HorizontalAlignment="Left" VerticalAlignment="Top"
Width="80" Margin="328,161,0,0" Click="clsbtn_Click" FontSize="14" FontWeight="Bold">
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="0.123"/>
</LinearGradientBrush>
</Button.Background>
</Button>

<Label Content="Result:" HorizontalAlignment="Left" VerticalAlignment="Top"


Margin="43,212,0,0" FontSize="14" FontWeight="Bold"/>
<TextBox x:Name="rstTextBox" HorizontalAlignment="Left" VerticalAlignment="Top"
Width="280" Margin="128,215,0,0" Background="#FFE0CDCD" IsReadOnly="True" Height="22"
FontSize="14" FontWeight="Bold"/>
</Grid>
</Window>

//Put your C# code (code of the MainWindow.xaml.cs file) here


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;

3
CS411 – Visual Programming
Total Marks: 20
Assignment No. 02
Semester: Spring 2024 Due Date: June 24, 2024

using System.Windows.Shapes;

namespace BC210420793
{

public partial class MainWindow : Window


{
public MainWindow()
{
InitializeComponent();
}
private void sumbtn_Click(object sender, RoutedEventArgs e)
{
try
{
int fist = int.Parse(frttxtbx.Text);
int snd = int.Parse(sndtxtbx.Text);
int resut = fist + snd;
rstTextBox.Text = resut.ToString();
}
catch (FormatException)
{
MessageBox.Show("Please enter valid numbers in textboxes.", "Invalid Input",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}

private void clsbtn_Click(object sender, RoutedEventArgs e)


{
frttxtbx.Clear();
sndtxtbx.Clear();
rstTextBox.Clear();
}

private void mulbtn_Click(object sender, RoutedEventArgs e)


{

4
CS411 – Visual Programming
Total Marks: 20
Assignment No. 02
Semester: Spring 2024 Due Date: June 24, 2024

try
{
int fst = int.Parse(frttxtbx.Text);
int scnd = int.Parse(sndtxtbx.Text);
int rst = fst * scnd;
rstTextBox.Text = rst.ToString();
}
catch (FormatException)
{
MessageBox.Show("Please enter valid numbers in textboxes.", "Invalid Input",
MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

You might also like