зеркало из https://github.com/telerik/xaml-sdk.git
Examples update
This commit is contained in:
Родитель
ffddb5b775
Коммит
0d60ce37bd
|
@ -283,11 +283,10 @@
|
|||
Foreground="{TemplateBinding Foreground}"
|
||||
CanContentScroll="True">
|
||||
<!--<ItemsPresenter/>-->
|
||||
<telerik:RadGridView DataContext="{StaticResource ViewModel}"
|
||||
ItemsSource="{Binding Materials}"
|
||||
<telerik:RadGridView ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
RowIndicatorVisibility="Collapsed"
|
||||
EnableLostFocusSelectedState="False"
|
||||
SelectedItem="{Binding SelectedMaterial, Mode=TwoWay, Source={StaticResource ViewModel}}"
|
||||
SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ShowGroupPanel="False" IsFilteringAllowed="False" IsReadOnly="True" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
@ -438,11 +437,10 @@
|
|||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
CanContentScroll="True">
|
||||
<!--<ItemsPresenter/>-->
|
||||
<telerik:RadGridView DataContext="{StaticResource ViewModel}"
|
||||
ItemsSource="{Binding Materials}"
|
||||
<telerik:RadGridView ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
RowIndicatorVisibility="Collapsed"
|
||||
EnableLostFocusSelectedState="False"
|
||||
SelectedItem="{Binding SelectedMaterial, Mode=TwoWay, Source={StaticResource ViewModel}}"
|
||||
SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ShowGroupPanel="False" IsFilteringAllowed="False" IsReadOnly="True" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconSourceDemo_WPF", "IconSourceDemo\IconSourceDemo_WPF.csproj", "{5CCA6BEC-3B2F-401F-93B3-8353E3976FA4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaPlayer.Example", "MediaPlayer.Example\MediaPlayer.Example.csproj", "{4D7BB387-757E-4628-B074-8001F2C50BF0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaPlayer.Library", "MediaPlayer.Library\MediaPlayer.Library.csproj", "{F489A6B0-5281-4615-B293-6AAA53FC5F99}"
|
||||
EndProject
|
||||
Global
|
||||
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
|
@ -14,8 +19,17 @@ Global
|
|||
{5CCA6BEC-3B2F-401F-93B3-8353E3976FA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5CCA6BEC-3B2F-401F-93B3-8353E3976FA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5CCA6BEC-3B2F-401F-93B3-8353E3976FA4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4D7BB387-757E-4628-B074-8001F2C50BF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4D7BB387-757E-4628-B074-8001F2C50BF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4D7BB387-757E-4628-B074-8001F2C50BF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4D7BB387-757E-4628-B074-8001F2C50BF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F489A6B0-5281-4615-B293-6AAA53FC5F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F489A6B0-5281-4615-B293-6AAA53FC5F99}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F489A6B0-5281-4615-B293-6AAA53FC5F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F489A6B0-5281-4615-B293-6AAA53FC5F99}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
|
||||
EndGlobal
|
||||
|
|
|
@ -92,6 +92,9 @@
|
|||
<Resource Include="Icons\Dark\background.png" />
|
||||
<Resource Include="Icons\Light\background.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="README.md" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
##Icon Source Demo##
|
||||
## Icon Source Demo ##
|
||||
This example shows how to utilize the IconResource markup extension in order to dynamically change images at run-time.
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="MediaPlayer.Example.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:MediaPlayer.Example"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace MediaPlayer.Example
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<Window x:Class="MediaPlayer.Example.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mpLibrary="clr-namespace:MediaPlayer.Library;assembly=MediaPlayer.Library"
|
||||
xmlns:local="clr-namespace:MediaPlayer.Example"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="350" Width="525">
|
||||
<Grid>
|
||||
<mpLibrary:MediaPlayerFullscreenWrapper>
|
||||
<mpLibrary:MediaPlayer>
|
||||
<mpLibrary:MediaPlayer.Playlist>
|
||||
<mpLibrary:MediaItem MediaName="Getting started using RadCartesianChart for Silverlight and WPF"
|
||||
Source="http://773649a1298f63779f19-68dcd217a70edadad8c7b04ba4a904f0.r12.cf2.rackcdn.com/XAMLflix_ChartView_Getting-Started_Using-RadCartesianChart-for-Silverlight-and-WPF.mp4"/>
|
||||
<mpLibrary:MediaItem MediaName="Getting started using RadPolarChart for Silverlight and WPF"
|
||||
Source="http://773649a1298f63779f19-68dcd217a70edadad8c7b04ba4a904f0.r12.cf2.rackcdn.com/XAMLflix_ChartView_Getting-Started_Using-RadPolarChart-for-Silverlight-and-WPF.mp4"/>
|
||||
<mpLibrary:MediaItem MediaName="Getting started with RadMap"
|
||||
Source="http://773649a1298f63779f19-68dcd217a70edadad8c7b04ba4a904f0.r12.cf2.rackcdn.com/XAMLflix_Map_Getting-Started_Getting-Started-with-RadMap.mp4"/>
|
||||
</mpLibrary:MediaPlayer.Playlist>
|
||||
<mpLibrary:MediaPlayer.AdditionalMediaControlContent>
|
||||
<mpLibrary:GlyphButton GlyphValue="" GlyphSize="10" Command="MediaCommands.Stop"/>
|
||||
</mpLibrary:MediaPlayer.AdditionalMediaControlContent>
|
||||
<mpLibrary:MediaPlayer.AdditionalSettingsContent>
|
||||
<mpLibrary:GlyphButton GlyphValue="" Command="mpLibrary:AdditionalMediaCommands.ToggleFullscreenCommand"/>
|
||||
</mpLibrary:MediaPlayer.AdditionalSettingsContent>
|
||||
</mpLibrary:MediaPlayer>
|
||||
</mpLibrary:MediaPlayerFullscreenWrapper>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,12 @@
|
|||
using System.Windows;
|
||||
|
||||
namespace MediaPlayer.Example
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4D7BB387-757E-4628-B074-8001F2C50BF0}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MediaPlayer.Example</RootNamespace>
|
||||
<AssemblyName>MediaPlayer.Example</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
|
||||
|
||||
|
||||
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SkipSdkExample>true</SkipSdkExample>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls, Version=2017.2.503.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<None Include="Readme.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MediaPlayer.Library\MediaPlayer.Library.csproj">
|
||||
<Project>{f489a6b0-5281-4615-b293-6aaa53fc5f99}</Project>
|
||||
<Name>MediaPlayer.Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,55 @@
|
|||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MediaPlayer.Example")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MediaPlayer.Example")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MediaPlayer.Example.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MediaPlayer.Example.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MediaPlayer.Example.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,4 @@
|
|||
## Media Player ##
|
||||
This example shows how to create and use MediaPlayer custom control using the WPF native controls and customized RadButtons. See the MediaPlayer.Library project for the MediaPlayer implementation.
|
||||
|
||||
<keywords: mediaplayer, mediaelement>
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
public class GlyphButton : RadButton
|
||||
{
|
||||
static GlyphButton()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(GlyphButton), new FrameworkPropertyMetadata(typeof(GlyphButton)));
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty GlyphValueProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphValue",
|
||||
typeof(string),
|
||||
typeof(GlyphButton),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty GlyphSizeProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphSize",
|
||||
typeof(double),
|
||||
typeof(GlyphButton),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty GlyphMarginProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphMargin",
|
||||
typeof(Thickness),
|
||||
typeof(GlyphButton),
|
||||
new PropertyMetadata(new Thickness()));
|
||||
|
||||
public static readonly DependencyProperty GlyphBrushProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphBrush",
|
||||
typeof(Brush),
|
||||
typeof(GlyphButton),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public string GlyphValue
|
||||
{
|
||||
get { return (string)GetValue(GlyphValueProperty); }
|
||||
set { SetValue(GlyphValueProperty, value); }
|
||||
}
|
||||
|
||||
public double GlyphSize
|
||||
{
|
||||
get { return (double)GetValue(GlyphSizeProperty); }
|
||||
set { SetValue(GlyphSizeProperty, value); }
|
||||
}
|
||||
|
||||
public Thickness GlyphMargin
|
||||
{
|
||||
get { return (Thickness)GetValue(GlyphMarginProperty); }
|
||||
set { SetValue(GlyphMarginProperty, value); }
|
||||
}
|
||||
|
||||
public Brush GlyphBrush
|
||||
{
|
||||
get { return (Brush)GetValue(GlyphBrushProperty); }
|
||||
set { SetValue(GlyphBrushProperty, value); }
|
||||
}
|
||||
|
||||
protected override void OnInitialized(EventArgs e)
|
||||
{
|
||||
base.OnInitialized(e);
|
||||
StyleManager.SetDefaultStyleKey(this, typeof(GlyphButton));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
public class GlyphToggleButton : RadToggleButton
|
||||
{
|
||||
static GlyphToggleButton()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(GlyphToggleButton), new FrameworkPropertyMetadata(typeof(GlyphToggleButton)));
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty GlyphValueProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphValue",
|
||||
typeof(string),
|
||||
typeof(GlyphToggleButton),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty ToggledGlyphValueProperty =
|
||||
DependencyProperty.Register(
|
||||
"ToggledGlyphValue",
|
||||
typeof(string),
|
||||
typeof(GlyphToggleButton),
|
||||
new PropertyMetadata(string.Empty));
|
||||
|
||||
public static readonly DependencyProperty GlyphSizeProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphSize",
|
||||
typeof(double),
|
||||
typeof(GlyphToggleButton),
|
||||
new PropertyMetadata(0d));
|
||||
|
||||
public static readonly DependencyProperty GlyphMarginProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphMargin",
|
||||
typeof(Thickness),
|
||||
typeof(GlyphToggleButton),
|
||||
new PropertyMetadata(new Thickness()));
|
||||
|
||||
public static readonly DependencyProperty GlyphBrushProperty =
|
||||
DependencyProperty.Register(
|
||||
"GlyphBrush",
|
||||
typeof(Brush),
|
||||
typeof(GlyphToggleButton),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public string GlyphValue
|
||||
{
|
||||
get { return (string)GetValue(GlyphValueProperty); }
|
||||
set { SetValue(GlyphValueProperty, value); }
|
||||
}
|
||||
|
||||
public string ToggledGlyphValue
|
||||
{
|
||||
get { return (string)GetValue(ToggledGlyphValueProperty); }
|
||||
set { SetValue(ToggledGlyphValueProperty, value); }
|
||||
}
|
||||
|
||||
public double GlyphSize
|
||||
{
|
||||
get { return (double)GetValue(GlyphSizeProperty); }
|
||||
set { SetValue(GlyphSizeProperty, value); }
|
||||
}
|
||||
|
||||
public Thickness GlyphMargin
|
||||
{
|
||||
get { return (Thickness)GetValue(GlyphMarginProperty); }
|
||||
set { SetValue(GlyphMarginProperty, value); }
|
||||
}
|
||||
|
||||
public Brush GlyphBrush
|
||||
{
|
||||
get { return (Brush)GetValue(GlyphBrushProperty); }
|
||||
set { SetValue(GlyphBrushProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using System.Windows.Input;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
public static class AdditionalMediaCommands
|
||||
{
|
||||
public static RoutedUICommand ToggleFullscreenCommand { get; set; }
|
||||
|
||||
static AdditionalMediaCommands()
|
||||
{
|
||||
ToggleFullscreenCommand = new RoutedUICommand("Toggle full screen", "ToggleFullscreenCommand", typeof(AdditionalMediaCommands));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
public class MediaItem
|
||||
{
|
||||
private static string[] videoExtensions = { ".AVI", ".MP4", ".DIVX", ".WMV", ".MKV" };
|
||||
|
||||
private Uri source;
|
||||
private string mediaName;
|
||||
|
||||
public Uri Source
|
||||
{
|
||||
get { return source; }
|
||||
set
|
||||
{
|
||||
if (this.source != value)
|
||||
{
|
||||
this.source = value;
|
||||
this.OnPropertyChanged("Source");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string MediaName
|
||||
{
|
||||
get { return mediaName; }
|
||||
set
|
||||
{
|
||||
if (this.mediaName != value)
|
||||
{
|
||||
this.mediaName = value;
|
||||
this.OnPropertyChanged("MediaName");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVideo
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsVideoFile(this.source.AbsoluteUri);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsVideoFile(string path)
|
||||
{
|
||||
return -1 != Array.IndexOf(videoExtensions, Path.GetExtension(path).ToUpperInvariant());
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] String propertyName = "")
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
public partial class MediaPlayer
|
||||
{
|
||||
private void RegisterCommandBindings()
|
||||
{
|
||||
CommandBinding playCommandBinding = new CommandBinding(MediaCommands.Play, OnPlayCommandExecuted, OnPlayCommandCanExecute);
|
||||
this.CommandBindings.Add(playCommandBinding);
|
||||
|
||||
CommandBinding stopCommandBinding = new CommandBinding(MediaCommands.Stop, OnStopCommandExecuted, OnStopCommandCanExecute);
|
||||
this.CommandBindings.Add(stopCommandBinding);
|
||||
|
||||
CommandBinding togglePlayPauseCommandBinding = new CommandBinding(MediaCommands.TogglePlayPause, OnTogglePlayPauseCommandExecuted);
|
||||
this.CommandBindings.Add(togglePlayPauseCommandBinding);
|
||||
|
||||
CommandBinding muteVolumeCommandBinding = new CommandBinding(MediaCommands.MuteVolume, OnMuteVolumeCommandExecuted);
|
||||
this.CommandBindings.Add(muteVolumeCommandBinding);
|
||||
|
||||
CommandBinding selectCommandBinding = new CommandBinding(MediaCommands.Select, OnSelectCommandExecuted);
|
||||
this.CommandBindings.Add(selectCommandBinding);
|
||||
}
|
||||
|
||||
private void OnPlayCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
e.CanExecute = !this.IsPlaying;
|
||||
}
|
||||
|
||||
private void OnPlayCommandExecuted(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
this.Play();
|
||||
}
|
||||
|
||||
private void OnStopCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
e.CanExecute = this.IsPlaying;
|
||||
}
|
||||
|
||||
private void OnStopCommandExecuted(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
this.Stop();
|
||||
}
|
||||
|
||||
private void OnTogglePlayPauseCommandExecuted(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
this.TogglePlayPause();
|
||||
}
|
||||
|
||||
private void OnMuteVolumeCommandExecuted(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
this.IsMuted ^= true;
|
||||
}
|
||||
|
||||
private void OnSelectCommandExecuted(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
MediaItem selectedItem = e.Parameter as MediaItem;
|
||||
if (selectedItem != null)
|
||||
{
|
||||
this.CurrentPlaylistItem = selectedItem;
|
||||
this.Position = TimeSpan.Zero;
|
||||
this.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{F489A6B0-5281-4615-B293-6AAA53FC5F99}</ProjectGuid>
|
||||
<OutputType>library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MediaPlayer.Library</RootNamespace>
|
||||
<AssemblyName>MediaPlayer.Library</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
||||
|
||||
|
||||
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SkipSdkExample>true</SkipSdkExample>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="Telerik.Windows.Controls, Version=2017.2.503.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(TELERIKWPFDIR)\Binaries\WPF40\Telerik.Windows.Controls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Commands\AdditionalMediaCommands.cs" />
|
||||
<Compile Include="MediaPlayerFullscreenWrapper.cs" />
|
||||
<Compile Include="TrackInfoMode.cs" />
|
||||
<Page Include="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="Buttons\GlyphButton.cs" />
|
||||
<Compile Include="Buttons\GlyphToggleButton.cs" />
|
||||
<Compile Include="MediaPlayer.Commands.cs" />
|
||||
<Compile Include="MediaPlayer.cs" />
|
||||
<Compile Include="MediaPlayer.Properties.cs" />
|
||||
<Compile Include="MediaItem.cs" />
|
||||
<Page Include="Themes\GlyphButtonsStyles.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<None Include="Readme.md" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,260 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
public partial class MediaPlayer
|
||||
{
|
||||
private ObservableCollection<MediaItem> playlist;
|
||||
|
||||
public static readonly DependencyProperty CurrentPlaylistItemProperty =
|
||||
DependencyProperty.Register(
|
||||
"CurrentPlaylistItem",
|
||||
typeof(MediaItem),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(null, OnCurrentPlaylistItemChanged));
|
||||
|
||||
public static readonly DependencyProperty PositionProperty =
|
||||
DependencyProperty.Register(
|
||||
"Position",
|
||||
typeof(TimeSpan),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(TimeSpan.Zero, OnPositionChanged));
|
||||
|
||||
public static readonly DependencyProperty VolumeProperty =
|
||||
DependencyProperty.Register(
|
||||
"Volume",
|
||||
typeof(double),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(0.5, OnVolumeChanged));
|
||||
|
||||
public static readonly DependencyProperty IsPlayingProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsPlaying",
|
||||
typeof(bool),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(false));
|
||||
|
||||
public static readonly DependencyProperty IsMutedProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsMuted",
|
||||
typeof(bool),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(false, OnIsMutedChanged));
|
||||
|
||||
public static readonly DependencyProperty IsPlaylistOpenProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsPlaylistOpen",
|
||||
typeof(bool),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(false));
|
||||
|
||||
public static readonly DependencyProperty PlaylistItemTemplateProperty =
|
||||
DependencyProperty.Register(
|
||||
"PlaylistItemTemplate",
|
||||
typeof(DataTemplate),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty AdditionalMediaControlContentProperty =
|
||||
DependencyProperty.Register(
|
||||
"AdditionalMediaControlContent",
|
||||
typeof(object),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty AdditionalSettingsContentProperty =
|
||||
DependencyProperty.Register(
|
||||
"AdditionalSettingsContent",
|
||||
typeof(object),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty TrackInfoModeProperty =
|
||||
DependencyProperty.Register(
|
||||
"TrackInfoMode",
|
||||
typeof(TrackInfoMode),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(TrackInfoMode.CurrentAndEndTime, OnTrackInfoModeChanged));
|
||||
|
||||
public static readonly DependencyProperty VideoControlsPanelVisibilityProperty =
|
||||
DependencyProperty.Register(
|
||||
"VideoControlsPanelVisibility",
|
||||
typeof(Visibility),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(Visibility.Visible));
|
||||
|
||||
public static readonly DependencyProperty MediaStretchProperty =
|
||||
DependencyProperty.Register(
|
||||
"MediaStretch",
|
||||
typeof(Stretch),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(Stretch.Uniform));
|
||||
|
||||
public static readonly DependencyProperty MediaStretchDirectionProperty =
|
||||
DependencyProperty.Register(
|
||||
"MediaStretchDirection",
|
||||
typeof(StretchDirection),
|
||||
typeof(MediaPlayer),
|
||||
new PropertyMetadata(StretchDirection.Both));
|
||||
|
||||
public MediaItem CurrentPlaylistItem
|
||||
{
|
||||
get { return (MediaItem)GetValue(CurrentPlaylistItemProperty); }
|
||||
set { SetValue(CurrentPlaylistItemProperty, value); }
|
||||
}
|
||||
|
||||
public TimeSpan Position
|
||||
{
|
||||
get { return (TimeSpan)GetValue(PositionProperty); }
|
||||
set { SetValue(PositionProperty, value); }
|
||||
}
|
||||
|
||||
public double Volume
|
||||
{
|
||||
get { return (double)GetValue(VolumeProperty); }
|
||||
set { SetValue(VolumeProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsPlaying
|
||||
{
|
||||
get { return (bool)GetValue(IsPlayingProperty); }
|
||||
private set { SetValue(IsPlayingProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsMuted
|
||||
{
|
||||
get { return (bool)GetValue(IsMutedProperty); }
|
||||
set { SetValue(IsMutedProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsPlaylistOpen
|
||||
{
|
||||
get { return (bool)GetValue(IsPlaylistOpenProperty); }
|
||||
set { SetValue(IsPlaylistOpenProperty, value); }
|
||||
}
|
||||
|
||||
public DataTemplate PlaylistItemTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(PlaylistItemTemplateProperty); }
|
||||
set { SetValue(PlaylistItemTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public object AdditionalMediaControlContent
|
||||
{
|
||||
get { return (object)GetValue(AdditionalMediaControlContentProperty); }
|
||||
set { SetValue(AdditionalMediaControlContentProperty, value); }
|
||||
}
|
||||
|
||||
public object AdditionalSettingsContent
|
||||
{
|
||||
get { return (object)GetValue(AdditionalSettingsContentProperty); }
|
||||
set { SetValue(AdditionalSettingsContentProperty, value); }
|
||||
}
|
||||
|
||||
public TrackInfoMode TrackInfoMode
|
||||
{
|
||||
get { return (TrackInfoMode)GetValue(TrackInfoModeProperty); }
|
||||
set { SetValue(TrackInfoModeProperty, value); }
|
||||
}
|
||||
|
||||
public Visibility VideoControlsPanelVisibility
|
||||
{
|
||||
get { return (Visibility)GetValue(VideoControlsPanelVisibilityProperty); }
|
||||
set { SetValue(VideoControlsPanelVisibilityProperty, value); }
|
||||
}
|
||||
|
||||
public Stretch MediaStretch
|
||||
{
|
||||
get { return (Stretch)GetValue(MediaStretchProperty); }
|
||||
set { SetValue(MediaStretchProperty, value); }
|
||||
}
|
||||
|
||||
public StretchDirection MediaStretchDirection
|
||||
{
|
||||
get { return (StretchDirection)GetValue(MediaStretchDirectionProperty); }
|
||||
set { SetValue(MediaStretchDirectionProperty, value); }
|
||||
}
|
||||
|
||||
public ObservableCollection<MediaItem> Playlist
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.playlist == null)
|
||||
{
|
||||
this.playlist = new ObservableCollection<MediaItem>();
|
||||
}
|
||||
return this.playlist;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnPositionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var mediaPlayer = (MediaPlayer)d;
|
||||
if (mediaPlayer.mediaElement != null)
|
||||
{
|
||||
var newPosition = (TimeSpan)e.NewValue;
|
||||
mediaPlayer.UpdateTrackBarValue(newPosition.TotalSeconds);
|
||||
mediaPlayer.mediaElement.Position = newPosition;
|
||||
mediaPlayer.UpdateTrackBarInfo();
|
||||
|
||||
if (mediaPlayer.mediaElement.NaturalDuration.HasTimeSpan &&
|
||||
newPosition == mediaPlayer.mediaElement.NaturalDuration.TimeSpan)
|
||||
{
|
||||
mediaPlayer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnCurrentPlaylistItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var mediaPlayer = (MediaPlayer)d;
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
if (mediaPlayer.IsPlaying)
|
||||
{
|
||||
mediaPlayer.Stop();
|
||||
}
|
||||
mediaPlayer.IsPlaylistOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnVolumeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var mediaPlayer = (MediaPlayer)d;
|
||||
double newVolume = (double)e.NewValue;
|
||||
if (newVolume > 0)
|
||||
{
|
||||
mediaPlayer.IsMuted = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnIsMutedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var mediaPlayer = (MediaPlayer)d;
|
||||
bool isMuted = (bool)e.NewValue;
|
||||
if (isMuted)
|
||||
{
|
||||
mediaPlayer.cachedVolume = mediaPlayer.Volume;
|
||||
mediaPlayer.Volume = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mediaPlayer.Volume == 0)
|
||||
{
|
||||
mediaPlayer.Volume = mediaPlayer.cachedVolume;
|
||||
}
|
||||
mediaPlayer.cachedVolume = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnTrackInfoModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var mediaPlayer = (MediaPlayer)d;
|
||||
mediaPlayer.UpdateTrackBarInfo();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Telerik.Windows.Controls;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
public partial class MediaPlayer : ContentControl
|
||||
{
|
||||
private const string DefaultTrackInfoValueFormatString = "hh\\:mm\\:ss";
|
||||
private const string DefaultTrackInfoLayoutFormatString = "{0} / {1}";
|
||||
|
||||
private DispatcherTimer trackBarMediaPositionSyncTimer;
|
||||
private MediaElement mediaElement;
|
||||
private TextBlock trackInfo;
|
||||
private RadSlider trackBar;
|
||||
|
||||
private double cachedVolume = -1;
|
||||
private bool isTrackbarValueUpdating = false;
|
||||
private bool shouldNormalizeTrackBarValue = false;
|
||||
|
||||
static MediaPlayer()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MediaPlayer), new FrameworkPropertyMetadata(typeof(MediaPlayer)));
|
||||
}
|
||||
|
||||
public MediaPlayer()
|
||||
{
|
||||
this.RegisterCommandBindings();
|
||||
this.Unloaded += OnUnloaded;
|
||||
this.Loaded += OnLoaded;
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
this.mediaElement = GetTemplateChild("PART_MediaElement") as MediaElement;
|
||||
this.trackInfo = GetTemplateChild("PART_TrackInfo") as TextBlock;
|
||||
this.trackBar = GetTemplateChild("PART_ProgressTrackBar") as RadSlider;
|
||||
this.UpdateTrackBarInfo();
|
||||
|
||||
this.shouldNormalizeTrackBarValue = true;
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (this.mediaElement != null && this.CurrentPlaylistItem != null)
|
||||
{
|
||||
this.mediaElement.Play();
|
||||
this.trackBarMediaPositionSyncTimer.Start();
|
||||
this.IsPlaying = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (this.mediaElement != null && this.mediaElement.CanPause)
|
||||
{
|
||||
this.mediaElement.Pause();
|
||||
this.trackBarMediaPositionSyncTimer.Stop();
|
||||
this.IsPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void TogglePlayPause()
|
||||
{
|
||||
if (this.IsPlaying)
|
||||
{
|
||||
this.Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Play();
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (this.mediaElement != null)
|
||||
{
|
||||
this.mediaElement.Stop();
|
||||
this.trackBarMediaPositionSyncTimer.Stop();
|
||||
this.Position = TimeSpan.Zero;
|
||||
this.IsPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
this.Focus();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Space)
|
||||
{
|
||||
this.TogglePlayPause();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string GetProgressTrackInfo(Duration naturalDuration, TimeSpan currentPosition, TrackInfoMode mode)
|
||||
{
|
||||
if (mode == TrackInfoMode.CurrentAndEndTime)
|
||||
{
|
||||
if (naturalDuration == Duration.Automatic)
|
||||
{
|
||||
return string.Format(DefaultTrackInfoLayoutFormatString, TimeSpan.Zero.ToString(DefaultTrackInfoValueFormatString), TimeSpan.Zero.ToString(DefaultTrackInfoValueFormatString));
|
||||
}
|
||||
return string.Format(DefaultTrackInfoLayoutFormatString, currentPosition.ToString(DefaultTrackInfoValueFormatString), naturalDuration.TimeSpan.ToString(DefaultTrackInfoValueFormatString));
|
||||
}
|
||||
else if (mode == TrackInfoMode.CurrentTime)
|
||||
{
|
||||
if (naturalDuration == Duration.Automatic)
|
||||
{
|
||||
return TimeSpan.Zero.ToString(DefaultTrackInfoValueFormatString);
|
||||
}
|
||||
return currentPosition.ToString(DefaultTrackInfoValueFormatString);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (naturalDuration == Duration.Automatic)
|
||||
{
|
||||
return TimeSpan.Zero.ToString(DefaultTrackInfoValueFormatString);
|
||||
}
|
||||
return (naturalDuration.TimeSpan - currentPosition).ToString(DefaultTrackInfoValueFormatString);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnMediaFailed(object sender, ExceptionRoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show(e.ErrorException.Message);
|
||||
}
|
||||
|
||||
private void OnTrackBarMediaPositionSyncTimerTick(object sender, EventArgs e)
|
||||
{
|
||||
if (this.trackBarMediaPositionSyncTimer.IsEnabled)
|
||||
{
|
||||
this.Position = this.mediaElement.Position;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMediaElementMediaOpened(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.UpdateTrackBarMaximum();
|
||||
this.TryNormalizeTrackBarValue();
|
||||
}
|
||||
|
||||
private void OnTrackBarValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (!this.isTrackbarValueUpdating)
|
||||
{
|
||||
this.Position = TimeSpan.FromSeconds(e.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.SetupSyncTimer();
|
||||
|
||||
if (this.mediaElement != null)
|
||||
{
|
||||
this.mediaElement.MediaOpened += OnMediaElementMediaOpened;
|
||||
this.mediaElement.MediaFailed += OnMediaFailed;
|
||||
}
|
||||
|
||||
if (this.trackBar != null)
|
||||
{
|
||||
this.trackBar.ValueChanged += OnTrackBarValueChanged;
|
||||
}
|
||||
|
||||
if (this.trackInfo != null)
|
||||
{
|
||||
this.trackInfo.MouseLeftButtonDown += OnTrackInfoMouseLeftButtonDown;
|
||||
}
|
||||
|
||||
if (this.CurrentPlaylistItem == null && this.Playlist.Count > 0)
|
||||
{
|
||||
this.CurrentPlaylistItem = this.Playlist[0];
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Stop();
|
||||
this.trackBarMediaPositionSyncTimer.Tick -= OnTrackBarMediaPositionSyncTimerTick;
|
||||
this.mediaElement.MediaOpened -= OnMediaElementMediaOpened;
|
||||
this.mediaElement.MediaFailed -= OnMediaFailed;
|
||||
this.trackBar.ValueChanged -= OnTrackBarValueChanged;
|
||||
this.trackInfo.MouseLeftButtonDown -= OnTrackInfoMouseLeftButtonDown;
|
||||
this.Unloaded -= OnUnloaded;
|
||||
}
|
||||
|
||||
private void OnTrackInfoMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var values = (TrackInfoMode[])Enum.GetValues(typeof(TrackInfoMode));
|
||||
var currentIndex = Array.IndexOf(values, this.TrackInfoMode) + 1;
|
||||
TrackInfoMode newMode = (values.Length == currentIndex) ? values[0] : values[currentIndex];
|
||||
this.TrackInfoMode = newMode;
|
||||
}
|
||||
|
||||
private void SetupSyncTimer()
|
||||
{
|
||||
this.trackBarMediaPositionSyncTimer = new DispatcherTimer();
|
||||
this.trackBarMediaPositionSyncTimer.Interval = TimeSpan.FromSeconds(1);
|
||||
this.trackBarMediaPositionSyncTimer.Tick += OnTrackBarMediaPositionSyncTimerTick;
|
||||
}
|
||||
|
||||
private void UpdateTrackBarValue(double value)
|
||||
{
|
||||
this.isTrackbarValueUpdating = true;
|
||||
this.trackBar.Value = value;
|
||||
this.isTrackbarValueUpdating = false;
|
||||
}
|
||||
|
||||
private void UpdateTrackBarInfo()
|
||||
{
|
||||
if (this.trackInfo != null && this.mediaElement != null)
|
||||
{
|
||||
this.trackInfo.Text = GetProgressTrackInfo(this.mediaElement.NaturalDuration, this.mediaElement.Position, this.TrackInfoMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTrackBarMaximum()
|
||||
{
|
||||
if (this.mediaElement.NaturalDuration != Duration.Automatic)
|
||||
{
|
||||
this.trackBar.Maximum = this.mediaElement.NaturalDuration.TimeSpan.TotalSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
private void TryNormalizeTrackBarValue()
|
||||
{
|
||||
if (this.shouldNormalizeTrackBarValue)
|
||||
{
|
||||
double normalizedValue = this.trackBar.Value * this.trackBar.Maximum;
|
||||
this.Position = TimeSpan.FromSeconds(normalizedValue);
|
||||
this.shouldNormalizeTrackBarValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace MediaPlayer.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// A control that allows you to display the MediaPlayer control in a fullscreen mode.
|
||||
/// </summary>
|
||||
[ContentProperty("MediaPlayer")]
|
||||
public class MediaPlayerFullscreenWrapper : Control
|
||||
{
|
||||
private const double ShowVideoControlsPanelOffset = 50;
|
||||
|
||||
private bool requestToggleFullscreen = false;
|
||||
private Window fullscreenPresenter;
|
||||
private ContentControl contentPresenter;
|
||||
|
||||
static MediaPlayerFullscreenWrapper()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MediaPlayerFullscreenWrapper), new FrameworkPropertyMetadata(typeof(MediaPlayerFullscreenWrapper)));
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MediaPlayerProperty =
|
||||
DependencyProperty.Register(
|
||||
"MediaPlayer",
|
||||
typeof(MediaPlayer),
|
||||
typeof(MediaPlayerFullscreenWrapper),
|
||||
new PropertyMetadata(null, OnMediaPlayerChanged));
|
||||
|
||||
public static readonly DependencyProperty IsFullscreenProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsFullscreen",
|
||||
typeof(bool),
|
||||
typeof(MediaPlayerFullscreenWrapper),
|
||||
new PropertyMetadata(false, OnIsFullscreenChanged));
|
||||
|
||||
public MediaPlayer MediaPlayer
|
||||
{
|
||||
get { return (MediaPlayer)GetValue(MediaPlayerProperty); }
|
||||
set { SetValue(MediaPlayerProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsFullscreen
|
||||
{
|
||||
get { return (bool)GetValue(IsFullscreenProperty); }
|
||||
set { SetValue(IsFullscreenProperty, value); }
|
||||
}
|
||||
|
||||
public MediaPlayerFullscreenWrapper()
|
||||
{
|
||||
this.Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
this.contentPresenter = this.GetTemplateChild("PART_MediaPlayerPresenter") as ContentControl;
|
||||
|
||||
if (this.requestToggleFullscreen)
|
||||
{
|
||||
this.GoToFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.CloseFullscreen();
|
||||
}
|
||||
|
||||
private static void OnMediaPlayerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
MediaPlayerFullscreenWrapper wrapper = (MediaPlayerFullscreenWrapper)d;
|
||||
MediaPlayer mediaPlayer = (MediaPlayer)e.NewValue;
|
||||
|
||||
CommandBinding fullscreenCommandBinding = new CommandBinding(AdditionalMediaCommands.ToggleFullscreenCommand, wrapper.OnToggleFullscreenExecuted);
|
||||
mediaPlayer.CommandBindings.Add(fullscreenCommandBinding);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnIsFullscreenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var wrapper = (MediaPlayerFullscreenWrapper)d;
|
||||
if (wrapper. MediaPlayer == null)
|
||||
{
|
||||
wrapper.requestToggleFullscreen = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((bool)e.NewValue)
|
||||
{
|
||||
wrapper.GoToFullscreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
wrapper.CloseFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnToggleFullscreenExecuted(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
this.IsFullscreen = (this.fullscreenPresenter == null);
|
||||
}
|
||||
|
||||
private void OnFullscreenPresenterKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape)
|
||||
{
|
||||
this.IsFullscreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFullscreenPresenterMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
this.UpdateVideoControlsPanelVisibility(e.GetPosition(this.fullscreenPresenter));
|
||||
}
|
||||
|
||||
private Window CreateFullscreenPresenter(MediaPlayer mediaPlayer)
|
||||
{
|
||||
var presenter = new Window();
|
||||
presenter.Content = mediaPlayer;
|
||||
presenter.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
presenter.WindowStyle = WindowStyle.None;
|
||||
presenter.KeyDown += OnFullscreenPresenterKeyDown;
|
||||
presenter.MouseMove += OnFullscreenPresenterMouseMove;
|
||||
|
||||
|
||||
return presenter;
|
||||
}
|
||||
|
||||
private void MaximizeFullscreenPresenter()
|
||||
{
|
||||
if (this.fullscreenPresenter != null && this.fullscreenPresenter.IsLoaded)
|
||||
{
|
||||
this.fullscreenPresenter.Left = Window.GetWindow(this).Left;
|
||||
this.fullscreenPresenter.Top = Window.GetWindow(this).Top;
|
||||
this.fullscreenPresenter.Topmost = true;
|
||||
this.fullscreenPresenter.WindowState = WindowState.Maximized;
|
||||
}
|
||||
}
|
||||
|
||||
private void GoToFullscreen()
|
||||
{
|
||||
var isPlaying = this.MediaPlayer.IsPlaying;
|
||||
var playerPosition = this.MediaPlayer.Position;
|
||||
this.contentPresenter.Content = null;
|
||||
this.fullscreenPresenter = this.CreateFullscreenPresenter(this.MediaPlayer);
|
||||
this.fullscreenPresenter.Show();
|
||||
this.fullscreenPresenter.Activate();
|
||||
this.MaximizeFullscreenPresenter();
|
||||
this.MediaPlayer.Position = playerPosition;
|
||||
if (isPlaying)
|
||||
{
|
||||
this.MediaPlayer.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseFullscreen()
|
||||
{
|
||||
this.fullscreenPresenter.Content = null;
|
||||
this.fullscreenPresenter.Close();
|
||||
this.contentPresenter.Content = this.MediaPlayer;
|
||||
this.fullscreenPresenter.KeyDown -= OnFullscreenPresenterKeyDown;
|
||||
this.fullscreenPresenter.MouseMove -= OnFullscreenPresenterMouseMove;
|
||||
this.fullscreenPresenter = null;
|
||||
|
||||
this.MediaPlayer.VideoControlsPanelVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void UpdateVideoControlsPanelVisibility(Point mousePosition)
|
||||
{
|
||||
double delta = (this.fullscreenPresenter.ActualHeight - mousePosition.Y);
|
||||
if (delta <= ShowVideoControlsPanelOffset)
|
||||
{
|
||||
this.MediaPlayer.VideoControlsPanelVisibility = Visibility.Visible;
|
||||
}
|
||||
else if (delta > ShowVideoControlsPanelOffset && this.MediaPlayer.VideoControlsPanelVisibility == Visibility.Visible)
|
||||
{
|
||||
this.MediaPlayer.VideoControlsPanelVisibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MediaPlayer.Library")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MediaPlayer.Library")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly:ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MediaPlayer.Library.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MediaPlayer.Library.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MediaPlayer.Library.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
|
@ -0,0 +1,5 @@
|
|||
## Media Player ##
|
||||
This example shows how to create a MediaPlayer custom control using the WPF native controls and customized RadButtons. The MediaPlayerFullscreenWrapper control allows you to show the MediaPlayer in a fullscreen mode, but it is not a mandatory to use it.
|
||||
See the MediaPlayer.Example project for an example usage of the control.
|
||||
|
||||
<keywords: mediaplayer, mediaelement>
|
|
@ -0,0 +1,256 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
xmlns:local="clr-namespace:MediaPlayer.Library">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/MediaPlayer.Library;component/Themes/GlyphButtonsStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<telerik:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter" />
|
||||
|
||||
<DataTemplate x:Key="ButtonEllipseBorderTemplate">
|
||||
<Ellipse x:Name="ButtonEllipse" StrokeThickness="2" Stroke="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}"/>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsMouseOver}" Value="True">
|
||||
<Setter TargetName="ButtonEllipse" Property="Stroke" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsMouseCaptured}" Value="True">
|
||||
<Setter TargetName="ButtonEllipse" Property="Stroke" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="PlaylistItemTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontFamily="{StaticResource TelerikWebUI}"
|
||||
Margin="0 0 5 0"
|
||||
FontSize="16">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsVideo}" Value="False">
|
||||
<Setter Property="Text" Value="" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsVideo}" Value="True">
|
||||
<Setter Property="Text" Value="" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<TextBlock Text="{Binding MediaName}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="PlayButtonStyle" TargetType="local:GlyphButton" BasedOn="{StaticResource GlyphButtonStyle}">
|
||||
<Setter Property="Height" Value="80" />
|
||||
<Setter Property="Width" Value="80" />
|
||||
<Setter Property="GlyphValue" Value="" />
|
||||
<Setter Property="GlyphSize" Value="40" />
|
||||
<Setter Property="GlyphMargin" Value="10 0 0 0" />
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource ButtonEllipseBorderTemplate}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PlayPauseButtonStyle" TargetType="local:GlyphToggleButton" BasedOn="{StaticResource GlyphToggleButtonStyle}">
|
||||
<Setter Property="Height" Value="22" />
|
||||
<Setter Property="Width" Value="22" />
|
||||
<Setter Property="GlyphValue" Value="" />
|
||||
<Setter Property="GlyphSize" Value="10" />
|
||||
<Setter Property="GlyphMargin" Value="3 0 0 0" />
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource ButtonEllipseBorderTemplate}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="GlyphValue" Value="" />
|
||||
<Setter Property="GlyphMargin" Value="0" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="MuteButtonStyle" TargetType="local:GlyphToggleButton" BasedOn="{StaticResource GlyphToggleButtonStyle}">
|
||||
<Setter Property="GlyphValue" Value="" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="GlyphValue" Value="" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PlaylistButtonStyle" TargetType="local:GlyphToggleButton" BasedOn="{StaticResource GlyphToggleButtonStyle}">
|
||||
<Setter Property="GlyphValue" Value="" />
|
||||
<Setter Property="GlyphMargin" Value="0 2 0 0" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="GlyphBrush" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Thumb" x:Key="ThumbStyle">
|
||||
<Setter Property="IsTabStop" Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Grid Background="Transparent"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="RepeatButton" x:Key="LargeHandleStyle">
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="RepeatButton">
|
||||
<Grid Background="{TemplateBinding Background}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="MediaPlayerSliderTemplate" TargetType="telerik:RadSlider">
|
||||
<Grid x:Name="LayoutRoot" MinHeight="0" Height="6" Background="{TemplateBinding Background}" Cursor="Hand">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentControl x:Name="Track" Grid.ColumnSpan="3" VerticalAlignment="Center"/>
|
||||
<Rectangle Cursor="Hand" Width="Auto" VerticalAlignment="Center" Fill="{telerik:VisualStudio2013Resource ResourceKey=AccentMainBrush}" Height="6"/>
|
||||
<telerik:RadTickBar x:Name="TopTickBar"
|
||||
ItemsSource="{TemplateBinding ResultTicks}"
|
||||
Grid.ColumnSpan="3"
|
||||
ItemTemplate="{TemplateBinding TickTemplate}"
|
||||
ItemTemplateSelector="{TemplateBinding TickTemplateSelector}"
|
||||
Maximum="{TemplateBinding Maximum}"
|
||||
Minimum="{TemplateBinding Minimum}"
|
||||
Style="{TemplateBinding TickBarStyle}"/>
|
||||
<RepeatButton x:Name="LargeDecreaseButton" Style="{StaticResource LargeHandleStyle}" Background="#3399FF" Delay="{TemplateBinding Delay}" Interval="{TemplateBinding RepeatInterval}"/>
|
||||
<Grid Grid.Column="1" Visibility="{TemplateBinding ThumbVisibility}">
|
||||
<Thumb x:Name="SingleThumbHost" Style="{StaticResource ThumbStyle}"/>
|
||||
</Grid>
|
||||
<RepeatButton x:Name="LargeIncreaseButton" Grid.Column="2" Style="{StaticResource LargeHandleStyle}" Background="Transparent" Delay="{TemplateBinding Delay}" Interval="{TemplateBinding RepeatInterval}"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="MediaPlayerTemplate" TargetType="local:MediaPlayer">
|
||||
<Grid x:Name="PlayerRootPanel" TextElement.Foreground="White" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="ElementsPanel">
|
||||
<MediaElement x:Name="PART_MediaElement"
|
||||
KeyboardNavigation.IsTabStop="True"
|
||||
ScrubbingEnabled="True"
|
||||
Source="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CurrentPlaylistItem.Source, Mode=OneWay}"
|
||||
LoadedBehavior="Manual"
|
||||
UnloadedBehavior="Manual"
|
||||
Stretch="{TemplateBinding MediaStretch}"
|
||||
StretchDirection="{TemplateBinding MediaStretchDirection}"
|
||||
Volume="{TemplateBinding Volume}"
|
||||
IsMuted="{TemplateBinding IsMuted}"/>
|
||||
|
||||
<TextBlock x:Name="AudioVisual" Text="" FontFamily="{StaticResource TelerikWebUI}" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
|
||||
<local:GlyphButton Style="{StaticResource PlayButtonStyle}"
|
||||
Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsPlaying, Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Command="MediaCommands.Play"/>
|
||||
|
||||
<ContentControl x:Name="PlaylistPanel" Visibility="Collapsed">
|
||||
<telerik:RadListBox x:Name="PlaylistElement"
|
||||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Playlist}"
|
||||
ItemTemplate="{TemplateBinding PlaylistItemTemplate}"
|
||||
SelectedItem="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CurrentPlaylistItem, Mode=OneWay}"
|
||||
telerik:StyleManager.Theme="VisualStudio2013">
|
||||
<telerik:EventToCommandBehavior.EventBindings>
|
||||
<telerik:EventBinding EventName="MouseDoubleClick"
|
||||
Command="MediaCommands.Select"
|
||||
CommandParameter="{Binding ElementName=PlaylistElement, Path=SelectedItem}" />
|
||||
</telerik:EventToCommandBehavior.EventBindings>
|
||||
</telerik:RadListBox>
|
||||
</ContentControl>
|
||||
|
||||
<Border Background="Black" Padding="10 5 10 5"
|
||||
VerticalAlignment="Bottom" x:Name="VideoControlsPanel"
|
||||
Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=VideoControlsPanelVisibility}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<local:GlyphToggleButton Style="{StaticResource PlayPauseButtonStyle}"
|
||||
IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsPlaying, Mode=OneWay}"
|
||||
Command="MediaCommands.TogglePlayPause"/>
|
||||
<ContentControl Content="{TemplateBinding AdditionalMediaControlContent}" Margin="10 0 0 0"/>
|
||||
</StackPanel>
|
||||
<telerik:RadSlider x:Name="PART_ProgressTrackBar"
|
||||
Grid.Column="1"
|
||||
Margin="10 0"
|
||||
Minimum="0"
|
||||
MinWidth="70"
|
||||
ThumbVisibility="Hidden"
|
||||
IsMoveToPointEnabled="True"
|
||||
Template="{StaticResource MediaPlayerSliderTemplate}"/>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal">
|
||||
<TextBlock x:Name="PART_TrackInfo" VerticalAlignment="Center" Background="Transparent" />
|
||||
<local:GlyphToggleButton Style="{StaticResource MuteButtonStyle}"
|
||||
IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsMuted, Mode=TwoWay}"
|
||||
Margin="10 0 10 0" />
|
||||
<telerik:RadSlider x:Name="VolumeTrackBar"
|
||||
Width="70"
|
||||
Margin="0 0 10 0"
|
||||
Minimum="0"
|
||||
Maximum="1"
|
||||
Value="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Volume}"
|
||||
ThumbVisibility="Hidden"
|
||||
IsMoveToPointEnabled="True"
|
||||
Template="{StaticResource MediaPlayerSliderTemplate}"/>
|
||||
<local:GlyphToggleButton x:Name="PlaylistButton"
|
||||
IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=IsPlaylistOpen}"
|
||||
Style="{StaticResource PlaylistButtonStyle}" />
|
||||
<ContentControl Content="{TemplateBinding AdditionalSettingsContent}" Margin="10 0 0 0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger SourceName="PlaylistButton" Property="IsChecked" Value="True">
|
||||
<Setter TargetName="PlaylistPanel" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=CurrentPlaylistItem.IsVideo}" Value="True">
|
||||
<Setter TargetName="AudioVisual" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="PART_MediaElement" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<EventTrigger SourceName="PlayerRootPanel" RoutedEvent="MouseEnter">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="VideoControlsPanel" Storyboard.TargetProperty="Opacity" To="1" Duration="00:00:.7"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
<EventTrigger SourceName="PlayerRootPanel" RoutedEvent="MouseLeave">
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="VideoControlsPanel" Storyboard.TargetProperty="Opacity" To="0" BeginTime="00:00:.3" Duration="00:00:.7"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="MediaPlayerFullscreenWrapperTemplate" TargetType="local:MediaPlayerFullscreenWrapper">
|
||||
<ContentControl x:Name="PART_MediaPlayerPresenter" Content="{TemplateBinding MediaPlayer}"/>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style TargetType="local:MediaPlayer">
|
||||
<Setter Property="Background" Value="#B2000000" />
|
||||
<Setter Property="PlaylistItemTemplate" Value="{StaticResource PlaylistItemTemplate}" />
|
||||
<Setter Property="Template" Value="{StaticResource MediaPlayerTemplate}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="local:MediaPlayerFullscreenWrapper">
|
||||
<Setter Property="Template" Value="{StaticResource MediaPlayerFullscreenWrapperTemplate}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -0,0 +1,121 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
|
||||
xmlns:local="clr-namespace:MediaPlayer.Library">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Telerik.Windows.Controls;component/Themes/FontResources.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<ControlTemplate x:Key="GlyphButtonTemplate" TargetType="local:GlyphButton">
|
||||
<Grid Cursor="Hand">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="MouseOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphPresenter" Storyboard.TargetProperty="Foreground" Duration="0">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphPresenter" Storyboard.TargetProperty="Foreground" Duration="0">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="GlyphPresenter" Storyboard.TargetProperty="Opacity" Duration="0">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="0.5"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid x:Name="ContentPanel">
|
||||
<ContentPresenter />
|
||||
<TextBlock x:Name="GlyphPresenter"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="{StaticResource TelerikWebUI}"
|
||||
Text="{TemplateBinding GlyphValue}"
|
||||
FontSize="{TemplateBinding GlyphSize}"
|
||||
Margin="{TemplateBinding GlyphMargin}"
|
||||
Foreground="{TemplateBinding GlyphBrush}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="GlyphToggleButtonTemplate" TargetType="local:GlyphToggleButton">
|
||||
<Grid Cursor="Hand" Background="{TemplateBinding Background}">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="MouseOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphPresenter" Storyboard.TargetProperty="Foreground" Duration="0">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphPresenter" Storyboard.TargetProperty="Foreground" Duration="0">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{telerik:VisualStudio2013Resource ResourceKey=MouseOverBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="GlyphPresenter" Storyboard.TargetProperty="Opacity" Duration="0">
|
||||
<DiscreteDoubleKeyFrame KeyTime="0" Value="0.5"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="CheckStates">
|
||||
<VisualState x:Name="Checked" />
|
||||
<VisualState x:Name="Unchecked" />
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid x:Name="ContentPanel">
|
||||
<ContentPresenter />
|
||||
<TextBlock x:Name="GlyphPresenter"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="{StaticResource TelerikWebUI}"
|
||||
Text="{TemplateBinding GlyphValue}"
|
||||
FontSize="{TemplateBinding GlyphSize}"
|
||||
Margin="{TemplateBinding GlyphMargin}"
|
||||
Foreground="{TemplateBinding GlyphBrush}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style TargetType="local:GlyphButton" x:Key="GlyphButtonStyle">
|
||||
<Setter Property="GlyphBrush" Value="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}" />
|
||||
<Setter Property="GlyphSize" Value="16" />
|
||||
<Setter Property="Template" Value="{StaticResource GlyphButtonTemplate}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="GlyphToggleButtonStyle" TargetType="local:GlyphToggleButton">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="GlyphBrush" Value="{telerik:VisualStudio2013Resource ResourceKey=SelectedBrush}" />
|
||||
<Setter Property="GlyphSize" Value="16" />
|
||||
<Setter Property="Template" Value="{StaticResource GlyphToggleButtonTemplate}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="local:GlyphButton" BasedOn="{StaticResource GlyphButtonStyle}" />
|
||||
<Style TargetType="local:GlyphToggleButton" BasedOn="{StaticResource GlyphToggleButtonStyle}" />
|
||||
|
||||
<!--This is used to override the default RadButton styles with the custom implicit styles for GlyphButton-->
|
||||
<Style x:Key="{telerik:ThemeResourceKey ThemeType=telerik:Office_BlackTheme, ElementType=local:GlyphButton}"
|
||||
BasedOn="{StaticResource GlyphButtonStyle}"
|
||||
TargetType="local:GlyphButton"/>
|
||||
|
||||
<Style x:Key="{telerik:ThemeResourceKey ThemeType=telerik:Office_BlackTheme, ElementType=local:GlyphToggleButton}"
|
||||
BasedOn="{StaticResource GlyphToggleButtonStyle}"
|
||||
TargetType="local:GlyphToggleButton"/>
|
||||
</ResourceDictionary>
|
|
@ -0,0 +1,9 @@
|
|||
namespace MediaPlayer.Library
|
||||
{
|
||||
public enum TrackInfoMode
|
||||
{
|
||||
CurrentAndEndTime,
|
||||
RemainingTime,
|
||||
CurrentTime,
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче