Advertisement
andrzejiwaniuk

Klawiatura z obrazka - Część 1 - Microsoft Visual C #

Jul 19th, 2013
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.37 KB | None | 0 0
  1. <Window x:Class="klawiatura.MainWindow"
  2.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4.         Title="Program do pisania" Height="590" Width="772.165" Background="#FFD8F3C5" ResizeMode="NoResize" Icon="obazki/computer-hacked.jpg">
  5.     <Grid Margin="0,-31,16.2,-4.2">
  6.         <Image HorizontalAlignment="Left" Margin="18,202,-0.4,10" Width="732" Source="obazki/keyboardfng.gif"/>
  7.         <Button x:Name="_1btn" Content="Button" HorizontalAlignment="Left" Margin="69,329,0,0" VerticalAlignment="Top" Width="32" Height="33" Opacity="0" Click="_1btn_Click"/>
  8.         <TextBox x:Name="pisanietb" HorizontalAlignment="Left" Height="193" Margin="10,50,-0.4,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="740" Background="#FFEBE6CC" FontSize="20" UndoLimit="20000" Cursor="Arrow" AcceptsReturn="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"/>
  9.         <Button x:Name="_1btn_Copy" Content="Button" HorizontalAlignment="Left" Margin="69,329,0,0" VerticalAlignment="Top" Width="32" Height="33" Click="_1btn_Click" Opacity="0"/>
  10.         <Button x:Name="_2btn" Content="Button" HorizontalAlignment="Left" Margin="106,329,0,0" VerticalAlignment="Top" Width="32" Height="33" Opacity="0" Click="_2btn_Click"/>
  11.         <Button x:Name="_Enterbtn" Content="Button" HorizontalAlignment="Left" Margin="575,392,0,0" VerticalAlignment="Top" Width="32" Height="33" Opacity="0" Click="_Enterbtn_Click" RenderTransformOrigin="15.21,2.439"/>
  12.         <Button x:Name="_abtn" Content="Button" HorizontalAlignment="Left" Margin="98,406,0,0" VerticalAlignment="Top" Width="32" Height="33" Opacity="0" Click="_abtn_Click" RenderTransformOrigin="1.454,2.828"/>
  13.         <Button x:Name="_caps" Content="Button" HorizontalAlignment="Left" Margin="43,406,0,0" VerticalAlignment="Top" Width="32" Height="33" Opacity="0" Click="_caps_Click" RenderTransformOrigin="1.454,2.828"/>
  14.         <Button x:Name="_backspacebtn" Content="Button" HorizontalAlignment="Left" Margin="585,329,0,0" VerticalAlignment="Top" Width="32" Height="33" Opacity="0" Click="_backspacebtn_Click" RenderTransformOrigin="15.21,2.439"/>
  15.        
  16.     </Grid>
  17.     <Window.Triggers>
  18.     <EventTrigger RoutedEvent="Button.Click">
  19.         <EventTrigger.Actions>
  20.             <SoundPlayerAction Source="dzwieki/click.wav" />
  21.          </EventTrigger.Actions>
  22.     </EventTrigger>
  23. </Window.Triggers>
  24. </Window>
  25.    
  26. using System;
  27. using System.Collections.Generic;
  28. using System.Linq;
  29. using System.Text;
  30. using System.Threading.Tasks;
  31. using System.Windows;
  32. using System.Windows.Controls;
  33. using System.Windows.Data;
  34. using System.Windows.Documents;
  35. using System.Windows.Input;
  36. using System.Windows.Media;
  37. using System.Windows.Media.Imaging;
  38. using System.Windows.Navigation;
  39. using System.Windows.Shapes;
  40.  
  41. namespace klawiatura
  42. {
  43.     /// <summary>
  44.     /// Prosta klawiatura generowana ze zdjęcia
  45.     /// </summary>
  46.     public partial class MainWindow : Window
  47.     {
  48.         TextBox BehaveTextbox;
  49.         static bool capsLockwlaczony= false;
  50.         public MainWindow()
  51.         {
  52.             InitializeComponent();
  53.         }
  54.  
  55.         private void _1btn_Click(object sender, RoutedEventArgs e)
  56.         {
  57.             pisanietb.Text += "1";
  58.         }
  59.  
  60.         private void _Enterbtn_Click(object sender, RoutedEventArgs e)
  61.         {
  62.             pisanietb.Text += "\r\n";
  63.         }
  64.  
  65.         private void _2btn_Click(object sender, RoutedEventArgs e)
  66.         {
  67.             pisanietb.Text += "2";
  68.         }
  69.  
  70.         private void _abtn_Click(object sender, RoutedEventArgs e)
  71.         {
  72.             if(!capsLockwlaczony)
  73.                 pisanietb.Text += "a";
  74.             else
  75.                 pisanietb.Text += "A";
  76.         }
  77.  
  78.         private void _caps_Click(object sender, RoutedEventArgs e)
  79.         {
  80.            
  81.             if(capsLockwlaczony)
  82.                 capsLockwlaczony = false;
  83.             else
  84.                 capsLockwlaczony = true;
  85.         }
  86.    
  87.          
  88.  
  89.         private void _backspacebtn_Click(object sender, RoutedEventArgs e)
  90.         {
  91.            string s = pisanietb.Text;
  92.  
  93.             if (s.Length > 1)
  94.             {
  95.                 s = s.Substring(0, s.Length - 1);
  96.             }
  97.             else
  98.             {
  99.                 s = "";
  100.             }
  101.  
  102.             pisanietb.Text = s;
  103.         }
  104.    
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement