About DiamondDrake

Known as DiamondDrake on 25+ forums, Real name: Rickey Ward. Formerly springfield, Tn, now resides in Columbia, SC

PackageTracker for windows phone 7 released

by DiamondDrake 3. May 2011 01:34

I just released packagetracker for windows phone 7 a great tool for tracking packages from DHL, UPS, USPS, and FexEx. Check it out in the zune marketplace or watch this demo video to see more.

 

Tags: ,

Programming

New venture, windows phone 7 development

by DiamondDrake 28. February 2011 17:33

Recently I have been learning silverlight optimized for windows phone 7. I switched to a Samsung Focus with Windows Phone 7 and I am 70% through development for a package tracking application that will go on the market for 99 cents. Reading the numbers on line, the platform isn't quite popular enough to make applicattions sold extremely profitable, A very successful application can look at 40 dollars a month profit, where most applications might look at 2 to 3 dollars a month. But as phone numbers increase, there is a good change that a application that got its foot inthe door early might have a big advantage. So here I am, learning silverlight and working on what seems to be a very useful and attractive application.

Tags:

Personal | Programming

Some site changes that need to be made

by DiamondDrake 26. December 2010 21:10

I have been noticing some issue with the new site's XML storage system. I knew using XML for storing data that only I would change is no problem. It works very well. But for the counters it's just not working out well. Not to metion that it kind of keeps me from adding comment sections on the software pages. which I plan on doing. So I think I am going to migrate to jet databases for simple comments and (note to self) store the home page's html in an xml doc that is editable in place so I can easily update the homepage from anywhere.

But first I need to finish a couple controls I am working on, and add a new section to the site, a .net control library section. I am working on a few custom controls that i really would like to share with the world.

Tags: ,

Site

Vista/Seven Style Question Box

by DiamondDrake 19. December 2010 23:13

I wanted a managed API free way to easily display a question Vist/Seven style task dialog in C#. So I hacked up a custom control, laid out a form and threw together a static class to make it easy to show like the standard winforms messagebox.

//2010 Rickey Ward Diamonddrake.com
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DiamondDrake.Forms
{

    public class frmQuestionBox : Form
    {
        public frmQuestionBox()
        {
            InitializeComponent();
            this.Icon = SystemIcons.Question;
            pictureBox1.Image = SystemIcons.Question.ToBitmap();
        }

        public frmQuestionBox(string caption, string question)
            : this()
        {
            this.Text = caption;
            this.QuestionText = question;
            this.DescriptionText = string.Empty;
        }

        public frmQuestionBox(string caption, string question, Image Image24x24)
            : this()
        {
            this.Text = caption;
            this.QuestionText = question;
            this.DescriptionText = string.Empty;
            pictureBox1.Image = (Image)Image24x24.Clone();
        }

        public frmQuestionBox(string caption, string question, string description)
            : this()
        {
            this.Text = caption;
            this.QuestionText = question;
            this.DescriptionText = description;
        }

        public frmQuestionBox(string caption, string question, string description, Image Image24x24)
            : this()
        {
            this.Text = caption;
            this.QuestionText = question;
            this.DescriptionText = description;
            pictureBox1.Image = (Image)Image24x24.Clone();
        }

        public string QuestionText
        {
            get { return this.lblbx_question.Text; }
            set { this.lblbx_question.Text = value; }
        }

        public string DescriptionText
        {
            get { return this.lblbx_descripton.Text; }
            set { this.lblbx_descripton.Text = value; }
        }

        #region VSDesigner stuff

                /// 
        /// Required designer variable.
        /// 
        private System.ComponentModel.IContainer components = null;

        /// 
        /// Clean up any resources being used.
        /// 
        /// true if managed resources should be disposed; otherwise, false.
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// 
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// 
        private void InitializeComponent()
        {
            this.pnlButtons = new System.Windows.Forms.Panel();
            this.btnCancel = new System.Windows.Forms.Button();
            this.btnOK = new System.Windows.Forms.Button();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.lblbx_question = new DiamondDrake.Controls.LabelBox();
            this.lblbx_descripton = new DiamondDrake.Controls.LabelBox();
            this.pnlButtons.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();
            // 
            // pnlButtons
            // 
            this.pnlButtons.BackColor = System.Drawing.SystemColors.Control;
            this.pnlButtons.Controls.Add(this.btnCancel);
            this.pnlButtons.Controls.Add(this.btnOK);
            this.pnlButtons.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.pnlButtons.Location = new System.Drawing.Point(0, 105);
            this.pnlButtons.Name = "pnlButtons";
            this.pnlButtons.Size = new System.Drawing.Size(335, 39);
            this.pnlButtons.TabIndex = 0;
            // 
            // btnCancel
            // 
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.No;
            this.btnCancel.Location = new System.Drawing.Point(171, 8);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(75, 23);
            this.btnCancel.TabIndex = 1;
            this.btnCancel.Text = "No";
            this.btnCancel.UseVisualStyleBackColor = true;
            // 
            // btnOK
            // 
            this.btnOK.DialogResult = System.Windows.Forms.DialogResult.Yes;
            this.btnOK.Location = new System.Drawing.Point(252, 8);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(75, 23);
            this.btnOK.TabIndex = 0;
            this.btnOK.Text = "Yes";
            this.btnOK.UseVisualStyleBackColor = true;
            // 
            // pictureBox1
            // 
            this.pictureBox1.Location = new System.Drawing.Point(12, 12);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(48, 48);
            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
            this.pictureBox1.TabIndex = 1;
            this.pictureBox1.TabStop = false;
            // 
            // lblbx_question
            // 
            this.lblbx_question.BackColor = System.Drawing.Color.Transparent;
            this.lblbx_question.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
            this.lblbx_question.ForeColor = System.Drawing.Color.Blue;
            this.lblbx_question.HorizontalAlignment = System.Drawing.StringAlignment.Near;
            this.lblbx_question.Location = new System.Drawing.Point(66, 12);
            this.lblbx_question.Name = "lblbx_question";
            this.lblbx_question.Size = new System.Drawing.Size(257, 48);
            this.lblbx_question.TabIndex = 2;
            this.lblbx_question.Text = "This is a sample question?";
            this.lblbx_question.VerticalAlignment = System.Drawing.StringAlignment.Center;
            // 
            // lblbx_descripton
            // 
            this.lblbx_descripton.BackColor = System.Drawing.Color.Transparent;
            this.lblbx_descripton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblbx_descripton.HorizontalAlignment = System.Drawing.StringAlignment.Near;
            this.lblbx_descripton.Location = new System.Drawing.Point(12, 66);
            this.lblbx_descripton.Name = "lblbx_descripton";
            this.lblbx_descripton.Size = new System.Drawing.Size(311, 33);
            this.lblbx_descripton.TabIndex = 3;
            this.lblbx_descripton.Text = "This is a sample description";
            this.lblbx_descripton.VerticalAlignment = System.Drawing.StringAlignment.Near;
            // 
            // frmQuestionBox
            // 
            this.AcceptButton = this.btnOK;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.White;
            this.CancelButton = this.btnCancel;
            this.ClientSize = new System.Drawing.Size(335, 144);
            this.Controls.Add(this.lblbx_descripton);
            this.Controls.Add(this.lblbx_question);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.pnlButtons);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "frmQuestionBox";
            this.ShowInTaskbar = false;
            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "frmQuestionBox";
            this.TopMost = true;
            this.pnlButtons.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Panel pnlButtons;
        private System.Windows.Forms.Button btnCancel;
        private System.Windows.Forms.Button btnOK;
        private System.Windows.Forms.PictureBox pictureBox1;
        private DiamondDrake.Controls.LabelBox lblbx_question;
        private DiamondDrake.Controls.LabelBox lblbx_descripton;

        #endregion


    }

    public static class QuestionBox
    {
        public static DialogResult Show(string caption, string question)
        {
            using (frmQuestionBox dialog = new frmQuestionBox(caption, question))
            {
                return dialog.ShowDialog();
            }    
        }

        public static DialogResult Show(string caption, string question, string description)
        {
            using (frmQuestionBox dialog = new frmQuestionBox(caption, question, description))
            {
                return dialog.ShowDialog();
            }
        }

        public static DialogResult Show(string caption, string question, string description, Image Image24x24)
        {
            using (frmQuestionBox dialog = new frmQuestionBox(caption, question, description, Image24x24))
            {
                return dialog.ShowDialog();
            }
        }

        public static DialogResult Show(string caption, string question, Image Image24x24)
        {
            using (frmQuestionBox dialog = new frmQuestionBox(caption, question, Image24x24))
            {
                return dialog.ShowDialog();
            }
        }
    }
}

