I ran into an issue using NHibernate + domain objects with the Syncfusion grid.
I am using an auto incremented [generated identity] integer primary key that NHibernate expects to be null when creating a new item.

With the syncfusion grid, the primary key is a required field on the “add new” form/dialog by default.
To avoid the requirement of supplying a value in the “add new” form, you can hide the parent div of the primary key input item by using the “OnActionSuccess” client event.

@(Html.Syncfusion().Grid("GenericListGrid")
        .ClientSideEvents(events =>
        {
            events.OnActionSuccess("HideOnAdd");
        });
)

Then the javascript function to hide the field from validation…
In this case, the field mapping is “Id”.

        
            function HideOnAdd(sender, args) {
                alert(args.RequestType);
                if (args.RequestType == 'AddNew') {
                    var gridObj = $('#GenericListGridEditDialog');
                    gridObj.find('#Id').parent().css('display', 'none');
                }
            }
        

If you are using a different edit method, the name of the form or dialog could be a different format.

SQL table for US States

Posted: August 31, 2013 in SQL
Tags:

I saw a script here…

http://www.webcosmoforums.com/databases/21515-insert-script-us-states-abbreviation-ms-sql.html

But changed it to better suit my needs -

CREATE TABLE [dbo].[USStates](
 [StateID] [int] IDENTITY(1,1) NOT NULL,
 [Name] [varchar](50) NULL,
 [Abbrev] [varchar](3) NULL
 CONSTRAINT [PK_USStates] PRIMARY KEY CLUSTERED 
(
 [StateID] ASC
 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
 ) ON [PRIMARY]
 
 insert into USStates (Name,Abbrev)
 Select 'Alabama', 'AL' UNION ALL
 Select 'Alaska', 'AK' UNION ALL
 Select 'Arizona', 'AZ' UNION ALL
 Select 'Arkansas', 'AR' UNION ALL
 Select 'California', 'CA' UNION ALL
 Select 'Colorado', 'CO' UNION ALL
 Select 'Connecticut', 'CT' UNION ALL
 Select 'Delaware', 'DE' UNION ALL
 Select 'District of Columbia', 'DC' UNION ALL
 Select 'Florida', 'FL' UNION ALL
 Select 'Georgia', 'GA' UNION ALL
 Select 'Hawaii', 'HI' UNION ALL
 Select 'Idaho', 'ID' UNION ALL
 Select 'Illinois', 'IL' UNION ALL
 Select 'Indiana', 'IN' UNION ALL
 Select 'Iowa', 'IA' UNION ALL
 Select 'Kansas', 'KS' UNION ALL
 Select 'Kentucky', 'KY' UNION ALL
 Select 'Louisiana', 'LA' UNION ALL
 Select 'Maine', 'ME' UNION ALL
 Select 'Maryland', 'MD' UNION ALL
 Select 'Massachusetts', 'MA' UNION ALL
 Select 'Michigan', 'MI' UNION ALL
 Select 'Minnesota', 'MN' UNION ALL
 Select 'Mississippi', 'MS' UNION ALL
 Select 'Missouri', 'MO' UNION ALL
 Select 'Montana', 'MT' UNION ALL
 Select 'Nebraska', 'NE' UNION ALL
 Select 'Nevada', 'NV' UNION ALL
 Select 'New Hampshire', 'NH' UNION ALL
 Select 'New Jersey', 'NJ' UNION ALL
 Select 'New Mexico', 'NM' UNION ALL
 Select 'New York', 'NY' UNION ALL
 Select 'North Carolina', 'NC' UNION ALL
 Select 'North Dakota', 'ND' UNION ALL
 Select 'Ohio', 'OH' UNION ALL
 Select 'Oklahoma', 'OK' UNION ALL
 Select 'Oregon', 'OR' UNION ALL
 Select 'Pennsylvania', 'PA' UNION ALL
 Select 'Rhode Island', 'RI' UNION ALL
 Select 'South Carolina', 'SC' UNION ALL
 Select 'South Dakota', 'SD' UNION ALL
 Select 'Tennessee', 'TN' UNION ALL
 Select 'Texas', 'TX' UNION ALL
 Select 'Utah', 'UT' UNION ALL
 Select 'Vermont', 'VT' UNION ALL
 Select 'Virginia', 'VA' UNION ALL
 Select 'Washington', 'WA' UNION ALL
 Select 'West Virginia', 'WV' UNION ALL
 Select 'Wisconsin', 'WI' UNION ALL
 Select 'Wyoming', 'WY' 

[Regarding Game Salad version 0.10.0]

It took me a little bit to realize you can’t just type the name of the table in the tableCellValue().

You need to use the attribute browser to insert the table as a parameter.

GameSaladTableCellValue

I’ve constructed a primitive batch based on the Microsoft and Farseer examples that can apply a texture to a 2D polygon.

Texture configuration properties are stored in the ‘user data’ property in the Farseer Body and Fixture objects.

I use the body position to determine the texture coordinates. This allows you to apply rotation and translation to the texture coordinates based on the body, in addition to the stored properties.

As you can see, the textures can be applied across multiple sub fixtures.

alphaEditor_03

XNA Development – Turnip Toss

Posted: December 27, 2012 in .NET, XNA
Tags: , ,

Working on a XNA game I am currently calling “Turnip Toss” using the Farseer physics engine.

The editor is in early alpha stages now.
2 dimensional “bodies” and simple shapes can be created by right clicking a position on the editing surface.

alphaEditor_01

alphaEditor_02

Converting a Frequency to a Midi Note

Posted: December 3, 2012 in .NET

This is a C# method to convert a pitch or frequency to a midi note.
I am shifting detected frequencies to the nearest semi-tone before using this formula.


private double GetMidiNote(float freq)
{
return Math.Ceiling(69 + 12 * (Math.Log(freq/440, 2)));
}

Introduction to Umbraco

Posted: August 27, 2012 in .NET, Umbraco
Tags: ,

I recently hosted the first Fort Worth .NET User’s Group first SIG.

The topic was Umbraco CMS. Here is the deck -