Featured Post

Smart Product designer

download and purchase link:

Live preview :

Smart Product Designer is a  tool to create your own product and get directly from your website. It is well documented, very easy to customize and use. It is build using most advance technologies including javascript, jQuery and html5.
Features Choose different product from collectionAdd custom texts to product.Change text colorChange the size and font of the TextLet the user drag, move or remove elementsAdd images to product selected from art gallery or browse it from systemDesign both frontside and back-sideShows preview while designingDownload designVery easy to customize and useHere is the purchase link :

Enable, Disable and Start the task of task scheduler in C#.Net

Below function demonstrates how to enable, disable and run the already created scheduled task. It will first check if the task exists in task scheduler:

publicstaticvoidupdateUserTaskInScheduler(string action) { try { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C schtasks /query /TN <<TaskNameWithQuotes>>; //Check if task exists startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; startInfo.WindowStyle = ProcessWindowStyle.Hidden; if (System.Environment.OSVersion.Version.Major < 6) { startInfo.Verb = "runas"; } using (Process process = Process.Start(startInfo)) { // Re…

Text styling of HTML5 Canvas using fabricjs

In previous post I have shared code to add text to HTML5 canvas using fabricjs. refer

Here in this post below is the code to change text style to italic, making text bold and underline the text using fabricjs on html5 canvas.

This code will work when text object is selected.

<canvasid="c"width="600"height="600"></canvas><inputtype="text"class="add-text"><buttonclass="add-text-btn">Add Text</button><buttonclass="bold-text-btn">Bold</button><buttonclass="underline-text-btn">Underline</button><buttonclass="italic-text-btn">Italic</button>
javascript code:
// initialize fabric canvas and assign to global windows object for debugvar canvas =window._canvas =new fabric.Canvas('c'); fabric.Image.fromURL('', fun…

Drawing a dotted circle using C#.NET windows form

Dotted circle can be used for showing circular progress. Here is the code to draw a dotted/dashed circle using C# in windows form application:

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms; usingSystem.Drawing.Drawing2D; usingSystem.Threading; namespaceWindowsFormsApplication1 { publicpartialclassForm1 : Form { publicForm1() { InitializeComponent(); } int angle = 0; int Startangle = 0; privatevoidForm1_Load(object sender, EventArgs e) { } privatevoidpanel1_Paint(object sender, PaintEventArgs e) { //draw a dashed cricle using(Graphics g = panel1.CreateGraphics()) { System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(5, 5, 200, 200); g.SmoothingMode = Smoo…

Write text on HTML5 Canvas using fabricjs

Here is the code to add text on html5 canvas using fabricjs

<canvasid="c"width="600"height="600"></canvas><inputtype="text"class="add-text"><buttonclass="add-text-btn">Add Text</button>

Javascript code:
var canvas =window._canvas =new fabric.Canvas('c'); fabric.Image.fromURL('', function(img){ canvas.add(img.scale(1).set({ left:0, top:0, angle:0, selectable:false})); }); canvas.renderAll(); document.querySelectorAll('.add-text-btn')[0].addEventListener('click', function(){ var textToAdd =new fabric.Text(document.querySelectorAll('.add-text')[0].value, { fontFamily:'arial' }); canvas.add(textToAdd); });
Link for jsfiddle

Convert content of XML file to JSON string in C#.Net

Convert content of XML file to JSON string in C#.Net
The below function will convert the content of XML file to JSON string:

privatestringconvertXMLToJSON() { string xmlLogPath = "<<Path to the xml file>>"; // Load the XML filevar xDocument = System.Xml.Linq.XDocument.Load(xmlLogPath); // Read the XML file content and write it to stringstring xml = xDocument.ToString(); // Load the XML string XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); // Convert the XML string to JSON stringstring jsonText = JsonConvert.SerializeXmlNode(doc); //Release the memory doc = null; xmlLogPath = null; xml = null; xDocument = null; //Return the JSON stringreturn jsonText; } IMPORTANT NOTE:

Releasing object memory is very important. Even if your object went out of scope, it is not removed from the…

Display Tooltip for Combo Box item C#.NET Winforms

In windows form combo box control sometimes while adidng items dynamically we have items whose width is greater than width of combox box control. In this case for making UI more user friendly we can show tooltip over such item. Here is the sample C# code to display such tooltip:

 Add a Tooltip control on the form. Add following code :
this.combo_box1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.combo_box1.DrawMode = DrawMode.OwnerDrawFixed; this.combo_box1.DrawItem += new DrawItemEventHandler(combo_box1_DrawItem); this.combo_box1.DropDownClosed += new EventHandler(combo_box1_DropDownClosed); this.combo_box1.MouseLeave += new EventHandler(combo_box1_Leave); void combo_box1_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index <0) { return; } string text = combo_box1.GetItemText(combo_box1.Items[e.Index]); e.DrawBackground(); using (SolidBr…