Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Added a WinForms sample for initialization from code
Browse files Browse the repository at this point in the history
Rather than adding it in the designer
  • Loading branch information
jeremyVignelles committed Jan 20, 2019
1 parent f0d3e2a commit 0c8ee33
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Samples/Samples.WinForms.InitWithCode/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>
</configuration>
40 changes: 40 additions & 0 deletions src/Samples/Samples.WinForms.InitWithCode/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions src/Samples/Samples.WinForms.InitWithCode/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using Vlc.DotNet.Forms;

namespace Samples.WinForms.InitWithCode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var control = new VlcControl();


var currentAssembly = Assembly.GetEntryAssembly();
var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
// Default installation path of VideoLAN.LibVLC.Windows
var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));

control.BeginInit();
control.VlcLibDirectory = libDirectory;
control.EndInit();
this.Controls.Add(control);

control.Play(new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"));
}
}
}
22 changes: 22 additions & 0 deletions src/Samples/Samples.WinForms.InitWithCode/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Samples.WinForms.InitWithCode
{
static class Program
{
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Samples.WinForms.InitWithCode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Samples.WinForms.InitWithCode")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]

// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("a2c8dbd2-d3c5-416e-ab8e-fded1043fe79")]

// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{A2C8DBD2-D3C5-416E-AB8E-FDED1043FE79}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Samples.WinForms.InitWithCode</RootNamespace>
<AssemblyName>Samples.WinForms.InitWithCode</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Vlc.DotNet.Core.Interops\Vlc.DotNet.Core.Interops.csproj">
<Project>{dcf701c3-6635-4b9f-a90f-5d71b5bce0c7}</Project>
<Name>Vlc.DotNet.Core.Interops</Name>
</ProjectReference>
<ProjectReference Include="..\..\Vlc.DotNet.Core\Vlc.DotNet.Core.csproj">
<Project>{77e6622a-ce25-4571-a913-9c647f63477b}</Project>
<Name>Vlc.DotNet.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Vlc.DotNet.Forms\Vlc.DotNet.Forms.csproj">
<Project>{04de974c-bb77-45b3-889c-03640cffb91c}</Project>
<Name>Vlc.DotNet.Forms</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\VideoLAN.LibVLC.Windows.3.0.4\build\VideoLAN.LibVLC.Windows.targets" Condition="Exists('..\..\packages\VideoLAN.LibVLC.Windows.3.0.4\build\VideoLAN.LibVLC.Windows.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\VideoLAN.LibVLC.Windows.3.0.4\build\VideoLAN.LibVLC.Windows.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\VideoLAN.LibVLC.Windows.3.0.4\build\VideoLAN.LibVLC.Windows.targets'))" />
</Target>
</Project>
4 changes: 4 additions & 0 deletions src/Samples/Samples.WinForms.InitWithCode/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="VideoLAN.LibVLC.Windows" version="3.0.4" targetFramework="net471" />
</packages>
7 changes: 7 additions & 0 deletions src/Vlc.DotNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Core.Thumbnailer",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.WinForms.MultiplePlayers", "Samples\Samples.WinForms.MultiplePlayers\Samples.WinForms.MultiplePlayers.csproj", "{7EA1C3C5-72EA-4721-BD78-4FACBED5920C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.WinForms.InitWithCode", "Samples\Samples.WinForms.InitWithCode\Samples.WinForms.InitWithCode.csproj", "{A2C8DBD2-D3C5-416E-AB8E-FDED1043FE79}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AnyCPU = Debug|AnyCPU
Expand Down Expand Up @@ -106,6 +108,10 @@ Global
{7EA1C3C5-72EA-4721-BD78-4FACBED5920C}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{7EA1C3C5-72EA-4721-BD78-4FACBED5920C}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{7EA1C3C5-72EA-4721-BD78-4FACBED5920C}.Release|AnyCPU.Build.0 = Release|Any CPU
{A2C8DBD2-D3C5-416E-AB8E-FDED1043FE79}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{A2C8DBD2-D3C5-416E-AB8E-FDED1043FE79}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{A2C8DBD2-D3C5-416E-AB8E-FDED1043FE79}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{A2C8DBD2-D3C5-416E-AB8E-FDED1043FE79}.Release|AnyCPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -122,6 +128,7 @@ Global
{58B6FEE5-E2F8-4895-9147-00407C89F58E} = {44AE198F-A3F8-45F9-85CF-605858D6BD59}
{FAAE9D11-0762-43AF-91AD-DC28F275D1E6} = {44AE198F-A3F8-45F9-85CF-605858D6BD59}
{7EA1C3C5-72EA-4721-BD78-4FACBED5920C} = {44AE198F-A3F8-45F9-85CF-605858D6BD59}
{A2C8DBD2-D3C5-416E-AB8E-FDED1043FE79} = {44AE198F-A3F8-45F9-85CF-605858D6BD59}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8200848B-5F8D-4A79-B989-3A667BE003E0}
Expand Down

0 comments on commit 0c8ee33

Please sign in to comment.