ok i create new project with monodevelp and add this code :
using System;
using Gtk;
using GtkSharp;
using WebKit;
namespace browserapp
{
public class browser
{
public static void Main () {
Application.Init ();
Window window = new Window ("a browser in 12 lines...");
window.Destroyed += delegate (object sender, EventArgs e) {
Application.Quit ();
};
ScrolledWindow scrollWindow = new ScrolledWindow ();
WebView webView = new WebView ();
webView.Open ("http://mono-project.com");
scrollWindow.Add (webView);
window.Add (scrollWindow);
window.ShowAll ();
Application.Run ();
}
}
}
and i add all the reference that code need except for :
using WebKit;
and i search in monodevelop library reference and couldn't find webkit_sharp
so i searched in Google to find the library and i found this :
https://github.com/mono/webkit-sharp
but i couldn't manage how to build it in windows and extract the right dll file for reference so pls if someone can tell me how to build it in windows and i'm using mono develop the windows version thanks
You could download the suse rpm here: http://download.opensuse.org/repositories/openSUSE:/Factory/standard/noarch/webkit-sharp-0.3-7.2.noarch.rpm
It's just an archive. You could extract it and pull the dlls out. I'm not sure what you're trying to do would work though.
Related
I am totally blind, I use NVDA screen reader to operate my system, and I am trying to create a Windows desktop application. Visual Studio isn't screen-reader friendly, at least not the forms designer part. VS Code is pretty much accessible, although powershell's protools' designer isn't.
Whenever I see a question about writing GUI in WPF with pure code I find a lot of "why in the name of God would you want to do that? Use VS!" answers. Well, here is the reason, VS form designer is out of reach to blind programmers, so the least practical approach will have to do.
So, can it be done? Would you suggest any resources or approaches to this?
I'm going to try and build up from the other example to get you compile-able code. To get WPF working, you'll need a project that builds with WPF support.
The simplest way is to create a .csproj ourself and use the previously posted code-only solution.
So, start with a minimal App.csproj file as so:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
Then the app & window code in App.cs as before. I've added a couple controls to it, as you'll need a container anyway (I used StackPanel) if you want to start adding more stuff later.
using System;
using System.Windows;
using System.Windows.Controls;
public class App : Application {
protected override void OnStartup(StartupEventArgs e) {
base.OnStartup(e);
new MainWindow().Show();
}
[STAThread]
public static void Main() => new App().Run();
}
public class MainWindow : Window {
protected override void OnInitialized(EventArgs e) {
base.OnInitialized(e);
var panel = new StackPanel();
this.Content = panel;
var label = new Label { Content = "Click me:" };
panel.Children.Add(label);
var closeButton = new Button { Content = "Close", Height = 100 };
closeButton.Click += (sender, args) => this.Close();
panel.Children.Add(closeButton);
(this.Width, this.Height) = (200, 200);
}
}
You then build the whole project by using dotnet build. And you can run it with dotnet run or invoking the exe directly.
Alternatively, if you'd like to explore a WPF project with separate .xaml and .xaml.cs code, you can create your project using dotnet new wpf -o MyProjectName. This will produce a project, a xaml-based App, and a xaml-based form.
Yes. You can do WPF only with code.
Here is a simple example from http://www.java2s.com/Tutorial/CSharp/0470__Windows-Presentation-Foundation/CodeOnlyWPFApplicationSample.htm
using System;
using System.Windows;
using System.Windows.Controls;
public class App : Application {
protected override void OnStartup(StartupEventArgs e) {
base.OnStartup(e);
MainWindow window = new MainWindow();
window.Show();
}
[STAThread]
public static void Main()
{
App app = new App();
app.Run();
}
}
public class MainWindow : Window {
protected override void OnInitialized(EventArgs e) {
base.OnInitialized(e);
Button closeButton = new Button();
closeButton.Content = "Close";
this.Content = closeButton;
closeButton.Click += delegate {
this.Close();
};
}
}
Also, it might be easier to use WinForms since it uses C# as code-behind and less XML.
I am trying to make a small 2d game in c# using the RLNET library. The RLNET library has OpenTK as a dependency, so I added the latest versions of both RLNET and OpenTK to my project using the NuGet packages manager in Visual Studio. I was following along with a tutorial explaining how to work with these libraries. But, when I got to running the code I ran into a MissingMethodException at run-time.
The tutorial I was following along with is here: https://roguesharp.wordpress.com/2016/03/02/roguesharp-v3-tutorial-creating-the-project/
The Solution Explorer shows both libraries included in the project under the References dropdown. And I also included them in my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RLNET;
using OpenTK;
namespace Rouge_Game
{
class Program
{
private static readonly int _screenWidth = 100;
private static readonly int _screenHeight = 70;
private static RLRootConsole _rootConsole;
static void Main(string[] args)
{
// This must be the exact name of the bitmap font file we are using or it will error.
string fontFileName = "terminal8x8.png";
// The title will appear at the top of the console window
string consoleTitle = "RougeSharp V3 Tutorial - Level 1";
// Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
_rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
8, 8, 1f, consoleTitle);
// Set up a handler for RLNET's Update event
_rootConsole.Update += OnRootConsoleUpdate;
// Set up a handler for RLNET's Render event
_rootConsole.Render += OnRootConsoleRender;
// Begin RLNET's game loop
_rootConsole.Run();
}
// Event handler for RLNET's Update event
private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
{
_rootConsole.Print(10, 10, "It worked!", RLColor.White);
}
// Event handler for RLNET's Render event
private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
{
// Tell RLNET to draw the console that we set
_rootConsole.Draw();
}
}
}
The part of the code that has a run time error is this:
// Event handler for RLNET's Render event
private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
{
// Tell RLNET to draw the console that we set
_rootConsole.Draw();
}
When I run the project it compiles with no errors and the program launches, but then throws this exception:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void
OpenTK.Graphics.OpenGL.GL.BlendFunc(OpenTK.Graphics.OpenGL.BlendingFactorSrc, OpenTK.Graphics.OpenGL.BlendingFactorDest)'.
Source=RLNET
StackTrace:
at RLNET.RLRootConsole.Draw()
at Rouge_Game.Program.OnRootConsoleRender(Object sender, UpdateEventArgs e) in C:\Users\pjmul\source\repos\Rouge Game\Rouge Game\Program.cs:line 45
at RLNET.RLRootConsole.window_RenderFrame(Object sender, FrameEventArgs e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at OpenTK.GameWindow.OnRenderFrame(FrameEventArgs e)
at OpenTK.GameWindow.RaiseRenderFrame(Double elapsed, Double& timestamp)
at OpenTK.GameWindow.DispatchRenderFrame()
at OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second)
at OpenTK.GameWindow.Run(Double updateRate)
at RLNET.RLRootConsole.Run(Double fps)
at Rouge_Game.Program.Main(String[] args) in
C:\Users\pjmul\source\repos\Rouge Game\Rouge Game\Program.cs:line 32
I don't understand this error however as when I use the object viewer built into Visual Studio I can find the "missing" function when I open OpenTK.dll. Any suggestions as to how I might fix this error are greatly appreciated. I would also like to thank anyone who takes the time to help me in advance.
There is something wrong with the 3.x branch of OpenTK. Try downgrading your OpenTK package back to 2.x and it will work.
I'm trying to create a window and initializing a device to the window but every time I run the program the window does not load. I am doing this in visual studio 2015 for a windows forms application.
here the form1.cs:
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX.Direct3D;
namespace DirectXTutorial2
{
public partial class Form1 : Form
{
private Device device;
public Form1()
{
InitializeComponent();
InitializeDevice();
}
public void InitializeDevice()
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
}
private void Render()
{
device.Clear(ClearFlags.Target, Color.DarkSlateBlue, 0, 1);
device.Present();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Render();
}
}
}
Does anyone know of a solution to this?
I don't know if it helps but I am running windows 10, 64 bit, Directx 2010, and I have been added my references before.
okay, i have found a solution to my problem. DirectX for managed code is no longer supported by the devs. the latest framework that works for DirectX is .net Framework 3.5. managed code also does not support 64 bit. to fix this problem go to project properties. in the application tab find target framework and change your .net framework to 3.5 or less. next go to the build tab and find platform target, change this to x86.
First think use try catch in your application, because there is alot of stuff happening in DirectX, so you need to confirm the step, where you are getting error.
try
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed=true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing, presentParams);
}
catch (DirectXException)
{
return false;
}
Try to use different device type like DeviceType.Software.
After clearing your device add begin and end scene
device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
device.BeginScene();
device.EndScene();
device.Present();
And try calling your 'Render; function in 'Main' function
I want create a new component which shows a splash screen when i call the .show() method. The component must be like a Windows Form with an image and a duration in msec passed like parameters. What type of project should I choose in Visual Studio for do that? If I choose a ClassLibrary, it create a dll Class but if I choose a new ControlLibrary it create a new control, but I can't use a Windows Form.
protected int nSec;
public SplashScreen(string img, int nSec)
{
// duration
this.nSec = nSec;
// background splash screen
this.BackgroundImage = Image.FromFile("img.jpg");
InitializeComponent();
}
private void SplashScreen_Load(object sender, EventArgs e)
{
timer1.Interval = nSec * 1000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Close()
}
I want reuse this "component" in other future work without create a new one every time.
Avoid assuming there's magic behind these project templates, you can easily configure the project yourself. Using the Class Library project template is fine, just right-click the project after you created it, pick Add New Item and select "Windows Form". Other than adding the form and opening it in the designer, that also added two items to your project's References node: System.Drawing and System.Windows.Forms
Which you automatically get when you pick the "Windows Forms Control Library" project template. Which also automatically added a UserControl. Which you don't need, just right-click the UserControl1.cs item in the project and pick Delete. Add New Item to select "Windows Form", just as above. Two ways to get the same result.
Sounds like they want you to make a class library and have it create the form for you.
//Whatever other usings you want
using System.Windows.Forms; //Include the win forms namespace so you create the form
namespace ClassLibrary1
{
public static class Class1
{
public static Form CreateNewForm()
{
var form1 = new Form();
form1.Width = 200;
form1.Height = 200;
form1.Visible = true;
form1.Activate(); //Unsure if you need to call Activate...
//You're going to want to modify all the values you want the splash screen to have here
return form1;
}
}
}
So in another project, say a console app, I can just reference the class library I just made, call the CreateForm function and it's gonna make a form at runtime pop up with a width and height of 200.
using ClassLibrary1; //You'll need to reference this
//Standard console app template
static void Main(string[] args)
{
var x = Class1.CreateNewForm(); //Bam form pops up, now just make it a splash screen.
Console.ReadLine();
}
Hope that's what you were looking for
I'm trying to capture the camera feed from an EasyCap 4 Channel USB DVR Device that i got recently
and i have bought a super Mimi Monochrome/Color Camera and connected it to the DVR Device and managed to correctly setup the device with the driver "SMI Grabber" and installed the software that comes with the Device "SuperViewer"
and i have wrote a simple windows form application that contains a PictureBox to priview the camera feed
(There is an edit in the bottom)
The Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DirectX.Capture;
namespace DirectShowWithCrossbar
{
public partial class Form1 : Form
{
private CrossbarSource crossbar;
private Filters filters;
private Capture capture;
public Form1()
{
InitializeComponent();
filters = new Filters();
capture = new Capture(filters.VideoInputDevices[0], filters.AudioInputDevices[0]);
foreach (Filter device in filters.VideoInputDevices)
{
comboBox1.Items.Add(device);
}
if (comboBox1.Items.Count > 0)
comboBox1.SelectedIndex = 0;
foreach (Filter device in filters.AudioInputDevices)
{
comboBox2.Items.Add(device);
}
if (comboBox2.Items.Count > 0)
comboBox2.SelectedIndex = 0;
foreach (Source source in capture.VideoSources)
{
comboBox3.Items.Add(source);
}
if (comboBox3.Items.Count > 0)
comboBox3.SelectedIndex = 0;
ShowPropertPagesInMenuStrip();
crossbar = (CrossbarSource)capture.VideoSource;
crossbar.Enabled = true;
capture.PreviewWindow = pictureBox1;
}
private void ShowPropertPagesInMenuStrip()
{
foreach (PropertyPage pro in capture.PropertyPages)
{
menusToolStripMenuItem.DropDownItems.Add(new ToolStripMenuItem(pro.Name));
}
}
private void button1_Click(object sender, EventArgs e)
{
capture.Cue();
capture.Start();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
capture.Stop();
capture.Dispose();
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
capture.VideoSource = (Source)comboBox3.SelectedItem;
}
}
}
and i got a black screen in the picture box ??
and by mistake after closing my application i ran the SuperViewer application that comes with the DVR device and then open my application then my picture box began to show me the feed from the camera, strange!!! and the feed from the original software freezes !!
DirectX.Capture Example and Sources tried with the same result http://www.codeproject.com/Articles/3566/DirectX-Capture-Class-Library
and i have also used OpenCV and Touchless and i got the same result :(
Edit:
I have been searching and found that i need to get the filter (IAMCrossbar) i think that is the problem DirectShow USB webcam changing video source and after appling the changes in this link in the DirectX.Capture Wrapper i still get the same results :(
Thanks for any help in advance Yaser
If your capture device has option, to select one from multiple input interfaces, then yes, you are right about, that you needed to use IAMCrossbar.
If you want to stick to Directshow( as others have suggested OpenCV), then I would suggest,
Try building all capturing related code in a C++/CLI dll,
Build all your UI in C#.
You can take this MP3 Player Sample Project as starting point for your dll.
For capturing, AmCap is a detailed example.
What I mean is that you need to get the capturing code out of AmCap into above MP3 Player Sample dll, and expose it to your C# application.