Click here to Skip to main content
13,091,300 members (49,823 online)
Click here to Skip to main content
Add your own
alternative version


44 bookmarked
Posted 26 Dec 2006

Desktop Sheep

, 22 Mar 2008
Rate this:
Please Sign up or sign in to vote.
Animated sheep for your desktop
Sample Image - Desktop_Sheep.jpg


I really don't know what to say about this article, but I'd like to stress on "It only took me one hour to code this application so be nice and don’t beat me so hard with your comments".

Well, I just read a nice article this morning by Igor Tolmachev called Falling Snow on Your Desktop! here on the CP and said Merry X-Mas to everyone, but I thought there are good muslems here in the forum who would like to hear Happy Eid because it's about time too they have their sheep slaughtered!


I'm sorry, but I think there's nothing to explain about such an easy piece of application,
but here's what I would call the recipé.


  • Three Image objects are created for the three faces of the good sheep.

    Sheep1 = Image.FromFile("Sheeps\weird_sheep1.gif");
    Sheep2 = Image.FromFile("Sheeps\weird_sheep2.gif");
    Sheep3 = Image.FromFile("Sheeps\weird_sheep3.gif");
  • Two timers to control the three sheepfaces, the sheep movement on the desktop.
  • One Notify icon to control the application.
  • One Context menu popped from the notify icon.

Start Cooking

The form which has the sheep is set to transparent using the transparency key property, form borders are removed, and a picture box control is added and docked to the parent container form.

The timers are started when the form is loaded with the interactivity of adjusting the sheep speed, this is done by using a variable sheepSpeed which is modified during run-time using the notify icon's context menu.

The Code

//By Muammar Yacoob

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Sheep
    public partial class Form1 : Form
        int flipper, screenW, screenH;  //variable I'll be using later
        int sheepX, sheepSpeed; 
        Image Sheep1, Sheep2, Sheep3;   //to set the location and speed
        public Form1()                  //image files are attached here 
                                        //of the form (the sheep)
            Sheep1 = Image.FromFile(@"Sheeps\weird_sheep1.gif");
            Sheep2 = Image.FromFile(@"Sheeps\weird_sheep2.gif");
            Sheep3 = Image.FromFile(@"Sheeps\weird_sheep3.gif");
            flipper = 1;
               = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
               = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            sheepX = screenW;
            sheepSpeed = 2;

        private void Form1_Load(object sender, EventArgs e)
            //setting the initial location for the form
            this.Location = new Point(screenW, screenH - this.Height);
            //initializing the form with sheep face1
            BoxSheep.Image = Sheep1;                     
            tmrSheeper.Start(); //starts changing the image
            tmrMoveit.Start();   //starts moving the form

        private void tmrSheeper_Tick(object sender, EventArgs e)
            switch (flipper)
                case 1:
                    BoxSheep.Image = Sheep1;
                case 2:
                    BoxSheep.Image = Sheep2;
                case 3:
                    BoxSheep.Image = Sheep3;
                    flipper = 1; //back to face1

        private void tmrMoveit_Tick(object sender, EventArgs e)
        {   //############ We add this line to get the sheep ###########//
            //############ on the taskbar after modifying it ###########//
            screenH = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;

            if (sheepX >= this.Width * -1) //end of sheep tail
                this.Location = new Point(sheepX, (screenH - this.Height)-22);
                sheepX -= sheepSpeed;      //this is set by the context menu
            }             //by default, it's set to 2 in
            else                     //the constructor
                sheepX = screenW;

        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
            About about = new About();

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
            notifyIcon1.Dispose();//getting rid of the notify
            this.Close();         //icon from the system tray

        private void fastToolStripMenuItem_Click(object sender, EventArgs e)
            sheepSpeed = 3; //fast, "moves 3 pixels at a time"

        private void mediumToolStripMenuItem_Click(object sender, EventArgs e)
            sheepSpeed = 2; //medium, "moves 2 pixels at a time"

        private void slowToolStripMenuItem_Click(object sender, EventArgs e)
            sheepSpeed = 1; //slow, "moves 1 pixels at a time"

        private void notifyIcon1_DoubleClick(object sender, EventArgs e)
            About about = new About();

Points of Interest

Notice that I've used System.Windows.Forms.Screen.PrimaryScreen.Bounds to get the primary screen boundaries nevertheless; I endup with adding 22 pixels to fix
the Form Y location. Now I'm using:


Only now can I remove the 22 tweaking pixels. Thanks to cokeman's feedback!


Because CodeProject doesn't allow EXEs in article submission, I've renamed the *.exe demo file to *.zip, so it's actually not a zip file! Please rename it first to *.exe before running it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Retired QSoft
Yemen Yemen
Biography?! I'm not dead yet!

You may also be interested in...

Comments and Discussions

