Exemple #1
0
        public bool AddClip(Clipboard.Clip clip)
        {
            // Check if a clip with the same content exists in the last clips.
            var equalClips = Clips.Take(10).Where(vm => vm.Clip.Content == clip.Content);

            if (equalClips.Count() > 0)
            {
                // If a clip with the same content already exists, just update the creation time.
                // TODO: Possibly refresh list view to push clip to top.
                equalClips.First().Clip.Created = DateTime.Now;
                return false;
            }

            var viewModel = new ClipViewModel(clip);

            viewModel.PropertyChanged += OnClipViewModelPropChanged;

            if (Clips.Count >= ClipLimit && ClipLimit > 0)
            {
                // If the limit is reached, throw out the oldest one.
                // Make sure it is not pinned.
                var first = Clips.Where((c) => !c.Pinned).First();
                Clips.Remove(first);
            }

            Clips.Add(viewModel);

            return true;
        }
Exemple #2
0
 private void OnTargetsSelectionChanged()
 {
     foreach (var target in Current.AllTargets)
     {
         foreach (var clip in Clips.Where(c => c != Current))
         {
             var t = clip.AllTargets.FirstOrDefault(x => x.TargetsSameAs(target));
             if (t == null)
             {
                 continue;
             }
             t.selected = target.selected;
         }
     }
 }
Exemple #3
0
        private void DetermineNextAnimation(float time)
        {
            _nextAnimation     = null;
            _nextAnimationTime = 0;

            if (Current.NextAnimationName == null)
            {
                return;
            }
            if (Clips.Count == 1)
            {
                return;
            }

            if (Current.NextAnimationTime > 0 + float.Epsilon)
            {
                _nextAnimationTime = (time + Current.NextAnimationTime).Snap();
            }
            else
            {
                return;
            }

            if (Current.NextAnimationName == RandomizeAnimationName)
            {
                var idx = Random.Range(0, Clips.Count - 1);
                if (idx >= Clips.IndexOf(Current))
                {
                    idx += 1;
                }
                _nextAnimation = Clips[idx].AnimationName;
            }
            else if (Current.NextAnimationName.EndsWith(RandomizeGroupSuffix))
            {
                var prefix = Current.NextAnimationName.Substring(0, Current.NextAnimationName.Length - RandomizeGroupSuffix.Length);
                var group  = Clips
                             .Where(c => c.AnimationName != Current.AnimationName)
                             .Where(c => c.AnimationName.StartsWith(prefix))
                             .ToList();
                var idx = Random.Range(0, group.Count);
                _nextAnimation = group[idx].AnimationName;
            }
            else
            {
                _nextAnimation = Current.NextAnimationName;
            }
        }