コード例 #1
0
        public RepositoryOutlinerVm(RepositoryVm repos)
            : base(string.Empty, RepositoryOutlinerItemType.Root, null, repos, null)
        {
            Debug.Assert(repos != null);
            _repos = repos;

            SelectedItem = new ReactiveProperty<RepositoryOutlinerItemVm>()
                .AddTo(MultipleDisposable);

            // 各項目のルートノードを配置する
            _localBranch =
                new RepositoryOutlinerItemVm("Local", RepositoryOutlinerItemType.LocalBranchRoot, null, repos, this)
                    .AddTo(MultipleDisposable);

            _remoteBranch =
                new RepositoryOutlinerItemVm("Remote", RepositoryOutlinerItemType.RemoteBranchRoot, null, repos, this)
                    .AddTo(MultipleDisposable);

            Children.AddOnScheduler(_localBranch);
            Children.AddOnScheduler(_remoteBranch);

            UpdateBranchNodes(_localBranch, repos.LocalBranches, false);
            UpdateBranchNodes(_remoteBranch, repos.RemoteBranches, true);

            repos.LocalBranches.CollectionChangedAsObservable()
                .Subscribe(_ => UpdateBranchNodes(_localBranch, repos.LocalBranches, false))
                .AddTo(MultipleDisposable);

            repos.RemoteBranches.CollectionChangedAsObservable()
                .Subscribe(_ => UpdateBranchNodes(_remoteBranch, repos.RemoteBranches, true))
                .AddTo(MultipleDisposable);

            SwitchBranchCommand = new ReactiveCommand().AddTo(MultipleDisposable);
            SwitchBranchCommand.Subscribe(_ => SwitchBranch()).AddTo(MultipleDisposable);
        }
コード例 #2
0
ファイル: BranchVm.cs プロジェクト: YoshihiroIto/Anne
        public BranchVm(RepositoryVm repos, Model.Git.Branch model)
        {
            Debug.Assert(repos != null);
            Debug.Assert(model != null);

            Name = model
                .ObserveProperty(x => x.Name)
                .ToReadOnlyReactiveProperty()
                .AddTo(MultipleDisposable);

            LocalName = model
                .ObserveProperty(x => x.LocalName)
                .ToReadOnlyReactiveProperty()
                .AddTo(MultipleDisposable);

            RemoteName = model
                .ObserveProperty(x => x.RemoteName)
                .ToReadOnlyReactiveProperty()
                .AddTo(MultipleDisposable);

            CanonicalName = model
                .ObserveProperty(x => x.CanonicalName)
                .ToReadOnlyReactiveProperty()
                .AddTo(MultipleDisposable);

            IsRemote = model
                .ObserveProperty(x => x.IsRemote)
                .ToReadOnlyReactiveProperty()
                .AddTo(MultipleDisposable);

            IsCurrent = model
                .ObserveProperty(x => x.IsCurrent)
                .ToReadOnlyReactiveProperty()
                .AddTo(MultipleDisposable);
        }
コード例 #3
0
ファイル: DoneCommitVm.cs プロジェクト: YoshihiroIto/Anne
        public DoneCommitVm(RepositoryVm repos, Model.Git.Commit model, TwoPaneLayoutVm twoPaneLayout)
        {
            Debug.Assert(model != null);
            _repos = repos;
            _model = model;

            TwoPaneLayout = twoPaneLayout ?? new TwoPaneLayoutVm().AddTo(MultipleDisposable);

            MultipleDisposable.AddFirst(() =>
            {
                lock (_isDownloadingLockObj)
                {
                    if (_isDownloading)
                        _disposeResetEvent = new ManualResetEventSlim();
                }
            });
        }
