added comments and wpf base
This commit is contained in:
parent
74c6a87254
commit
ab86652859
146 changed files with 2046 additions and 290 deletions
57
karnaugh-map/WPF-kmap/WPF-kmap/MainWindow.xaml.cs
Normal file
57
karnaugh-map/WPF-kmap/WPF-kmap/MainWindow.xaml.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
using System.Text;
|
||||
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;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WPF_kmap
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
private void boxOnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Button btn = sender as Button;
|
||||
if (btn == null)
|
||||
return;
|
||||
|
||||
int currentValue = 0;
|
||||
if (btn.Tag != null)
|
||||
{
|
||||
currentValue = (int)btn.Tag;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (btn.Content.ToString() == "X")
|
||||
currentValue = -1;
|
||||
else if (!int.TryParse(btn.Content.ToString(), out currentValue))
|
||||
currentValue = 0;
|
||||
}
|
||||
|
||||
int newValue;
|
||||
if (currentValue == -1)
|
||||
newValue = 0;
|
||||
else if (currentValue == 0)
|
||||
newValue = 1;
|
||||
else
|
||||
newValue = -1;
|
||||
|
||||
btn.Tag = newValue;
|
||||
btn.Content = newValue == -1 ? "X" : newValue.ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue