JSEDLAK » .NET

Archive for the ‘.NET’ Category

Korkboard 1.1.0.0

Korkboard has been updated to version 1.1.0.0 after a couple changes and fixes. If you have already installed Korkboard, it will check for the update next time you run it. It will install the update the next (next) time it is run. If you do not have Korkboard, you can download it for free!

Korkboard v1.1.0.0 (177)

Here is a full list of the changes made since 1.0.0.4:

  • Added drag and drop sorting.
  • Added item pinning (will stay at the top).
  • Added settings for turning off (and on) certain data formats.
  • Added a “Clear Korkboard” button to clear all non-pinned and unselected items from the list
  • Fixed current item selection for when items are selected outside the application
  • Fixed text alignment issues in the settings page

I have also changed the download to point to the ClickOnce EXE file instead of the Application file. This should fix any issues with non-IE browsers. Thanks to Long Zheng and MetroTwit for this idea.

Korkboard 1.0.0.4

Korkboard Screenshot

Korkboard is a little tool I have been developing that enables a uniform method of storing multiple items on the clipboard. When Korkboard runs, it hooks into the clipboard chain and attempts to intercept messages as you use the Copy and Cut commands. It then stores the items on its own list so that they may be retrieved at a later time. It is important to note that Korkboard does not mess with the functionality of the clipboard. If you copy an item, the clipboard works as expected without any interruption or user required interception. Check it out, and let me know what you think!

Korkboard is written in WPF/.NET4 and uses ClickOnce to manage the installation and update processes.

Update: Added the Zip file for those having trouble using the ClickOnce method.

Cache Problems with ASP.NET MVC Views?

If you have done any decent amount of work with the ASP.NET MVC platform, you have probably run into the following problem. You have a page where you want to update data on the server without a postback and so you whip out some fancy Javascript to send a request to the server. What happens is the response you get back is a success, and the data is updated, but subsequent requests don’t seem to be updated. This is most noticeable with partial views and content views called via the infamous “$.ajax” call. What you forgot was to make sure the browser isn’t caching the result:

?View Code CHSARP
1
HttpContext.Response.AddHeader("cache-control", "no-cache");

Note that if you have already hit the particular view and it is cached, you can generally clear the cache by navigating to the URI of the view manually and hitting refresh.

FGF 0.1.2.0 Released with Gesture Recognition

New to the input engine within the Focused Games Framework is the gesture recognition capabilities, housed in the GestureTracker class. The gesture recognition class currently supports a small subset of the gestures I plan on supporting, but all are useful none-the-less. The included gestures are press, two fingered press, swipe, two fingered swipe, zoom and pinch. To use the gesture recognition, instantiate a GestureTracker object, add it to the IGame.Modules list and then listen to its GestureTracked even. You will also need an instance of the InputManager class added to the list of modules.

The following is a small sample taken from one of my games that handles some simple menu swiping (a full sample is on the way).

If you do happen to use FGF, I would love to hear what you think! Drop me a line via the Contact form or leave a comment here.

?View Code CSHARP
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
private void OnGestureTracked(object sender, GestureArgs args)
{
    // If it wasn't a swipe, we don't care!
    if (args.Gesture != Gesture.Swipe) return;
 
    // Get the direction of the swipe to determine what way
    // the menus should move
    if (args.Direction.X < 0)
    {
        // If we are capped at the right side of the menus, return
        if (current == menus.Length - 1) return;
 
        // Transition the menus
        menus[current].Transition(Menu.MoveDir.OffToLeft);
 
        current++;
 
        menus[current].Transition(Menu.MoveDir.OnFromRight);
    }
    else
    {
        if (current == 0) return;
 
        menus[current].Transition(Menu.MoveDir.OffToRight);
 
        current--;
 
        menus[current].Transition(Menu.MoveDir.OnFromLeft);
    }
}

 Download FGF 0.1.2.0 Bin

Read the rest of this entry »

What is DMS?

During the last semester I was taking a class on ASP.NET where we formed teams to write a website from scratch. The website was a “project manager” that would help users maintain projects, employees and customers. Given my experience with ASP.NET prior to the class, my team hit the ground in a full on sprint. We hit a wall when it came time to bind the site’s controls to the data behind it, in this case a Microsoft SQL database. The problems weren’t associated with a lack of knowledge but rather the gross disconnect between interfaces and the data with which they associate. It is easy to think that a textbox on a page can represent a name, but how that name is actually filled in can be the most complicated process.

This is just one instance of running into issues with data. How many times have you used a converter of some sort to scrub data or used a validator to make sure it can be stored? How many times have you written the same try-catch block for the SqlConnection class? How many times have you written a statement with “XmlDocument” or an instance somewhere in the middle? I have come to realize that there within the .NET Framework, there are many classes to get all the work done, but they aren’t really put together in a unified way. When you look at all the data-oriented classes (e.g. System.Xml.*, System.Data.*) you will find that there is no grand picture. For some reason the framework architects didn’t take a step back and see a possibility to unify the approach to reaching, converting, validating and consuming data.

So what is DMS? In short, the Data Management System prototype is a look into how possible it is to unify the approach to using data and whether or not it can make a developer’s life easier. The first step is to consider open architectures that are highly extensible and configurable. The current version of the DMS Prototype is focusing on just that by experimenting with converting runtime objects to and from XML. The important part isn’t the conversion; XML serialization has been done to death before. The important part to take away is that the serialization is being done in an abstracted manner. It is trying to gain as much information as possible from as little information as possible. The fewer attributes a developer has to use and the more generic they are, the easier life will be.

Read the rest of this entry »

FGF: Modules, Not Components

As you no doubt saw in the writing of the Application class, FGF implements its own version of the XNA Framework’s component classes. The first major reason for doing so is that the builtin component classes require you to pass in a (Framework) Game object through the constructor. While this dependency can be circumvented by implementing the interfaces directly and supplying a manual workaround, the attempt is exactly that: a workaround. The second major reason for my implementation is that by controlling the interfaces and base classes, I can easily support more advanced situations such as the separation between initialization and content loading/unloading. You will see more of this later on when I modify the classes to support asynchronous content loading.

For now, the focus is being put on building a robust base for developers to start working with my framework. Because the goal is to fix the XNA Framework’s implementation, we begin with a simplification of the IGameComponent, IUpdateable and IDrawable interfaces. We combine these three into a single, multi-purpose interface, IModule.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public interface IModule
{
    event EventHandler DrawOrderChanged;
    event EventHandler UpdateOrderChanged;
 
    void Initialize(IGame game);
 
    void Draw(GameTime gameTime);
    void Update(GameTime gameTime);
 
    int DrawOrder { get; }
    int UpdateOrder { get; }
 
    bool IsVisible { get; set; }
    bool IsEnabled { get; set; }
    bool IsInitialized { get; set; }
 
    IModule Parent { get; set; }
    ModuleCollection Modules { get; }
}

Read the rest of this entry »

Linking To CSS Files In MasterPages

A common problem for beginning ASP.NET developers is relative linking to CSS files in a MasterPage file. As it turns out, this is incredibly easy as shown below. Even better is that it works in ASP.NET MVC!

1
<link rel="Stylesheet" href="<%= ResolveUrl("css/Master.css") %>" type="text/css" media="screen" />

FGF: Oriented Drawing

After you’ve read about the Display Orientation features of FGF, a natural question to ask is “How do I draw and take input with a rotated display?” Fortunately FGF has some methods to help in this department that sit alongside the rotation methods and properties in the Application class.

Application.OrientedDisplaySize

If you need to draw something relative to the size of the screen, use the OrientedDisplaySize property of the Application class. This property differs from DisplaySize, which is used to change the actual size of the display, in that OrientatedDisplaySize reacts to the selected rotation of the display, set with the DisplayOrientation property.

?View Code CSHARP
1
2
3
4
DisplaySize = new Vector2(272, 480);
DisplayOrientation = DisplayOrientation.Rotated;
 
Console.WriteLine(OrientedDisplaySize.ToString());

Because the display is set to be rotated (landscape on the Zune HD), the above code will actually print out a display size of (480, 272) rather than the standard (272, 480) size.

Read the rest of this entry »

FGF: Display Orientation on the Zune HD

New in the Focused Games Framework is the support for rotating and resizing the display on the fly. The main reason for this functionality is for mobile platforms like the Zune HD that support games in a landscape mode as well as a portrait mode. Supporting either in your game is made easy with FGF-you just need to know the right properties. In the standard display mode, the Zune HD has a display resolution of 272 pixels by 480 pixels. In landscape mode those two measurements are switched: 480 pixels by 272 pixels. While it is important to know the standard resolution, mucking about with a render target and backbuffer size is no longer necessary.

The one hitch? Your game class needs to inherit from FocusedGames.Xna.Application instead of Microsoft’s Game class. The following code block sets a Zune HD game up for landscape rendering.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
public class Game1 : Application
{
    public Game1()
    {
        // Set the display size and the rotation
        DisplaySize = new Vector2(272, 480);
        DisplayOrientation = DisplayOrientation.Rotated;
    }
 
    // ...
}

Note that to keep the device in portrait mode, you don’t need to change the value of DisplayOrientation but setting the DisplaySize property to the standard value is a good idea. Happy landscaping!

FGF: A Helper For Creating Render Targets

Before I begin this post, big thanks to Eibx and David over at the Community Forums for helping me find these methods. I have modified the CheckTexture method a bit, but its purpose remains unchanged.

As of the last FGF article, the Application class was implementing the IGame interface but was missing the ability to create a render target object on the PC and Xbox 360. For PC games this can be a troubling problem since different hardware can obviously require different formats and dimensions of render target. Rather than bake this functionality into the Application class itself, it is moved to a static helper class so that all developers can make good use of its functionality at any point in time.

To start off, a simple default creation method is included to give the basic functionality an easy access point.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
 
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
 
namespace FocusedGames.Xna.Graphics
{
    public static class GraphicsHelper
    {
        public static RenderTarget2D CreateRenderTarget(GraphicsDevice device)
        {
            return CreateRenderTarget(
                device, 
                device.PresentationParameters.BackBufferWidth, 
                device.PresentationParameters.BackBufferHeight, 
                1, 
                device.PresentationParameters.BackBufferFormat
            );
        }

Read the rest of this entry »