It’s already in 2010, that Google will be releasing it’s new OS: Google Chrome. The announce was made yesterday (07/07/09) at the Official Google Blog.
So today, we’re announcing a new project that’s a natural extension of Google Chrome — the Google Chrome Operating System. It’s our attempt to re-think what operating systems should be.
Google Chrome OS is an open source, lightweight operating system that will initially be targeted at netbooks. Later this year we will open-source its code, and netbooks running Google Chrome OS will be available for consumers in the second half of 2010.
(…)
Speed, simplicity and security are the key aspects of Google Chrome OS. We’re designing the OS to be fast and lightweight, to start up and get you onto the web in a few seconds. The user interface is minimal to stay out of your way, and most of the user experience takes place on the web. And as we did for the Google Chrome browser, we are going back to the basics and completely redesigning the underlying security architecture of the OS so that users don’t have to deal with viruses, malware and security updates.
(…)
The software architecture is simple — Google Chrome running within a new windowing system on top of a Linux kernel.
Visit the Official Google Blog for more details.
C#.codebox 6
WPF – How to get the location of a control?
1
2
3
4
5
6
7
| private Point GetControlLocation(UIElement myControl)
{
Vector vector = VisualTreeHelper.GetOffset(myControl);
Point currentPoint = new Point(vector.X, vector.Y);
return currentPoint;
} |
C#.codebox 5
WPF – How to drag an Image with the mouse?
The code below was used in ShortcutMan.G 3.0 to drag an image around the window (a TabItem in this case) with the mouse.
The image is contained within a Canvas which is contained within a TabItem.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
| Image myImage = null; //selected image
Boolean MouseIsDown = false; //mouse down state
//Left button down - when the mouse button is down in the image
void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
myImage = (Image)sender;
if (e.ClickCount == 1) //if one click
{
//Drag image
TabItem Tab = (TabItem)TabControl1.SelectedItem;
Canvas TabCanvas = (Canvas)Tab.Content;
////Get mouse coordinates and center the cursor in the image (optional)
Point mouseCoordinates = new Point(e.GetPosition(TabCanvas).X, e.GetPosition(TabCanvas).Y);
Canvas.SetLeft(myImage, mouseCoordinates.X - (myImage.Width / 2));
Canvas.SetTop(myImage, mouseCoordinates.Y - (myImage.Height / 2));
//Update mouse state
MouseIsDown = true;
}
}
//Left button up - when the mouse button goes up
void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//Update mouse state
MouseIsDown = false;
}
//Mouse leave - when the mouse button leaves the image
void Image_MouseLeave(object sender, MouseEventArgs e)
{
//Update mouse state
MouseIsDown = false;
}
//Mouse move - when the mouse moves
void Image_MouseMove(object sender, MouseEventArgs e)
{
if (myImage != null && MouseIsDown) //if there's an image selected and if mouse is down
{
TabItem Tab = (TabItem)TabControl1.SelectedItem;
Canvas TabCanvas = (Canvas)Tab.Content;
//Get mouse coordinates
Point mouseCoordinates = new Point(e.GetPosition(TabCanvas).X, e.GetPosition(TabCanvas).Y);
//Set limits - the limits within the tab (optional)
if (mouseCoordinates.X < 0)
mouseCoordinates.X = 0;
if (mouseCoordinates.Y < 0)
mouseCoordinates.Y = 0;
if (mouseCoordinates.X > TabCanvas.Width)
mouseCoordinates.X = TabCanvas.Width;
if (mouseCoordinates.Y > TabCanvas.Height)
mouseCoordinates.Y = TabCanvas.Height;
//Update image location
Canvas.SetLeft(myImage, mouseCoordinates.X - (myImage.Width / 2));
Canvas.SetTop(myImage, mouseCoordinates.Y - (myImage.Height / 2));
}
} |
C#.codebox 3
WPF – How to set the tab order in XAML Designer in VS2008?
Unfortunately, currently there is no simple way to do this (like in Windows Forms, with View->Tab Order).
An easy way to do it, is to use the properties window search functionality to filter only the TabIndex property and then apply appropriate values for each control. However, when your window is loaded you have to press the TAB key at least once, to set the focus on the first control in the tab order.
To do this automatically though, and to select/set focus on a control at runtime, you can do something like:
1
2
3
4
5
| //Load
private void Window_Loaded(object sender, RoutedEventArgs e)
{
TextBox1.Focus(); //set focus on a textbox
} |
C#.codebox 1
WPF – How to get the parent window of a control?
1
| Window thisControl_Window = Window.GetWindow(this); |
Filed under General, News
Just to say thanks to the ones that reviewed TextFindIT.
Check them out at the TextFindIT official post.
FreewareFiles.com
DownloadTube.com
BeyondSearch.com
TextFindIT 1.5 is now available for download.
Official post at LINK
Log:
1.5
-> Now working for PDF files (using colorpilot.com/pdflibrary.html);
-> You can now use the ‘Del’ key to remove an extension from the list;
-> No more case sensitive/non-case sensitive problems with the extensions;
-> Keywords are now separated by commas instead of spaces;
-> New icon made freely available by Artua.com;
-> Some graphical improvements;
-> Installation is now required.
Hi,
As you probably may know, C# library has a function that allows you to get all folders and sub-folders within a certain path. Even though it’s simple and easy to use, you can face a few problems when trying to access files that for some reason are not accessible. This simply throws an exception and the application fails.
When searching for sub-folders, there is no way to get all the exceptions thrown since they can be quite a lot, so the solution is to do a ‘get folders and sub-folders’ function yourself. Note that when we simply want the folders within a path (no sub-folders) then it is possible to catch the exceptions.
The code provided below was used in my project TextFindIT.
The function below will get all folders and sub-folders within a path and will add the results to a List of strings.
1
2
3
| //Get folders in a path
List<string> folders = new List<string>(); // Our list of folders where we will keep the results
folders = GetAllFolders(path); // Call the function |
So the code above will just call our function and send a valid path path.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| //Returns all folders inside a folder, including sub-folders
private List<string> GetAllFolders(string path)
{
List<string> folders = new List<string>(); // The list of results to be returned
folders.Add(path); // Our first result is our path (top folder)
// For each folder in our path, we will add the folder to the list, and check for sub-folders within that folder.
foreach (string folder in GetFolders(path))
{
folders.Add(folder); // Add the folder as a result
folders.AddRange(GetAllFolders(folder).ToList()); // Get all folders and sub-folders within the folder
}
return folders; // Return the list of results
}
//Returns all folders inside a folder (top only)
private string[] GetFolders(string path)
{
string[] folders = { }; // Array of results
// Below we try to add the folders inside 'path' and catch any possible exceptions.
try
{
folders = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);
}
catch
{
//catch exceptions to avoid breaking the search
}
return folders; // Return the results
} |
So basically, for each folder inside our path, we will check for sub-folders, and for each sub-folder we will also check for sub-folders, and so on…
Notice the line folders.AddRange(GetAllFolders(folder).ToList());. We are calling the function GetAllFolders while still inside of that same function. This is called Recursion. Also, because GetAllFolders returns a List of strings with the results, we must do .AddRange(...) to add to our main List of strings the entire list of results (i.e. add a List to a List).
In the second function, we just put in an array all the folders inside path by doing Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly); while catching any possible exception. path is our current path, * is the search pattern (in this case it’s anything), and the last parameter SearchOption.TopDirectoryOnly is our search options (top only). Because we are not trying to go for sub-folders it is possible to do this (catch the exceptions), otherwise it wouldn’t.
And I guess that’s basically it.
Hope you find it useful.