RichTextBox -- Preserving Horizontal Spacing - winforms

I would like to copy some lines from a .txt file into a RichTextBox in a Windows Form.
When I view the lines in Notepad++, they align evenly:
| a. XXXXXXXXXXXXXXXX . . .XXXXX__________ XXXXXXX__________ |
| b. XXXXXXXXXXXXXXXXX . . . . . . . . . . . . . . __________ |
When I add them to a RichTextBox, the alignment is lost, and the vertical bar at the end of the second line is indented twenty or so characters.
Does anyone have any suggestions about how I can preserve the alignment that I see in Notepad++?

You have to use a fixed-width spaced font, like Courier New or Consolas.

Related

Plotting irregularly-spaced arrays in gnuplot 5.x

gnuplot 5.x now supports arrays, but there seems to be no way to plot, or fit, to an irregularly-spaced set of data, if it is not provided in an external file. What I would like to see is the ability to plot "y vs x":
array z[8]=[0,1,2,3,4,5,6,6.4]
array f[8]=[0.468,0.405,0.342,0.279,0.216,0.153,0.090,0.064]
plot z,f
or even
plot [3,3],[0,0.25] w lines
which would, for example, provide a handy vertical marker line at x=3 without needing to resort to arrows without heads:
plot '+' using (3):(0):(0):(0.25) with vectors nohead
One can achieve the plotting in this awkward-looking way:
plot sample [j=1:|x|] '+' using (x[j]):(y[j])
but, unfortunately, the same syntax is not recognized by the fit command.
The only way I figured so far is to write the data to a virtual file (a data block), and use it as input to both plot and fit commands:
set print $DATA
print sprintf("# z\tf") ## header line, overwrite old content if any
set print $DATA append ## append data lines
do for [j=1:|z|] {
print sprintf("%f\t%f",z[j],f[j])
}
unset print
y(x)=m*x-y0
y0=0.25
m=1
fit y(x) $DATA via m,y0
plot $DATA t 'data',y(x) w lines t 'fit'
Is there a better way? Or can someone explain to me why such an obvious task is not a part of the standard plot/array implementation? It certainly would be one of the first things on my wish list.
What describe is exactly the purpose of data blocks:
$DATA <<EOD
0 0.468
1 0.405
2 0.342
3 0.279
4 0.216
5 0.153
6 0.090
6.4 0.064
EOD
y(x)=m*x-y0
y0=0.25
m=1
fit y(x) $DATA via m,y0
plot $DATA t 'data',y(x) w lines t 'fit'
Thanks Christoph for extensive help. It has emerged that data block syntax together with the appropriate "using" options would achieve what I had set out to do. Inline specification for a data block is perfectly compact, and the pre-processing can be replaced for both plot... and fit... with identical syntax:
$DATA <<EOD
0 0.468
1 0.405
2 0.342
3 0.279
4 0.216
5 0.153
6 0.090
6.4 0.064
EOD
y(x)=m*(x-x0)**2+y0
y0=0.9
m=-0.1
x0=4
fit y(x) $DATA using ($1):($1)*($2) via m,x0,y0
plot $DATA using ($1):($1)*($2) t 'data',y(x) w lines t 'fit'
To plot the data stored in arrays as it is, you can write it in the following way (I tried this in version 5.4).
array z[8]=[0,1,2,3,4,5,6,6.4]
array f[8]=[0.468,0.405,0.342,0.279,0.216,0.153,0.090,0.064]
plot z using (z[$0+1]):(f[$0+1])
At first glance, it seems that (z[$0+1]) in using can be replaced by 1, but in the version I tried, I had to do this.

Formatting generated data

I generated data - 1000 rows, used https://www.mockaroo.com
Matthew,Richards,2/2/1992,mrichards0#sbwire.com,86-(493)702-4682,0284 Artisan Avenue
Arthur,Myers,5/30/1959,amyers1#globo.com,56-(105)354-8682,5 Center Hill
Stephanie,Hayes,8/6/1976,shayes2#cdc.gov,62-(945)765-1251,979 Aberg Parkway
Lisa,Reynolds,5/10/1956,lreynolds3#i2i.jp,256-(450)430-9937,8 Aberg Terrace
Kathleen,Gonzales,12/11/1971,kgonzales4#sciencedirect.com,86-(745)695-8094,520 Basil Court
...
...
...
Now I need to add this to an array in C, so I want it to look like this:
{"Matthew","Richards","2/2/1992","mrichards0#sbwire.com","86-(493)702-4682","0284 Artisan Avenue"},
{"Arthur","Myers","5/30/1959","amyers1#globo.com","56-(105)354-8682","5 Center Hill"},
...
...
...
Do you know how to add quotes and braces? Is there and app/program which could do that?
open up your favorite text editor such as MS Word, Notepad++, Sublime Text, Atom, etc... even Notepad that comes with windows can do this
look for a find and replace option. (usual Ctrl + F does it), it's also usually under "Edit" on the menu bar.
replace all , with ","

How to select only few plot to output as a pdf in gnuplot

