Beispiel #1
0
        private void LaunchCardIdle(object sender, StartupEventArgs e)
        {
            //Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
            //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("ru-Ru");

            // http://stackoverflow.com/questions/1472498/wpf-global-exception-handler
            // http://stackoverflow.com/a/1472562/1506454
            DispatcherUnhandledException += LogUnhandledDispatcherException;
            AppDomain.CurrentDomain.UnhandledException += LogUnhandledDomainException;
            TaskScheduler.UnobservedTaskException      += LogTaskSchedulerUnobservedTaskException;

            Logger.Info(String.Format("{0} {1}bit", Environment.OSVersion, Environment.Is64BitOperatingSystem ? 64 : 32));

            string localDatafolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string appFolder       = Path.Combine(localDatafolder, Path.GetFileNameWithoutExtension(AppSystemName));

            if (Directory.Exists(appFolder) == false)
            {
                Directory.CreateDirectory(appFolder);
            }

            string storageFile = Path.Combine(appFolder, "Settings.txt");

            IsNewUser = !File.Exists(storageFile);

            var storage = new SettingsStorage();

            storage.FileName = storageFile;
            storage.Init();

            CookieClient.Storage = storage;

            _account                 = new AccountModel();
            _account.Storage         = storage;
            _account.ShowcaseStorage = new FileStorage("ShowcaseDb.txt");
            _account.PricesStorage   = new FileStorage(Path.Combine(appFolder, "PricesDb.txt"));

            Palette = PaletteItemsCollection.Create();
            if (storage.AppBrushes != null)
            {
                Palette.Deserialize(storage.AppBrushes.OfType <string>());
            }
            Palette.SetNotifier(() =>
            {
                storage.AppBrushes.Clear();
                storage.AppBrushes.AddRange(Palette.Serialize().ToArray());
                storage.Save();
            });

            var w = new BadgesWindow {
                DataContext = _account
            };

            w.Show();

            _account.Startup();
        }
Beispiel #2
0
        public static PaletteItemsCollection Create()
        {
            var resources = App.CardIdle.Resources;
            var brushes   = resources.Keys
                            .OfType <string>()
                            .Where(key => key.StartsWith("Dyn"))
                            .Select(resKey => new PaletteItemVm(resKey, ((SolidColorBrush)resources[resKey]).Color))
                            .ToList();

            var palette = new PaletteItemsCollection();

            palette._items = new ObservableCollection <PaletteItemVm>(brushes);
            return(palette);
        }