namespace DiamondDrake.Controls
{
    public class LabelBox : Control
    {
        public LabelBox()
        {
            //Set up double buffering and a little extra.
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer |
            ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor,
            true);

            //set up some default values
            this.BackColor = Color.Transparent;
            _stringformat = new StringFormat();
            _stringformat.LineAlignment = StringAlignment.Near;
            _stringformat.Alignment = StringAlignment.Center;
            this.Font = new Font("Microsoft Sans Serif", 12F);
        }

        private StringFormat _stringformat;

        public StringAlignment VerticalAlignment
        {
            get { return _stringformat.LineAlignment; }
            set { _stringformat.LineAlignment = value; this.Invalidate(); }
        }
        public StringAlignment HorizontalAlignment
        {
            get { return _stringformat.Alignment; }
            set { _stringformat.Alignment = value; this.Invalidate(); }
        }
        

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.ClientRectangle, _stringformat);
        }


    }
    
}

Tags:

Programming

Today I missed my bestfriend's daughter's 1st Birthday...

by DiamondDrake 15. November 2010 06:15

Today I missed my best friend Louis' daughter Abigail's first birthday, It's starting to really sink in that I don't live in Springfield anymore. My sister and her husband Andrew have really made me feel at home here, just like their family had 6 people instead of 4 so its been easier than I though to keep my head up and my eyes toward the future. Still hit me hard though when I realized that I wouldn't be there, that it's been two months since I broke away from Springfield.

I owe much of my sanity to Louis and Sabrina D'Antonio. They helped me through hard times, supported me through my endeavors, and believed in me when most people didn't. Louis himself provided me with the opportunity to make the money that paid for the truck that I needed to move to SC and for all these reasons and many more I love them.

Sorry I coudln't be there today guys, know that I wanted to.

Rickey Ward
(DiamondDrake)

 

Tags: , , ,

Personal

Forms of the "InvokeRequired" cross-thread pattern

by DiamondDrake 11. November 2010 17:21

When writing software practically every application will eventually run a method that takes a couple seconds to complete, when this happens the gui hangs and this could even lead to the user forcing the application close because they think it stopped working. Microsoft added a nice set of threading tools, but that leads to errors when trying to update your controls. The answer is the Control's Invoke class, but it gets messy and many people find a similar way around it. Here are some different versions of the InvokeRequired patterns that i have come across.

First the one I use most often.

void mymethod(type arg)
        {
            if (InvokeRequired)
            {
                this.Invoke((Action)delegate { mymethod(arg);});
            }
            else
            {
               //useful method body
            }
        }

 

 

another similar variation.

void mymethod(type arg)
        {
            if (InvokeRequired)
            {
               BeginInvoke(new MethodInvoker(delegate() { mymethod(args); }));
            }
            else
            {
               //useful method body
            }
        }

 

 

another similar variation that seems not to work with arguments.

void mymethod()
        {
            if (InvokeRequired)
            {
               BeginInvoke(new Action(mymethod));

            }
            else
            {
               //useful method body
            }
        }

 

 

And a whole new idea, writing an extention method for the control class that accepts an action and handles the invoke

