public static ArcMovementItem Create(ILinkViewModel link, double targetValue)
 {
     return(new ArcMovementItem()
     {
         Link = link,
         TargetValue = targetValue
     });
 }
        public void AddLink(ILinkViewModel link)
        {
            if (link == null)
            {
                throw new ArgumentNullException("link");
            }

            links.Add(link);
        }
Exemple #3
0
 public static LinearMovementItem Create(ILinkViewModel link, double targetValue)
 {
     return(new LinearMovementItem()
     {
         Link = link,
         Value = link.Value,
         TargetValue = targetValue
     });
 }
Exemple #4
0
        public void RemoveLink(ILinkViewModel link)
        {
            if (link == null)
            {
                throw new ArgumentNullException("link");
            }

            item.RemoveLink(link);
        }
Exemple #5
0
        public async Task Initialize(ILinkViewModel link)
        {
            CurrentLink = link;
            Comments.Clear();

            IsBusy = true;
            await LoadComments();

            IsBusy = false;
        }
Exemple #6
0
        public async Task <(ILinkViewModel, IList <ICommentViewModel>)> GetComments(ILinkViewModel link)
        {
            var json = await m_httpClient.GetAsync($"/{link.PrefixedSubreddit}/comments/{link.Id}.json");

            var listings = JsonConvert.DeserializeObject <List <ListingWrapper> >(json);

            var(linkViewModel, commentViewModels) = m_thingMapper.LinkWithCommentsMapper(listings);

            return(linkViewModel, commentViewModels);
        }
Exemple #7
0
        public PlaceholderLinkModel(ILinkViewModel existing)
        {
            Href = existing.Href;

            Method = existing.Method;

            if (existing is PlaceholderLinkModel asPlaceholder)
            {
                Values = new RouteValueDictionary(asPlaceholder.Values);
            }
        }
Exemple #8
0
 public PagedCollectionFactoryModel(string endpoint, int skip, int take, string terms, long total, List <T> items, Dictionary <string, object> additionalData, string method = "GET")
 {
     _endpoint       = endpoint;
     _meta           = PlaceholderLinkModel.ToCollection(_endpoint, method, new { skip, take, terms });
     _skip           = skip;
     _take           = take;
     _terms          = terms;
     _total          = total;
     _items          = items;
     _additionalData = additionalData;
 }
        public void Add(ILinkViewModel link, double targetValue, ArcComponentData data)
        {
            IArcMovementItem md = ArcMovementItem.Create(link, targetValue);

            md.Angle            = data.Angle;
            md.StartAngle       = data.StartAngle;
            md.CenterCoordinate = data.CenterCoordinate;
            md.Radius           = data.Radius;
            md.ArcComponent     = data.Component;

            Items.Add(md);
        }
Exemple #10
0
 public static LinearLinkMovementItem Create(ILinkViewModel link, double targetValue, double duration, int notifyId = 0)
 {
     return(new LinearLinkMovementItem()
     {
         Link = link,
         Value = link.Value,
         TargetValue = targetValue,
         Duration = TimeSpan.FromSeconds(duration),
         Start = DateTime.Now,
         NotifyId = notifyId
     });
 }
Exemple #11
0
 public PagedCollectionFactoryModel(IUrlHelper urlHelper, int skip, int take, string terms, long total, List <T> items, Dictionary <string, object> additionalData, string method = "GET")
 {
     _endpoint       = urlHelper.ActionContext.HttpContext.Request.Path.Value;
     _endpoint       = urlHelper.AbsoluteContent(_endpoint);
     _meta           = PlaceholderLinkModel.ToCollection(_endpoint, method, new { skip, take, terms });
     _skip           = skip;
     _take           = take;
     _terms          = terms;
     _total          = total;
     _items          = items;
     _additionalData = additionalData;
 }
        public static ILinkViewModel GetLink(this BaseAction action, int linkId)
        {
            ILinkViewModel link = null;

            MVMIoc.SimpleIoc <IMessenger> .GetInstance().Send(new GetLinkMessage()
            {
                Id      = linkId,
                SetLink = (lnk) => link = lnk
            });

            return(link);
        }
        public void RemoveLink(ILinkViewModel link)
        {
            if (link == null)
            {
                throw new ArgumentNullException("link");
            }

            if (links.Contains(link))
            {
                links.Remove(link);
            }
        }
Exemple #14
0
        public PlaceholderLinkViewModel(ILinkViewModel existing)
        {
            Href      = existing.Href;
            Relations = existing.Relations;
            Method    = existing.Method;

            var asPlaceholder = existing as PlaceholderLinkViewModel;

            if (asPlaceholder != null)
            {
                Values = new RouteValueDictionary(asPlaceholder.Values);
            }
        }
