| Steven's profileDevelopmentalBlogLists | Help |
DevelopmentalFlinging crap at other monkeys in the development forest |
May 24 WPF ListViewItem – Stretch to take the full widthI’m doing a bit of WPF at the moment for a company in Sydney and also working on a WPF project in my spare time. Tonight I came across this issue and thought I’d document the simple solution in case I run into it again in the future. I have a ListView that takes up the full width of my window. I’ve edited the ListViewItem template to put a border around the items. The code looked like this:
The problem was that the border was only as big as the content inside it, even though the listview was the width of the window. What I wanted was to show an equal sized border for each item despite the size of the content inside. The solution in the end was really quite simple: to add the HorizontalContentAlignment="Stretch" attribute to the ListView declaration. Easy! March 24 Ada Lovelace Day 2009 – Catherine Eibner
From: http://findingada.com/ I only heard about this today to be honest. Perhaps that makes me part of the problem, I’m not sure. I don’t want to go into the gory details of equality in the workplace. What I do want to say is that there is definitely a clear lack of female role models in the industry. That’s why this pledge is so important: there are a lot of women out there doing excellent things in the community and that’s why I’m writing this post: my pledge to talk about a woman in the industry that I admire: Catherine Eibner. Catherine is one of the most community focused people I have ever met, male or female. A single mother who also started her own company, while kicking off the Sydney CRM user group, a podcaster and geek girl, a regular attendee of Sydney user groups in general and frequent speaker herself, Australia wide. Catherine was awarded the MVP status from Microsoft, only to have it recalled when she became a Microsoft full-time employee for the DPE group: just two more indicators of how much the community appreciates her involvement. Whenever I am in Sydney and looking for the local community events, Catherine is always there to show me the way! Thankyou Catherine, and keep up your good work. The world’s a better place for having you. You can find Catherine here: I encourage all of you to post about a female in the tech industry you admire and why. If you don’t know one, at least spend the time to think about why that might be. February 27 A Fractal Generator in C# for .Net 3.5Fractals are interesting creatures. They are the visual representation of complex mathematical functions. Writing a fractal generator was something I always wanted to do, and recently found the time. My initial motivation was to discover if fractals were able to be generated using parallel processing, which they most certainly are, so I set off with a clear goal in mind: a multi-threaded fractal generator. This post is the result of that work. I’ll start by linking to Snagy.Fractals.zip. This zip file contains 3 projects: a core fractal library, a console app, and a WPF app. The 2 apps use the fractal library to generate fractals in both single and multi-threaded scenarios. Mandelbrot One of the most common functions is the set of numbers defined by Benoit Mandelbrot in the Mandelbrot Set. This function relates to the concept of Complex Numbers and the plotting of co-ordinates on the Complex Plane. This particular branch of mathematics is complex and I’m not going to talk about it here (mostly because I still don’t know how it all works!). Suffice to say that the fractals generated from the Mandelbrot set are the most common and well documented. I selected the Mandelbrot algorithm for my fractal generator. Existing Generators Before I started this work I thought it more worth while to use an existing generator if one was available. There were some, but one of the key problems I discovered was that they were badly written and difficult to understand. Having said that, some might find the same problems with mine, and if that is the case, please let me know! Another problem I discovered was that some of these generators were written by mathematicians. This meant that the language and terminology used presumed an understanding of the maths (which I only have part of) and that made the code difficult to read. So my goal was to lose the jargon and stick to programming terms. Snagy.Fractals After spending some time on the mathematics, I followed some online guides to programming the fractal, as well as munging in some concepts from some example applications I found. Snagy.Fractals namespace is the end result, and here is an overview of the important classes within. FractalSettings – Contains just properties representing the required settings for a fractal How It Works This won’t be a math lecture so we’ll just cover some simple concepts. First, fractals are generated on a pixel by pixel basis. This makes them excellent candidates for parallelism: 2 pixels can be generated at the same time because there is no relationship between pixels. The work we do is broken up into ‘Strips’. Imagine we want a fractal that is 900x900 pixels in size. We can break this up into 200x900 strips, with the 5th strip only being 100x900 pixels. These strips allow us to break our work up into logical units. These strips are what get distributed amongst multiple threads. Scale Think about a 900x900 fractal image again. If we just run the standard co-ordinates through the functions (x = 1 to 900, y = 1 to 900) then the Mandelbrot fractal is quite small (a couple pixels). This doesn’t let us see anything interesting! So we need to simulate “zoom”. To do this we take a scale modifier and multiple the numbers against that. The best top level zoom starts at scale 0.01. This means we are supplying the algorithm with the numbers x = 0.01 to 9.00 and y = 0.01 to 9.00. But the most amazing art occurs much deeper still! Offsets Because Mandelbrot is based on quadratic equations (eg. y = ax^2 + bx + c ) then everything happens around the ‘Origin’. This means we need to introduce negative X and Y values, with the centre of our image being co-ordinate 0:0. To achieve this we need to offset calculations based on how big our image is (Height/2, Width/2) and also based on our zoom level. This moves the fractal to the centre of our screen (in this case, the centre of our bitmap that we are creating). Centre When we start zooming in, we don’t actually want to look at the exact centre of the image. If you look at pictures of Mandelbrot, you’ll see the very centre is empty! Nothing exciting happening there, so we actually need to zoom in at specific x/y locations. These locations have to take into account the offsets mentioned above, and of course the scale factor. Iterations The colour of any pixel is decided by the number of iterations of the Mandelbrot function that can occur. What we mean by this is that the function : f(n) can be called on itself recursively “i” number of times while satisfying the core equation (see complex quadratic equations for details). So if the deepest we can go at a particular point is f(f(f(f(f(n))))) then this means we reached 5 iterations. Forget the math though; the MandelbrotBase class will calculate the iteration for you based on the x/y co-ordinate. However this x/y co-ordinate is actually relative to the centre mentioned above, so is in fact quite a small number pair, rather than the actual X/Y of the bitmap we are calculating. To Infinity – And Beyond! If you zoom in on an ‘edge’ of a fractal, you will see that you can keep zooming.. forever and ever. Well this isn’t technically true: the app is hardcoded to 1000 iterations max, which means that there are defined edges between the fractal and space. But theoretically.. .there is no such edge! Snagy.Fractals.Console All the fractal work is done in the class library, so its really very easy to consume and use in your own application. The console application is a perfect example of this. All the code in this app is around getting command line parameters and turning them into a FractalSettings instance, and then saving the resulting fractal image. Use this application as a guide to using the fractal classes. Snagy.Fractals.WPF This is a simple harness that will show you the fractal based on your settings on the left. Enter a scale and centre point, then click create. I did attempt to put some navigation into it, but its very flaky. There is this tendency for UI events to “queue” while the fractal is being generated. As a result the experience is rather poor, but the framework is there if someone wants to work on it and make it work better. Summary This is open to anyone to use. Since its unusual to embed a fractal generator in a commercial app, I’m not too concerned about what you use it for. But if you do republish an app with my code, I’d appreciate a mention and a link through. =) Thanks I have to thank Buddhike for his help around the threading. Bud helped me get the locking sorted along with the right threading classes. So thanks Bud! I’d also like to thank Paul Stovell for making me ditch my original Win Forms harness and use WPF instead, which resulted in more work to convert bitmaps, recreate my flashy UX, and fight against dispatchers. The WPF navigation (pan and zoom) was based on this article on the topic. January 30 TFS Shared Resources in MeshI was lucky enough to get an early invite to Live Mesh (I was working at Microsoft at the time). Back then it seemed more like a concept than an implementation there were that many flaws. I tried it for a while, but fell back to folder share and other technologies. Mesh got uninstalled. To be honest, I hadn’t looked at Mesh since that time. Until today. It all started as the result of a TFS engagement I had just finished consulting on down at the Gold Coast. I decided to build a TFS Resource Pack for all the common files you typically need on a TFS engagement. For example, VSTS SP1, TFS 08 SP1, SQL Server 2005 SP1, TFS sync tool, TFS migration tool, Branching Guidance document, TF Power Tools, Team System Web Access SP1, the list goes on! Usually I just download these tools on site at the client but I figured it would be easier to have a portable HDD with all these items (I don’t own such a HDD but was willing to buy one). I ran the list of items in my pack past some internal Readify guys and one of the responses was: ‘Why not mesh?’ Why not indeed! There’s 5Gb worth of space in the cloud that I can use so why not put all these resources in one place where I can always get them? Maybe not the 1Gb ISO’s for service packs, but certainly the rest can go there. So as of today, there is a folder in mesh with all this information, and I plan on continuing to add to it over time. Want access? All you need is a Live Mesh account and send me your email: I’ll invite you to the folder so you can get the files as well (read access only if I don’t know you). And then just email me if you think I should add any particular file or application.
January 24 The Right Administrator Permissions in TFS, WSS, and RSI tend to forget the right permissions to set for TFS 2008 and its various components. And not all the various permissions are readily searchable on the net. So this quick blog entry is just a reminder for myself. Create Projects in TFS To create a project in TFS you need the relevant TFS permission ‘Create new projects’ which is defined at the server level. By default, the ‘[SERVER] Team Foundation Administrators’ group has this permission, but being a member of this group is just not enough. When you create a new team project, TFS also creates a new site in Windows Sharepoint Services (WSS), and a new folder in Reporting Services (RS). So it only makes sense that the user should have permissions to be able to perform both those operations as well. Reporting Services is pretty easy. With your admin account that installed TFS (TFSSetup perhaps?) go to your Reporting Services web folder, typically it is something like this: http://tfsrtm08/Reports. You will be able to see the sub folders for each of your projects, but we need to set permissions at this root level. Click on the ‘Properties’ tab and click ‘New Role Assignment’. Specify your user account (or AD group) and tick all the boxes. Finally click OK and you are done. RS permissions are inherited so the user will get access to all sub folders, now and in the future. WSS is a bit more interesting. Adding a user to the root site and giving them ‘Full Control’ in fact does nothing. It is not like RS where the permissions are inherited. Full Control on the root site means ONLY the root site, not sub sites, and not the ability to create new sub sites. What you need is the ‘Site Collection Administrators’ permission for the root site instead. Find it by going ‘Site Actions –> Site Settings –> Site Collection Administrators’. Add your user here and they will be able to create sub sites. However it is worth noting that this does not entitle your user to full control over all sites that are created: it will only give them full access to the ones that THEY create. If someone else creates one, this user will NOT have access. We’ll deal with this below. Full Admin Privileges One of the things I find is that TFS management (including permissions) falls to the hands of the infrastructure team. And infrastructure guys like to manage permissions through Active Directory. They like to have a ‘TFS Admins’ group in AD and for anyone to have full access, they want to be able to just add them to that group and not have to think about it any further. It makes sense somewhat because this is how a lot of their user maintenance occurs in their day-to-day jobs. As mentioned earlier, just because you have Site Collection Administrator privileges does not mean you have full control over all sub sites. If you create a new site, you will be given admin access to that site. But if someone else creates one, then you will NOT have access. Site Collection Admin only lets you create sites, nothing more. So normally you have to add users to a site after it is created. But sometimes there is a lead developer or sys admin who should have full access over all WSS sites, regardless of who created them. This permission is a little harder to find. To fix this, you need to access WSS Central Administration, which is typically something like http://tfsrtm08:17012/. You will need to do this with your TFSSetup account (or equivalent) since it will be the only account out of the box that has WSS Central Admin privileges. Go to: ‘Application Management –> Policy for Web Application’ and click ‘Add Users’. On the first screen, ensure Zones is set to ‘All Zones’ and click Next. Then under ‘Choose Users’ add your user account to the box and click the little ‘tick’ icon below to ‘check names’. Check the box for ‘Full Control’ and click ‘Finish’. This gives your user full access over the whole application, which means all future sub sites that may get created. Summary I’m not really sure what best practice is, but from my experience it is often best that only the TFSSetup account has master access to everything. Creating a new team project is not something that should happen every day. It represents something big, a new era of development. Its something that will have a lifecycle, iterations, management and buy-in from stakeholders inside and outside your development team. It makes sense that there should be one person responsible for the project and relevant RS and WSS site. This should be the person who gives out additional privileges for developers and managers to those additional components. Still, the customer is always right. =) |
|
|||||||||||||
|
|