November 2003 - Posts

  • Now Taking Requests

    Filed under: ,

    I'm going to blantantly copy Chris, and take requests for blog content. My expertise is Layout, but I can pass on requests for other areas to my coworkers.

    Proposed future topics:

    • Walkthroughs for building interfaces/documents using Avalon layout classes
    • Creating custom layout elements (e.g. a Panel which flows its children along an arc)
    • Avalon layout architecture (how, when, and where layout happens)
    • Design decisions: History, motivation behind design decisions
    • Reader suggestions

    I realize I haven't posted much in the past few weeks, I was quite busy with Post-PDC planning, etc. Don't get your hopes up quite yet though, I'm going on vacation for two and a half weeks next week, so new content won't appear until mid-December. On the plus side, I'll be all rested (and tan) and actually have time to write some in-depth content.

    Let me know what you're interested in hearing about.

    PostTypeIcon
    4,939 Views
  • Outputting Debug Text to the Console

    Filed under: ,

    Erik Ardvisson asks:

    ... [I]s there some way to be able to output debug text to the console? (I tried #define DEBUG and all that.) I ended up using a log file but that is a bit cumbersome.

    We have a bug in our .Target files which cause the debug info to not get passed into CSC. We needed a quick workaround for the PDC build; we placed a hack into your myapp.xaml.cs file. To get console debugging working, do the following:

    1. Change "Debug" to "DEBUG" (all caps) in MyApp.xaml.cs
    2. Add "using System.Diagnostics"
    3. Call Debug.WriteLine("Hello!")
    4. See the output in the console

    This shouldn’t be an issue if you’re using VB.

    What if you're not using MyApp.xaml.cs? Just make sure "#define DEBUG" is in one of your .cs files.

    PostTypeIcon
    2,832 Views
  • Custom Layouts in Avalon

    Filed under: , ,

    RichB asks:

    What sort of layout does Avalon limit me to? Can I add my own layout engines instead of the standard flow layout?

    Avalon doesn’t place any limits on layout, developers are free to write the layout algorithm of their choosing. How would you implement a custom layout? Well, first you’ll need a quick introduction to the Avalon layout APIs.

    Layout computation occurs in two phases: Measure and Arrange; these functions are introduced on the UIElement base class. Measure and Arrange are the primary means for parent-child layout interaction (other interfaces exist, but they are optional). These passes can be (over) simplified as such:

    • Measure: Parent asks child how much size it requires
    • Arrange: Parent sets child size

    This is easily illustrated with a simple element such as Image. The layout parent Measures the Image, which computes its “desired size” by reading the source file’s dimensions (say 100 x 100). The parent will later call Arrange to set the Image’s size, usually taking the Image’s desired size into account.

    In most cases the child requires information about its layout context. A TextPanel with various paragraphs of text needs to know a line length to use when wrapping text, otherwise you end up with text which extends far off to the side of the screen. That is why Measure has a parameter, “available size,” which is commonly used as a wrapping size for flow layouts. Available size is usually the size of the window, getting partitioned as we descend the layout tree.

    In summary:

    • Measure: How much size is needed given this available size?
    • Arrange: Set size

    The Measure and Arrange concepts are the bare minimum you need to know for participating in layout. FrameworkElement introduces common properties such as Height, Width, MinHeight, MaxHeight, etc which add some complexity to the story, but you now have a basic understanding of the API.

    Finishing Rich’s question:

    ...[W]ould I be able to plug a layout engine into Avalon which is capable of laying out the SQL Server ER Diagram - which lays out each table in a database connected via primary/foreign key relationships and arranged so that no entities overlap?

    You can write your own custom element which implements such a layout algorithm, aside from the logic which ensures that no entities overlap, the code should be fairly simple.

    PostTypeIcon
    3,778 Views
  • XAMLXAMLXAMLXAML

    Filed under: ,

    Chris Anderson has written a series of articles about XAML:

    1. A Brief History of XAML
    2. Is XAML just data?
    3. Of Styles and Styling
    4. Response in some XUL newsgroups
    5. More on Avalon Styling... and CSS
    6. Another view on XUL
    7. XAML and the Web
    8. Dynamic UI

    I was inadvertently propelled into the midst of the XAML / XUL comparisons with an early post I wrote. Chris Anderson’s site is a far better place for these discussions. I’m sure this topic will remain active in the community, but I’ll let Chris be the host.

    PostTypeIcon
    3,311 Views
  • Weblog, take 2

    Filed under:

    Hopefully this will be the last time I move this weblog; I apologize for the broken links, if I had any control over the server I’d setup the right redirects.

    Meanwhile, I'm not quite sure how to move over my entries such that they keep their timestamps and comments (again, the lack of control over the server hurts me here). (Update: Robert says there's a quick script we should be able to use to port the content over)

    We now return you to our regularly scheduled weblog, already in progress.

    PostTypeIcon
    1,850 Views