Sunday, December 13, 2009
Inversion of Control
You can download the sample here
Friday, November 20, 2009
GSF beta 1 approaching
Basically what you get when you use GSF are the following modules:
- VS 2005 integration
- Database modeling with import schema from SQl-server or Oracle
- Business object class diagram created from the Datamodel but extendable with OO features
- DOA and Domain generation with partial classes and partial methods
- MVVM framework (Model view - View model pattern)
- Made for WPF binding but not limited to WPF.
Saturday, November 29, 2008
Microsoft DSL Tools
In general the extensibility is not so well documented, and there seems to be only a few specialists around. I do not know if we will come to a marketable product at this point in time, but I'm sure if you keep an eye on Genwise.com that sooner or later you will be able to find more about our DSL adventures.
Tuesday, February 19, 2008
Dicom the easy way
I wanted to report on a great Dicom library I came across today. It is called ClearCanvas See www.clearcanvas.ca
It is unbelievable how accessible thay made dicom file access and dicom file viewing.
I wanted to modify some dicom file programmatically in VS 2005. You can do this very easily with the Clearcanvas SDK. The SDK is vary well documented and it took me about 30 minutes to get code going to change a patient Id in a dicom image, somthing I was not able to do very easily with other open source dicom libraries.
The library is also documented very well, with sample code, and the site has a good forum.
Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ClearCanvas.Dicom;
namespace CCDicom
{
public partial class DicomAttibuteViewer : Form
{
public DicomAttibuteViewer()
{
InitializeComponent();
}
private void btGo_Click(object sender, EventArgs e)
{
DicomFile _df = new DicomFile(@"C:\user\DotNet\OpenDicom\DicomSampleFiles\00000014.dcm");
_df.Load(DicomReadOptions.Default);
DicomAttributeCollection _ds = _df.DataSet;
foreach (DicomAttribute _da in _ds)
{
if (_da.Tag.Group == 16 && _da.Tag.Element == 32)
{
// Patient ID
_da.SetString(0, "mypatientid");
}
if (_da.Tag.Group == 10)
{
}
this.listBox1.Items.Add(_da.Tag +"->" + _da.ToString());
}
_df.Save(@"c:\user\DotNet\OpenDicom\DicomSampleFiles\erik1.dcm");
}
}
}
Wednesday, January 23, 2008
Using Log4net in a Winforms Application
1. Offcourse first add the log4net dll to your application as a reference.
2. Then initiate logging as following:
public ILog log;
public void InitiateLogging()
{
log4net.Config.XmlConfigurator.Configure();
this.log = LogManager.GetLogger("user");
}
3. Do not forget to make a log4 net section in your application config file. Here is my config file (my application is named IMSBEWFM. The config file is named: ImsBeWfm.EXE.config
< ?xml version="1.0" encoding="utf-8" ?>
< configuration>
< configSections>
< section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
< /configSections >
< appSettings file="" >
< clear />
< add key="log4net.Internal.Debug" value="true"/>
< /appSettings>
< log4net>
< appender name="GeneralLog" type="log4net.Appender.RollingFileAppender">
< file value="general.txt"/>
< appendToFile value="true"/>
< maximumFileSize value="100KB"/>
< rollingStyle value="Size"/>
< layout type="log4net.Layout.PatternLayout">
< conversionPattern value="%d{HH:mm:ss} [%t] %-5p %c - %m%n"/>
< /layout>
< /appender>
< root>
< level value="DEBUG"/>
< appender-ref ref="GeneralLog"/>
< /root>
< logger name="NHibernate" additivity="false">
< level value="DEBUG"/>
< appender-ref ref="GeneralLog"/>
< /logger>
< /log4net>
< /configuration>
4. Notice the:
< add key="log4net.Internal.Debug" value="true"/ >
That line is very usefull in the debug output window of your application log4net will tell you any errors while initializing, tracking down problems. Later when it works you can remove that line.
Now to log someting is quite easy:
log.Debug("Sucessfull login");
Be carefull if you want to log for a released application, then you will have to change level value = "DEBUG" to level value = "INFO" and use log.info in your code to log to the released application.
Excelent reference is: here
Sunday, August 19, 2007
Starting an external program from C# procedure
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.WorkingDirectory = this.WorkingFolder;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.FileName = this.VSSClientProgram;
proc.StartInfo.Arguments = pArguments;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
string Error = proc.StandardError.ReadToEnd();
int ExitCode = proc.ExitCode;
proc.Close();
The CreateNoWindow sees to it that you will not see some Window popping up from your own program normally with no contents. The UseShellExecute = false makes it so you can redirect the standard outpout, input and error streams.