Exemple #15
0
        private static Matrix3D GetLinkTransformation(ILinkViewModel link)
        {
            switch (link.MoveType)
            {
            case LinkMoveType.Linear:
                return(GetLinearLinkTransformation(link as ILinearLinkViewModel));

            case Data.Enums.LinkMoveType.Pneumatic:
                return(GetPenumaticLinkTransformation(link as IPneumaticLinkViewModel));

            default:
                throw new ArgumentOutOfRangeException();
            }
            throw new NotImplementedException();
        }
        public static LinkType GetLinkTypeImplementation(ILinkViewModel link)
        {
            if (link == null)
            {
                throw new ArgumentNullException();
            }

            if (link is LinearPositionViewModel linPosVM)
            {
                return(LinkType.LinearPosition);
            }
            else if (link is LinearPneumaticViewModel linPnmVM)
            {
                return(LinkType.LinearPneumatic);
            }
            else if (link is RotaryPneumaticViewModel rotPnmVM)
            {
                return(LinkType.RotaryPneumatic);
            }
            else
            {
                throw new NotImplementedException();
            }
        }
        public static Link Convert(this ILinkViewModel link)
        {
            if (link == null)
            {
                return(null);
            }

            if (link is LinearPositionViewModel linPosVM)
            {
                return(UpdateModel(new LinearPosition(), linPosVM));
            }
            else if (link is LinearPneumaticViewModel linPnmVM)
            {
                return(UpdateModel(new LinearPneumatic(), linPnmVM));
            }
            else if (link is RotaryPneumaticViewModel rotPnmVM)
            {
                return(UpdateModel(new RotaryPneumatic(), rotPnmVM));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Exemple #18
0
 public PagedCollectionFactoryViewModel(ILinkViewModel meta, string hrefPattern)
 {
     _meta        = meta;
     _hrefPattern = hrefPattern;
 }
		public static ObservableCollection<ILinkViewModel> MakeFilteredContentStream(ObservableCollection<ILinkViewModel> raw, ILinkViewModel hasImmunity)
		{
			var filterFunc = new Func<ILinkViewModel, bool>((link) =>
			{
				if (link == hasImmunity)
					return true;
				else if (SnooStreamViewModel.Settings.OnlyFlipViewUnread && SnooStreamViewModel.OfflineService.HasHistory(link.Url))
					return false;
				else if (link.Content is InternalRedditViewModel)
					return false;
				else if (SnooStreamViewModel.Settings.OnlyFlipViewImages)
				{
					if (link.Content is PlainWebViewModel || link.Content is SelfViewModel)
						return false;
				}

				return true;
			});

            var filteredList = raw.Where(filterFunc).ToList();
            var selectedIndex = filteredList.IndexOf(hasImmunity);
            ObservableCollection<ILinkViewModel> filteredCollection = new ObservableCollection<ILinkViewModel>(filteredList.Skip(selectedIndex));
            if(selectedIndex > 0)
            {
                var rawBefore = filteredList.Take(selectedIndex);
                DelayContentStreamAddition(rawBefore, filteredCollection);
            }

			raw.CollectionChanged += (s, e) =>
				{
					switch (e.Action)
					{
						case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                            if (filterFunc(e.NewItems[0] as ILinkViewModel))
							    filteredCollection.Add(e.NewItems[0] as ILinkViewModel);
							break;
						case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                            if (filteredCollection.Contains(e.OldItems[0] as ILinkViewModel) &&
                                filteredCollection.Contains(e.NewItems[0] as ILinkViewModel))
                            {
                                filteredCollection.Move(filteredCollection.IndexOf(e.OldItems[0] as ILinkViewModel),
                                    filteredCollection.IndexOf(e.NewItems[0] as ILinkViewModel));
                            }
							break;
						case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                            if (filteredCollection.Contains(e.OldItems[0] as ILinkViewModel))
                            {
                                filteredCollection.Remove(e.OldItems[0] as ILinkViewModel);
                            }
							break;
						case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                            if (filterFunc(e.NewItems[0] as ILinkViewModel))
                            {
                                filteredCollection[filteredCollection.IndexOf(e.OldItems[0] as ILinkViewModel)] = e.NewItems[0] as ILinkViewModel;
                            }
                            else if (filteredCollection.Contains(e.OldItems[0] as ILinkViewModel))
                            {
                                filteredCollection.Remove(e.OldItems[0] as ILinkViewModel);
                            }
							break;
						case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
							filteredCollection.Clear();
							break;
						default:
							break;
					}
				};
			return filteredCollection;
		}
        public void AddLink(ILinkViewModel link)
        {
            if (link == null)
                throw new ArgumentNullException("link");

            links.Add(link);
        }
 public void Add(ILinkViewModel link, double targetValue) => Items.Add(LinearMovementItem.Create(link, targetValue));
 public static LinkType GetLinkType(this ILinkViewModel link) => GetLinkTypeImplementation(link);
        public void RemoveLink(ILinkViewModel link)
        {
            if (link == null)
                throw new ArgumentNullException("link");

            if (links.Contains(link))
                links.Remove(link);
        }