Inheritance: Livet.ViewModel
Beispiel #1
0
        public void InitializeToolTip(object sender, RoutedEventArgs e)
        {
            var link = sender as Hyperlink;

            //すでにツールチップがあったらスキップ
            if(link.ToolTip != null) {

                return;
            }

            var inline = link.Inlines.First() as Run;
            if(inline != null) {

                var uri = link.NavigateUri;
                //#○○:×× リンクだとnullになるので
                if(uri == null) {

                    var time = inline.Text;

                    if(time.StartsWith("#")) {

                        link.NavigateUri = new Uri(time, UriKind.Relative);
                    }

                    return;
                }
                var text = uri.OriginalString;

                if(text.StartsWith("http://www.nicovideo.jp/watch/")) {

                    VideoToolTip tooltip = new VideoToolTip();
                    VideoDataViewModel vm = new VideoDataViewModel(text.Substring(30));
                    tooltip.DataContext = vm;
                    link.ToolTip = tooltip;

                } else if(text.StartsWith("http://www.nicovideo.jp/user/")) {

                    UserToolTip tooltip = new UserToolTip();
                    UserDataViewModel vm = new UserDataViewModel(text.Substring(29));
                    tooltip.DataContext = vm;
                    link.ToolTip = tooltip;

                } else if(text.StartsWith("http://www.nicovideo.jp/mylist/")) {

                    MylistToolTip tooltip = new MylistToolTip();
                    MylistDataViewModel vm = new MylistDataViewModel(text.Substring(31));
                    tooltip.DataContext = vm;
                    link.ToolTip = tooltip;

                } else {

                    link.ToolTip = text;
                }
            }
        }
        public void ShowInfomation()
        {
            if (ToolTip != null || Entry.VideoUrl == null)
            {
                return;
            }

            NicoRepoType = NicoNicoOpener.GetType(Entry.VideoUrl);

            if (NicoRepoType == NicoNicoUrlType.Video)
            {
                ToolTip           = new VideoDataViewModel(Entry.VideoUrl.Substring(30));
                ToolTipVisibility = Visibility.Visible;
            }
        }
        public void ShowInfomation()
        {
            if(ToolTip != null || Entry.VideoUrl == null) {

                return;
            }

            NicoRepoType = NicoNicoOpener.GetType(Entry.VideoUrl);

            if(NicoRepoType == NicoNicoUrlType.Video) {

                ToolTip = new VideoDataViewModel(Entry.VideoUrl.Substring(30));
                ToolTipVisibility = Visibility.Visible;
            }
        }