Monday, September 19, 2011

Myth Self Note 8 : C# - Moving a WPF Window with a WindowStyle of None

Moving a WPF Window when the WindowStyle is set to None.

Some use Thumb and DragDelta. But here i found easier way.

use DragMove();
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}

Ref: http://cloudstore.blogspot.com/2008/06/moving-wpf-window-with-windowstyle-of.html

Friday, September 16, 2011

Bt

central server - tracker
complete file - seed
connected computers with portion of the file - swarm
ordinary computers (not server) that have the file - peers

Wednesday, September 14, 2011

Myth Self Note 7: C# WPF - clear usercontrol


Situation:
i - stkBody children name 'usercontrolA' should be remove when btnStart is click. And 'usercontrolA' will be replace with other usercontrol
ii - usercontrolA : stkMain, stkLeft, stkRight, btnStart

Problem:
To clear the stkBody children (in this case is usercontrolA), use stkBody.Children.clear();
But we can't access stkBody within the 'usercontrolA' body itself.

Solution:
When declaring and adding usercontrolA to the stkBody children, declare btnStart

usercontrolA usercontrolA = new usercontrolA();
stkBody.Children.Add(usercontrolA);
usercontrolA.btnStart.Click += new RoutedEventHandler(btnStart_Click);

void btnScan_Click(object sender, RoutedEventArgs e)
{
stkBody.Children.Clear();
}

themythstoodstill: note for my future self; if don't understand,you should recall back 14/9/11..btnScan, clear parent stack

Source : Link

Tuesday, September 13, 2011

Myth Self Note 6: C# WPF - clear parent

1 - image above is a "usercontrol" which is included in another stack 'stkBody'
2 - motive : want to clear stack 'stkMain' when button 'btnStart' is clicked

Code:
((StackPanel)stkLeft.Parent).Children.Clear;

*stkLeft or stkRight, each can be use because we want to select its parent.

3 - motive : want to remove 'stkLeft' when 'btnStart' is clicked

Code:
((StackPanel)stkLeft.Parent).Children.Remove(stkLeft);


themythstoodstill: in btnStart_Click event, can't access the stkMain.

Monday, September 12, 2011

Myth self note 5: c# WPF - FolderBrowserDialog and listBox

My note on how to open and add folder path to listbox in WPF C#.


1) Right click -> Add Reference (Right click either on the project name "WPF1" or "Reference")
2) .NET -> System.Windows.Forms -> OK


3) using System.Windows.Forms
4) private FolderBrowserDialog openFolder = new FolderBrowserDialog();


5) btnAdd
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog browseFolder = new FolderBrowserDialog();
openFolder.SelectedPath = "C:\\";
DialogResult result = openFolder.ShowDialog();
if (result.ToString() == "OK")
{
lstPath.Items.Add(openFolder.SelectedPath);
}
}
6) btnRemove
private void btnRmv_Click(object sender, RoutedEventArgs e)
{
lstPath.Items.RemoveAt(lstPath.Items.IndexOf(lstPath.SelectedItem));
}


Example Run

themythstoodstill: note for myth future self, picture/figure explain itself..13/sep/2011

Myth self note 4: Window

Myth Self note; no 4:

var newWindow = new optionPath();
newWindow.Show();

Download Video in Opera

For those whose been using Opera Browser and does not install Orbit Downloader or IDM, and don't know how to download Streaming video (eg; youtube) from Opera.

Here an alternative;
1) http://userscripts.org/scripts/show/33042
Go to this URL, click install.
If so many words appear, just click Ctrl+A on the keyboard to select all the text, then open a Notepad and paste it there. Save As anyname with the extension of .js (eg: user.js)
2) Put the .js anywhere in your computer harddisk. Add the folder path that contain the js to opera script.