Exemplo n.º 1
0
        /// <summary>
        /// 切换预览图操作
        /// </summary>
        /// <param name="id">预览ID</param>
        private void SwitchPreview(int id)
        {
            if (selectedId != id)
            {
                if (selectedId != 0 && imgs.ContainsKey(selectedId))
                {
                    (btns.Children[imgs[selectedId]] as ToggleButton).IsChecked = false;

                    //(imgGrid.Children[imgs[selectedId]] as Image).Opacity = 0;
                    //(imgGrid.Children[imgs[selectedId]] as Image).BeginStoryboard(FindResource("imgClose") as Storyboard);
                    ScrollViewer tempPreview             = (imgGrid.Children[imgs[selectedId]] as ScrollViewer);
                    Storyboard   sb                      = new Storyboard();
                    DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames();
                    Storyboard.SetTargetProperty(frames, new PropertyPath(UIElement.OpacityProperty));
                    frames.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(80))));
                    sb.Children.Add(frames);
                    sb.Completed += new EventHandler(delegate(object s, EventArgs ea) { tempPreview.Visibility = Visibility.Hidden; });
                    sb.Begin(tempPreview);
                }
                selectedId = id;
                (btns.Children[imgs[selectedId]] as ToggleButton).IsChecked = true;
                ScrollViewer tempPreview1 = (imgGrid.Children[imgs[selectedId]] as ScrollViewer);
                tempPreview1.Visibility = Visibility.Visible;
                tempPreview1.BeginStoryboard(FindResource("imgShow") as Storyboard);
                ChangePreBtnText();

                ///////////////////////////////////////////////
                ////////////////////////////////////////////

                desc.Text = "";
                if (descs[selectedId].OriginalUrl == descs[selectedId].SampleUrl)
                {
                    desc.Inlines.Add("原图与预览图相同");
                    desc.Inlines.Add(new LineBreak());
                }
                desc.Inlines.Add("描述: " + descs[selectedId].Id + " " + descs[selectedId].Desc);
                desc.Inlines.Add(new LineBreak());
                desc.Inlines.Add("作者: " + descs[selectedId].Author);
                desc.Inlines.Add(new LineBreak());
                try
                {
                    string fileType = descs[selectedId].OriginalUrl.Substring(descs[selectedId].OriginalUrl.LastIndexOf('.') + 1);
                    desc.Inlines.Add("类型: " + BooruProcessor.FormattedImgUrl("", fileType.ToUpper()));
                }
                catch { }
                desc.Inlines.Add(" 大小: " + descs[selectedId].FileSize);
                desc.Inlines.Add(" 尺寸: " + descs[selectedId].Dimension);
                //desc.Inlines.Add(new LineBreak());
                desc.Inlines.Add(" 评分: " + descs[selectedId].Score);
                desc.Inlines.Add(new LineBreak());
                desc.Inlines.Add("时间: " + descs[selectedId].Date);
                if (descs[selectedId].Source.Length > 0)
                {
                    desc.Inlines.Add(new LineBreak());
                    desc.Inlines.Add("来源: " + descs[selectedId].Source);
                }
            }
        }