QuestionHow would i be able to... [modified] Pin
C# Beginner Nick3-Oct-07 14:43
memberC# Beginner Nick3-Oct-07 14:43 
AnswerRe: How would i be able to... Pin
Muammar©4-Oct-07 3:23
memberMuammar©4-Oct-07 3:23 
Questionmodifying source files?? Pin
Muammar©7-Jan-07 20:09
memberMuammar©7-Jan-07 20:09 
JokeSheeps slaughtered!! Pin
Muammar©5-Jan-07 22:36
memberMuammar©5-Jan-07 22:36 
GeneralRe: Sheeps slaughtered!! Pin
nEo.X6-Jan-07 15:21
membernEo.X6-Jan-07 15:21 
GeneralRe: Sheeps slaughtered!! Pin
Muammar©6-Jan-07 19:10
memberMuammar©6-Jan-07 19:10 
GeneralEXE Pin
Polymorpher3-Jan-07 15:31
memberPolymorpher3-Jan-07 15:31 
GeneralRe: EXE Pin
Muammar©5-Jan-07 22:21
memberMuammar©5-Jan-07 22:21 
GeneralRe: EXE Pin
The_Mega_ZZTer6-Jan-07 5:41
memberThe_Mega_ZZTer6-Jan-07 5:41 
GeneralRe: EXE Pin
Polymorpher6-Jan-07 10:09
memberPolymorpher6-Jan-07 10:09 
GeneralRe: EXE Pin
Muammar©6-Jan-07 19:21
memberMuammar©6-Jan-07 19:21 
GeneralRe: EXE Pin
Polymorpher6-Jan-07 20:15
memberPolymorpher6-Jan-07 20:15 
GeneralRe: EXE Pin
Muammar©6-Jan-07 20:43
memberMuammar©6-Jan-07 20:43 
QuestionNot working in VB Pin
Patel Pranav2-Jan-07 18:37
memberPatel Pranav2-Jan-07 18:37 
AnswerRe: Not working in VB Pin
Muammar©5-Jan-07 22:13
memberMuammar©5-Jan-07 22:13 
QuestionNET? Pin
Radek Chalupa2-Jan-07 10:42
memberRadek Chalupa2-Jan-07 10:42 
AnswerRe: NET? Pin
Muammar©5-Jan-07 21:47
memberMuammar©5-Jan-07 21:47 
NewsBehind the task bar Pin
Santosh M. P.27-Dec-06 22:18
memberSantosh M. P.27-Dec-06 22:18 
GeneralRe: Behind the task bar Pin
Muammar©30-Dec-06 5:19
memberMuammar©30-Dec-06 5:19 
GeneralRe: Behind the task bar Pin
The_Mega_ZZTer6-Jan-07 5:44
memberThe_Mega_ZZTer6-Jan-07 5:44 
GeneralRe: Behind the task bar Pin
Muammar©6-Jan-07 19:25
memberMuammar©6-Jan-07 19:25 
GeneralRe: Behind the task bar Pin
The_Mega_ZZTer7-Jan-07 12:28
memberThe_Mega_ZZTer7-Jan-07 12:28 
GeneralRe: Behind the task bar Pin
Muammar©7-Jan-07 19:03
memberMuammar©7-Jan-07 19:03 
AnswerFixed:) Pin
Muammar©7-Jan-07 19:32
memberMuammar©7-Jan-07 19:32 
Generalthx for fun Pin
subai26-Dec-06 18:08
membersubai26-Dec-06 18:08 
GeneralRe: thx for fun Pin
Muammar©27-Dec-06 5:43
memberMuammar©27-Dec-06 5:43 
GeneralRe: thx for fun Pin
subai27-Dec-06 18:48
membersubai27-Dec-06 18:48 
GeneralMore fun:) Pin
Muammar©26-Dec-06 15:48
memberMuammar©26-Dec-06 15:48 
GeneralPrimaryScreen.Bounds Pin
cokeman1926-Dec-06 6:28
membercokeman1926-Dec-06 6:28 
GeneralRe: PrimaryScreen.Bounds Pin
Muammar©26-Dec-06 15:36
memberMuammar©26-Dec-06 15:36 
Generalhey wait:) Pin
Muammar©26-Dec-06 15:45
memberMuammar©26-Dec-06 15:45 
GeneralEid Milad Saeed Pin
Grimolfr26-Dec-06 3:56
memberGrimolfr26-Dec-06 3:56 
GeneralOops Pin
Grimolfr26-Dec-06 4:02
memberGrimolfr26-Dec-06 4:02 
GeneralRe: Oops Pin
Muammar©26-Dec-06 4:09
memberMuammar©26-Dec-06 4:09 
GeneralRe: Oops Pin
Grimolfr26-Dec-06 4:17
memberGrimolfr26-Dec-06 4:17 
GeneralRe: Oops Pin
Muammar©26-Dec-06 4:21
memberMuammar©26-Dec-06 4:21 
GeneralPure Fun Pin
WillemM26-Dec-06 3:55
memberWillemM26-Dec-06 3:55 
GeneralRe: Pure Fun Pin
Muammar©26-Dec-06 4:04
memberMuammar©26-Dec-06 4:04 
GeneralRe: Pure Fun Pin
Final Fantasy VIII26-Dec-06 5:37
memberFinal Fantasy VIII26-Dec-06 5:37 
General:) Pin
Raiyan_Kamal26-Dec-06 3:05
memberRaiyan_Kamal26-Dec-06 3:05 
GeneralRe: :) Pin
Muammar©26-Dec-06 3:31
memberMuammar©26-Dec-06 3:31 
GeneralHappy Eid to you too Pin
BaselNimer26-Dec-06 2:56
memberBaselNimer26-Dec-06 2:56 
GeneralRe: Happy Eid to you too Pin
Muammar©26-Dec-06 3:28
memberMuammar©26-Dec-06 3:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 23 Mar 2008
Article Copyright 2006 by Muammar©
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid