Friday, May 18, 2018

Hello.  It has been a very long while.  However, I believe it will be good for me to begin blogging again and this time make use of Github for sharing the source code samples I built.  I will be placing all of my samples in public repos here: https://github.com/boardermindtrick

Stay tuned...

Friday, August 5, 2011

Video Chat with Kinect

I have recently been writing articles for Que Publishing. My latest article deals with the video chat functionality with Kinect. You can find it by following this link.

Tuesday, December 14, 2010

Intentionally fill up isolated storage in Silverlight

I came across a bug in my application which required me to fill the IsolatedStorageFile to reproduce. I thought I would share this snippet for any of you out there that need to quickly fill your isolated storage in your app to reproduce a full isolated storage environment.

private static void FillUpISO()
{

int loopCount = 600;

string content = "al;jd fkjasdklfj alks;djf lkajsd klfjlkdasj fklj alsdjfk jadlkjflk;ajsd;lfkj kldsjf lk;jdkljldjglkjdgk dghkd fjkl dlk;fj l;kdj sfk asd " +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj";


if (!IsolatedStorageFile.IsEnabled)
return;

using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForSite())
{
using (IsolatedStorageFileStream isfs
= new IsolatedStorageFileStream("Whatever",
FileMode.OpenOrCreate,
FileAccess.ReadWrite,
isf))
{
using (StreamWriter writer = new StreamWriter(isfs))
{
writer.WriteLine(content);
writer.Close();
}
isfs.Close();
}
}
try
{

for (int i = 0; i < loopCount; i++)
{

using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForSite())
{
using (IsolatedStorageFileStream isfs
= new IsolatedStorageFileStream("Whatever",
FileMode.Append,
FileAccess.Write,
isf))
{
using (StreamWriter writer = new StreamWriter(isfs))
{

writer.WriteLine(content);
writer.Close();
}
isfs.Close();
}
}
}
}
catch (IsolatedStorageException isex)
{
var i = isex.Message;
}
}




Simply add the method from my sample app, or above, to one of your classes in your application and make the call to it. Here is the sample app.

http://cid-ab80127ae39f5a1e.office.live.com/self.aspx/.Public/fillIsolatedStorageHelper.zip

Cheers,

Bryon

Wednesday, August 18, 2010

WPF Modal Dialog when owner is IWin32Window

Today I was working on a plugin for Windows Live Photo Gallery, using WPF, and ran into an issue where I could not seem to set up modal dialog behavior. When a user opened up my plugin the task bar would have two entries, Windows Live Photo Gallery (WLPG), and my plugin. If a user selected the WLPG our plugin would be hidden behind the WLPG window.

However, I noticed other plugins made the border flash when trying to go back to WLPG without closing the plugin. I wanted the modal behavior in my plugin also. Simply using a WPF Window's .ShowDialog does not do the trick. This is because the WLPG is a IWin32Window, not a System.Windows.Window. WindowInteropHelper to the rescue!!!

GET TO THE POINT OF HOW TO DO IT! OK, OK, I hear you. So to make this simple make the following assumption. You have a WPF window named wpfWindow. You want to show wpfWindow as a modal dialog of the IWin32Window. Code the following:

//BEGIN CODE Snippet
//Use WindowInteropHelper to the wpfWindow
WindowInteropHelper helper = new WindowInteropHelper(wpfWindow);

//Get the process containing the IWin32Window
Process procs = Process.GetCurrentProcess();
IntPtr hwnd = procs.MainWindowHandle;

//Set the owner so it behaves like a true Modal Dialog
helper.Owner = hwnd;
wpfWindow.ShowDialog();

//End code snippet


That is all.
Cheers!
Bryon

Friday, June 25, 2010

JetBrains ReSharper 4.5 screen refresh issue and workaround

Problem:
I have ran across an issue with Visual Studio 2008 and JetBrains ReSharper 4.5 which prevents part of the screen from refreshing properly. This is frustrating at times because it even affects the scrollbar from functioning forcing you to use the keyboard to scroll through your code.

