Ejemplo n.º 1
0
                public override void CanClose(Action <bool> callback)
                {
                    CloseStrategy.Execute(items.ToList(), (canClose, closable) =>
                    {
                        if (!canClose && closable.Any())
                        {
                            if (closable.Contains(ActiveItem))
                            {
                                var list = items.ToList();
                                var next = ActiveItem;
                                do
                                {
                                    var previous = next;
                                    next         = DetermineNextItemToActivate(list, list.IndexOf(previous));
                                    list.Remove(previous);
                                } while (closable.Contains(next));

                                var previousActive = ActiveItem;
                                ChangeActiveItem(next, true);
                                items.Remove(previousActive);

                                var stillToClose = closable.ToList();
                                stillToClose.Remove(previousActive);
                                closable = stillToClose;
                            }

                            EnumerableExtensions.Apply(closable.OfType <IDeactivate>(), x => x.Deactivate(true));
                            items.RemoveRange(closable);
                        }

                        callback(canClose);
                    });
                }
Ejemplo n.º 2
0
                public OneActive()
                {
                    items.CollectionChanged += (s, e) =>
                    {
                        switch (e.Action)
                        {
                        case NotifyCollectionChangedAction.Add:
                            EnumerableExtensions.Apply(e.NewItems.OfType <IChild>(), x => x.Parent = this);
                            break;

                        case NotifyCollectionChangedAction.Remove:
                            EnumerableExtensions.Apply(e.OldItems.OfType <IChild>(), x => x.Parent = null);
                            break;

                        case NotifyCollectionChangedAction.Replace:
                            EnumerableExtensions.Apply(e.NewItems.OfType <IChild>(), x => x.Parent = this);
                            EnumerableExtensions.Apply(e.OldItems.OfType <IChild>(), x => x.Parent = null);
                            break;

                        case NotifyCollectionChangedAction.Reset:
                            EnumerableExtensions.Apply(items.OfType <IChild>(), x => x.Parent = this);
                            break;
                        }
                    };
                }
Ejemplo n.º 3
0
 protected override void OnDeactivate(bool close)
 {
     if (close)
     {
         EnumerableExtensions.Apply(items.OfType <IDeactivate>(), x => x.Deactivate(true));
         items.Clear();
     }
     else
     {
         ScreenExtensions.TryDeactivate(ActiveItem, false);
     }
 }
Ejemplo n.º 4
0
        public static GitStashInfo GetStashDetails(GitStash stash)
        {
            GitStashInfo res  = null;
            var          cmd  = "git";
            var          args = $"-C \"{stash.GitDirectory}\" stash show {stash.Id}";

            ScriptHelper.ExecuteScript(cmd, args, ScriptExecutionSettings.OneOutputStream, s =>
            {
                res = GitStashInfo.ParseFromCmdResult(s, stash.GitDirectory);
                EnumerableExtensions.Apply(res.Changes, change => change.Image = FileHelper.GetFileIconForExtensionOrFilename(Path.GetExtension(change.FileName)).ToBitmap().ToImageSource());
                res.Stash = stash;
            });
            return(res);
        }