Thursday, June 24, 2010

7-Zip Theme Manager

http://7ztm.de.vu/

Many users of the excellent file archiver 7-Zip criticized its nostalgic appearance. That's exactly where my program "7-Zip Theme Manager", in short "7zTM", comes in and offers the following features:

Stylish...
  • Toolbar Themes - change the look of the toolbar of 7-Zip
  • Filetype Themes - change the look of archived files, for instance in Explorer
  • *new* 90 Toolbar Themes and 22 Filetype Themes integrated
  • *new* changing the SFX-icon (self-extracting archive) is now possible - see FAQ #5
Handy...
  • automatic or manual search of the 7-Zip installation folder
  • convenient activation of the Themes with just a click
  • Themes previews integrated directly into the program
  • multi-lingual user interface
  • online update for up to date Themes and features - see FAQ #6
  • possibility to create your own Themes
  • *new* supports 7-Zip 32-Bit and 64-Bit

Costs?

0, Nichts, Nada, Niente, Nothing, Rien, Tipota, 12-3x4

Bild "German:7ztm_preview_2.jpg"

Bild "German:7ztm_preview_1.jpg"

Sunday, June 13, 2010

ImageShack.us image upload (C# code)

Spent a couple hours yesterday looking for some code to upload images to ImageShack.us (I need it for a XBMC for Xbox remote control app I’m writting) and thought I might share the code.

The image I have is already available in a PictureBox and this only concentrates on the upload itself, won’t go into parsing the XML reply, that should be fairly easy to implement it yourself…

More information about the ImageShack.us Upload API and how to apply for a key here:
http://code.google.com/p/imageshackapi/wiki/ImageshackAPI

Working example here:
https://code.google.com/p/dandar3-apps/source/browse/#svn/trunk/ImageShack Upload

/**
 * ImageShack Unified upload API
 * http://code.google.com/p/imageshackapi/wiki/ImageshackAPI
 */
private void buttonUpload_Click(object sender, EventArgs e)
{
  //
  Cursor.Current = Cursors.WaitCursor;

  //
  // Init
  //
  String      filename    = "fake_name";
  String      mimeType    = "image/jpeg";
  ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;

  //
  // Prepare POST contents...
  //
  MemoryStream memoryStream = new MemoryStream();

  // Parts boundary
  String boundary = "-------" + DateTime.Now.Ticks.ToString("x");
  String crlf     = "\r\n";
  
  // Image file...
  write(memoryStream, "--" + boundary + crlf);
  write(memoryStream, String.Format("Content-Disposition: form-data; name=\"fileupload\"; filename=\"{0}\"", filename) + crlf);
  write(memoryStream, String.Format("Content-Type: {0}", mimeType) + crlf);
  write(memoryStream, crlf);
  
  pictureBox.Image.Save(memoryStream, imageFormat);
  write(memoryStream, crlf);
  
  // Other parameters (Key, Username, Password etc)
  NameValueCollection parameters = new NameValueCollection();
  parameters.Add("key",        "your_key");
  parameters.Add("a_username", "your_username");
  parameters.Add("a_password", "your_password");
  parameters.Add("tags",       "your_tags");

  foreach (String param_name in parameters.Keys)
  {
    write(memoryStream, "--" + boundary + crlf);
    write(memoryStream, String.Format("Content-Disposition: form-data; name=\"{0}\"", param_name) + crlf);
    write(memoryStream, crlf);
    write(memoryStream, parameters.Get(param_name));
    write(memoryStream, crlf);
  }

  // End...
  write(memoryStream, "--" + boundary + crlf);
  
  //
  // Upload (POST)...
  //
  try
  {
    HttpWebRequest webRequest = (HttpWebRequest) HttpWebRequest.Create("http://www.imageshack.us/upload_api.php");
    webRequest.ContentType    = "multipart/form-data; boundary=" + boundary;
    webRequest.Method         = "POST";

    //
    // Request
    //
    webRequest.ContentLength = memoryStream.Length;
    using (Stream requestStream = webRequest.GetRequestStream())
    {
      memoryStream.Seek(0, SeekOrigin.Begin);
      memoryStream.WriteTo(requestStream);
    }

    //
    // Response
    //
    using (WebResponse  webResponse  = webRequest.GetResponse())
    using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
    {
      String imageshackReply = streamReader.ReadToEnd().Trim();
      MessageBox.Show(imageshackReply, "HTTP POST Response", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
  }
  catch (Exception ex)
  {
    MessageBox.Show(ex.Message, "HTTP POST Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  }

  //
  // Clean-up...
  //
  memoryStream.Close();
}

/**
 * 
 */
private void write(MemoryStream p_memoryStream, String p_data)
{
  byte[] bytes = Encoding.ASCII.GetBytes(p_data);
  p_memoryStream.Write(bytes, 0, bytes.Length);
}

Saturday, June 12, 2010

Network Monitor v0.8

Network Monitor, 0.8 - 12 June 2010

[download: binaries | sources]

  • remeber last used network device;
  • rewrite 4 GB "wrapping" logic;
  • embed readme.txt (display in About box);

imageimage