public static void InvokeIfRequired(this Control c, Action action)
{
    if(c.InvokeRequired)
    {
        c.Invoke(() => action(c));
    }
    else
    {
        action(c);
    }


which is used something like...

object1.InvokeIfRequired(c => { c.Visible = true; });

 

 

Those are just a few of the dozens I have found. I'll leave these here for personal reference, and for public reference of course.

Tags: ,

Programming

RockBand Drum-Kit Beta added to downloads

by DiamondDrake 10. November 2010 07:57

I finally have a decent release of the RockBand Drum-Kit for Windows ready so I popped it into an installer and dropped it here on the site. I am hopping that I get some feedback to help make it a better application. I ran into a little problem with permissions on vista and windows 7 so for the time being the app requests admin privileges, but hopefully that will change when i get some time to re-factor the code a bit.

I'm really proud of it to say the least, spent a lot of time working on an attractive interface and tweaking the performance. Give it a go, you know you want to play the drums!

Download the RockBand Drum-Kit for Windows Beta V0.0.1.0

 

 

Tags: ,

Site

Windows 7 Upgrade Key Patch added to downloads

by DiamondDrake 7. November 2010 17:06

When I first purchased windows 7, I was running windows xp so I purchased an upgrade key. After formatting and installing windows 7 it became clear that Microsoft wasn't going to let me just use an upgrade key after a fresh install. So I began to browse the web in search of an answer, Not long there after I had my solution; A registry edit, and a command prompt script. After I performed the operations i decided to hack up this little tool that performs the patch "automagically"

This little app simply edits the registry to change the install type from "full" to "upgrade", and then calls a VB scripts from the system directory that rearms the system, the same functionality that allows you to change your product key without a reinstall if Microsoft blacklists your system and sells you a key (these two concepts are completely different, it just uses that innate functionality).

it's far from pretty, never intended it to be, Some programmers are so proud of their little patches that they spend more time on a theme and background music than they do on the patch itself. This is just a simple dialog with a "Enable Upgrade key" button. But it works, so I'm satisfied.

Download DiamondDrake's Windows7 Upgrade Key Enabler Patch

Tags: , ,

Site

DD Video Screen Saver

by DiamondDrake 6. November 2010 18:58

Quite a few years back AnalogX wrote a video screen saver that used windows media player 7 as an active x control to play any video file as a screen saver. I really liked this idea, but who has Windows Media Player 7? A year ago I wrote a DirectX version of a video screen saver that matched the functionality of analog x's screen saver. That wasn't good enough for me. There just is no way to gaurantee a decent supply of codecs are available on a system. Yesterday I re-wrote my Video Screen Saver from the ground up based completely on Video Lan Player's core libraries. It makes for a larger download, but it almost guarantees that whatever video files you have will play. All in all, I think it works very well, although I am sure there are a few bugs that I haven't discovered yet.

In a future release I intend to trim the amount of plugins provided, thus decreasing the download size. I can easily trim about 5mb, but I need to experiement for the right balance of plugins. I would love to get some feedback on this screen saver. Feel free to post comments here on the blog, or for a private or more simple way to leave feedback, use the feedback feature of the screen saver it's self; Located in the Video Screen Savers configuration dialog box.

Download The DiamondDrake Video Screen Saver Here

Tags: , , ,

Programming

Calculating "Time Remaining" on a long running proccess

by DiamondDrake 24. October 2010 22:00

Sometimes when a proccess is long enough users of your applications might like to know about how long your proccess has left. This isn't always the easisest task, but in the event that you have a set number of itterations, or a consistently changing percentage you can calculate the time remaining very easily. The idea is that you measure the time from when you started til the current itteration and devide it by the current itteration giving you the average time of each itteration. then multiply that by the itterations left to get the estimated time remaining. so the formula at its simpilest is

Time Remaining = (currentTime / currentItteration) * itterationsRemaining

This formula can also work with a percentage being Time Remaining = (currentTime / currentPercent) * precentRemaining

Here is an example of using this formula in C#

void looping_Proccess(int count)
        {
            DateTime startTime = DateTime.Now;

            for (int i = 0; i < count; i++)
            {
                doLongThing(i);

                TimeSpan currenttime = DateTime.Now - start;
                if(i > 0) //Prevent devide by zero
                {
                  TimeSpan TimeRemaining = TimeSpan.FromSeconds((currenttime.TotalSeconds / i) * (count - i));
                  reportTimeRemaining(TimeRemaining);
                }
            }
        }

 

Tags: ,

Programming


Copyright © 2010 DiamondDrake Design - Rickey Ward Powered by BlogEngine.NET 1.6.1.0 - Log in