I'm trying out C# WinForms with CefSharp (installed via Nuget (VS 2017)) but I can't get the refresh button to do anything. I've tried different variations, but nothing.
I have effectively two browsers, one to our epos and one to our local system. The forward and back buttons work okay between the two, but refresh doesn't do a damn thing.
This is what I have. I'm far from a coder so if anyone could point me in the right direction :-)
private void PictureBox5_Click(object sender, EventArgs e)
{
if (WFSbrowserkiosk != null)
WFSbrowserkiosk.Refresh();
if (WFSbrowservend != null)
WFSbrowservend.Refresh();
}
Related
I'm trying to create a simple application with two pages.
Using one window, I created a frame called frameHolder and within it, I want to open two pages, one is the MainMenuPage and the other is the PicturesPage. I can use frameHolder.Navigate(MainMenuPage) and frameHolder.Navigate(PicturesPage), but every time I click on the button of one of the pages, it creates another instead of going to the one which was already created.
In a simple application like mine there's no problem, but in a big application where you need to save memory it would. How can I verify if a page is open using Frame? If it's not I want to open, if it's open I want to go there.
---- I solved it, for the moment -----
As I said, it's a simple program that only have two pages. It makes it easy to fix using Frame.CanGoBack() and Frame.CanGoForward().
private void goMainMenu(object sender, MouseButtonEventArgs e)
{
if (frameHolder.CanGoBack == true)
{
frameHolder.GoBack();
}
else
{
frameHolder.Navigate(mainPage);
}
}
private void goPicturesPage(object sender, MouseButtonEventArgs e)
{
if (frameHolder.CanGoForward == true)
{
frameHolder.GoForward();
}
else
{
frameHolder.Navigate(picPage);
}
}
I'm basically telling the program that if I can go forward, then do it. If not, create a picPage, for example.
Not sure how I would do it if I had more than two pages though.
First off I would like to say that I am kinda new to visual studio C# (2 months in) & I've studied other languages but I know the fundimentals & the project is somewhat done, its just this one feature I cant seem to get the hang of.
So I am trying to connect a trackBar to my WinForm application which is a SoundBoard.
It is not driven by Windows Media Player it is simply just some resources (Audio Files)
It is a really boring project its really nothing special but I really cant seem to get the code to work.
(Will provide the .cs files if necessary)
What I am trying to accomplish is that I want to make a trackBar that connects to the winForm app & lets the user control the volume of the WinForm itself.
I know I need to set the min and max values according to my needs at the beginning, like in the Form_Load event.
E.g. the volume control uses percentage 0 - 100%
Then I need to set min=0, max=100.
the thing is, I have no idea how to do it, I have never seen any code that makes any sence in this scenario.
Here is the code for the trackBar, or this is what I've gotten so far. I know its not much but I am really bad with trackBars.
(Sorry for my bad english, not my native tounge.)
private void trackBar1_Scroll(object sender, EventArgs e)
{
trackBar1.Minimum = 0;
trackBar1.Maximum = 100;
}
This is the code for the sounds being played with each button that is named differently.
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.cow;
player.Play();
There is no sense in modifying the Minimum and Maximum values within an Scroll event. Just set these values to 0 and 100 in designer (Properties window).
Then, you will be able to use this event and control the volume through it:
private void trackBar1_Scroll(object sender, EventArgs e)
{
yourSoundPlayer.Volume = trackBar1.Value;
}
As you haven't told what you use for playing a sound, I have assumed the Volume property. However, it may be another in your case.
I have a WPF .NET 4.6 application running on a Windows 8.1 tablet and for the last few days I've been struggling to make my app touch friendly to make it work as expected. My main problems are focus related, these affect several controls in my app. for example:
Textboxes: sometimes requires a double or triple touch in order to get input focus, they do enter a mouse over state but the caret isn't there;
ComboBoxes: takes a couple of touches in order to open it, and once touching an item in order to select it the combo stays open with the newly selected item highlighted;
Buttons: takes a couple of clicks to run the connected command and stay in mouse over state;
Keyboard support
There are a couple of approaches I tried while searching for a solution that each has it's own downsides:
Removing the tablet support for the entire application (taken from here). this one solves most of the focus problems mentioned above but makes scrolling (and I guess some other Tablet related functionality that I haven't found yet) unusable.
Explicitly activating the keyboard when required (Example here). Focus problem remains, scrolling works as expected
I also tried to remove all styles and tested everything on 2 different tablets from different manufacturers but without success
Recently Microsoft announced that "Touch is better" But I couldn't find any official documentation about the best way to approach this subject.
Any suggestion on how to make my application work better with touch would be a big help.
I was able to remove mouse over state by using following behavior:
public class TouchDeviceMouseOverUIElementFixBehavior : Behavior<UIElement>
{
protected override void OnAttached()
{
AssociatedObject.StylusUp += AssociatedObject_StylusUp;
}
protected override void OnDetaching()
{
AssociatedObject.StylusUp -= AssociatedObject_StylusUp;
}
private void AssociatedObject_StylusUp(object sender, StylusEventArgs e)
{
var control = sender as FrameworkElement;
if (control != null)
{
if (!VisualStateManager.GoToElementState(control, "Normal", true))
{
VisualStateManager.GoToState(control, "Normal", true);
}
}
}
}
I have created a little Win Form App in C# and added the WebBrowser component to it. What i am trying to achieve is a little app that can load a local html page from a file which has "custom" protocols in it and can of course also navigate to a web address.
For example i would have entry as follows in my webpage
'Close Company</TD></TR>' which would open a task in a program.
The way i tried to achieve this was via the Navigating event as shown below
private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if ((webBrowser.StatusText.Contains("Special")))
{
//For some reason the stop doesn't do much it still tries to proceed to special:123
//diplaying can not load page..
webBrowser.Stop();
//Launch program here.
MessageBox.Show("Special Command Found");
}
}
Problem is that it still navigates and says it can't find of course the page.
I swapped Stop with GoBack which for some reason has the same issue the first time i run it and when i then select backward in the browser it works from thereon.
I also tried navigated and use of GoBack, besides having a flashing in the app from going back the event does not fire again after the first time anymore.
Has anyone any ideas how to solve this or what i am doing wrong here ?
Instead of using WebBrowser.Stop();
just set e.cancel = true;
Do any have any experience how this cold be done, if you look at the image im looking for a solution to programacly change the Name field to somehing else stored inn a variable from a other textbox.
i was thinking of using something like
private void button1_Click(object sender, EventArgs e)
{
var xBox = textbox1.value;
webBrowser1.Document.All.GetElementsByName("Name")[0].SetAttribute("Value", xBox);
}
but i dont know the name of the Textbox, and Sieble seems to be a java thing? so i cant see the source behind it? does anyone know how to solve this issue. im making a automate app to help at work for handeling over 100 cases a day. Instead of typing the names, im looking for a solution to populate by the click of a button.
I cant handel this by the sieble API because we dont have contorle of the Siebel develompent, and wold take years to get the Sieble department to implement somthing like this in to the GUI. so im making a desktop app that can handel the issue.
Sounds like you need to just search through the html (manually) until you find the names/ids of the fields you need to set.
Also, if the site supports Firefox, try using Firebug. In Firebug's inspect mode you can mouse over a text field and get the id of it.
My solution to this was using cordinates, and simulate keys klicks, im using Global Mouse and Keyboard Library for this, found at this location http://www.codeproject.com/KB/system/globalmousekeyboardlib.aspx
private void button1_Click(object sender, EventArgs e)
{
this.Location = new Point(0, 0);
inputBlocker();
xX = int.Parse(this.Location.X.ToString());
yY = int.Parse(this.Location.Y.ToString());
defaultMousePos();
//Thread.Sleep(600);
Cursor.Position = new Point(Cursor.Position.X + 1185, Cursor.Position.Y + 254);
//Thread.Sleep(600);
MouseSimulator.DoubleClick(MouseButton.Left);
KeyboardSimulator.KeyPress(Keys.T);
KeyboardSimulator.KeyPress(Keys.E);
KeyboardSimulator.KeyPress(Keys.S);
KeyboardSimulator.KeyPress(Keys.T);
KeyboardSimulator.KeyPress(Keys.O);
KeyboardSimulator.KeyPress(Keys.K);
KeyboardSimulator.KeyPress(Keys.Enter);
needUnblock = true;
inputBlocker();
}
#Darkmage - Is this a winforms application ?.If so did you not have any issues with loading the siebel activeX controls in the .NET webroswer control?