Posts

Showing posts from May, 2008

ASP MVC preview 3 released

I'm trying to upgrade from Preview 2 to Preview 3. I think the idea of having each action return an ActionResult was a good one, so far it has actually made my code slightly smaller. What I don't understand though is why Html.Select seems to have disappeared... Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1501: No overload for method 'Select' takes '5' arguments Source Error: Line 8: Product Line 9: Line 10: <%= Html.Select("SoftwareID", (object)ViewData["SoftwareList"], "Name", "ID", (object)ViewData["SoftwareID"]) %> Line 11: Line 12: When I go into the APX and type Html. there is no Select method listed along with

Hooking into ECO multi-association events

Although I have not (yet) needed this myself I can see myself needing it in the future and the question has been asked before. "Setting HasUserCode=True on a Child.Parent single role does what I want, but how do I handle the scenario where Parent.Children.Add(item) is called on a multirole?" By default you can’t, but with the addition of a single class and a small amount of tweaking you can get it to do what you want! Here is how to do it: 01: Mark Parent.Children’s association end with HasUserCode=True in the modeler and then generate code. 02: In the source code of your class (not within an ECO region) add the following   private EcoMultiAssociation<Child> m_Children; This is a class that does not yet exist, I will show the source code for it later. 02: In the source code locate the "Children" property and change it like so   public IEcoList<Child> Children   {     get     {       if (m_Children == null)       {         m_Children= new EcoMultiAssocia

Using Vista Aero theme in XP WPF apps

I found this article on the web recently which shows how to use the Vista Aero theme on XP in your WPF apps. I found two things: 01: It is less complicated that the article states. 02: It is a bit different if you already have stuff in your app resources, such as styles or control templates etc. So here are my steps 01: Add PresentationFramework.Aero to your applications References list. It is listed in the [.NET] tab. 02: Edit your App.xaml and change it from this <Application.Resources>   <!-- Your stuff here --> </Application.Resources> to this <Application.Resources>   <ResourceDictionary>     <!-- Put your stuff here instead -->     <ResourceDictionary.MergedDictionaries>       <ResourceDictionary Source="/PresentationFramework.Aero;component/themes/aero.normalcolor.xaml"/>     </ResourceDictionary.MergedDictionaries>   </ResourceDictionary> </Application.Resources>

Selecting WPF ListView row in code

An app I am considering migrating to WPF uses a DevExpress grid to show a list of events, as I animate my composition I highlight the current event in the grid. Things I have learned about WPF: 01: You can create a data grid type view like so: <ListView Name="ListView">   <ListView.View>     <GridView AllowsColumnReorder="False">       <GridViewColumn DisplayMemberBinding="{Binding Path=Title}" Header="Title"/>       <GridViewColumn DisplayMemberBinding="{Binding Path=FirstName}" Header="FirstName"/>       <GridViewColumn DisplayMemberBinding="{Binding Path=LastName}" Header="LastName"/>     </GridView>   </ListView.View> </ListView> 02: Don’t put a ListView in a <StackPanel>! It renders all of the data at once. When you have 6K rows of data for example it takes about 1 second to select the next row. Instead you should put it in a grid <Gri

Creating a drop shadow

Requirement: Take a PNG image that has an alpha mask and from it generate a new bitmap which has the same alpha mask but every pixel is black. Solution: private Bitmap GenerateDropShadowImage(Image image) {   Bitmap bitmap = new Bitmap(image);   BitmapData bits = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);   IntPtr bottomScanLine = bits.Scan0;   int bytesPerRow = bits.Width * 4;   unsafe   {     byte* pixelValue = (byte*)bottomScanLine.ToPointer();     for (int count = 0; count < bits.Width * bits.Height; count++)     {       pixelValue[0] = 0;       pixelValue[1] = 0;       pixelValue[2] = 0;       pixelValue = pixelValue + 4;     }   }   bitmap.UnlockBits(bits);   return bitmap; }