Workaround
To work around this you can DISABLE and ENABLE JetBrains ReSharper 4.5 in the Add-in Manager of Visual Studio.

Disable:
Open up Add-In Manager from the menu Tools->Add-in Manager.
Uncheck JetBrains ReSharper 4.5 and click OK.
It is good to disable before checking code into TFS or when reviewing existing code.

Enable:
Open up Add-In Manager from the menu Tools->Add-in Manager.
Check JetBrains ReSharper 4.5 and click OK.
It is good to enable when you are writing new code or doing any refactoring.


I have not seen any fix for this bug yet, but until then this workaround is not too time consuming.

Cheers!

Thursday, October 8, 2009

How to find windows revision number

Looking for windows version, build number and revision number? The computer properties only tell you the version number. So the following is how to see the revision number:

Click Start, type regedit and press Enter to open the Windows registry
Navigate to the registry key – HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion and Bam!, there it is.

Tuesday, August 18, 2009

Updating an attribute in multiple xml nodes with transact SQL XML

I ran into a situation where I needed to update an attribute of each node of XML that is stored in a column of one of our database tables. This logic needed to be performed in a stored procedure, so I needed to make use of the XML functionality of SQL Server 2008.

First Thought:
1) set an xml variable value to the value from the table
2) loop through the xml nodes and update the attribute values
3) execute an update statement to place the xml variable value back into the record's column value.


Second Thought:
1) set an xml variable value to the value from the table
2) Select xml into a temp table and use SQL Update statements (much cleaner than looping)
3) execute an update statement to place the xml variable value back into the

So after much more thinking my second thought seemed like a cleaner coding choice. Here is an example of how to do this.

The XML value in column [Style] of table [CustomProject] is as follows:
<Styles>
<Style id="60161" sortorder="1" />
<Style id="60152" sortorder="2" />
<Style id="60159" sortorder="3" />
<Style id="60158" sortorder="4" />
<Style id="60191" sortorder="5" />
<Style id="60162" sortorder="6" />
<Style id="60160" sortorder="7" />
</Styles>

I place the XML into a variable as follows:

--declare before and after variables
declare @OldStyleXML as XML
declare @NewStyleXML as XML

--place the CustomProjects.StyleXML into the xml variable
SELECT @OldStyleXML = p.StyleXML
FROM CustomProjects p
WHERE p.CustomProjectID = 12345

--create the temp table to dump the xml data into
create table #StylesXML
(
styleid int null,
sortorder int null
)

--insert into the temp table from the xml variable
insert into #StylesXML
( styleid,
[sortorder]
)
select
Tab.Col.query('.').value('(//@id)[1]','int') AS 'styleid',
Tab.Col.query('.').value('(//@sortorder)[1]','int') AS 'sortorder'
FROM
@OldStyleXML .nodes('//Style) as Tab(Col)


--perform normal SQL update statement to update the information to what you want. My example updates the old styleIDs to the new styleIDs based on styletypeid and with the assumption that the old styles sortorder and new styles sortorder are their equivalent replacements.
update #StylesXML
set styleid = NewStyle.styleid
from ( select s.*
from #StylesXML temp,
Styles s
where temp.styleid = s.styleid) OldStyles,
( select s.*
from styles s
where s.StyleTypeID = @NewStyleTypeID) NewStyles where OldStyles.SortOrder = NewStyles.SortOrder
and #StylesXML.styleid = OldStyles.styleid


--Put the new updated styles back into the xml variable with <style> tags wrapping each element
SET @NewStyleXML = (
SELECT styleid AS [style/@id]
,sortorder AS [style/@sortorder]
FROM #StylesXML
FOR XML PATH('') )

--Wrap the entire set of tags with <styles> "plural" tag
SET @NewStyleXML = (
SELECT @NewStyleXML
FOR XML PATH('styles')
)

--Put it back into the record
UPDATE CustomProjects p
SET p.StyleXML = @NewStyleXML
WHERE p.CustomProjectID = 12345

That is it!