You are on page 1of 9

Unfied software suit (facebook ,pdf editor ,photo edit ,searching files.webcam) using .

net c# Introduction
A computer user can be any one paprgrammer or non programmer .so I decided to make a software which include most of the daily task of our computuing life . after the deail servay of computer users(4rnds and family) I found that most of the people read pdf files,use social networks(sharing pictures) edit photos. The idea is to provide a unified solution of many problems. I call it unified software suit .

Libraries: (1) Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library.
Allowing OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++,

IronPython etc. The wrapper can be compiled in Mono and run on Windows, Linux, Mac OS X, iPhone, iPad and Android devices.

(2) facebook ghraph api :


The Graph API is the primary way to get data in and out of Facebook's social graph. It's a low-level HTTP-based API that you can use to query data, post new stories, create check-ins or any of the other tasks that an app might need to do. Facebook's Open Graph allows you to define new objects and actions in a user's social graph, and the way that you create new instances of those actions and objects is via the Graph API

In this solution you need this library hardly. All of the software depends upon these libraries.

Webcam: here we need emgcv open source library .

step 1
add libraries
using Emgu.CV; using Emgu.CV.Structure; using Emgu.Util; in event of the camera button(on/off) private void btnStart_Click(object sender, EventArgs e) {

// you need to check if its initialzed or not if not then initialize it #region if capture is not created, create it now if (capture == null) { try { capture = new Capture(0);// 0 is default video device } catch (Exception excpt) { MessageBox.Show(excpt.Message); } } #endregion

if (capture != null) { if (captureInProgress) { //if camera is getting frames then stop the capture and set button Text // "Start" for resuming capture btnStart.Text = "Start!"; // Application.Idle -= ProcessFrame;

} else { //if camera is NOT getting frames then start the capture and set button // Text to "Stop" for pausing capture btnStart.Text = "Stop"; btnStart.BackColor = Color.Red; Application.Idle += ProcessFrame; } captureInProgress = !captureInProgress; }

Step 2 Now we want to add multiple special effects in picture boxes we have added 6 picture box

try { Image<Bgr, Byte> frame = capture.QueryFrame(); //capture image frame // its a wrapper of ipllimage of open cv bgr stand for blue green red . its a 8bit //image Adding image color effects Image<Gray, Byte> grayFrame = frame.Convert<Gray, Byte>(); Image<Gray, Byte> smallGrayFrame = grayFrame.PyrDown(); Image<Gray, Byte> smoothedGrayFrame = smallGrayFrame.PyrUp(); Image<Gray, Byte> cannyFrame = smoothedGrayFrame.Canny(new Gray(80), new Gray(40)); Image<Gray, Byte> blurr = cannyFrame.SmoothBlur(10, 20); Image<Gray, Byte> xtra = grayFrame.SmoothBilatral(11, 12, 33);

Now assign each image box above effects .


imageBox5.Image = imageBox4.Image = CamImageBox.Image imageBox1.Image = imageBox2.Image = imageBox3.Image = } catch (Exception) { } xtra; blurr; = frame; smallGrayFrame; cannyFrame; smoothedGrayFrame;

Now our next module Uploading files to facebook

Introduction : Uploading files via a desktop application in just one click. Here it is . He idea is to provide a interface to uploading pictures pictures from desktop Add library
using Facebook; creat a facebook client instance token is the acces token of your facebook profile

then creat a dictionary throught aces token .

of message and your profile id . we acces facebook accounts

note acces token expire after new login . try { FacebookClient fc = new FacebookClient("token"); var parameters = new Dictionary<string, object>

{ {"message", "hello"}, {"place", "id "} };

Now select file to upload We convert files into bytes byte[] fileBytes = File.ReadAllBytes(@"" + file); mediaObject.SetValue(fileBytes); IDictionary<string, object> upload = new Dictionary<string, object>(); string tb = textBox1.Text;

upload.Add("name", tb); now facebook client upload photo to photos . photos represent the photos of your facebook account thats it . fc.Post("photos", upload); MessageBox.Show("photos uploaded "); } catch (Exception E) { MessageBox.Show("Uploading failed check your connection!! "); }

Module 3 :

Now about my searching algorithm This is how its look like .

Step 1 get logical drives


I have used tree for side menu and for detail view or thumbnail views as list view
String[] ids = Directory.GetLogicalDrives(); foreach(String id in ids) { treeView1.Nodes.Add(id); }

Now for after click event add this code to show the sub directries
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { listView1.Clear(); ImageList img = new ImageList(); Image img1;

Here we are setting the thumbnail size of files it will show .


img.ColorDepth = ColorDepth.Depth32Bit; img.ImageSize = new Size(100,100); listView1.LargeImageList = img; listView1.SmallImageList = img; listView1.StateImageList = img;

Step 2 : Now how I have hard coded the images for the files according to their types . try { String[] dirs = Directory.GetDirectories(treeView1.SelectedNode.Text); String[] dir = Directory.GetFiles(treeView1.SelectedNode.Text); img1 = Image.FromFile("folder.jpg");//0 img.Images.Add(img1); img1 = Image.FromFile("q.jpg");//1 img.Images.Add(img1); img1 = Image.FromFile(@"icon_PDF.png");//2 img.Images.Add( img1);

img1 = Image.FromFile(@"Doc.jpg");//3 img.Images.Add( img1); img1 = Image.FromFile(@"txt.jpg");//4 img.Images.Add(img1); img1 = Image.FromFile(@"ppt.jpg");//5 img.Images.Add( img1); img1 = Image.FromFile(@"rar.jpg");//6 img.Images.Add( img1); img1 = Image.FromFile(@"excel.jpg");//7 img.Images.Add( img1); img1 = Image.FromFile(@"exe.jpg");//8 img.Images.Add( img1); img1 = Image.FromFile(@"vlc.png");//9 img.Images.Add( img1); img1 = Image.FromFile(@"pic.png"); img.Images.Add(img1); int t = 11;

foreach (String S in dirs) { listView1.Items.Add(S,0); treeView1.SelectedNode.Nodes.Add(S); }

foreach (String S in dir) {

Here I am detecting what kind of files are present if the file is un known then we can give it uknown icon image.

if ((S.Contains(".flv")||S.Contains(".jpg") || S.Contains(".jpeg") || S.Contains(".bmp") || S.Contains(".png") || S.Contains(".pdf") || S.Contains(".doc") || S.Contains(".docx") || S.Contains(".txt") || (S.Contains(".ppt") || S.Contains(".doc") || S.Contains(".docx") || S.Contains(".rar") || S.Contains(".FLV") || S.Contains(".mp3") || S.Contains(".avi") || S.Contains(".mkv") || S.Contains(".mp4") || S.Contains(".exe") || S.Contains(".xlsx") || S.Contains(".zip") || S.Contains(".xls")))) {

Step 3: Get the images from the pictures only . for folder and exe files we have hard coded icons if (S.Contains(".jpg") || S.Contains(".jpeg") || S.Contains(".bmp") || S.Contains(".png")) { Image image = Image.FromFile(@""+S);

img.Images.Add(image); listView1.Items.Add(S, t); t++; } if (S.Contains(".pdf")) {

listView1.Items.Add(S, 2);

} if (S.Contains(".doc") || S.Contains(".docx")) { listView1.Items.Add(S, 3); } if (S.Contains(".txt")) { listView1.Items.Add(S, 4);

} if (S.Contains(".ppt")) { listView1.Items.Add(S,5 );

} if (S.Contains(".rar") || S.Contains(".zip")) { listView1.Items.Add(S, 6);

} if (S.Contains(".xls") || S.Contains(".xlsx")) { listView1.Items.Add(S, 7);

} if (S.Contains(".exe")) { listView1.Items.Add(S, 8);

} if (S.Contains(".FLV") || S.Contains(".flv") || S.Contains(".mp3") || S.Contains(".avi") || S.Contains(".mkv") || S.Contains(".mp4")) { listView1.Items.Add(S, 9);

} }else{ listView1.Items.Add(S,1); }

} }

catch (Exception E) { MessageBox.Show(E.Message); }