コード例 #4
0
        public RepositoryOutlinerItemVm(string caption, RepositoryOutlinerItemType type, BranchVm branch, RepositoryVm repos, RepositoryOutlinerVm parent)
        {
            Debug.Assert(repos != null);

            _parent = parent;

            Type = type;
            Branch = branch;

            if (Branch != null)
            {
                IsCurrent = branch.IsCurrent
                    .ToReactiveProperty()
                    .AddTo(MultipleDisposable);
            }
            else
            {
                IsCurrent = new ReactiveProperty<bool>(false)
                    .AddTo(MultipleDisposable);
            }

            Caption.AddTo(MultipleDisposable);
            Caption.Value = caption;

            IsExpanded.AddTo(MultipleDisposable);
            IsExpanded.Value =
                type == RepositoryOutlinerItemType.LocalBranchRoot ||
                type == RepositoryOutlinerItemType.RemoteBranchRoot;

            Children.AddTo(MultipleDisposable);

            MultipleDisposable.Add(() => Children.ForEach(x => x.Dispose()));

            RemoveSelectedBranchesCommand = new ReactiveCommand().AddTo(MultipleDisposable);
            RemoveSelectedBranchesCommand.Subscribe(_ => _parent.RemoveSelectedBranches()).AddTo(MultipleDisposable);
        }
コード例 #5
0
ファイル: WipCommitVm.cs プロジェクト: YoshihiroIto/Anne
        public WipCommitVm(RepositoryVm repos, TwoPaneLayoutVm twoPaneLayout)
        {
            Debug.Assert(repos != null);
            _repos = repos;

            TwoPaneLayout = twoPaneLayout ?? new TwoPaneLayoutVm().AddTo(MultipleDisposable);

            SelectedWipFiles = new ObservableCollection<WipFileVm>();
            SelectedWipFiles.CollectionChangedAsObservable()
                .Subscribe(_ =>
                {
                    var count = SelectedWipFiles.Count;

                    if (count == 0)
                        DiffFileViewSource = WipFiles.Value.FirstOrDefault();
                    else if (count == 1)
                        DiffFileViewSource = SelectedWipFiles.FirstOrDefault();
                    else
                        DiffFileViewSource = SelectedWipFiles;
                })
                .AddTo(MultipleDisposable);

            SummaryRemaining =
                this.ObserveProperty(x => x.Summary)
                    .Select(x => 80 - x.Length)
                    .ToReadOnlyReactiveProperty()
                    .AddTo(MultipleDisposable);

            SummaryRemainingBrush = SummaryRemaining
                .Select(x =>
                {
                    if (x < 0)
                        return Brushes.Red;
                    if (x < 20)
                        return Brushes.DarkRed;
                    return Brushes.Gray;
                })
                .ToReadOnlyReactiveProperty()
                .AddTo(MultipleDisposable);

            CommitCommand =
                this.ObserveProperty(x => x.Summary)
                    .Select(x => string.IsNullOrWhiteSpace(x) == false)
                    .ToReactiveCommand()
                    .AddTo(MultipleDisposable);

            CommitCommand.Subscribe(_ => repos.Commit((Summary + "\n\n" + Description).Trim()))
                .AddTo(MultipleDisposable);

            DiscardChangesCommand = SelectedWipFiles.CollectionChangedAsObservable()
                .Select(x => SelectedWipFiles.Any())
                .ToReactiveCommand()
                .AddTo(MultipleDisposable);

            DiscardChangesCommand.Subscribe(_ =>
                repos.DiscardChanges(SelectedWipFiles.Select(x => x.Path.Value))
                ).AddTo(MultipleDisposable);

            // IsAllSelected 関係
            {
                IsAllSelected = new ReactiveProperty<bool?>().AddTo(MultipleDisposable);
                IsAllSelected.Subscribe(i =>
                {
                    // UI からの操作では on/off のどちらかに設定する
                    if (_isInUpdateIsAllSelected == false)
                    {
                        if (i.HasValue == false)
                        {
                            IsAllSelected.Value = false;
                            return;
                        }
                    }

                    if (i.HasValue == false)
                        return;

                    WipFiles.Value.ForEach(x => x.IsInStaging.Value = i.Value);
                }).AddTo(MultipleDisposable);

                this.ObserveProperty(x => x.WipFiles)
                    .Subscribe(x =>
                    {
                        _isInStageingDisposer?.Dispose();
                        _isInStageingDisposer = new MultipleDisposable();

                        x.Value.ForEach(y =>
                            y.IsInStaging.Subscribe(_ => UpdateIsAllSelected()).AddTo(_isInStageingDisposer));
                    })
                    .AddTo(MultipleDisposable);

                MultipleDisposable.Add(() => _isInStageingDisposer?.Dispose());
            }
        }