/// <summary> /// method for reacting on users click upon treeview-Node and displaying / loading lists accordingly /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TreeView_FeedGroupAfterSelect(object sender, TreeViewEventArgs e) { lVFeedItems.Items.Clear(); if (tVMain.SelectedNode != null) { object tagObj = tVMain.SelectedNode.Tag; if (tagObj != null) { if (tagObj.GetType() == typeof(Feed)) { Feed selFeed = (Feed)tagObj; ShowFeedList(selFeed); } if (tagObj.GetType() == typeof(FeedGroup)) { FeedGroup selGroup = (FeedGroup)tagObj; List <FeedItem> items = controller.GetUnreadFeedItems(selGroup); UpdateListView(items); } } } }
public MainForm() { InitializeComponent(); IntializeColumns(); PopulateComboboxes(); _FeedGroup = new FeedGroup(); _CategoryGroup = new CategoryGroup(); LoadAllFeeds(); LoadAllCategories(); }
internal void RemoveFeedSrouce(FeedItemSourceListItem feedSourceListItem) { var feedSource = feedSourceListItem.FeedSource; FeedGroup.RemoveUserFeedSource(feedSource); switch (feedSource.FollowItemType) { case FollowItemType.Tag: if (TagFeedSources.Remove(feedSourceListItem)) { var favInfo = HohoemaApp.FollowManager.Tag.FollowInfoItems.SingleOrDefault(x => x.Id == feedSource.Id); if (favInfo != null) { TagFavItems.Add(favInfo); } } break; case FollowItemType.Mylist: if (MylistFeedSources.Remove(feedSourceListItem)) { var favInfo = HohoemaApp.FollowManager.Mylist.FollowInfoItems.SingleOrDefault(x => x.Id == feedSource.Id); if (favInfo != null) { MylistFavItems.Add(favInfo); } } break; case FollowItemType.User: if (UserFeedSources.Remove(feedSourceListItem)) { var favInfo = HohoemaApp.FollowManager.User.FollowInfoItems.SingleOrDefault(x => x.Id == feedSource.Id); if (favInfo != null) { UserFavItems.Add(favInfo); } } break; default: break; } }
private void openAllUnreadToolStripMenuItem1_Click(object sender, EventArgs e) { if (tVMain.SelectedNode != null) { object ob = tVMain.SelectedNode.Tag; if (ob != null) { if (ob.GetType() == typeof(FeedGroup)) { FeedGroup subGroup = (FeedGroup)ob; controller.OpenUnreadFeeds(subGroup); } if (ob.GetType() == typeof(Feed)) { Feed selFeed = (Feed)ob; controller.OpenUnreadFeeds(selFeed); } } } }
public FeedGroupPageViewModel(HohoemaApp hohoemaApp, PageManager pageManager, Views.Service.ContentSelectDialogService contentSelectDialogService) : base(hohoemaApp, pageManager) { ContentSelectDialogService = contentSelectDialogService; IsDeleted = new ReactiveProperty <bool>(); FeedGroupName = new ReactiveProperty <string>(); MylistFeedSources = new ObservableCollection <FeedItemSourceListItem>(); TagFeedSources = new ObservableCollection <FeedItemSourceListItem>(); UserFeedSources = new ObservableCollection <FeedItemSourceListItem>(); HasMylistFeedSource = MylistFeedSources.ObserveProperty(x => x.Count) .Select(x => x > 0) .ToReadOnlyReactiveProperty(); HasTagFeedSource = TagFeedSources.ObserveProperty(x => x.Count) .Select(x => x > 0) .ToReadOnlyReactiveProperty(); HasUserFeedSource = UserFeedSources.ObserveProperty(x => x.Count) .Select(x => x > 0) .ToReadOnlyReactiveProperty(); MylistFavItems = new ObservableCollection <FollowItemInfo>(); TagFavItems = new ObservableCollection <FollowItemInfo>(); UserFavItems = new ObservableCollection <FollowItemInfo>(); SelectFromFavItems = new ReactiveProperty <bool>(true); SelectedFavInfo = new ReactiveProperty <FollowItemInfo>(); FavItemType = new ReactiveProperty <FollowItemType>(); FeedSourceId = new ReactiveProperty <string>(); FeedSourceItemName = new ReactiveProperty <string>(); ExistFeedSource = new ReactiveProperty <bool>(); IsPublicFeedSource = new ReactiveProperty <bool>(); CanUseFeedSource = Observable.CombineLatest( ExistFeedSource, IsPublicFeedSource ) .Select(x => x.All(y => y)) .ToReactiveProperty(); FavItemType.Subscribe(x => { FeedSourceId.Value = ""; ExistFeedSource.Value = false; FeedSourceItemName.Value = ""; // お気に入りアイテムがある場合は、「お気に入りから選択」をデフォルトに switch (x) { case FollowItemType.Tag: SelectFromFavItems.Value = TagFavItems.Count > 0; break; case FollowItemType.Mylist: SelectFromFavItems.Value = MylistFavItems.Count > 0; break; case FollowItemType.User: SelectFromFavItems.Value = UserFavItems.Count > 0; break; default: break; } }); FeedSourceId.ToUnit() .Subscribe(_ => { ExistFeedSource.Value = false; FeedSourceItemName.Value = ""; }); Observable.Merge( SelectFromFavItems.ToUnit(), SelectedFavInfo.ToUnit(), FavItemType.ToUnit(), FeedSourceId.ToUnit().Throttle(TimeSpan.FromSeconds(1)) ) .Subscribe(async x => { if (SelectFromFavItems.Value) { ExistFeedSource.Value = SelectedFavInfo.Value != null; IsPublicFeedSource.Value = true; FeedSourceItemName.Value = ""; return; } ExistFeedSource.Value = false; if (FavItemType.Value == FollowItemType.Tag) { ExistFeedSource.Value = !string.IsNullOrWhiteSpace(FeedSourceId.Value); IsPublicFeedSource.Value = true; FeedSourceItemName.Value = FeedSourceId.Value; } else { if (string.IsNullOrWhiteSpace(FeedSourceId.Value)) { ExistFeedSource.Value = false; } else { if (FavItemType.Value == FollowItemType.Mylist) { try { var mylistRes = await HohoemaApp.ContentFinder.GetMylistGroupDetail(FeedSourceId.Value); var mylist = mylistRes?.MylistGroup; if (mylist != null) { ExistFeedSource.Value = true; IsPublicFeedSource.Value = mylist.IsPublic; FeedSourceItemName.Value = Mntone.Nico2.StringExtention.DecodeUTF8(mylist.Name); } } catch { ExistFeedSource.Value = false; } } else if (FavItemType.Value == FollowItemType.User) { try { var user = await HohoemaApp.ContentFinder.GetUserDetail(FeedSourceId.Value); if (user != null) { ExistFeedSource.Value = true; IsPublicFeedSource.Value = !user.IsOwnerVideoPrivate; FeedSourceItemName.Value = user.Nickname; } } catch { ExistFeedSource.Value = false; } } if (!ExistFeedSource.Value) { IsPublicFeedSource.Value = false; FeedSourceItemName.Value = ""; } } } }); AddFeedCommand = Observable.CombineLatest( ExistFeedSource, IsPublicFeedSource ) .Select(x => x.All(y => y == true)) .ToReactiveCommand(); AddFeedCommand.Subscribe(_ => { string name = ""; string id = ""; if (SelectFromFavItems.Value) { var favInfo = SelectedFavInfo.Value; name = favInfo.Name; id = favInfo.Id; if (favInfo.FollowItemType != FavItemType.Value) { throw new Exception(); } } else { // idからMylistGroupを引く // 公開されていない場合にはエラー id = FeedSourceId.Value; name = FeedSourceItemName.Value; FeedSourceItemName.Value = ""; FeedSourceId.Value = ""; } var favManager = HohoemaApp.FollowManager; var feedManager = HohoemaApp.FeedManager; IFeedSource feedSource; switch (FavItemType.Value) { case FollowItemType.Tag: feedSource = FeedGroup.AddTagFeedSource(id); if (feedSource != null) { var favInfo = favManager.Tag.FollowInfoItems.SingleOrDefault(x => x.Id == id); if (favInfo != null) { TagFavItems.Remove(favInfo); } TagFeedSources.Add(new FeedItemSourceListItem(feedSource, this)); } break; case FollowItemType.Mylist: feedSource = FeedGroup.AddMylistFeedSource(name, id); if (feedSource != null) { var favInfo = favManager.Mylist.FollowInfoItems.SingleOrDefault(x => x.Id == id); if (favInfo != null) { MylistFavItems.Remove(favInfo); } MylistFeedSources.Add(new FeedItemSourceListItem(feedSource, this)); } break; case FollowItemType.User: feedSource = FeedGroup.AddUserFeedSource(name, id); if (feedSource != null) { var favInfo = favManager.User.FollowInfoItems.SingleOrDefault(x => x.Id == id); if (favInfo != null) { UserFavItems.Remove(favInfo); } UserFeedSources.Add(new FeedItemSourceListItem(feedSource, this)); } break; default: break; } HohoemaApp.FeedManager.SaveOne(FeedGroup); }); RenameApplyCommand = FeedGroupName .Where(x => HohoemaApp.FeedManager != null && x != null) .Select(x => HohoemaApp.FeedManager.CanAddLabel(x)) .ToReactiveCommand(); RenameApplyCommand.Subscribe(async _ => { if (await FeedGroup.Rename(FeedGroupName.Value)) { UpdateTitle(FeedGroup.Label); } FeedGroupName.ForceNotify(); }); }
public void UpdateCompleted() { NowUpdate.Value = false; Description = FeedGroup.GetUnreadItemCount().ToString(); OptionText = FeedGroup.UpdateTime.ToString(); }
public void Build(FilteredNewsFeedForm i_Form) { this.m_FeedGroup = new FeedGroup(i_Form); }
public static FeedGroup CalcFeedGroup(Curve curve, bool isStartCurve, int sign, FeedType feedType, int radius, int angle, int length) { var feedGroup = new FeedGroup(); Vector3d vector; Point3d point = isStartCurve ? curve.StartPoint : curve.EndPoint; if (!curve.Closed || isStartCurve) { vector = curve.GetFirstDerivative(point); } else if (curve is Circle) { vector = new Vector3d(0, 1, 0); } else // расчет касательной в конце замкнутой полилинии { int param; var polyline = curve as Polyline; if (polyline != null) { param = polyline.NumberOfVertices - 1; } else { var polyline2d = curve as Polyline2d; if (polyline2d != null) { param = polyline2d.Cast <object>().Count(); } else { AutocadUtils.ShowError("Ошибка в расчете подвода-отвода"); feedGroup.Point = point; return(feedGroup); } } vector = curve.GetFirstDerivative(param); } switch (feedType) { case FeedType.None: feedGroup.Point = point; break; case FeedType.Line: vector = (isStartCurve ? -1 : 1) * vector.GetNormal() * length; feedGroup.Point = point + vector; feedGroup.Line = new Line(point, feedGroup.Point); break; case FeedType.Arc: vector = vector.GetPerpendicularVector() * sign * radius; feedGroup.Point = point + vector; vector = vector.Negate(); var angle1 = vector.GetAngleTo(Vector3d.XAxis, Vector3d.ZAxis.Negate()); var turnSign = (isStartCurve ? -1 : 1) * sign; vector = vector.RotateBy(DegreesToRadians(angle) * turnSign, Vector3d.ZAxis); feedGroup.Line = new Line(feedGroup.Point, feedGroup.Point + vector); var angle2 = feedGroup.Line.Angle; var isCrossAxis = Math.Abs(angle2 - angle1) > Pi; feedGroup.Arc = new Arc(feedGroup.Point, radius, isCrossAxis ? Math.Max(angle1, angle2) : Math.Min(angle1, angle2), isCrossAxis ? Math.Min(angle1, angle2) : Math.Max(angle1, angle2)); break; } return(feedGroup); }