Calvin Hsia's WebLog

thoughts from a professional developer

Browse by Tags

Tagged Content List
  • Blog Post: Embed a ListView inside another ListView for one to many relationships

    In the old days (about 16 years ago), FoxPro’s object, containership and inheritance models made it easy to put objects inside other objects. So, for example, a FoxPro grid of Customers could have a column containing a grid of each customer’s orders, and each order, in turn, could have a grid of the...
  • Blog Post: Use colors in WPF to show virtual memory fragmentation

    In this post What is your computer doing with all that memory? Write your own memory browser is sample code that shows how to create a WPF grid view of a memory map of a process. You can click on a column header to sort, and you can see the various loaded images and even a binary display of the actual...
  • Blog Post: Are you running out of disk space? Treemap your files to see what's eating the most

    I was running out of disk space and wanted to see what was eating the most. About 6 years ago I wrote a FoxPro version of a TreeMap program that shows a rectangle subdivided into various subrectangles, each proportional to the amount of space taken by files on disk. The old program had some...
  • Blog Post: Write your own Linq query viewer

    Sometimes you just want to see data in a tabular format. It could be stored in a server somewhere in the cloud, in a SQL server, a FoxPro database, an EntityFramework object, or just a local object. You’d like to see all columns, without having to write code to select each column. Linq allows...
  • Blog Post: Collect system info for your application's runtime environment

    Often your code gets run on a machine far away and it’s useful to gather some information about that machine automatically, perhaps for error reporting or statistics gathering. This information could include the Operating System version, how much memory, logged in user, etc. There are...
  • Blog Post: Sometimes you want 2 returned values: playing around with Tuples

    When writing code in various languages, you’ll write functions from which you get a return value. Sometimes you’ll want to get 2 return values. A common way to handle this is to use parameters to pass a variable by reference that will get one of the return values. Alternatively, you could use a...
  • Blog Post: Use a dictionary to help create a mnemonic

    I was using a program that was yet another TLA and I wanted to create a mnemonic to help me remember what it was. One of the letters was “k”, so I wanted to find a word that starts with “k” Simple: load a dictionary, search for words starting with “k” and browse through them: “Killer” sounded fine...
  • Blog Post: Persist user form size and location settings per session

    My prior post ( Create your own Test Host using XAML to run your unit tests ) shows how to create a form and present it to the user. The user can resize and reposition the form, even on a 2 nd monitor. When the user exits the form, we can persist or remember the form size and location, so the next...
  • Blog Post: Use XLINQ to query the references in your project

    Visual studio creates project files for you for the various languages, such as C++, C#, VB. These files are XML format, and can thus be queried. Try this: open any non-temporary Visual Studio project (see Use temporary projects in Visual Studio ) , right click on it in solution explorer, choose...
  • Blog Post: How to Create dynamic XAML to display arbitrary XML

    Here's a sample of creating dynamic XAML to display arbitrary XML You can use the XML DataProvider to supply XML data to XAML, a web service, or you can use a Query. Each way, you can generate XAML dynamically to display the XML. (echoes of XSLT) I took the prior sample ( Create your own...
  • Blog Post: Use LINQ to Foxpro or any SQL data and display it in a WPF form using DataSetExtensions and DataRowExtensions

    In the last post Create your own media browser: Display your pictures, music, movies in a XAML tooltip , we created a query of your local media and displayed it. Today, we'll make a query to my Foxpro picture database of 28,000 pictures/movies. We'll make the query result structure to be similar...
  • Blog Post: Create your own media browser: Display your pictures, music, movies in a XAML tooltip

    In my prior post , I showed how to use XAML and XAMLReader to create inline XAML to display the results of a query. Today, let's take it a step further: let's create a query of all the media (pictures, movies, music) in your "My Documents" folder and display the names and sizes in a ListView. As...
  • Blog Post: WPF Animation: Use dynamic XAML to animate movies using XAMLReader or animate in code using BeginStoryBoard

    Using WPF, it’s great to use declarative XAML , but it’s also great to use dynamic code. With VB’s new XML Features , you can do either. Below is a sample showing how to use XAMLReader to take XML generated in code and use it to create XAML to present as UI. The XAMLPanel demonstrates some...
  • Blog Post: Use the DispatcherTimer, Popup and even a movie to enhance your data presentation

    We can subclass the prior Windows Presentation Foundation (WPF) class called Browse that displays the results of a query. This subclass will add a WPF Popup to it. The popup can easily be added to either a ListView or the ListBox sample I posted earlier ( Use LINQ with WPF : Styles and DataTemplates...
  • Blog Post: Use DataTemplates and WPF in code to create a general purpose LINQ Query results display

    In my last post, Use LINQ with WPF : Styles and DataTemplates in code , I showed how to use DataTemplates in code to show the results of a query in a ListBox. Let's make a reusable class called Browse which creates WPF content as a ListView from a LINQ query and generates columns and headers. It...
  • Blog Post: Use LINQ with WPF : Styles and DataTemplates in code

    Using Windows Presentation Foundation (WPF) and LINQ is easy in code. We'll create a query and display it in a WPF ListBox Using XAML is harder: the ObjectDataProvider class works with non-anonymous types. Start Visual Studio 2008 (or 2005 with Visual Studio 2005 extensions for .NET Framework...
  • Blog Post: Use new XML Features of VB to generate dynamic scripts and text files

    There's a very useful feature that FoxPro users have had for over 2 decades: being able to output text in any format, with WYSIWYG and the ability to embed expressions (The TEXT…ENDTEXT command ) Generating XML, HTML, Bat files, PowerShell Script, etc is a breeze with this command. Free form text...
  • Blog Post: Querying Northwind with Group By bug fixed

    In this post: http://blogs.msdn.com/calvin_hsia/archive/2007/08/17/install-northwind-for-sql-express-and-use-visual-studio-and-dlinq-to-query-it.aspx I mentioned how a bug with Group By and composite keys made more local calculations. Using the AsEnumerable operator caused the query to execute...
  • Blog Post: Use Stored Procedures when you can for efficiency

    In this post ( Install Northwind for SQL Express and use Visual Studio and DLINQ to query it ) I posted a fairly complex SQL command. Of course, it’s important to keep in mind that a more efficient way of executing this query may be by keeping all the data on the server (which might be remote) and just...
  • Blog Post: Install Northwind for SQL Express and use Visual Studio and DLINQ to query it

    SQLExpress is free and comes with Visual Studio, but the sample Northwind database isn’t included. You can download sample databases Northwind and Pubs from http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en . (or you can use the Fox...
  • Blog Post: Linq Queries for .Net Framework members

    How many members in the .Net framework contain the string ‘file” ? Make a query like this: Dim q As Object q = From Assembly In AppDomain.CurrentDomain.GetAssemblies _ From typ In Assembly.GetTypes _ From Member In typ.GetMembers _ Where Member.Name.ToLower.Contains( "file...
  • Blog Post: C# and Fox versions of Cool Linq Query

    In my prior post ( Cool Linq Query ) I promised a C# and Fox versions of a query to sort all the “Words” found in many files in a C++ project and sort them by frequency of occurrence. The C# version: it’s almost the same as the VB version. Try typing it out and you’ll see differences in Intellisense...
  • Blog Post: Cool Linq Query

    Now that Visual Studio 2008 Beta 2 is out the door, I can write about some cool Linq Queries, and you can run them. Foxpro has had Language Integrated Query (Linq) in the form of embedded SQL statements (Create Table/Select/Update/Insert/Delete/Alter Table) for almost 2 decades (I believe it was...
Page 1 of 1 (23 items)