Exemplo n.º 1
0
        public void SaveStickers(bool showMessage)
        {
            var state = XmlWriter.CheckBackup("stickers.xml");

            if (state == XmlWriter.BackupState.FileOlder || state == XmlWriter.BackupState.BackupOlder || state == XmlWriter.BackupState.FileNotFoundButBackupFound)
            {
                if (showMessage)
                {
                    MessageBox.Show("Stickers file failed (" + state + ").");
                }
                return;
            }

            try
            {
                XmlWriter.SaveWithBackup(_vmodel.Root, "stickers.xml");
            }
            catch (Exception exc)
            {
                if (showMessage)
                {
                    MessageBox.Show("Save stickers failed " + exc);
                }
            }
        }
Exemplo n.º 2
0
        private void OnFormLoaded(object sender, RoutedEventArgs e)
        {
            _vmodel = new MainViewModel();
            try
            {
                var state = XmlWriter.CheckBackup("stickers.xml");

                if (state == XmlWriter.BackupState.FileNotFoundAndBackupNotFound)
                {
                    _vmodel = new MainViewModel();
                    var plugin = new StickerPlugin.ViewModel.MainViewModel()
                    {
                        ParentFacade = _vmodel
                    };
                    _vmodel.Plugins.Add(plugin);
                }
                else
                {
                    if (state == XmlWriter.BackupState.FileOlder || state == XmlWriter.BackupState.BackupOlder || state == XmlWriter.BackupState.FileNotFoundButBackupFound)
                    {
                        MessageBox.Show("Stickers files failed (" + state + "). Stickers will not be saved!");
                    }

                    var plugin = XmlWriter.Load <StickerPlugin.ViewModel.MainViewModel>("stickers.xml");
                    _vmodel.Plugins.Add(plugin);
                }
            }
            catch (Exception exc)
            {
                _vmodel = new MainViewModel();
                var plugin = new StickerPlugin.ViewModel.MainViewModel()
                {
                    ParentFacade = _vmodel
                };
                _vmodel.Plugins.Add(plugin);

                MessageBox.Show("Load stickers failed. " + exc);
            }

            _vmodel.Init();

            this.DataContext = _vmodel.Root;
        }