2017-06-17 119 views
0

好的,所以我很难在WPF应用程序中嵌入Flash动画。我尝试了很多东西,但只有一件真正为我工作。将Flash嵌入到WPF应用程序

我找到了解决方案,所以我会在下面发布。

+0

您需要发布一个**特定的**问题,然后才能更容易地使用**特定的**正确的答案来解决它。尝试一些然后在卡住时也会问这里添加问题代码的代码段。例如,看右边的_Related_部分:[**在vb.net **中播放flash文件](https://stackoverflow.com/questions/13467108/playing-flash-file-in-vb-net? rq = 1) –

+0

实际上,我一直坚持我可以重现这个应用程序的方式......我不知道哪些工具可以帮助我做所有我想要的事情,因为我发现的大多数项目都有局限性由于微软许可证或其他事情。自从尝试了大约3天以来,我一直在努力挣扎...我知道这是更好的具体,但实际上我不能更多。我知道如何在WinForms中嵌入Flash,问题是实现_customizable_功能区。而在WPF中则相反,功能区几乎已经实现,但无法嵌入Flash。顺便说一下,我更喜欢留在WinForms上。 – Meivyn

+1

我终于设法在WPF中添加Flash,所以我会看看是否可以继续为我的项目,我会回来进一步的信息。我将用这个* specific *问题的解决方案编辑我的第一篇文章:p – Meivyn

回答

0

我找到了解决办法,我跟着本教程中,将C#到VB:http://blogs.microsoft.co.il/janiv/2009/09/20/embedding-and-communicating-with-the-macromedia-flash-player-in-wpf/

但最后,我成功地结束了只有30行代码做什么,我想在第一...

下面是从WinForm的用户控制的代码,WFFlashPlayer.vb

Imports System.Windows.Forms 

Namespace FlashAxControls 
    Partial Public Class WFFlashPlayer 
     Inherits UserControl 
     Public Sub New() 
      InitializeComponent() 
      AxShockwaveFlash.Base = "#" 
      AxShockwaveFlash.Movie = "#" 
     End Sub 
    End Class 
End Namespace 

在情况下,WFFlashPlayer.Designer.vb

Namespace FlashAxControls 
    Partial Class WFFlashPlayer 
     ''' <summary> 
     ''' Required designer variable. 
     ''' </summary> 
     Private components As System.ComponentModel.IContainer = Nothing 

     ''' <summary> 
     ''' Clean up any resources being used. 
     ''' </summary> 
     ''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
     Protected Overrides Sub Dispose(disposing As Boolean) 
      If disposing AndAlso (components IsNot Nothing) Then 
       components.Dispose() 
      End If 
      MyBase.Dispose(disposing) 
     End Sub 

#Region "Component Designer generated code" 

     ''' <summary> 
     ''' Required method for Designer support - do not modify 
     ''' the contents of this method with the code editor. 
     ''' </summary> 
     Private Sub InitializeComponent() 
      Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(WFFlashPlayer)) 
      Me.AxShockwaveFlash = New AxShockwaveFlashObjects.AxShockwaveFlash() 
      CType(Me.AxShockwaveFlash, System.ComponentModel.ISupportInitialize).BeginInit() 
      Me.SuspendLayout() 
      ' 
      'AxShockwaveFlash 
      ' 
      Me.AxShockwaveFlash.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ 
      Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) 
      Me.AxShockwaveFlash.Enabled = True 
      Me.AxShockwaveFlash.Location = New System.Drawing.Point(0, 0) 
      Me.AxShockwaveFlash.Margin = New System.Windows.Forms.Padding(0) 
      Me.AxShockwaveFlash.Name = "AxShockwaveFlash" 
      Me.AxShockwaveFlash.OcxState = CType(resources.GetObject("AxShockwaveFlash.OcxState"), System.Windows.Forms.AxHost.State) 
      Me.AxShockwaveFlash.Size = New System.Drawing.Size(1125, 825) 
      Me.AxShockwaveFlash.TabIndex = 0 
      ' 
      'WFFlashPlayer 
      ' 
      Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) 
      Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font 
      Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(239, Byte), Integer), CType(CType(239, Byte), Integer), CType(CType(242, Byte), Integer)) 
      Me.Controls.Add(Me.SimpleButton1) 
      Me.Controls.Add(Me.AxShockwaveFlash) 
      Me.Name = "WFFlashPlayer" 
      Me.Size = New System.Drawing.Size(1125, 825) 
      CType(Me.AxShockwaveFlash, System.ComponentModel.ISupportInitialize).EndInit() 
      Me.ResumeLayout(False) 
     End Sub 

#End Region 

     Private AxShockwaveFlash As AxShockwaveFlashObjects.AxShockwaveFlash 
    End Class 
End Namespace 

这里的WPF用户控件,FlashPlayer.xaml.vb

Imports System.Windows.Forms.Integration 

Namespace FlashAxControls 
    Partial Public Class FlashPlayer 
     Inherits UserControl 

     Private Sub FlashPlayer_Loaded(sender As Object, e As RoutedEventArgs) 
      Dim host As New WindowsFormsHost() 
      Dim player As New WFFlashPlayer() 

      host.Child = player 
      FlashPlayerGrid.Children.Add(host) 
     End Sub 
    End Class 
End Namespace 

FlashPlayer.xaml

<UserControl x:Class="FlashAxControls.FlashPlayer" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="300" Loaded="FlashPlayer_Loaded"> 
    <Grid x:Name="FlashPlayerGrid"> 

    </Grid> 
</UserControl> 

最后,这里是我的WPF应用程序的XAML代码(一点点定制):

<dxr:DXRibbonWindow x:Class="MyProject.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
     xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" 
     xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon" 
     xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
     xmlns:controls="clr-namespace:FlashAxControls.FlashAxControls;assembly=FlashAxControls" 
     Title="MainWindow" Height="922" Width="1127" Background="#FFEFEFF2" ResizeMode="CanMinimize" BorderEffect="Default" IsAeroMode="False" DisplayShowModeSelector="False" WindowStyle="SingleBorderWindow" ShowInTaskbar="True"> 
    <Grid> 
     <Grid HorizontalAlignment="Left" Grid.Row="1" Grid.ColumnSpan="2"> 
      <controls:FlashPlayer Height="825" Width="1125"/> 
     </Grid> 
    </Grid> 
</dxr:DXRibbonWindow> 

我希望这可以帮助别人。