I'm working on my eyetracking Windows Forms application. I need to play a video and keep track of eye movements simultaneously. Eyetracking part is done, now I need to open a video. I can open a DialogBox to choose which video to play, but I need to have a fullscreen, in order to make more accurate operations.
In my VideoStream class I have got :
public static string videoPath;
public VideoStream(string path)
{
InitializeComponent();
videoPath = path;
axWindowsMediaPlayer1.URL = videoPath;
axWindowsMediaPlayer1.Dock = DockStyle.Fill;
}
with the dockstyle fill, I can make my form maximized, but the video is just playing in a small screen like this
but what I want is actually this
I tried to use axWindowsMediaPlayer1.fullScreen = true; but just expands the borders of the form, not the video itself. How can I solve this?
Try adding these lines after initializeComponent():
FormBorderStyle = FormBorderStyle.None;
WindowsState = FormWindowState.Maximized;
TopMost = true;
Related
I am trying to play a video after a certain event is triggered.
Currently the video starts playing but it stays behind the form (You can see it playing in the opacity of the toolbar). I have tried to bring it to the front, refresh it, select it, update it but none of it seems to work. Also, if I manually open the windows media player program and close it the video "jumps" to the front of the screen.
This is the code used to start playing the video
wmp.settings.autoStart = true;
wmp.uiMode = "none";
wmp.Visible = true;
wmp.URL = #"C:\folder\video.mp4";
wmp.Update();
I also check if the video is still playing using the Status_Change event to set it to full screen and try to bring it to front
private void wmp_StatusChange(object sender, EventArgs e)
{
if (wmp.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
wmp.fullScreen = true;
wmp.BringToFront();
wmp.Update();
}
}
Despite these efforts the video still plays behind the form. Any suggestions would be appreciated!
I am using CefSharp.WinForms version 84.4.10.
My application is a wip game launcher for the games I make.
Screenshot of the launcher.
There is a Main form that loads and unloads child forms when buttons are pressed. The child forms contain a panel stretched to fill the whole child form. The CefSharp is initialized on the panel.
Here's the code that does that:
public CefSharp.WinForms.ChromiumWebBrowser browser;
private void Changelog_Load(object sender, EventArgs e)
{
browser = new CefSharp.WinForms.ChromiumWebBrowser("https://aerial-knightstudios.com/store/akslauncher/")
{
Dock = DockStyle.Fill,
Size = new Size(600, 600),
Location = new Point(200, 200),
};
this.panelChangelogPage.Controls.Add(browser);
}
When the child form is enabled, a black box appears that fills half the form then it flickers white then the webpage loads.
So far I have tried the following:
I have turned on double buffering by adding DoubleBuffered = true; inside public FormMain() and this made the flickering less intense, but it still flickers a lot.
I also changed [STAThread] in program.cs to [MTAThread]. This also helped, but very slightly.
Any solutions are welcome.
I am trying to create a form that is maxed out, without allowing the user to resize it. I tried to maximize the FormWindowState, and remove the minimize and maximize button. By setting this.MimimumSize and this.MaximumSize to this.Size (the maximized size), this should account to a maximized form.
Yet, when I run it, the form becomes a really small square. Any thoughts on how I can fix this?
public partial class Testscherm : Form
{
public Testscherm()
{
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MinimumSize = this.Size;
this.MaximumSize = this.Size;
this.MaximizeBox = false;
this.MinimizeBox = false;
InitializeComponent();
}
}
Try calling InitializeComponent() first, then add any statements which changes attributes/properties of the form. Otherwise, the designer generated code may undo any of changes you did beforehand.
Second, Form.Size does not deliver the form's size in maximized state. You could instead iterate over
System.Windows.Forms.Screen.AllScreens
then get the actual screen size along the lines of
System.Windows.Forms.Screen.AllScreens.First().WorkingArea.Size;
and assign it to this.Size;
Another problem here is, as soon as you assign this, this.MaximizeBox = false, Winforms forbids WindowState to be FormWindowState.Maximized. This is obviously "by design". What you probably want here is to use
this.FormBorderStyle = FormBorderStyle.None;
which does not only remove the maximum and minimum buttons, but also the close button. If you need such button, consider to add your own close button to the window.
Putting this all together gives
InitializeComponent();
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.None;
this.Size = System.Windows.Forms.Screen.AllScreens.First().WorkingArea.Size;
this.MinimumSize = this.Size;
this.MaximumSize = this.Size;
But: are you sure it is a good idea what you are trying there? How will this behave on a machine with two monitors of different resolution for example? It may be ok for a program which uses specific hardware and works as a dedicated software which takes over the machine exclusively (something like a Kiosk mode). Note the window may still be moved around using certain Win-<Key> keyboard shortcuts.
I'm developing an app in C#. This app will run on a PC and also in a WACOM tablet, which is a duplicated monitor of the PC.
I want to switch off or cover the tablet with an image because the client can't see the beginning and the end of the process. When the time is right, the tablet will turn on or the screensaver will be removed so that the client can interact and, once the client's actions are finished, the WACOM tablet returns to the initial state. How can I do this?
I've been searching and I've found how to switch off the principal monitor but I don't know how to switch off only the tablet. Also some kind of screensaver would be right, but I didn't found how to put an image only in one screen.
You didn't mention the framework you are working, assuming you can reference WinForms, here is a way to show a form maximized on a specific screen:
System.Windows.Forms.Screen[] screens;
screens = System.Windows.Forms.Screen.AllScreens;
System.Windows.Forms.Screen selectedScreen = screens[1]; // choose your preffered monitor
// Sets the form to show maximized on the selected screen:
form.Left = currentScreen.Bounds.Width;
form.Top = currentScreen.Bounds.Height;
form.StartPosition = FormStartPosition.Manual;
form.Location = currentScreen.Bounds.Location;
Point p = new Point(currentScreen.Bounds.Location.X, currentScreen.Bounds.Location.Y);
form.Location = p;
form.WindowState = FormWindowState.Maximized;
form.Show();
If you disable form borders and have a PictureBox docked to "Fill" displaying your selected image you will achieve your intended goal and cover your tablet screen with an image.
I am very new to c# and windows form.
What I am trying is to add a PictureBox to a windows form and display an animated .gif image before I display the data in the form.
Here is the code for the PictureBox :
private System.Windows.Forms.PictureBox pictureBox1;
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(374, 442);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(16, 16);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 19;
this.pictureBox1.TabStop = false;
this.pictureBox1.Visible = false;
Now, on a button click the gif image should be loaded in the picture box . The code for that goes like this :
private void scanButton_Click(object sender, EventArgs e)
{
pictureBox1.Visible = true;
pictureBox1.Refresh();
}
Now, when I click the button "Scan Button", the image becomes visible,but the animation is not working.
Please can anyone help me what is happening here ?
Thanks!
For your .gif animation to work, your main (UI) thread should be free. If you are performing any process on main thread then you will not get animation effect.
From your question, it seems like you are performing Scanning operation on click of button. That may be the problem.
To get rid of this problem, you will have to make sure that your main thread is free and any operation (like Scanning) should be on separate thread.
Just assign the path to the image in ImageLocation.
pictureBox1.ImageLocation = "C:\\throbber.gif";
The PictureBox will understand that it's an animated image and play it. Disabling the PictureBox or the Form will stop the animation from playing.
If you really need to use picture box you can iterate over a collection of images. But i strongly recommend using WebBrowser (mind it is basically IE)
This should help you with all animations using windows forms
Simple animation using C#/Windows Forms