Ejemplo n.º 1
0
 public WebVideoDetail(WebVideo webVideo, Video video, string videotype)
 {
     this.webVideo  = webVideo;
     this.video     = video;
     this.videotype = videotype;
     SetStyle(
         ControlStyles.UserPaint |
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.OptimizedDoubleBuffer |
         ControlStyles.ResizeRedraw |
         ControlStyles.Selectable | ControlStyles.DoubleBuffer, true);
     //强制分配样式重新应用到控件上
     UpdateStyles();
     InitializeComponent();
     btn_close.Image = FontAwesome.GetImage("4FA4", 30, Color.Black);
     if (video.videoImg != null)
     {
         Rectangle Rect   = new Rectangle(0, 0, video.videoImg.Width, video.videoImg.Height);
         Bitmap    bitmap = new Bitmap(video.videoImg);
         using (Graphics gTop = Graphics.FromImage(bitmap))
         {
             gTop.FillRectangle(new SolidBrush(Color.FromArgb(200, 255, 255, 255)), Rect);
         }
         bitmap.GaussianBlur(ref Rect, 80, false);
         this.BackgroundImage = bitmap;
     }
     pictureBox1.Image = video.videoImg;
     label1.Text       = video.videoName;
     label3.Text       = video.videoQuality;
     foreach (VideoInfo item in video.videoTotalInfo)
     {
         Label label = new Label
         {
             BackColor = Color.Transparent,
             Text      = item.key + ":" + item.value + "    ",
             AutoSize  = true
         };
         panel1.Controls.Add(label);
         label.MouseDown += Frn_Move;
     }
     foreach (PlayAddress item in video.playInformation)
     {
         menuXList1.Items.Add(new TPlayerList.TopItem
         {
             Visible = true,
             Enabled = true,
             Name    = item.playType
         });
     }
     menuXList1.InPaint();
     menuXList1.Invalidate();
     label4.Text = video.videoSynopsis;
 }
