Thursday, February 26, 2009
Augmented Reality in flash
http://www.boffswana.com/news/?p=392 //includes source
http://www.mikkoh.com/blog/?p=182 //good example with source
http://www.libspark.org/wiki/saqoosha/FLARToolKit/en
http://createdigitalmotion.com/2009/02/10/opencv-motion-tracking-face-recognition-with-processing-im-forever-popping-bubbles/
http://createdigitalmotion.com/2009/01/07/happy-new-year-with-augmented-reality-flying-words-of-wisdom/
http://www.boffswana.com/news/
http://saqoosha.net/2008/08/31/1221/
http://blog.tarotaro.org/archives/category/ar/flartoolkit
http://ubaa.net/shared/processing/opencv/
http://www.timovirtanen.com/category/flash/
Later I will try to correct errors in the articles
Sorry for bad english.
Saturday, February 21, 2009
Traversing and adding file structure to a tree node
using System.Text;
using System.Threading;
using System.IO;
public void ListDir(string src, TreeNode d){
try{
DirectoryInfo dinfo = new DirectoryInfo(@"" + src);
FileInfo[] finfo = dinfo.GetFiles();
for (int j = 0; j < finfo.Length; j++)
{
d.Nodes.Add(@"" + finfo[j].Name);
}
DirectoryInfo[] dname = dinfo.GetDirectories();
TreeNode[] treend = new TreeNode[dname.Length];
for (int i = 0; i < dname.Length; i++)
{
treend[i] = new TreeNode(dname[i].Name);
d.Nodes.Add(treend[i]);
}
for (int i = 0; i < dname.Length; i++)
{
ListDir(dname[i].FullName, treend[i]);
Thread.Sleep(5);
}
}
Listing Logical Drives
int i = 0;
while (i < dinf.Length)
{
MessageBox.show(dinf[i]);
}
Create XML file using C#
using System.Data;
using System.Drawing;
using System.Xml;
using System.IO;
//code
XmlTextWriter xmlWriter = new XmlTextWriter("temp.xml", System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
xmlWriter.WriteStartElement("root");
xmlWriter.Close();
// creation complete
doc = new XmlDocument();
doc.Load("temp.xml");
XmlNode newNode = doc.CreateNode(XmlNodeType.Element, "firstnode", ""); // creating Node
newNode.InnerText = “Content”; // set your content
doc.DocumentElement.AppendChild(newNode); //Adds a Node
doc.Save("temp.xml");
Dynamically add Picture box using C# delegate
The below code is just abstract just to show simple use of delegate
using System.Data;
using System.IO;
using System.Drawing;
using System.Text;
using System.Threading;
public partial class ImageView : Form{
Mydel a;
public delegate void Mydel(PictureBox p);
public ImageView(){
InitializeComponent();
}
private void ImageView_Load(object sender, EventArgs e){
a = new Mydel(Add);
Thread t = new Thread(load);
t.Start();
}
public void load(){
DirectoryInfo dinfo = new DirectoryInfo(@"F:\Mypics");
if (Image.FromFile(finfo[i].FullName) != null){ PictureBox p = new PictureBox();
Controls[Controls.IndexOf(panel1)].Invoke(a, obj);
if (x > this.Width-100){ y += 100;
}
} } public void Add(PictureBox p) { panel1.Controls.Add(p); } } }
FileInfo[] finfo = dinfo.GetFiles();
Graphics g = panel1.CreateGraphics();
int x = 20;
int y = 20;
for (int i = 0; i
p.Image = Image.FromFile(finfo[i].FullName);
p.SizeMode = PictureBoxSizeMode.StretchImage;
p.Left = x;
p.Top = y;
p.ImageLocation = finfo[i].FullName;
p.Width = 140;
p.Height = 90;
Object[] obj = new Object[1];
obj[0] = p;
x += 150;
x = 20;
}
if (i > 35)
break;
Function to retrieve RAM SIZE in MB C#
This is the sample code to retrieve total ram size of system using WMI (Windows Management Instrumentation) well it’s not perfect but it works
Name spaces
using System;
using System.Management;
using System.Collections.Generic;
using System.Text;
public int getRAMSize() {
int total=0;
try
{
ConnectionOptions connection = new ConnectionOptions();
ManagementScope scope;
scope = new ManagementScope("root\\CIMV2", connection);
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_ComputerSystem");
ManagementObjectSearcher searcher =new ManagementObjectSearcher(scope, query);
foreach (ManagementObject queryObj in searcher.Get(){
total = Convert.ToInt32(queryObj["TotalPhysicalMemory"].ToString());
}
total = total / 1024;
}
catch {} }
return total;
}
Welcome to my Blog
software student from India. I am onto programming from quite a time now. Then one day I suddenly thought about start blogging. So that I can share with you all whatever I know. I will try to give small code samples and all but I am not guaranteeing its correctness because still I am studying and I am careless and less worries about implementation. All the code given are simple and abstract . But I am sure even beginners can figure out what I ment, You can use the code at your own risk.