Take a capture of form - vb.net

Problem : Form is divided in two parts.
Left side for enter information's. Right side for preview those information's.
On top of form there is a button called Send.
When i click on that button it need to take a snapshot of the right side and send it to email address provided as a attachment.
Solution : Take a snapshot of right side of form and save it to Temp folder
- Send a email and attach the file from temp folder
- Delete the file ( for any case )
Is it possible to take a ss and convert it to pdf ? is that a better way ?
I found a very helpfull class on forum Class for Screen Capture
But is there any way to use method without entering position of the screen.
Example : Right side of form is at GroupBox2 .
Is there any way to take a snapshoot of the groupbox2 on form?

Is there any way to take a snapshoot of the groupbox2 on form?
and save it to Temp folder
As suggested by user3697824, use Control.DrawToBitmap() with Path.GetTempFileName:
Dim bmp As New Bitmap(GroupBox2.Width, GroupBox2.Height)
GroupBox2.DrawToBitmap(bmp, New Rectangle(New Point(0, 0), bmp.Size))
Dim FileName As String = System.IO.Path.GetTempFileName
bmp.Save(FileName) ' save it as a Bitmap
' < or >
bmp.Save(FileName, Imaging.ImageFormat.Jpeg) ' save it as a Jpeg
' *Either way, the file will have the .TMP file extension!
Debug.Print(FileName)

Related

How to link webform through vb.net code parsing data.

net and I am trying to create a project that will handle questions from a text file and save the answers to a new text file. I was searching the internet and I couldn't find an example for linking two webform through vb code so here is my problem:
I want to preprocess a text file that will be uploaded in a specific form through vb.net . That context is parsed in a string table. Now I want that table to pass over to the rest of my forms which they will handle the data in order to modify the below webform. Here is where I want to call the other forms in order.
Private Sub BtdContinue_Click(sender As Object, e As EventArgs) Handles BtdContinue.Click
If FileUpl.PostedFile IsNot Nothing Then
Dim finalTextTable(rows.Length, 4) As String
'Preprocess
'for i=0 to finalTextTable.Lenght-1
' for j=0 to 4
'Call the other web form from here in a loop if possible
End if
Here is my web form with labels and images that I want every question to change it
I also want to be able to go to the previous webform through a
previous button.
If i did understand your question correctly you are asking to redirect the data from the preprocessed text file to another form. The easiest solution i can think of is by using session variables. After you have preprocessed your text file and stored it into a dataTable you should add the following:
'Set the value of DataTable to session
Session("DataTb") = finalTextTable
'Perform your Redirect
Response.Redirect("FormB.aspx");
The above code should save the table into a session variable accessible by FormB.aspx. You can then handle the table in the second form as you wish.

Show file input when click button event on LotusScript?

I am working with Lotus Domino. When I read the xml file I want to click on a button and it displays a form to let me select the file:
Sub Click(Source As Button)
//How to file input form display here
End Sub
There's still one more problem.I read the xml file and output data is documents:
Dim reader As New XmlNodeReader
Call reader.ReadFile(datas)
documents = reader.getNodeReaders("egov.document ")
Forall document In documents
//How to display list document for my form
End Forall
Please help me in the shortest possible time.Thanks all!!!!
To display a dialog that allows you to select a file, use the Prompt method of the NotesUIWorkspace class.
The rest of your question requires knowledge of the particular XML schema you are working with.

selectDialog with address bar instead of dropdown with Photoshop script