I'm plotting in a pdf with a double loop like this :
set terminal pdf
set output "fichier.pdf"
set datafile separator ","
set title "test"
set grid
set ylabel "y"
set xlabel "x"
set autoscale
set key on inside left top
do for [t1=0:1]{
do for [t2=0:1]{
plot 'AirEauG10VEtHDebit1mLMinute.dat' using ($1):($2/(80.4/($2+t1)**2)) title 'e='.t1
replot 'a.dat' using ($1):($2/(80.4/($2+t2)**2)) title 'e='.t2
}
}
unset output
Now, I'm having all the plots. Which are all the graphs one with only one plot, one with the two plots, one with only one plot etc. But I just want, in the pdf, to have the graphs with the two plots. How can I say to gnuplot to only save the graph with the two plots ?
So, instead of having 4 pages (2 with one plot and 2 with two plots), I would like to have only 2 pages (the ones with two plots on it).
Tell me if I'm not clear enough :D
Don't use replot for output to a file! That makes sense only for an interactive plotting terminal.
The plot command can have many plots, separated by a comma:
set terminal pdf
set output "fichier.pdf"
set datafile separator ","
f(x, t) = x/(80.4/(x + t)**2)
do for [t1=0:1] {
do for [t2=0:1] {
plot 'AirEauG10VEtHDebit1mLMinute.dat' u 1:(f($2, t1)) title 'e='.t1,\
'a.dat' u 1:(f($2, t2)) title 'e='.t2
}
}

Change Joomla 3 page title and site name separator from '-' to '|'

how would i change the joomla page title and site name separator from - to |. I know which file generates the file. It's located at C:\xampp\htdocs\Yoursitename\libraries\joomla\document\html\renderer\head.php
$buffer .= $tab . '<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>' . $lnEnd;
I just can't figure out where the getTitle function is coming from.
Thanks
It uses a language constant JPAGETITLE which in english is set to %1$s - %2$s
You can use the language override manager in your Joomla backend to change that.
The title itself is usually set in the view you look at. There JDocument->setTitle() is used. Like for example here for com_content, article view: https://github.com/joomla/joomla-cms/blob/staging/components/com_content/views/article/view.html.php#L256

$Email->attachments() does not attach file

We are using Cake's E-Mail class to send emails with attachments. It works fine for all cases except one and we are not able to figure out where the problem is.
Process:
A pdf-File is created & written to the file-system (file is written correctly and exists)
when the Email is sent the attachment is 0bytes in size (whereas the file to attach is created correctly in the file-system)
Working code:
// Write invoice as file
$CakePdf->write(APP . 'tmp' . DS . 'invoices' . DS . $invoiceNo . '.pdf');
[...]
// Send invoice to customer
$Email = new CakeEmail('invoice');
$Email->attachments(APP . 'tmp' . DS . 'invoices' . DS . $invoiceNo . '.pdf');
$Email->to($this->Invoice->Customer->getEmailAdress($customerId));
$Email->viewVars(array('invoice_no' => $invoiceNo));
$Email->send();
Not working code (attachment is zero bytes in size):
$CakePdf->write(APP . 'tmp'. DS .'certificates' . DS . $certLoginId . $certCourseId . '.pdf');
[...]
// Send certificate to customer
$Email = new CakeEmail('certificate');
$Email->attachments(APP . 'tmp'. DS .'certificates' . DS . $certLoginId . $certCourseId . '.pdf');
$Email->to($emailOfUser);
$Email->viewVars(array('courseName' => $certCourseName, 'probandName' => $probandName));
$Email->send();
Edit - there is no typo it is all correctly set. The problem seems to be, that the generation of a PDF by tcpdf runs asycnronously in the background. So when Cake tries to attach the file it is not written to the file system completly. So it cannot be attached.
If tried to let the script sleep for a while with no success:
echo '<br>';
echo $path_to_certificate;
echo '<br>';
echo filesize($path_to_certificate);
sleep(10);
echo '<br>';
echo $path_to_certificate;
echo '<br>';
echo filesize($path_to_certificate);
echo '<br>';
sleep(10);
echo $path_to_certificate;
echo '<br>';
echo filesize($path_to_certificate);
Outputs:
C:\xampp\htdocs\www\eflux_frontend\app\tmp\certificates\13750.pdf
0
C:\xampp\htdocs\www\eflux_frontend\app\tmp\certificates\13750.pdf
0
C:\xampp\htdocs\www\eflux_frontend\app\tmp\certificates\13750.pdf
0
Whereas the file is generated in the meantime, because I can see & access the file in the filesystem. It isn't a locking Problem because the other code works in a different place, but the file generated is smaller so it does not take up so much time to process.
How can I now ensure that the generation process is complete?
It seems that we are not able to ensure, that the PDF is properly created before attaching it to an email (maybe someon can give me a hand here).
Due to the fact, that the created PDF is written to a database an ugly workaround is possible: After the PDF is written to database, we can take it out of the database, write a file using the CakeFileHandler and attach this to the email which works for me:
// Workaround
$this->Certificate->recursive = -1;
$data = $this->Certificate->findById($cert_id);
$pdf = base64_decode($data['Certificate']['certificate_pdf']);
$path_to_certificate = APP . 'tmp'. DS .'certificates' . DS . $certLoginId . $certCourseId . '.pdf';
$certificate_file = new File($path_to_certificate);
$certificate_file->write($pdf);
[do mail stuff]
$certificate_file->delete();
$certificate_file->close();

Resources