西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴(lài)的軟件下載站!
軟件
軟件
文章
搜索

首頁(yè)編程開(kāi)發(fā)C#.NET → 用WPF搭建自己的P2P 播放器

用WPF搭建自己的P2P 播放器

相關(guān)軟件相關(guān)文章發(fā)表評(píng)論 來(lái)源:西西整理時(shí)間:2013/5/1 19:39:58字體大小:A-A+

作者:Gavin_gzm點(diǎn)擊:85次評(píng)論:0次標(biāo)簽: WPF

Actipro WPF Studiov11.1.0541 注冊(cè)版
  • 類(lèi)型:編程控件大。58.9M語(yǔ)言:英文 評(píng)分:6.6
  • 標(biāo)簽:
立即下載

本次是用WPF實(shí)現(xiàn)的是一款基于BT協(xié)議的P2P 播放器。內(nèi)核是用vlc來(lái)實(shí)現(xiàn)。結(jié)果辛辛苦苦做了半天結(jié)果發(fā)現(xiàn)用wpf不能滿足公司一些需求。

所以擱淺,專(zhuān)用winform去開(kāi)發(fā),主要2個(gè)原因:

1、界面美觀時(shí)發(fā)現(xiàn)渲染視頻的時(shí)候會(huì)有問(wèn)題,這個(gè)問(wèn)題等會(huì)會(huì)講。

2、主要原因如果wpf這個(gè)程序開(kāi)發(fā)完成是不能內(nèi)嵌到網(wǎng)頁(yè)的。因?yàn)楹罄m(xù)還要要開(kāi)發(fā)IE ActiveX 插件。然后總監(jiān)就說(shuō):那就不用wpf了,轉(zhuǎn)用winform。 我只能呵呵!呵呵呵呵!

wpf我一竅不通,之前完全沒(méi)接觸過(guò)。做出這個(gè)效果已是我最大能力了。(專(zhuān)業(yè)人員請(qǐng)用看小白的態(tài)度)

ok,這里說(shuō)下第一個(gè)問(wèn)題,在渲染視頻的時(shí)候會(huì)發(fā)現(xiàn)只有聲音,沒(méi)有畫(huà)面,在我找了2天問(wèn)題之后發(fā)現(xiàn)是因?yàn)榻缑嬗昧薃llowsTransparency="True" WindowStyle="None" 這段屬性的修改。如果修改一下AllowsTransparency="False" WindowStyle="XXX"(除了不是None之外的都可以)。則就變成這樣了。

 仔細(xì)看,會(huì)多了個(gè)邊框。只有這樣,畫(huà)面才能出來(lái)。 這里可能只有自己重繪這個(gè)界面元素。希望有人能指教一下。

這里我會(huì)將這個(gè)界面的項(xiàng)目打包上傳,點(diǎn)擊這里下載。(有點(diǎn)大,含有vlc的dll文件)因?yàn)槿サ袅薟indowStyle,鼠標(biāo)在邊框進(jìn)行縮放效果和最大化處理以及多顯示器上的兼容都要自己來(lái)實(shí)現(xiàn)。項(xiàng)目都會(huì)有,我其他文章也有對(duì)這些技術(shù)點(diǎn)進(jìn)行部分的講解,這個(gè)就自己去看啦。連接就不打了。

<!--音量滾珠-->
    <Style TargetType="Thumb" >
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Thumb">
                    <Grid>
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver"/>
                                    <vsm:VisualTransition GeneratedDuration="0:0:0.1" To="Pressed"/>
                                </vsm:VisualStateGroup.Transitions>
                                <vsm:VisualState x:Name="Normal"/>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetName="Down" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                            <SplineColorKeyFrame KeyTime="00:00:00" Value="#004486B6"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Down" Storyboard.TargetProperty="(UIElement.Opacity)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Down" Storyboard.TargetProperty="(UIElement.Opacity)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Disabled" Storyboard.TargetProperty="(UIElement.Opacity)" BeginTime="00:00:00" Duration="00:00:00.0010000">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Ellipse x:Name="Down" Grid.Column="0" Width="15" Height="15" StrokeThickness="0.5" Opacity="0.1" Fill="#FF4486B6" Margin="0,0,0,0">
                            <Ellipse.Stroke>
                                <LinearGradientBrush EndPoint="0.507,-1.856" StartPoint="0.507,1.515">
                                    <GradientStop Color="#FF4E5F70" Offset="0"/>
                                    <GradientStop Color="#FFF6F7FA" Offset="1"/>
                                </LinearGradientBrush>
                            </Ellipse.Stroke>
                        </Ellipse>
                        <!--音量的滾珠-->
                        <Ellipse x:Name="VolBackground" Grid.Column="0" Width="12" Height="12" StrokeLineJoin="Round" StrokeThickness="1.6" Opacity="0.9" Stroke="#00232425">
                            <Ellipse.Fill>
                                <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                    <GradientStop Color="#66B3FF" Offset="0.3"/>
                                    <GradientStop Color="#FF6AC2F3" Offset="1"/>
                                </LinearGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>
                        <Path x:Name="WhiteBubble" Grid.Column="0" Width="6" Height="2" Stretch="Fill" StrokeLineJoin="Round" StrokeThickness="1.8" Data="M4.2160064,2.8920099 C4.2160064,1.7874404 5.1114369,1.7153466 6.2160064,1.7153466 L22.679308,1.7153466 C23.783877,1.7153466 24.679308,1.7874404 24.679308,2.8920099 24.679308,2.8920099 4.2160064,2.8920099 4.2160064,2.8920099 z" Margin="0,0,0,7.5" VerticalAlignment="Stretch" Opacity="0.5">
                            <Path.Stroke>
                                <!--滾珠亮點(diǎn)色-->
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFFFF" Offset="0.5"/>
                                    <GradientStop Color="#FFCDCDCD" Offset="1"/>
                                </LinearGradientBrush>
                            </Path.Stroke>
                        </Path>
                        <Ellipse x:Name="DisabledOverlay" Width="11" Height="10.5" StrokeLineJoin="Round" StrokeThickness="0.5" Opacity="0" Stroke="#B2FFFFFF" Margin="1.5,233.25,1.5,233.25" Fill="#B2FFFFFF"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True"/>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Cursor" TargetName="VolBackground" Value="Hand"></Setter>
                            <Setter Property="Stroke" TargetName="VolBackground" >
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
                                        <GradientStop Color="#2894FF" Offset="0.3"/>
                                        <GradientStop Color="#66B3FF" Offset="1"/>
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Stroke" TargetName="WhiteBubble">
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FCFCFC" Offset="0.6"/>
                                        <GradientStop Color="#FFECEC" Offset="1"/>
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False"/>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

這個(gè)是要利用到WPFToolkit.dll的引用才可以。像這些界面控件的美化一般是用Blend工具來(lái)做的。我都是代碼Copy一些,然后修改一些。 ^.^ 親,代碼要會(huì)抄哦。當(dāng)然了,前提你得懂。這樣也是一種學(xué)習(xí)

    相關(guān)評(píng)論

    閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過(guò)難過(guò)
    • 5 囧
    • 3 圍觀圍觀
    • 2 無(wú)聊無(wú)聊

    熱門(mén)評(píng)論

    最新評(píng)論

    發(fā)表評(píng)論 查看所有評(píng)論(0)

    昵稱(chēng):
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過(guò)審核才能顯示)