Ejemplo n.º 1
0
        private async void Update(object parameter = null)
        {
            loading.Start();
            await XPer.Load();

            loading.Stop();

            LoadingMessageVisibility = Visibility.Collapsed;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null));
        }
Ejemplo n.º 2
0
        public ViewModel()
        {
            XPer          = new XPer();
            LoadedCommand = new DelegateCommand(Update);
            UpdateCommand = new DelegateCommand(Update);

            SaveCommand = new DelegateCommand((o) =>
            {
                XPer.Save();
                Update();
            });

            ImageSelectCommand = new DelegateCommand((o) =>
            {
                var dialog = new OpenFileDialog();
                var result = dialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    try
                    {
                        var directory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "/XpJp/XP-Passbook/";
                        if (!Directory.Exists(directory))
                        {
                            Directory.CreateDirectory(directory);
                        }
                        var movedFileFullName = directory + Path.GetFileName(dialog.FileName);
                        File.Copy(dialog.FileName, movedFileFullName);
                        XPer.ImageFullName = movedFileFullName;
                    }
                    catch { }
                }
            });

            ExitCommand = new DelegateCommand((o) => System.Windows.Application.Current.MainWindow.Close());

            loading          = new DispatcherTimer();
            loading.Interval = new TimeSpan(0, 0, 1);
            loading.Tick    += (o, e) =>
            {
                if (LoadingMessageVisibility == Visibility.Collapsed)
                {
                    LoadingMessageVisibility = Visibility.Visible;
                }
                else
                {
                    LoadingMessageVisibility = Visibility.Collapsed;
                }
            };
        }