Click here to Skip to main content
15,886,701 members
Articles / Multimedia / GDI+

A complete C# Screensaver that does double-buffering on multiple monitor systems!

Rate me:
Please Sign up or sign in to vote.
4.75/5 (37 votes)
24 Jun 200534 min read 272.8K   1.8K   190  
Example screensaver in source code. Does a mini-preview too!
  • swarmscreensaver_src.zip
    • SwarmScreenSaver
      • CodeCommentReport
        • banner.htm
        • banner.jpg
        • CodeCommentReportError.htm
        • commentreport.css
        • CommonCode
        • darkcorner.jpg
        • gradleft.jpg
        • gradtop.jpg
        • graycorner.jpg
        • Insects
        • minus.jpg
        • plus.jpg
        • Solution_SwarmScreenSaver.HTM
        • SwarmScreenSaver
          • CWP0.HTM
          • CWP10.HTM
          • CWP100.HTM
          • CWP101.HTM
          • CWP102.HTM
          • CWP103.HTM
          • CWP104.HTM
          • CWP105.HTM
          • CWP106.HTM
          • CWP107.HTM
          • CWP108.HTM
          • CWP109.HTM
          • CWP11.HTM
          • CWP110.HTM
          • CWP111.HTM
          • CWP112.HTM
          • CWP113.HTM
          • CWP114.HTM
          • CWP115.HTM
          • CWP116.HTM
          • CWP117.HTM
          • CWP118.HTM
          • CWP119.HTM
          • CWP12.HTM
          • CWP120.HTM
          • CWP121.HTM
          • CWP122.HTM
          • CWP123.HTM
          • CWP124.HTM
          • CWP125.HTM
          • CWP126.HTM
          • CWP127.HTM
          • CWP128.HTM
          • CWP129.HTM
          • CWP13.HTM
          • CWP130.HTM
          • CWP131.HTM
          • CWP132.HTM
          • CWP134.HTM
          • CWP135.HTM
          • CWP136.HTM
          • CWP137.HTM
          • CWP138.HTM
          • CWP139.HTM
          • CWP14.HTM
          • CWP140.HTM
          • CWP141.HTM
          • CWP142.HTM
          • CWP143.HTM
          • CWP144.HTM
          • CWP145.HTM
          • CWP146.HTM
          • CWP147.HTM
          • CWP148.HTM
          • CWP149.HTM
          • CWP15.HTM
          • CWP150.HTM
          • CWP151.HTM
          • CWP152.HTM
          • CWP153.HTM
          • CWP154.HTM
          • CWP155.HTM
          • CWP156.HTM
          • CWP157.HTM
          • CWP158.HTM
          • CWP159.HTM
          • CWP16.HTM
          • CWP160.HTM
          • CWP161.HTM
          • CWP162.HTM
          • CWP163.HTM
          • CWP164.HTM
          • CWP165.HTM
          • CWP166.HTM
          • CWP167.HTM
          • CWP168.HTM
          • CWP169.HTM
          • CWP17.HTM
          • CWP170.HTM
          • CWP171.HTM
          • CWP172.HTM
          • CWP173.HTM
          • CWP174.HTM
          • CWP175.HTM
          • CWP176.HTM
          • CWP177.HTM
          • CWP178.HTM
          • CWP179.HTM
          • CWP18.HTM
          • CWP180.HTM
          • CWP181.HTM
          • CWP182.HTM
          • CWP183.HTM
          • CWP184.HTM
          • CWP185.HTM
          • CWP186.HTM
          • CWP187.HTM
          • CWP188.HTM
          • CWP189.HTM
          • CWP19.HTM
          • CWP190.HTM
          • CWP191.HTM
          • CWP192.HTM
          • CWP2.HTM
          • CWP20.HTM
          • CWP21.HTM
          • CWP22.HTM
          • CWP23.HTM
          • CWP24.HTM
          • CWP25.HTM
          • CWP26.HTM
          • CWP27.HTM
          • CWP28.HTM
          • CWP29.HTM
          • CWP3.HTM
          • CWP31.HTM
          • CWP32.HTM
          • CWP33.HTM
          • CWP34.HTM
          • CWP35.HTM
          • CWP36.HTM
          • CWP38.HTM
          • CWP39.HTM
          • CWP4.HTM
          • CWP40.HTM
          • CWP41.HTM
          • CWP42.HTM
          • CWP43.HTM
          • CWP44.HTM
          • CWP45.HTM
          • CWP46.HTM
          • CWP47.HTM
          • CWP48.HTM
          • CWP49.HTM
          • CWP5.HTM
          • CWP50.HTM
          • CWP51.HTM
          • CWP52.HTM
          • CWP53.HTM
          • CWP54.HTM
          • CWP55.HTM
          • CWP56.HTM
          • CWP57.HTM
          • CWP58.HTM
          • CWP59.HTM
          • CWP6.HTM
          • CWP60.HTM
          • CWP61.HTM
          • CWP62.HTM
          • CWP63.HTM
          • CWP64.HTM
          • CWP65.HTM
          • CWP66.HTM
          • CWP67.HTM
          • CWP68.HTM
          • CWP69.HTM
          • CWP7.HTM
          • CWP70.HTM
          • CWP71.HTM
          • CWP72.HTM
          • CWP73.HTM
          • CWP74.HTM
          • CWP75.HTM
          • CWP76.HTM
          • CWP77.HTM
          • CWP78.HTM
          • CWP79.HTM
          • CWP8.HTM
          • CWP80.HTM
          • CWP81.HTM
          • CWP82.HTM
          • CWP83.HTM
          • CWP84.HTM
          • CWP85.HTM
          • CWP86.HTM
          • CWP88.HTM
          • CWP9.HTM
          • CWP90.HTM
          • CWP91.HTM
          • CWP92.HTM
          • CWP93.HTM
          • CWP94.HTM
          • CWP95.HTM
          • CWP96.HTM
          • CWP97.HTM
          • CWP98.HTM
          • CWP99.HTM
          • SwarmScreenSaver.HTM
        • titletile.jpg
        • vt.js
      • CommonCode
      • Insects
      • SwarmScreenSaver.sln
      • SwarmScreenSaver
