Visual Studio 2015 How to run a .wsf with a button. Possible? - windows

Okay I have been trying to figure this out if anyone can help me I would be more then grateful.
The code is below im having an issue where it does not execute the .wsf
1. Does anyone see anything that im missing?
2. Am I approaching this correctly?
3.**The script is opening **cmd.exe and connecting to telnet and running commands.
namespace CamSwitch_V1._3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(#"cscript //B //Nologo c:\scripts\Cam1.wsf");
}
}
}
Let me know if you need any more information.

Related

Creating a Notepad- Windows forms

New in the business. Iam creating a windows form Notepad. How do I do the Button Open to open a file and a specific compatible file?
KInd off. I am creating a Notepad with Visual Studio. In the Menu strip, I created a buttion save and another open. De form design its ok, now I need to lear the code c#, to put in the event "Open file" in the notepad that I am creating.
public MeuBloco()
{
InitializeComponent();
}
private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog();
}
private void SalvarOK(object sender, CancelEventArgs e)
{
string caminho = saveFileDialog1.FileName;
File.WriteAllText(caminho, txbJanela.Text);
}
private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}
private void OpenOk(object sender, CancelEventArgs e)
{
}
}
}
// Now I need to code the event to open the file I want.

WebSocket4Net simple example fails with "Operation already in progress"

I'm trying to get a simple test going with Xamarin and WebSocket4Net but it fails on Open() with "Operation already in progress". Example code below:
using Xamarin.Forms;
using WebSocket4Net;
using System;
using SuperSocket.ClientEngine;
namespace SocketTest
{
public partial class SocketTest : ContentPage
{
private WebSocket websocket;
public SocketTest()
{
InitializeComponent();
}
void Handle_Clicked(object sender, System.EventArgs e)
{
websocket = new WebSocket("ws://echo.websocket.org/");
websocket.Opened += Websocket_Opened;
websocket.Error += Websocket_Error;
websocket.Closed += Websocket_Closed;
websocket.MessageReceived += Websocket_MessageReceived;
websocket.Open();
}
private void Websocket_Error(object sender, ErrorEventArgs e)
{
Console.WriteLine(e.Exception.Message);
}
private void Websocket_MessageReceived(object sender, EventArgs e)
{
Console.WriteLine(e.ToString());
}
private void Websocket_Closed(object sender, EventArgs e)
{
Console.WriteLine(e.ToString());
}
private void Websocket_Opened(object sender, EventArgs e)
{
websocket.Send("Hello World!");
}
}
}
I started with the standard multi-platform project (PCL) and added a button to initiate the connection.
Versions:
0.15.0 WebSocket4Net
0.8.0.13 SuperSocket
The PCL is configured with: .NET Standard Platform = netstandard1.4
I'm fairly new to .NET/Xamarin but have many years of software development behind me.
I've got the same issue with 0.15. Have you tried downgrading to 0.14, and removing SuperSocket?
There's a GitHub issue regarding this problem.
Getting this error when trying to connect in StartReceive()
Here's an excerpt:

GTK# - PropertyNotifyEvent doesn't seem to work

I try to make my app to react on property change of a widget, but the signal PropertyNotifyEvent is never invoke.
For test purpose i make a very simple application containing a label and a button. Pressing the button change text property of label but the PropertyNotifyEvent isn't responding.
using System;
using Gtk;
public partial class MainWindow : Gtk.Window
{
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
Build();
label1.AddEvents((int)(Gdk.EventMask.PropertyChangeMask));
}
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
protected void OnButton1Clicked(object sender, EventArgs e)
{
label1.Text = "new text";
}
protected void OnLabel1PropertyNotifyEvent(object o, PropertyNotifyEventArgs args)
{
Console.WriteLine("label property change");
}
}
I have no idea what I do wrong, do I missing something?
Found a solution:
label1.AddNotification("label", (o, args) => {Console.WriteLine("label property change");});

Call MarkerClick Method

I wonder how I could able to call MMap_MarkerClick from MMap_InfoWindowClick?
private void MMap_InfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
{
//call MMap_MarkerClick
}
private void MMap_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
{
ViewModel.MapMarkerSelected(e.Marker.Title);
}
I am trying to achive it, because MMap_InfoWindowClick does not open new ViewModel, but MMap_MarkerClick does. MarkerClick works but InfoWindowClick does not open ViewModel

Porting console based ui to a GUI one?

As most of you experienced, developing a console app is as easy as:
void mainloop(){
while (1){
giveInstructions();
getInput();
if (!process()) break;
printOutput();
}
}
int main(){
mainloop();
return 0;
}
However, in GUI it becomes an issue.
We can still giveInstructions(), process(), and printOutput(), but getInput() wouldn't work because it relies on an event, usually button click or key down.
How can I port a console app to a gui app with minimum code changes? (preferably do not change the main method, and as little change to the mainloop function as possible)
Note: I'm not too comfortable with threading yet.
Since there is no specific language given, I will show an example in C# where you would be able to use the same code as the console app with a simple GUI.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//using form-editor, double-click buttons or use the following
btnInput.Click += new EventHandler(btnInput_Click);
btnContinue.Click += new EventHandler(btnContinue_Click);
giveInstructions();
}
private void giveInstructions()
{
txtInfo.Text = "";
txtInput.Text = "";
//display instructions to multi-line textbox
}
private void btnInput_Click(object sender, EventArgs e)
{
//or you can just add another button for exit.
if (txtInput.Text == "expected value for exit")
{
Application.Exit();
}
else
{
getInput();
}
}
private void getInput()
{
string strInput = txtInput.Text;
//do stuff
printOutput();
}
private void printOutput()
{
//display output to multi-line textbox
}
private void btnContinue_Click(object sender, EventArgs e)
{
giveInstructions();
}
}

Resources