StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Yuichi  
#1 Posted : Thursday, June 13, 2019 6:06:26 PM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Hi
I started to be interested in it for some time and have made several attempts but without success and I would like to ask if S + Net allows you to create your own window, for example a window similar to "MessegeBox" but with the CheckBox option?
Rob  
#2 Posted : Thursday, June 13, 2019 6:57:22 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
No, that would really be a bit complicated. It's very easy to do this yourself, though!

Just make a plug-in BigGrin (someone other than me needs to at some point!)

- Download Visual Studio 2019 Community Edition
- New Project (.Net Framework Class Library, select 4.6.2 as target, just to match S+)
- Add a Form (YuichiForm) to the solution and drag-and-drop some controls on it
- Rename Class1 to YuichiFormLibrary
- Add some public properties
- In the YuichiForm() constructor method, show the form
- Compile, take the DLL and add it in S+, reload

Obviously you'll want to wire some things up in the form to handle things, and perhaps return a value, which is returned, etc.

Here's a quick project I made you can use as an example: https://www.strokesplus.net/files/YuichiFormLibrary.zip

Edited by user Thursday, June 13, 2019 7:53:37 PM(UTC)  | Reason: Not specified

thanks 1 user thanked Rob for this useful post.
Yuichi on 6/13/2019(UTC)
Yuichi  
#3 Posted : Thursday, June 13, 2019 7:02:51 PM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Oh, thanks man. This is the answer I need. BigGrin
Rob  
#4 Posted : Thursday, June 13, 2019 7:10:41 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Oh yeah, here's the sample script I used to test:

Code:
var form = new YuichiFormLibrary();
var isChecked = form.ShowForm(false);
sp.MessageBox(isChecked, "Check Value");

Edited by user Thursday, June 13, 2019 7:34:44 PM(UTC)  | Reason: Not specified

Rob  
#5 Posted : Thursday, June 13, 2019 7:48:29 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Bah, I also forget to set the form's checkbox value on load (the parameter passed into ShowForm)...but you get the idea!
Rob  
#6 Posted : Friday, June 14, 2019 3:24:23 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
I updated the download to have some new functionality, primarily just made a function to get the form itself and I changed the Modifier properties of the form controls to Public so they can be accessed outside of the form.

https://www.strokesplus.net/files/YuichiFormLibrary.zip

Note: Remove the plug-in first, then add the updated DLL plug-in before using the script below.

So here's a more useful example of making a generic/reusable form:

Code:
var formLib = new YuichiFormLibrary();
var form = formLib.GetForm();

form.listBox1.Items.Add("Test Item 1");
form.listBox1.Items.Add("Test Item 2");
form.label1.Text = "This is a test";
form.button1.Text = "Click OK";

form.ShowDialog();
sp.MessageBox(form.listBox1.SelectedItem, "Selected Item");
sp.MessageBox(form.checkBox1.Checked, "Checkbox State");

It doesn't have any error handling, like if you close the form without selecting an item in the list box, you get an error, for example.
But this is just to give you some ideas.

You could also make use of the various containers, like flow/table/split layouts etc. You could make all of the controls Public and be able to set things in the script, like checkBox1.Visible = false; to hide it if you don't need it for a certain purpose, etc.

Could also make the YuichiFormLibrary a static class so you don't need to instantiate it to get a form, so it would be more like var form = new YuichiFormLibrary.GetForm();

The possibilities are endless!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.