Ejemplo n.º 2
0
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                if (reader.TokenType == JsonToken.Null)
                {
                    return(null);
                }
                var urlString = (string)reader.Value;
                var url       = urlString.AsUri();

                return
                    (#if !STANDALONE
                     objectType == typeof(WebAudio) ? WebAudio.FromUrl(url) :
                     objectType == typeof(WebVideo) ? WebVideo.FromUrl(url) :
                     objectType == typeof(WebImage) ? WebImage.FromUrl(url) :
#endif
                     WebFile.FromUrl(url));
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts a string to an object of the specified type.
        /// </summary>
        /// <param name="str">The string to convert.</param>
        /// <param name="type">The destination type.</param>
        /// <param name="descriptiveName">A descriptive name for the object (if any).</param>
        /// <param name="culture">The culture identifier for number and dates.</param>
        /// <returns>The converted object.</returns>
        public static object ConvertFromString(string str, TypeBase type, string descriptiveName = null, string culture = null, Currency currency = Currency.None, HtmlDocument ownerDocument = null, string inlineListSeparator = null, string timezone = null, string format = null)
        {
            var cult           = GetCulture(culture);
            var underlyingType = TypeBase.GetUnderlyingType(type);

            if (underlyingType != null)
            {
                return(ConvertFromString(str, underlyingType, descriptiveName, culture, currency, ownerDocument, inlineListSeparator, timezone, format));
            }

            var enumType = type as EnumType;

            if (enumType != null)
            {
                return(enumType.Resolve(str, false));
            }


            var t = type.GetNativeType();



            if (t == typeof(string))
            {
                return(str);
            }
            if (t == typeof(Html))
            {
                return(new Html(str, ownerDocument != null ? ownerDocument.GetLazyBaseUrl() : null));
            }
            if (t == typeof(FileSize))
            {
                return(FileSize.Parse(str));
            }
            if (t == typeof(GeographicLocation))
            {
                return(GeographicLocation.FromString(str));
            }
            if (t == typeof(Uri))
            {
                return(new Uri(str));
            }
            if (t == typeof(UriObject))
            {
                return(UriObject.FromUrl(str.AsUri()));
            }
            if (t == typeof(WebImage))
            {
                return(WebImage.FromUrl(str.AsUri()));
            }
            if (t == typeof(WebFile))
            {
                return(WebFile.FromUrl(str.AsUri()));
            }
            if (t == typeof(WebAudio))
            {
                return(WebAudio.FromUrl(str.AsUri()));
            }
            if (t == typeof(WebVideo))
            {
                return(WebVideo.FromUrl(str.AsUri()));
            }

            if (t == typeof(Money))
            {
                if (string.IsNullOrEmpty(str))
                {
                    return(null);
                }
                return(Money.Parse(str, currency, cult));
            }

            // if (t == typeof(Memo)) return new Memo(str);

            if (t == typeof(SByte))
            {
                return(Convert.ToSByte(str));
            }
            if (t == typeof(Int16))
            {
                return(Convert.ToInt16(RemoveThousandsSeparators(str, cult), cult));
            }
            if (t == typeof(Int32))
            {
                return(Convert.ToInt32(RemoveThousandsSeparators(str, cult), cult));
            }
            if (t == typeof(Int64))
            {
                return(Convert.ToInt64(RemoveThousandsSeparators(str, cult), cult));
            }

            if (t == typeof(Byte))
            {
                return(Convert.ToByte(str));
            }
            if (t == typeof(UInt16))
            {
                return(Convert.ToUInt16(RemoveThousandsSeparators(str, cult), cult));
            }
            if (t == typeof(UInt32))
            {
                return(Convert.ToUInt32(RemoveThousandsSeparators(str, cult), cult));
            }
            if (t == typeof(UInt64))
            {
                return(Convert.ToUInt64(RemoveThousandsSeparators(str, cult), cult));
            }


            if (t == typeof(Single))
            {
                return(Convert.ToSingle(RemoveThousandsSeparators(str, cult), cult));
            }
            if (t == typeof(Double))
            {
                return(Convert.ToDouble(RemoveThousandsSeparators(str, cult), cult));
            }
            if (t == typeof(Decimal))
            {
                return(Convert.ToDecimal(RemoveThousandsSeparators(str, cult), cult));
            }



            if (t == typeof(DateTime))
            {
                return(ParseDateTime(str, cult, ownerDocument != null ? Utils.TryGetPageRetrievalDate(ownerDocument) : null, timezone, format));
            }
            if (t == typeof(Size))
            {
                return(new Size(int.Parse(str.Capture(@"(\d+)\s*(?:x|×|\*)")), int.Parse(str.Capture(@"(?:x|×|\*)\s*(\d+)"))));
            }
            if (type == TypeBase.BusinessWebsite)
            {
                return(BusinessWebsite.FromString(str));
            }
            if (type is EntityType)
            {
                return(ObjectManager.GetEntityAsync((EntityType)type, str.AsUri(), false, descriptiveName).AssumeCompleted());
            }
            if (t == typeof(TimeSpan))
            {
                return(ParseTimeSpan(str, cult));
            }
            if (t == typeof(bool))
            {
                var value = ConvertFromBoolean(str, true, cult);
                if (value == null)
                {
                    throw new InvalidDataException(string.Format("String cannot be converted to boolean: \"{0}\"", str));
                }
                return(value.Value);
            }

            if (t == typeof(BusinessWebsite))
            {
                return(BusinessWebsite.TryParse(str));
            }

            var simpleType = type as SimpleType;

            if (simpleType != null && simpleType.InlineListItemType != null)
            {
                return(Utils.ParseInlineList(str, simpleType, inlineListSeparator));
            }


            throw new ArgumentException("Type cannot be converted from string: " + t.ToString());
        }