I'm writing a custom script for Photoshop to handle batch processing of images. I have two input folders and an output folder that I need to specify. Right now I'm using something like this to select my folders:
var inputFolder = Folder.selectDialog("Select a folder of images to process");
Because I'm working on a server with a pretty deep folder hierarchy, it can be a real pain to select through the drop-down menu that Photoshop presents to me in this dialog.
It would be so much easier to have a folder selection dialog with an address bar and quick access panel like this:
All other PS scripts that I've been digging around in use the Folder.selectDialog method to set file paths to a variable. Is there a reason for this? If not, then how can I instruct Photoshop the second style of folder navigation dialog?
It doesn't appear that Adobe supports this dialog as a folder selecting option.
There was a similar thread to this posted on the Adobe forums where a workaround was suggested:
https://forums.adobe.com/thread/1094128
The solution that was suggested is to use a saveDialog function instead of selectFolder. This gives you the folder dialog that we want, but comes with the downside of having to type a dummy name into the filename path. It also says "Save As" on the top of the dialog box, which is confusing.
Here's what was offered:
by lilsmokie on Nov 8, 2012 2:19 PM
var dskTop = Folder.desktop;
var dskPth = String(dskTop);
var newSpot = new File(dskPth+"/poop");
var selectedFolder = newSpot.saveDlg('Select Destination Folder');
var illFilePath = selectedFolder.path;
alert(illFilePath);
This opens the dialog at the desktop. Then put "poop" or whatever you
like in the text field. There the user can navigate to where ever.
When they it save illFilePath will have the folder path. Not perfect
but its close enough for me right now.
I've also discovered that I can set the starting location of the selectDialog by using selectDlg instead:
var outputFolder = Folder(app.activeDocument.path).selectDlg("Select a folder to output images to:");
This gives some control over the starting location so that the user doesn't have to click through a million dropdowns.
At the bottom of your first screenshot you can see the unput text area Folder: This PC. It works just like an address bar. You can type (or paste) something like \\server\work\folder\subfolder into this area and you get this folder ('subfolder' in this case) immediately.
On MacOS this dialog doesn't show the Folder: ... input area. But you can press Cmd-Shift-G and get the native system 'address bar' anytime.

Visual Basic 2010 - How to append certain areas of a text document using data collected in a form

I routinely reuse code for Cisco routers / switches and some web accelerators. I usually have to open the text document, edit a few IPs, host names, license keys etc. The remaining 98% of the text document stays the same. My end goal is to develop a program in Visual Basic (or whatever anyone can recommend would accomplish this easier) that will allow me to generate a text document with their data in the right place.
I have been able to develop a GUI form, it looks exactly how I want. I have a box to enter their hostname, classification, IP address etc; now, when I press the "Generate" button at the bottom, I want a new text document on the desktop. When you open the txt, all of their data has been appended to the document in the exact places it should be and all of my original text is still there, just the specific parts have been changed.
I've got the gui, just dont know where to add my existing code and how to make the different objects change their respective parts.
Hopefully this all makes sense. Thank you in advance, I really appreciate it.
Josh
Here is a quick and dirty example of my comment, using String.Replace to replace the placeholders. See if this helps you.
Imports System.IO
Public Class Form1
Private Sub generate_Click(sender As System.Object, e As System.EventArgs) Handles generate.Click
Dim temp As String = System.IO.File.ReadAllText("C:\temp\template.txt")
temp = temp.Replace("##placeHolder1##", TextBox1.Text) _
.Replace("##placeHolder2##", TextBox2.Text) _
.Replace("##placeHolder3##", TextBox3.Text)
File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\custom.txt", temp)
End Sub
End Class
To answer your question about embedding the file into the application. Yes it is possible just go to Project --> Properties --> Resources click Add Resource and select Add Existing File (Just make sure that your template has a .txt file extension, you can rename it to what you want when you save the file), then when you go to your solution explorer you will see a directory called Resources with template.txt in it. right click on it and select properties then select the Build Action Property to Embedded Resource this will embed the file into the program. You will then be able to access the template like this.
Dim temp As String = My.Resources.template

Add Each Generated Code To .txt File - VB.net

I Have Button and TextBox. When i click on the button random code generated (working well).
I want each code will be save in the same .txt file. Like this:
my.txt:
RandomCode1
RandomCode2
Random3
I mean when i click on the button the generated code will added to the .txt file (same .txt file for all)
Thank's.
Or (if it's possible)
when i click on the button the program generate random code i need tons like this so maybe i'll click on time and then the program will generate around 100 codes in every single click or the program will not stop until i'll click on another button.
(if it's not easy just help me with the first option.)
If you want to make 100 codes per click you can do a loop like
Dim inc as Integer = 0
Do Until inc = 100
'your code for making code
inc = inc + 1
loop
As for text file saving
Dim outfile As StreamWriter
outfile = File.AppendText("C:\data\codes.txt")
outfile.Write(TextBox1.text)
outfile.Flush()
outfile.Close()