Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            this.invoker            = new Invoker();
            storage                 = CollectionStorage.GetInstance();
            NewVinylRecord          = new VinylRecord();
            commandCollection       = CommandCollection.GetInstance();
            recordCollectionHistory = new RecordCollectionHistory();
            recordCollectionHistory.History.Push(storage.SaveState());

            AddRecord_grid.DataContext  = NewVinylRecord;
            recordsDataGrid.ItemsSource = storage.GetCollection();

            App.LanguageChanged += LanguageChanged;
            CultureInfo currLang = App.Language;

            foreach (var lang in App.Languages)
            {
                MenuItem menuLang = new MenuItem();
                menuLang.Header    = lang.DisplayName;
                menuLang.Tag       = lang;
                menuLang.IsChecked = lang.Equals(currLang);
                menuLang.Click    += ChangeLanguageClick;
                Main_menu.Items.Add(menuLang);
            }
        }
Ejemplo n.º 2
0
        private void AddRecordInCollection_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.recordCollectionHistory.History.Push(storage.SaveState());
                var addInCollection = new AddInCollection(storage, NewVinylRecord);
                this.commandCollection.SaveLastCommand(addInCollection);
                this.invoker.SetOnStart(addInCollection);
                this.invoker.Do();

                //TODO: Maybe replace this part in another function
                //foreach(var ctl in AddRecord_grid.Children)
                //{
                //    if (ctl.GetType() == typeof(TextBox))
                //        ((TextBox)ctl).Text = String.Empty;
                //}
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }