예제 #1
0
        public TrayWindowViewModel(TaskbarIcon taskbarIcon)
        {
            _taskbarIcon = taskbarIcon;

            ExitCommand = new ExitCommand();
            ShowCommand = new ShowAllCommand();
            HideCommand = new HideAllCommand();
            AddRepoCommand = new AddRepositoryCommand();

            ShowAboutCommand = new ShowSingleViewCommand(typeof(AboutView));

            LeftClickCommand = new ToggleShowHideCommand();
            DoubleClickCommand = LeftClickCommand;

            ShowSettingsCommand = new ShowSingleViewCommand(typeof(SettingsView));
#if DEBUG
            ShowSettingsVisiblilty = "Visible";
#else
            ShowSettingsVisiblilty = "Collapsed";
#endif

            ShowUpdateCommand = new ShowSingleViewCommand(typeof(UpdateView));
            CheckUpdateCommand = ShowUpdateCommand;

            HotkeyHelper.OnHotkeyChanged += (sender, args) => OnPropertyChanged("ShowHideHeader");
            // todo: currently the only balloon is for update, so no distinction about what to do.
            _taskbarIcon.TrayBalloonTipClicked += (sender, args) => ShowUpdateCommand.Execute(null);
            UpdateManager.OnUpdateRequired += UpdateManager_OnUpdateRequired;
            UpdateManager.OnUpdateInfoChanged += delegate(object sender, EventArgs args)
            {
                OnPropertyChanged("CheckUpdateHeader");
                OnPropertyChanged("ToolTipText");
            };

        }
예제 #2
0
        // TODO: add refresh command

        public BubbleViewModel(Repository repo)
            : base(repo)
        {


            ClickCommand = new RelayCommand(ShowHideMenu);
            DblClkCommand = new OpenFolderCommand();
            DblClkCommandParam = repo.Info.WorkingDirectory;
            RefreshCommand = new RelayCommand(Refresh);

            // try compacting path
            string shortPath = repo.Info.WorkingDirectory;
            try
            {
                if (Settings.Default.MenuPathLength > 0)
                    shortPath = PathHelper.ShortDisplay(repo.Info.WorkingDirectory, Settings.Default.MenuPathLength);
            }
            catch (Exception ex)
            {
                ErrorHandler.Handle(ex, false);
                shortPath += " (*)";
            }

            FolderOpenMenuHeader = string.Format("Open {0}", shortPath);
            OpenFolderCommand = new OpenFolderCommand();
            OpenFolderCommandParameter = repo.Info.WorkingDirectory;

            HideAllCommand = new RelayCommand(() => BubblesManager.ShowAll(false), () => { return RepositoriesManager.Repos.Count() > 0; });
            ShowAllCommand = new RelayCommand(() => BubblesManager.ShowAll(true), () => { return RepositoriesManager.Repos.Count() > 0; });
            ExitCommand = new ExitCommand();

            ShowHideMenuCommand = new RelayCommand(ShowHideMenu);

            CurrentBranch = repo.Head.Name;
            var repoTracker = new RepoTracker(repo);
            repoTracker.OnLockFileCreated += (s, e) => { LockExists = true; };
            repoTracker.OnLockFileDeleted += (s, e) => { LockExists = false; };
            repoTracker.OnBranchChanged += (s, e) => { Refresh(); };
            //_repoTracker.OnStatusChanged += repoTracker_OnStatusChanged;

            CommandsListViewModel = new CommandsListViewModel(repo);

            _cmdModel = new CommandsListModel(repo);
            CommandsList = _cmdModel.GetCommandsList;

            ConfigurationHelper.Configuration.Settings.VisualSettings.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "BubbleOpacity")
                    OnPropertyChanged("BubbleOpacity");
            };

        }