Exemplo n.º 1
0
        public SettingViewModel() : base()
        {
            SettingsChanedCommand = new ActionCommand(s => { SettingsChanged(s); }, s => { return(!string.IsNullOrEmpty(apiKey)); });

            if (Settings.Properties.Contains("ApiKey"))
            {
                ApiKey = (string)Settings.Properties["ApiKey"];
            }
            if (Settings.Properties.Contains("UrlStatesRequest"))
            {
                urlStatesRequest = (string)Settings.Properties["UrlStatesRequest"];
            }
            else
            {
                urlStatesRequest = "http://api.dirble.com/v2/countries?";
            }
            if (Settings.Properties.Contains("UrlCategoriesRequest"))
            {
                urlCategoriesRequest = (string)Settings.Properties["UrlCategoriesRequest"];
            }
            else
            {
                urlCategoriesRequest = "http://api.dirble.com/v2/categories?";
            }

            countries = new ObservableCollection <string>();

            foreach (State state in JsonHelper.States)
            {
                countries.Add(state.Name);
            }
            categories = new ObservableCollection <string>();

            foreach (Category cat in JsonHelper.Categories)
            {
                categories.Add(cat.Title);
            }
        }
Exemplo n.º 2
0
        public MainWindowViewModel()
        {
            EditViewModel      = new EditViewModel(this);
            BrowserViewModel   = new BrowserViewModel();
            VisualViewModel    = new VisualViewModel();
            SettingViewModel   = new SettingViewModel();
            CountryModel       = CountryModel.Instance;
            EditViewCommand    = new ActionCommand(delegate { CurrentViewModel = EditViewModel; });
            BrowserViewCommand = new ActionCommand(delegate { CurrentViewModel = BrowserViewModel; });
            VisualViewCommand  = new ActionCommand(delegate { CurrentViewModel = VisualViewModel; });
            SettingViewCommand = new ActionCommand(delegate { CurrentViewModel = SettingViewModel; });
            if (!File.Exists(Settings.settingsPath))
            {
                CurrentViewModel = SettingViewModel;
            }
            else
            {
                CurrentViewModel = VisualViewModel; // call last saved viewModel!!!!
            }
            PlayProgramCommand = new ActionCommand(Play, CanPlay);
            RecordCommand      = new ActionCommand(Record, CanRecord);
            MuteCommand        = new ActionCommand(Silence, (o) => { return(true); });
            WebRadioControl.Instance.OnMessageChanged += ((s, args) => {
                if (args.Message != null)
                {
                    Message = args.Message;
                    if (Message.StatusColorString == "Green")    //program started
                    {
                        Settings.Properties["LastVisitedUrl"] = EditViewModel.CurrentItem.Url;
                    }
                }
            });
            PlayButtonIconPath     = Settings.ResourcePath + "play.png";
            FavoriteButtonIconPath = Settings.ResourcePath + "white.png";
            if (Settings.Properties.Contains("Volume"))
            {
                Volume = float.Parse((string)Settings.Properties["Volume"]);
            }
            else
            {
                Volume = 10;
            }
            if (Settings.Properties.Contains("LastVisitedUrl"))
            {
                FindTreeNode((string)ViewModels.Settings.Properties["LastVisitedUrl"]);
            }
            Favorite1Command   = new ActionCommand((o) => { Favorite("Favorite1"); }, (o) => { return(IsFavorite("Favorite1")); });
            Favorite2Command   = new ActionCommand((o) => { Favorite("Favorite2"); }, (o) => { return(IsFavorite("Favorite2")); });
            Favorite3Command   = new ActionCommand((o) => { Favorite("Favorite3"); }, (o) => { return(IsFavorite("Favorite3")); });
            AddFavoriteCommand = new ActionCommand((o) => {
                IsAddFavorite          = true;
                FavoriteButtonIconPath = Settings.ResourcePath + "Redmark.png";
            }, (o) => { return(EditViewModel.CurrentItem != null); });

            if (Settings.Properties.Contains("Favorite1"))
            {
                favorite1Name = ((FavoriteItem)Settings.Properties["Favorite1"]).Name;
            }
            if (Settings.Properties.Contains("Favorite2"))
            {
                favorite2Name = ((FavoriteItem)Settings.Properties["Favorite2"]).Name;
            }
            if (Settings.Properties.Contains("Favorite3"))
            {
                favorite3Name = ((FavoriteItem)Settings.Properties["Favorite3"]).Name;
            }

            WebBrowserBehavior.FixBrowserVersion();       // Eintrag in registry
        }