Ejemplo n.º 1
0
        public void Unload()
        {
            _shop = new Models.Shop();

            NotifyOfPropertyChange(nameof(Categories));
            NotifyOfPropertyChange(nameof(SubCategories));
            NotifyOfPropertyChange(nameof(Items));

            Version  = -1;
            FileType = FileType.Client;

            NotifyOfPropertyChange(nameof(AddItemsAvalaibility));

            NotifyOfPropertyChange(nameof(Version144Sections));
            NotifyOfPropertyChange(nameof(Version152Sections));
            NotifyOfPropertyChange(nameof(Version153Sections));
        }
Ejemplo n.º 2
0
        public void Load(int version, FileType fileType)
        {
            var dialog = new OpenFileDialog()
            {
                FileName = "gshop.data",
                Filter   = "gshop.data|*.data|All files|*.*"
            };

            var result = dialog.ShowDialog();

            if (result != null && !(bool)result)
            {
                return;
            }

            try
            {
                using (var stream = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read))
                    using (var reader = new BinaryReader(stream))
                    {
                        _shop = reader.ReadModelWithParameters <Models.Shop>(version, fileType);
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            NotifyOfPropertyChange(nameof(Categories));
            NotifyOfPropertyChange(nameof(SubCategories));
            NotifyOfPropertyChange(nameof(Items));

            Version  = version;
            FileType = fileType;

            NotifyOfPropertyChange(nameof(AddItemsAvalaibility));

            NotifyOfPropertyChange(nameof(Version144Sections));
            NotifyOfPropertyChange(nameof(Version152Sections));
            NotifyOfPropertyChange(nameof(Version153Sections));
        }