There is currently not an available WPF viewer for Active Reports 6. I was attempting to use a host control to display the viewer in a interop host but I'm not having much luck. Has anyone else attempted this successfully? I can't even get the wrapper Viewer control to add to the project toolbox as a custom control at this point. I'm hoping to avoid recreating the wheel.
The existing ActiveReports Viewer works fine in WPF. You can use the below XAML to host it in WPF:
<Window x:Class="ARViewerHostedInWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:arv="clr-namespace:DataDynamics.ActiveReports.Viewer;assembly=ActiveReports.Viewer6"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid>
<WindowsFormsHost Name="windowsFormsHost1">
<arv:Viewer x:Name="ARViewer" Dock="Fill" />
</WindowsFormsHost>
</Grid>
</Window>
The following code in the code-behind of the XAML file will connect a report to the viewer in the XAML above and run it:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
NewActiveReport1 rpt = new NewActiveReport1();
this.ARViewer.Document = rpt.Document;
rpt.Run();
}
}
I'm using the currently available version of ActiveReports 6 to test this.
Hope this helps!
Scott Willeke
GrapeCity
Related
I'm dealing with problem to show dwfx (auto cad) files in our WPF application. I'm using XpsDocument to show such a files.
Problem is lack of performance in case of more complex files. Sometime containing thousands of shapes, despite the fact we advise customers to export it as simple as they can.
By lack of performance I mean scroll and zoom when compared to Microsoft XPS viewer which opens this kind of files by default.
Have anybody experience with this? Can I achieve same scroll and zoom experience in WPF document viewer as I can see in Windows XPS viewer?
Sample file: https://1drv.ms/u/s!AhKm-nEB-Yrths4rY7b0V2rAWE4y1g (444 kB)
And this is how to show it in wpf app. xaml:
<Window x:Class="WpfApplication10.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Width="525"
Height="350">
<Grid>
<DocumentViewer x:Name="dv" />
</Grid>
</Window>
Code behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var file = #".\Plan-04.dwfx";
using (XpsDocument xpsDocument = new XpsDocument(file, FileAccess.Read))
dv.Document = xpsDocument.GetFixedDocumentSequence();
}
}
Currently i am using a simple PictureBox with GIF file inside and wonder if this is possible and if it does what the differences between this 2 options
This is what i have at this moment using PictureBox:
pictureBox1.BringToFront();
pictureBox1.Dock = DockStyle.None;
pictureBox1.Visible = true;
You can try hosting SilverLight inside Winforms.
While SilverLight is intended to be used in a web browser, WPF is more native to desktop, and WPF does have a simimar BusyIndicator, it is downloadable from CodePlex-Extended WPF Toolkit.
First define a WPF user control MyBusyIndicator.
<UserControl x:Class="Stackoverflow.MyBusyIndicator"
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"
xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<xctk:BusyIndicator IsBusy="True" />
</Grid>
</UserControl>
Then you can host this user control in Winform using an ElementHost, first you add the ElementHost from Form's designer, and in Form's constructor
public partial class MyForm : Form
{
public MyForm ()
{
InitializeComponent();
this.elementHost1.Child = new Stackoverflow.MyBusyIndicator();
}
}
The differences:
While BusyIndicator comes with some properties to let you customize the indicator, it adds a dependency on SL or WPF. With PictureBox all you need to do is preparing animated GIFs. There are many tools for generating animated GIFs.
I am creating a WPF Window in which I have text boxes. However, when I run the project in Debug mode, (F5), I am not able to edit the text boxes that I created, nor am I able to choose from the listbox that I created. I googled, found that WPF and Win32 need to communicate to accept keyboard input, and got these 3 lines :
Window w = new Window1();
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(w);
w.Show();
However, I am new to C# and hence I have absolutely no idea where to insert this C# code. I added the System.Windows.Forms and WindowsFormIntegration references to my project.
The window I am designing will be the first window that will appear at the launch of the application, hence I need the textboxes in this window to be editable without launching another window. Kindly guide me.
Edit : This is my XAML code:
<Window x:Name="Window1" x:Class="Myproject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Risk Assessment"
Height="741" Width="1216.091">
<GroupBox x:Name="GroupBox1">
<Grid>
<TextBox x:Name="Length" IsReadOnly ="False" IsEnabled="True" />
</Grid>
</GroupBox>
</Window>
This is my C# code:
namespace Myproject
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
Edit 2: I modified the first line in the App.Xaml code like this :
<Application x:Class="Myproject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">
And in the App.Xaml.cs I added this snippet:
private void Application_Startup(object sender, StartupEventArgs e)
{
MainWindow win = new MainWindow();
ElementHost.EnableModelessKeyboardInterop(win);
win.Show();
System.Windows.Threading.Dispatcher.Run();
}
But still no luck. Where am I going wrong?
Try to change your Application.xaml to include the StartupUri:
<Application x:Class="Myproject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"
>
Remove all the startup code you had in the cs file.
Or
Change your cs code to this:
Window1 window1 = new Window1();
this.ShutdownMode = ShutdownMode.OnMainWindowClose;
this.MainWindow = window1;
i am trying to run a .swf file in my WPF application, i have created a html page and in that i have referenced my .swf file using object tag and then loading that html page in my Main Window
my xaml looks like
<Window x:Class="sirajflash.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WebBrowser Name="myBrowser"></WebBrowser>
<!--<Frame Name="myframe"/>--> //tried with frame also but no luck
</Grid>
</Window>
assigning the source
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
myBrowser.Source = new Uri(CreateAbsolutePathTo("playflash.htm"), UriKind.Absolute);
}
private static string CreateAbsolutePathTo(string mediaFile)
{
return System.IO.Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, mediaFile);
}
}
The Problem:
when i run the application the warning occurs that ActiveX content is trying to access etc etc and when i allow it nothing appears in my main window the warning keeps on occuring multiple times.
if i run the flash movie in the browser directly it runs just fine.
Regards.
I have a flash based clock as a .swf file on my C:\Test\MyClock.swf
I have a htm file at C:\Test\MyHtml.htm
<embed src=C:\Test\MyClock.swf
width=200 height=200
wmode=transparent type=application/x-shockwave-flash>
</embed>
I have web browser control as below...
<Window x:Class="MyFlashApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WebBrowser Source="C:\Test\MyHtml.htm"></WebBrowser>
</Grid>
</Window>
On running the app, I see the webbrowser control giving warning as "To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options."
I accept the warning by right click and the left click "Allow Blocked Content". A confirmation popup appears to which I say Yes.
I see the Flash based clock.
WebBrowser control can support flash directly . If you don't need to present anything in HTML then you can directly provide the path to the flash file .
myWebBrowser.Source = "C:\Test\MyClock.swf"
However you will still get the IE warning message.
I want to embed the current Gecko in my WPF-Project.
I know there is the possibility with the Winforms-Host and the Skybound-Gecko-Library.
But I do not use the standard wpf-theme for my application. It is another and the scrollbar of the control will not be styled. Furthermore, this is an old library which is designed for Firefox 3.
Which is the best library/strategy to use the current Gecko in WPF?
You should have a look at these options, they all use Chromium:
paid: (Awesomium-based)
http://awesomium.com/ (is free for startups)
http://wpfchromium4.codeplex.com/ (uses awesomium)
free: (Chrome Embedded Framework-based)
https://github.com/chillitom/CefSharp (provides WinForms and WPF, but uses CEF1)
https://bitbucket.org/xilium/xilium.cefglue/wiki/Home (uses CEF3, and therefore supports Chrome's multi-process model, flash plugin, and WebGL)
You can probably use WindowsFormsHost, tutorial here
https://nhabuiduc.wordpress.com/2014/09/18/geckofx-net-webbrowser-setup-and-features/
the interesting part is
WindowsFormsHost host = new WindowsFormsHost();
GeckoWebBrowser browser = new GeckoWebBrowser();
host.Child = browser;
gridWeb.Children.Add(host);
WebKit.Net is free: http://sourceforge.net/projects/webkitdotnet/
Their GitHub page seems to have been more recently updated: https://github.com/webkitdotnet
Here is my answer. As stated by Roman, Gecko is Winforms-based, not WPF-based and so has to be incorporated via the WindowsFormsHost.
After creating the Visual Studio project, install the Gecko package via NuGet, using the command: Install-Package Geckofx45
Make sure the WindowsFormsIntegration and System.Windows.Forms references have been added to your project.
In your Configuration Manager, set your configuration to 32-bit, to get rid of the compiler warnings.
Update MainWindow.xaml 'Grid' element to give it a name and the handler for the 'Loaded' event
<Grid
Name="GridWeb"
Loaded="Window_Loaded">
</Grid>
Modify MainWindow.xaml.cs to incorporate the Gecko as well as make it navigate to a page on loading:
public MainWindow()
{
InitializeComponent();
Gecko.Xpcom.Initialize("Firefox");
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowsFormsHost host = new WindowsFormsHost();
GeckoWebBrowser browser = new GeckoWebBrowser();
host.Child = browser;
GridWeb.Children.Add(host);
browser.Navigate("http://www.google.com");
}
I struggle using the SO code editor, so for more detailed explanations and screenshots, see this blog page.
This is an old question, but I came up with a pseudo-solution to add GeckoFX as a XAML tag such as:
<local:GeckoBrowser Width="400" Height="250" />
This can be accomplished by simply wrapping the whole thing in a UserControl such as:
XAML:
<UserControl x:Class="WpfApp1.Browser"
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"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Border x:Name="border" Background="Black" Margin="0"></Border>
</UserControl>
C#:
public partial class Browser : UserControl
{
WindowsFormsHost host = new WindowsFormsHost();
GeckoWebBrowser browser = new GeckoWebBrowser();
public Browser()
{
InitializeComponent();
Xpcom.Initialize("Firefox");
browser.Navigate("http://www.google.com");
host.Child = browser;
border.Child = host;
}
}
Now, you can use the tag in WPF, in the same project where the UserControl exists.
I have been trying to get this to work as a Control in a library, so I can easily port it to any other project/solution, but it keeps giving me an error about mozglue.dll missing. I suspect this is due to the Xpcom.Initialize("Firefox") but I need to investigate further.