Ejemplo n.º 1
0
        public ViewModel(WidgetId id)
            : base(id)
        {
            Settings = id.GetSettings() as Settings;
            if (Settings == null)
                return;
            IsPaused = Settings.Freeze;
            ImageUrl = Settings.ImageUrl;
            AllowDrop = Settings.AllowDropFiles;

            TogglePlayPause = new RelayCommand(TogglePlayPauseExecute);

            _random = new Random();

            _changeTimer = new DispatcherTimer {Interval = Settings.ChangeInterval};
            _changeTimer.Tick += (sender, args) => NextImage();

            _directoryWatcher = new DirectoryWatcher(new DirectoryWatcherSettings
            {
                WatchFolders = new List<string> {Settings.RootPath},
                FileExtensionWhitelist = ImageHelper.SupportedExtensions,
                MaxSize = Settings.FileFilterSize,
                Recursive = Settings.Recursive,
                DetectNewFiles = false,
                DetectModifiedFiles = false
            });
            _directoryWatcher.CheckDirectoriesForNewFiles();
            NextImage();
            if (Settings.Recursive)
                _directoryWatcher.CheckDirectoriesForNewFilesAsync();

            _changeTimer.Start();
        }
Ejemplo n.º 2
0
        public ViewModel(WidgetId id)
            : base(id)
        {
            Settings = id.GetSettings() as Settings;
            if (Settings == null)
                return;
            AllowDrop = Settings.AllowDropFiles;
            IconCache = new Dictionary<string, ImageSource>();

            Refresh = new RelayCommand(RefreshExecute);
            NewShortcut = new RelayCommand(NewShortcutExecute);
            NewSeparator = new RelayCommand(NewSeparatorExecute);
            ManageShortcut = new RelayCommand(ManageShortcutsExecute);

            ShortcutFocus = new RelayCommand<Shortcut>(ShortcutFocusExecute);

            ShortcutEdit = new RelayCommand(ShortcutEditExecute);
            ShortcutMoveUp = new RelayCommand(ShortcutMoveUpExecute);
            ShortcutMoveDown = new RelayCommand(ShortcutMoveDownExecute);
            ShortcutRemove = new RelayCommand(ShortcutRemoveExecute);
            ShortcutOpenFolder = new RelayCommand(ShortcutOpenFolderExecute);
            ShortcutExecute = new RelayCommand<Shortcut>(ShortcutExecuteExecute);

            if (Settings.DefaultShortcutsMode != DefaultShortcutsMode.DontChange)
            {
                Settings.Shortcuts =
                    new ObservableCollection<Shortcut>(ShortcutHelper.GetDefaultShortcuts(Settings.DefaultShortcutsMode));
                Settings.DefaultShortcutsMode = DefaultShortcutsMode.DontChange;
            }
        }
        public WidgetView(WidgetId id, WidgetViewModelBase viewModel, UserControl userControl, bool systemStartup)
        {
            InitializeComponent();

            Opacity = 0;
            Hide();

            Id = id;
            Settings = id.GetSettings();
            ViewModel = viewModel;
            UserControl = userControl;

            SetupWidgetControl();

            SetScrollPosition();

            SetupFrame();

            ViewModel.View = this;

            _mouseChecker = new MouseChecker(this, Settings);

            if (!systemStartup && Settings.ShowIntroOnLaunch)
                _mouseChecker.QueueIntro = new IntroData {ExecuteFinishAction = false};

            DataContext = ViewModel;

            _mouseChecker.Start();

            ViewModel.OnLoad();

            HasLoaded = true;
        }
Ejemplo n.º 4
0
 public ViewModel(WidgetId id)
     : base(id)
 {
     Settings = id.GetSettings() as Settings;
     if (Settings == null)
         return;
 }
Ejemplo n.º 5
0
 public ViewModel(WidgetId guid)
     : base(guid)
 {
     Settings = guid.GetSettings() as Settings;
     if (Settings == null)
         return;
     TickAction = OnTickAction;
 }
Ejemplo n.º 6
0
 public ViewModel(WidgetId id)
     : base(id)
 {
     Settings = id.GetSettings() as Settings;
     if (Settings == null)
         return;
     Go = new RelayCommand(GoExecute);
     OnKeyUp = new RelayCommand<KeyEventArgs>(OnKeyUpExecute);
 }
Ejemplo n.º 7
0
 public ViewModel(WidgetId id)
     : base(id, false)
 {
     Settings = id.GetSettings() as Settings;
     if (Settings == null)
         return;
     StartStopCommand = new RelayCommand(StartStop);
     StartTime = CurrentTime;
 }
Ejemplo n.º 8
0
        public static string GetFriendlyName(this WidgetId id)
        {
            var settings = id.GetSettings();

            if (settings is Widgets.TimeClock.Settings)
            {
                return(Metadata.FriendlyName);
            }
            if (settings is Widgets.CountdownClock.Settings)
            {
                return(Widgets.CountdownClock.Metadata.FriendlyName);
            }
            if (settings is Widgets.StopwatchClock.Settings)
            {
                return(Widgets.StopwatchClock.Metadata.FriendlyName);
            }
            if (settings is Widgets.Weather.Settings)
            {
                return(Widgets.Weather.Metadata.FriendlyName);
            }
            if (settings is Widgets.Search.Settings)
            {
                return(Widgets.Search.Metadata.FriendlyName);
            }
            if (settings is Widgets.Note.Settings)
            {
                return(Widgets.Note.Metadata.FriendlyName);
            }
            if (settings is Widgets.PictureSlideshow.Settings)
            {
                return(Widgets.PictureSlideshow.Metadata.FriendlyName);
            }
            if (settings is Widgets.Sidebar.Settings)
            {
                return(Widgets.Sidebar.Metadata.FriendlyName);
            }
            if (settings is Widgets.Calculator.Settings)
            {
                return(Widgets.Calculator.Metadata.FriendlyName);
            }
            if (settings is Widgets.FolderWatcher.Settings)
            {
                return(Widgets.FolderWatcher.Metadata.FriendlyName);
            }
            if (settings is Widgets.RSSFeed.Settings)
            {
                return(Widgets.RSSFeed.Metadata.FriendlyName);
            }
            if (settings is Widgets.LatencyMonitor.Settings)
            {
                return(Widgets.LatencyMonitor.Metadata.FriendlyName);
            }
            return(null);
        }
Ejemplo n.º 9
0
        public static UserControl GetNewControlView(this WidgetId id)
        {
            var settings = id.GetSettings();

            if (settings is Widgets.TimeClock.Settings)
            {
                return(new ControlView());
            }
            if (settings is Widgets.CountdownClock.Settings)
            {
                return(new Widgets.CountdownClock.ControlView());
            }
            if (settings is Widgets.StopwatchClock.Settings)
            {
                return(new Widgets.StopwatchClock.ControlView());
            }
            if (settings is Widgets.Weather.Settings)
            {
                return(new Widgets.Weather.ControlView());
            }
            if (settings is Widgets.Search.Settings)
            {
                return(new Widgets.Search.ControlView());
            }
            if (settings is Widgets.Note.Settings)
            {
                return(new Widgets.Note.ControlView());
            }
            if (settings is Widgets.PictureSlideshow.Settings)
            {
                return(new Widgets.PictureSlideshow.ControlView());
            }
            if (settings is Widgets.Sidebar.Settings)
            {
                return(new Widgets.Sidebar.ControlView());
            }
            if (settings is Widgets.Calculator.Settings)
            {
                return(new Widgets.Calculator.ControlView());
            }
            if (settings is Widgets.FolderWatcher.Settings)
            {
                return(new Widgets.FolderWatcher.ControlView());
            }
            if (settings is Widgets.RSSFeed.Settings)
            {
                return(new Widgets.RSSFeed.ControlView());
            }
            if (settings is Widgets.LatencyMonitor.Settings)
            {
                return(new Widgets.LatencyMonitor.ControlView());
            }
            return(null);
        }
Ejemplo n.º 10
0
        public static WidgetViewModelBase GetNewViewModel(this WidgetId id)
        {
            var settings = id.GetSettings();

            if (settings is Widgets.TimeClock.Settings)
            {
                return(new Widgets.TimeClock.ViewModel(id));
            }
            if (settings is Widgets.CountdownClock.Settings)
            {
                return(new Widgets.CountdownClock.ViewModel(id));
            }
            if (settings is Widgets.StopwatchClock.Settings)
            {
                return(new Widgets.StopwatchClock.ViewModel(id));
            }
            if (settings is Widgets.Weather.Settings)
            {
                return(new Widgets.Weather.ViewModel(id));
            }
            if (settings is Widgets.Search.Settings)
            {
                return(new Widgets.Search.ViewModel(id));
            }
            if (settings is Widgets.Note.Settings)
            {
                return(new Widgets.Note.ViewModel(id));
            }
            if (settings is Widgets.PictureSlideshow.Settings)
            {
                return(new Widgets.PictureSlideshow.ViewModel(id));
            }
            if (settings is Widgets.Sidebar.Settings)
            {
                return(new Widgets.Sidebar.ViewModel(id));
            }
            if (settings is Widgets.Calculator.Settings)
            {
                return(new Widgets.Calculator.ViewModel(id));
            }
            if (settings is Widgets.FolderWatcher.Settings)
            {
                return(new Widgets.FolderWatcher.ViewModel(id));
            }
            if (settings is Widgets.RSSFeed.Settings)
            {
                return(new Widgets.RSSFeed.ViewModel(id));
            }
            if (settings is Widgets.LatencyMonitor.Settings)
            {
                return(new Widgets.LatencyMonitor.ViewModel(id));
            }
            return(null);
        }
Ejemplo n.º 11
0
 public ViewModel(WidgetId id) : base(id)
 {
     Settings = id.GetSettings() as Settings;
     if (Settings == null)
         return;
     LatencyHistory = new ObservableCollection<TextBlock>();
     _lastLatency = -1;
     _lastDownloadUsage = GetDownloadedBytes();
     _lastUploadUsage = GetUploadedBytes();
     _scanLatency = true;
     StartLatencyReader();
 }
Ejemplo n.º 12
0
        public ViewModel(WidgetId id)
            : base(id)
        {
            Settings = id.GetSettings() as Settings;
            if (Settings == null)
                return;
            _updateTimer = new DispatcherTimer();
            UpdateTimerInterval();
            _updateTimer.Tick += (sender, args) => UpdateWeather();

            UpdateWeather();
            _updateTimer.Start();
        }
Ejemplo n.º 13
0
        public ViewModel(WidgetId id)
            : base(id)
        {
            Settings = id.GetSettings() as Settings;
            if (Settings == null)
                return;
            NavigateHyperlink = new RelayCommand<RequestNavigateEventArgs>(NavigateHyperlinkExecute);
            FeedItems = new ObservableCollection<FeedItem>();
            UpdateTimer = new DispatcherTimer {Interval = Settings.RefreshInterval};
            UpdateTimer.Tick += (sender, args) => UpdateFeed();

            UpdateFeed();
            UpdateTimer.Start();
        }
Ejemplo n.º 14
0
        public ViewModel(WidgetId guid)
            : base(guid)
        {
            Settings = guid.GetSettings() as Settings;
            if (Settings == null)
                return;

            switch (Settings.ResumeOnStartMode)
            {
                case ResumeOnStartMode.Auto:
                    if (Settings.ResumeOnNextStart)
                    {
                        Settings.Paused = false;
                        Settings.ResumeOnNextStart = false;
                    }
                    break;
                case ResumeOnStartMode.Resume:
                    Settings.Paused = false;
                    break;
            }
            IsPaused = Settings.Paused;

            if (Settings.CurrentFile != null && !Settings.FileHistory.Contains(Settings.CurrentFile))
                Settings.FileHistory.Add(Settings.CurrentFile);
            CurrentFile = Settings.CurrentFile;

            OpenFile = new RelayCommand(OpenFileExecute);
            TogglePlayPause = new RelayCommand(TogglePlayPauseExecute);
            Next = new RelayCommand(NextExecute);
            Previous = new RelayCommand(PreviousExecute);

            _resumeTimer = new DispatcherTimer();
            _resumeTimer.Tick += (sender, args) => { Unpause(); };

            _directoryWatcher = new DirectoryWatcher(Settings.DirectoryWatcherSettings, AddToFileQueue);
            _directoryWatcher.Start();

            CheckFile(false);
        }