Esempio n. 1
0
 public RALVM()
 {
     ralCatalogSingleton = RALCatalogSingleton.Instance;
     _selecteedd         = null;
     AllUsers            = ralCatalogSingleton.rAl;
     AddUserCommand      = new RelayCommand.RelayCommand(AddUser);
     //LoginCommand = new RelayCommand.RelayCommand(CanNavigate(Username, Password),CanNavigate(Username,Password));
 }
Esempio n. 2
0
        public NewGadgetViewModel()
        {
            var url = System.Configuration.ConfigurationManager.AppSettings["serverGadgeothek"];

            Service = new LibraryAdminService(url);

            SaveCommand   = new RelayCommand.RelayCommand <Object>((o) => Save());
            CancelCommand = new RelayCommand.RelayCommand <Object>((o) => Cancel());
        }
Esempio n. 3
0
        public EditGadgetViewModel(Gadget gadget)
        {
            var url = System.Configuration.ConfigurationManager.AppSettings["serverGadgeothek"];

            Service = new LibraryAdminService(url);

            EditGadget = gadget;

            ConfirmEditCommand = new RelayCommand.RelayCommand <Object>((o) => ConfirmEdit());
            CancelEditCommand  = new RelayCommand.RelayCommand <Object>((o) => CancelEdit());
        }
Esempio n. 4
0
        public KuvertViewModel()
        {
            Instance      = KuvertCatalogSingleton.Instance;
            PrisBeregning = new PrisBeregning();
            Kuverter      = new Kuverter();


            TilmeldAlleCommand    = new RelayCommand.RelayCommand(AddAlleDage);
            KuvertPerDagCommand   = new RelayCommand.RelayCommand(prisPerKuvertEr);
            RydListeOverDeltagere = new RelayCommand.RelayCommand(StartNyUge);

            this.HentDataFraDiskAsync();
        }
        public ArbejderPlanViewModel()
        {
            Instance          = ArbejderCatalogSingleton.Instance;
            MandagsArbejdere  = new Arbejdere();
            TirsdagsArbejdere = new Arbejdere();
            OnsdagsArbejdere  = new Arbejdere();
            TorsdagsArbejdere = new Arbejdere();

            TilmeldArbejderCommand = new RelayCommand.RelayCommand(TilmeldArbejde);
            RydListeOverArbejdere  = new RelayCommand.RelayCommand(StartNyUge);

            this.HentDataFraDiskAsync();
        }
Esempio n. 6
0
        public MadPlanViewModel()
        {
            NewPris              = new PrisBeregning();
            MadplanListen        = new MadplanListe();
            localfolder          = ApplicationData.Current.LocalFolder;
            NewMad               = new Madplan();
            SelectedMadplan      = new Madplan();
            AddMadPlanCommand    = new RelayCommand.RelayCommand(AddNewMadplan);
            RemoveMadplanCommand = new RelayCommand.RelayCommand(RemoveMadPlan);
            LoadMadplanCommand   = new RelayCommand.RelayCommand(HentDataFraDiskAsync);
            SaveMadplanCommand   = new RelayCommand.RelayCommand(GemDataTilDiskAsync);
            RydMadPlanCommand    = new RelayCommand.RelayCommand(RydMadPlan);

            this.HentDataFraDiskAsync();
        }
Esempio n. 7
0
        /// <summary>
        /// Default constructor. Accepts a dependency property of the type <see cref="IDialogService"/>.
        /// </summary>
        public TaskViewModel(IDialogService dialogService)
        {
            // Initialize services
            _dialogService = dialogService;
            _repo          = new TodoRepository(_dialogService);

            this.PropertyChanged += TaskViewModel_PropertyChanged;

            // Commands
            ToggleRenameCommand    = new RelayCommand.RelayCommand(p => { RenameActive = !RenameActive; });
            ToggleExpandedCommand  = new RelayCommand.RelayCommand(p => { ExpandedActive = !ExpandedActive; });
            CheckTaskCommand       = new RelayCommand.RelayCommand(p => { this.IsCompleted = true; });
            UncheckTaskCommand     = new RelayCommand.RelayCommand(p => { this.IsCompleted = false; });
            AddSubtaskCommand      = new RelayCommand.RelayCommand(async p => { await AddSubtask(); SetMessage("Subtask added."); }, p => NewSubtaskName.Length > 0);
            DeleteSubtaskCommand   = new RelayCommand.RelayCommand(async p => { await DeleteSubtask(p as SubtaskViewModel); });
            MarkAsImportantCommand = new RelayCommand.RelayCommand(p => { this.IsImportant = !this.IsImportant; });
        }
        public GadgetViewModel()
        {
            var url = System.Configuration.ConfigurationManager.AppSettings["serverGadgeothek"];

            Service = new LibraryAdminService(url);

            Gadgets = Service.GetAllGadgets();
            Loans   = Service.GetAllLoans();

            EditGadgetCommand   = new RelayCommand.RelayCommand <Object>((o) => EditGadget());
            DeleteGadgetCommand = new RelayCommand.RelayCommand <Object>((o) => DeleteGadget());

            aTimer          = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimerEvent);
            aTimer.Interval = 5000;
            aTimer.Enabled  = true;
            aTimer.Start();
        }
Esempio n. 9
0
        /// <summary>
        /// Constructor that accepts the <see cref="IDialogService"/> interface.
        /// </summary>
        public TodoViewModel(IDialogService dialogService)
        {
            // Initialize services
            _dialogService = dialogService;
            _repo          = new TodoRepository(_dialogService);

            // Subscribe to Todo Property Changed
            this.PropertyChanged += TodoViewModel_PropertyChanged;

            // Initialize commands
            ResetTasksCommand        = new RelayCommand.RelayCommand(async p => { await ResetTasks(); }, p => Tasks.Count > 0);
            ToggleRenameCommand      = new RelayCommand.RelayCommand(p => { RenameActive = !RenameActive; });
            ToggleNewTaskCommand     = new RelayCommand.RelayCommand(p => { NewTaskActive = bool.Parse((string)p); });
            SaveNewTaskCommand       = new RelayCommand.RelayCommand(async p => { await AddTask(); SetMessage("Task added."); }, p => (NewTaskActive && !string.IsNullOrEmpty(NewTask.Name)));
            DeleteTaskCommand        = new RelayCommand.RelayCommand(async p => { await DeleteTask(SelectedTask); });
            CopyTaskCommand          = new RelayCommand.RelayCommand(async p => { await CopyTask(SelectedTask); });
            ActivateDragCommand      = new RelayCommand.RelayCommand(p => { DragHandleActive = true; });
            CloseImageMenuCommand    = new RelayCommand.RelayCommand(p => { IsImageMenuOpen = false; });
            ChangeBannerImageCommand = new RelayCommand.RelayCommand(async p => { await ChangeBannerImage((string)p); });
            MakeFavoriteCommand      = new RelayCommand.RelayCommand(p => { IsFavorite = !IsFavorite; });
        }
Esempio n. 10
0
        /// <summary>
        /// Constructor that accepts a <see cref="Window"/>.
        /// </summary>
        /// <param name="window"></param>
        public WindowViewModel(Window window)
        {
            // Initialize window
            _window = window;

            // Initialize NotifyIcon
            InitializeNotifyIcon();

            // Listen for location changed
            _window.LocationChanged += (sender, e) =>
            {
                if (Pinned)
                {
                    _window.Topmost = false;
                    _pinned         = false;
                    NotifyPropertyChanged(nameof(Pinned));
                }
            };

            // Get window settings
            _minimizeToTray        = bool.Parse(SettingsManager.LoadSetting(SettingsManager.Setting.MinimizeToTray.ToString()).ToString());
            _minimizeToTrayMessage = bool.Parse(SettingsManager.LoadSetting(SettingsManager.Setting.MinimizeToTrayMessage.ToString()).ToString());

            // Listen for window state changed
            _window.StateChanged += (sender, e) =>
            {
                NotifyPropertyChanged(nameof(ResizeBorderThickness));
                NotifyPropertyChanged(nameof(OuterMarginSize));
                NotifyPropertyChanged(nameof(OuterMarginSizeThickness));

                // Minimize to tray if setting is active
                if (_minimizeToTray)
                {
                    // If window is minimized, enable NotifyIcon
                    if (_window.WindowState == WindowState.Minimized)
                    {
                        // Hide window and enable NotifyIcon
                        _window.Hide();
                        _notifyIcon.Visible = true;

                        // Show message if setting is active
                        if (_minimizeToTrayMessage)
                        {
                            _notifyIcon.ShowBalloonTip(2000, "Window minimized", "You can change these settings under General Settings.", ToolTipIcon.None);
                            _minimizeToTrayMessage = false;
                        }
                    }
                    // If window is normal, disable NotifyIcon
                    else if (_window.WindowState == WindowState.Normal)
                    {
                        _notifyIcon.Visible = false;
                    }
                }
            };

            // Initialize commands
            MinimizeCommand = new RelayCommand.RelayCommand(p => { _window.WindowState = WindowState.Minimized; });
            MaximizeCommand = new RelayCommand.RelayCommand(p => { _window.WindowState ^= WindowState.Maximized; });
            CloseCommand    = new RelayCommand.RelayCommand(p => { _window.Close(); });

            // Resize windows when maximized
            var resizer = new WindowResizer.WindowResizer(_window);
        }
Esempio n. 11
0
        /// <summary>
        /// Constructor that accepts the <see cref="IDialogService"/> interface.
        /// </summary>
        public MainViewModel(IDialogService dialogService)
        {
            // Initialize dialog service
            _dialogService = dialogService;
            _dialogService.MessageChanged += MessageChanged;

            // Initialize theme manager
            _themeManager = new ThemeManager();            

            // Initialize first data repository
            _repo = new TodoRepository(_dialogService);

            // Initialize media player
            _mediaPlayer = new MediaPlayer();
            _mediaPlayer.Volume = 0.5;
            _mediaPlayer.IsMuted = false;

            // Get data and create filtered view
            Todos = new ObservableCollection<TodoViewModel>(_repo.GetTodos());
            foreach (var todo in Todos)
            {
                todo.UpdateProgress();
            }
            _filteredTodos = new ListCollectionView(Todos);

            // Check last opened list
            int lastOpened = (int)SettingsManager.LoadSetting(SettingsManager.Setting.LastTodo.ToString());
            SelectedTodo = Todos.Where(t => t.Id == lastOpened).FirstOrDefault();

            // Subscribe to settings events
            Properties.Settings.Default.PropertyChanged += Settings_PropertyChanged;
            Properties.Settings.Default.SettingsSaving += Settings_Saving;

            // Initialize commands
            NavigateHomeCommand = new RelayCommand.RelayCommand(p => { SelectedTodo = null; });
            CollapseMenuCommand = new RelayCommand.RelayCommand(p => { IsMenuOpen = !IsMenuOpen; });
            ToggleSearchModeCommand = new RelayCommand.RelayCommand(p => { SearchMode = !SearchMode; });
            ClearSearchStringCommand = new RelayCommand.RelayCommand(p => 
            {
                SearchString = ""; SearchMode = !SearchMode;
                SearchMode = !SearchMode;
            });
            ActivateDragCommand = new RelayCommand.RelayCommand(p => { DragHandleActive = true; });
            TogglePopupMenuCommand = new RelayCommand.RelayCommand(p => { IsPopupMenuOpen = !IsPopupMenuOpen; });
            ClosePopupMenuCommand = new RelayCommand.RelayCommand(p => { IsPopupMenuOpen = false; });
            CloseMessageBoxCommand = new RelayCommand.RelayCommand(p => { SetMessage(); });
            ToggleAccentsMenuCommand = new RelayCommand.RelayCommand(p => { IsAccentsMenuOpen = !IsAccentsMenuOpen; });
            InvertThemeCommand = new RelayCommand.RelayCommand(p => 
            {
                DarkThemeEnabled = !DarkThemeEnabled;
                SetMessage(DarkThemeEnabled ? "Dark theme enabled." : "Light theme enabled.");
            });
            SetAccentCommand = new RelayCommand.RelayCommand(p => {
                _themeManager.SetAccent((string)p);
                SettingsManager.WriteToSetting(SettingsManager.Setting.Accent.ToString(), p);
                SettingsManager.SaveAllSettings(); SetMessage("Accent applied.");
            });
            AddNewTodoCommand = new RelayCommand.RelayCommand(async p => 
            {
                await AddTodo(NewTodoName);
                SetMessage("List added.");
            }, p => !string.IsNullOrEmpty(NewTodoName));
            AddRandomTodoCommand = new RelayCommand.RelayCommand(async p => { await AddRandomTodo(); SetMessage("To-do added."); });
            DeleteTodoCommand = new RelayCommand.RelayCommand(async p => { await DeleteTodo(SelectedTodo); });
            UndeleteTodoCommand = new RelayCommand.RelayCommand(async p => { await UndeleteTodo(); });
            SaveSettingsCommand = new RelayCommand.RelayCommand(p => { SaveSettings(); }, p => SettingsTouched);
            ReloadSettingsCommand = new RelayCommand.RelayCommand(p => { ReloadSettings(); });
            ChangeAppImageCommand = new RelayCommand.RelayCommand(p => 
            {
                SettingsManager.WriteToSetting(SettingsManager.Setting.AppImage.ToString(), (string)p);
            });

            // Set welcome message
            SetMessage(SettingsManager.LoadSetting(SettingsManager.Setting.WelcomeMessage.ToString()).ToString());                        
        }