Friday, January 23, 2015

System.Drawing - How to DrawString in high quality format?


g is a System.Drawing.Graphics object

g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High
g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit


Wednesday, January 7, 2015

how to change the html content of asp.net controls rendering/output

let's say you have a textbox ABC. and for that textbox you want the append some strings in it


ABC.SetRenderMethodDelegate(Sub(h As HtmlTextWriter, c As Control)

h.Write("Hello Textbox!")

end sub)


Some controls won't work, such as because they don't implement Render function. Solution is to wrap these kinds of control inside a Placeholder and set the SetRenderMethodDelegate to the Placeholder instead

Example : Let's say you want to append the string " Good Bye" in the output of xml web control

Code Front

< asp:placeholder id="p" runat="server" >

 < asp:xml runat="server" id="x" transformsource="sheet.xslt" />

< / asp:placeholder >






Code Behind

x.DocumentSource = "Some Xml"

p.SetRenderMethodDelegate(Sub(h As HtmlTextWriter, c As Control)

Dim sb As New Text.StringBuilder
Dim tw As New System.IO.StringWriter(sb)
Dim htmlTW As New HtmlTextWriter(tw)
x.RenderControl(htmlTW)
               h.write(sb.ToString() & " - Good Bye ")

end sub)

Monday, January 5, 2015

PhoneGap Desktop / Developer App - Timeout

If you get Timeout in the Phonegap Developer App when trying to connect to your development computer's IP address, one probable cause is the desktop app did not bind to the IP properly. And you have already opened that port in firewall settings

Example
Your PC IP is 192.168.1.10 , port 3000

One solution in windows is to direct that IP and port to localhost (127.0.0.1)


type netsh in command prompt (run as administrator)
>interface
>portproxy
>add v4tov4 listenaddress=192.168.1.10 listenport=3000 connectaddress=127.0.0.1 connectport=3000


now try to connect again using your mobile