function resizeMe()	{
	alert('loaded');
}

function InitElements()  {
        for(var a=0; a<document.all.length; a++)  {
                if(document.all[a].tagName == 'DIV' && document.all[a].className.toLowerCase()=='namespacechild') {
                        document.all[a].style.display = 'none';
                }
                if(document.all[a].tagName=='IMG')  {
                        document.all[a].style.display='inline';
                }
        }
}

function gvResolve(param) {
	var lmSpan = param

	if (lmSpan.style.display == "block") {
		lmSpan.style.display = "none"
	}else{
		lmSpan.style.display = "block"
	}

		
}

function gvResolve2(param) {
	var lmSpan = param
	if (lmSpan.style.display == "block") {
		setCookie("TeamMenuDisplay", "none", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
		lmSpan.style.display = "none"
	}else{
		setCookie("TeamMenuDisplay", "block", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
		lmSpan.style.display = "block"
	}

		
}

function gvResolve2a(param) {
	var lmSpan = param
	if (lmSpan.style.display == "block") {
		setCookie("ProdMenuDisplay", "none", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
		lmSpan.style.display = "none"
	}else{
		setCookie("ProdMenuDisplay", "block", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
		lmSpan.style.display = "block"
	}

		
}

function gvResolveX2(param, whichArrow, path) {
	var lmSpan = param
	var changeArrow = whichArrow
        var rootpath = path
	if (lmSpan.style.display == "block") {
		lmSpan.style.display = "none";
		changeArrow.src = rootpath + "Plus.jpg";	
	}else{
		lmSpan.style.display = "block";
		changeArrow.src = rootpath + "Minus.jpg";
	}

		
}

function setStatus(param)	{
	var whatMSG = param;
	window.status = whatMSG;
}

function BTN_preloadImages() { //v1.2
  if (document.images) {
    var imgFiles = BTN_preloadImages.arguments;
    var preloadArray = new Array();
    for (var i=0; i<imgFiles.length; i++) {
      preloadArray[i] = new Image;
      preloadArray[i].src = imgFiles[i];
    }
  }
}


function BTN_swapImage() {
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.BTN_swapImgData;
  for (i=0; i < (BTN_swapImage.arguments.length-2); i+=3) {
    objStr = BTN_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = BTN_swapImage.arguments[i+2];
  } }
  document.BTN_swapImgData = swapArray; //used for restore
}

function BTN_swapImgRestore() { 
  if (document.BTN_swapImgData != null)
    for (var i=0; i<(document.BTN_swapImgData.length-1); i+=2)
      document.BTN_swapImgData[i].src = document.BTN_swapImgData[i+1];
}


//cookie code
function setCookie (name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
    	((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
	
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
	
function getVal(param)	{
	var myVal = getCookie(param);
	alert(myVal);
}


function toggleInfoDisplay (param)	{
	var myVal = getCookie(param);
		if (myVal == "none") {
			setCookie(param, "block", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
			toggleInfoBTN.innerText = "Hide Page Info"
			pageInfo.style.display = "block"
		}else{
			if (myVal == "block") {
				setCookie(param, "none", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
				toggleInfoBTN.innerText = "Show Page Info"
				pageInfo.style.display = "none"
				}
		}

}

function toggleTickerDisplay (param)	{
			setCookie("TickerTickler", param, "Mon, 01-Jan-2001 00:00:00 GMT", "/")
			top.location=param
}


function cookieINIT (param)	{
	var cookieVal = getCookie(param);
	if (cookieVal == null) {
		setCookie(param, "block", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
	}

}

function setCorrectBTNText(param)	{
	var myVal = getCookie(param);
		if (myVal == "none") {
			document.write("Show Page Info")
		}else{
		if (myVal == "block") {
			document.write("Hide Page Info")
			}
		}
}

function checkDefaultPage (param)	{
	var myVal = getCookie(param);
	if (myVal == null) {
		setCookie(param, "default_0.asp", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
		top.location="default_0.asp"
	}
		if (myVal == "default_0.asp") {
			top.location="default_0.asp"
		}else{
		if (myVal == "default_1.asp") {
			top.location="default_1.asp"
		}else{
		setCookie(param, "default_0.asp", "Mon, 01-Jan-2001 00:00:00 GMT", "/")
		}
		}
}


//end cookie

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Hello, I have been a professional hairpuller aka programmer for a large company during the last nine years. The acquiring company is closing down the california office so I'll be out of work at the end of June at the latest. I program in a variety of laguages, C#, C++, C, Visual Basic, SQl Server among others. I live north of Sacramento in Paradise CA. I've been programming since the early 1980 and people accuse me of going bald. I'm not going bald, my hair is just migrating south and into my ears.

I am a firm believer that the most widely used programming language is #$@$@$%#$%^ but folks tend to object to the unusual synatax where each word has a colorful meaning and sentences are limited to three words max, while the punching bag flys back and forth so fast it heats up from friction like a meteorite through the air.

In short, I'm nuts, but I'm good at what I do.

Programming is like beating my head against a brick wall, it hurts so bad I can't stand it, but when I stop beating my head against the wall (Solve the problem), it feels so good I gotta do it again!

Comments and Discussions