I have my own frontend just for Arduino Leonardo's and similar boards that use the Catarina bootloader that I currently use and this is the code I use to program them. I hope it is of use to you.
mySerial.Close();
Thread.Sleep(500);
int OldBaud = mySerial.BaudRate;
mySerial.BaudRate = 1200; // toggles the Leonardo into programming mode
mySerial.Open();
Thread.Sleep(1000);
mySerial.Close();
Thread.Sleep(4000);
int progPortNum;
//Note that the port is whatever com port it was before + 1
//So I grab the port number and add one to it here.
int.TryParse(mySerial.PortName.Replace("COM", ""), out progPortNum);
var app = new ConsoleAppLauncher.ConsoleApp(avrDudePath, String.Format(@"""-C{0}"" -v -patmega32u4 -cavr109 -P{1} -b57600 -D -Uflash:w:{2}:i", confPath, String.Format("COM{0}", progPortNum + 1), HexPath));
app.ConsoleOutput += updateListBox;
I have my own frontend just for Arduino Leonardo's and similar boards that use the Catarina bootloader that I currently use and this is the code I use to program them. I hope it is of use to you.