예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            PasswordCollection = new ObservableCollection <Passwordclass>();

            PasswordGameCollection = new ObservableCollection <Passwordclass>();

            PasswordCollection = Passworded.LoadDataFromXml();

            this.DataContext = this;

            this.PasswordListWiev.ItemsSource = PasswordCollection;

            this.PasswordsComboBox.ItemsSource   = Enum.GetValues(typeof(PasswordAmount));
            this.PasswordsComboBox.SelectedIndex = 0;

            this.TimeComboBox.ItemsSource   = Enum.GetValues(typeof(Time));
            this.TimeComboBox.SelectedIndex = 0;

            this.RoundComboBox.ItemsSource   = Enum.GetValues(typeof(FullRounds));
            this.RoundComboBox.SelectedIndex = 0;

            this.Team1ComboBox.ItemsSource   = Enum.GetValues(typeof(TeamAmount));
            this.Team1ComboBox.SelectedIndex = 0;

            this.Team2ComboBox.ItemsSource   = Enum.GetValues(typeof(TeamAmount));
            this.Team2ComboBox.SelectedIndex = 0;

            this.ValueSortTypeComboBox.ItemsSource   = Enum.GetValues(typeof(ValueTypeSort));
            this.ValueSortTypeComboBox.SelectedIndex = 0;

            Timer          = new DispatcherTimer(DispatcherPriority.Normal);
            Timer.Interval = new TimeSpan(0, 0, 1);
            Timer.Tick    += Timer_Tick;

            UpdateLayout();
        }
예제 #2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            var NewPasswordCollection = new ObservableCollection <Passwordclass>();
            var PasswordModel         = new Passwordclass();
            var PasswordXml           = new PasswordsXml();

            NewPasswordCollection = PasswordXml.LoadDataFromXml();

            if (this.newName.Text.ToString() == String.Empty || this.newCategory.Text.ToString() == String.Empty)
            {
                MessageBox.Show("Żadne pole nie może być puste!...");
            }
            else
            {
                bool IfExist = PasswordModel.SearchDataInCollection(NewPasswordCollection, this.newName.Text.ToString(), this.newCategory.Text.ToString());

                if (IfExist == true)
                {
                    MessageBox.Show("Przykro mi, takie hasło jest już w bazie...");
                }
                else
                {
                    int lastId = PasswordModel.GetLastIdIndexValue(NewPasswordCollection) + 1;
                    PasswordXml.AddDataToXml(lastId, this.newName.Text.ToString(), this.newCategory.Text.ToString(), this.newLevel.Text.ToString());
                    PasswordModel.Id       = lastId;
                    PasswordModel.Category = this.newCategory.Text.ToString();
                    PasswordModel.Name     = this.newName.Text.ToString();
                    PasswordModel.Level    = this.newLevel.Text.ToString();

                    NewPasswordCollection.Add(PasswordModel);
                    MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                    mainWindow.PasswordCollection = NewPasswordCollection;
                    mainWindow.UpdateListView(mainWindow.PasswordCollection);
                    // this.Close();
                    //MessageBox.Show("Dodano nowe hasło!"); - optionally
                }
            }
        }