Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
G

GazzaJ

@GazzaJ
About
Posts
29
Topics
15
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Reflection: Getting property name from property itself
    G GazzaJ

    Thanks for all the help. I'm still not sure this is what I want. I don't want any hardcoded literal strings. In the code above I still have to use the string "Name" to get the information. I have an object myObject which has a property TestProperty ie myObject.TestProperty. Using only this I want to get a string of the property name e.g. SomeCode(myObject.TestProperty) returns "TestProperty"

    C# css help

  • Reflection: Getting property name from property itself
    G GazzaJ

    That looks like what I want but I am stuck on .NET v2!

    C# css help

  • Reflection: Getting property name from property itself
    G GazzaJ

    If I get a list of properties using GetProperties() how do I get the propertyInfo of the property I'm interested in without specifying a string to identify it.

    C# css help

  • Reflection: Getting property name from property itself
    G GazzaJ

    I was wondering if someone could help with the magic xxx

    C# css help

  • Reflection: Getting property name from property itself
    G GazzaJ

    I am configuring a grid and pass in the name of the property within an object to display e.g. myGrid.AddColumn(new ColumnDefn("TestPropertyName", "", false, true)); where TestPropertyName is the property within the object to display. Instead of using a string to identify the property I want to use the object itself e.g. MyObject myObject = new MyObject(); myGrid.AddColumn(new ColumnDefn(myObject.TestPropertyName.xxxxx, "", false, true)); where xxx is some magic to get the property name (I assume using reflection). This means if myObject changes (e.g. TestPropertyName becomes TestPropertyName2) I will pick up the error at compile time.

    C# css help

  • Compressing a jpg file
    G GazzaJ

    Thanks Russell. For completeness my final solution was: // Method to get the apprpriate encoder private ImageCodecInfo GetEncoderInfo(String mimeType) { int j; ImageCodecInfo[] encoders; encoders = ImageCodecInfo.GetImageEncoders(); for(j = 0; j < encoders.Length; ++j) { if(encoders[j].MimeType == mimeType) return encoders[j]; } return null; } // Compress file code Image image = Image.FromFile(sourceFile); string mimeType = "image/jpeg"; ImageCodecInfo codecInfo = GetEncoderInfo(mimeType); if (codecInfo == null) raise error; // Set the quality (must be a long) Encoder qualityEncoder = Encoder.Quality; EncoderParameter ratio = new EncoderParameter(qualityEncoder, 40L); EncoderParameters encoderParams = new EncoderParameters(1); encoderParams.Param[0] = ratio; image.Save(destFile, codecInfo, encoderParams); image.Dispose();

    C# csharp

  • Compressing a jpg file
    G GazzaJ

    I am trying to compress a jpg file in the same manner that you would set the quality factor in an image processing package e.g. Open image1.jpg Set quality factor to 50 Save as image2.jpg This is to reduce the size of the jpg files in my application. Does anyone know if there are .NET libraries for this or any good commercial toolkits.

    C# csharp

  • Centralising event handling in a Windows Form application
    G GazzaJ

    This looks good although I am still on .NET 1.1 at the moment.

    C# winforms design data-structures regex architecture

  • Centralising event handling in a Windows Form application
    G GazzaJ

    I am effectively using the .NET event model. My question seems to be how to handle controls that are programatically created. Say the main hub of my application deals with the events that controls can generate and passes these to the other controls to process. If the main hub programatically creates a user control, how does it know what events this can fire and hook up an event handler to these?

    C# winforms design data-structures regex architecture

  • Centralising event handling in a Windows Form application
    G GazzaJ

    I am trying to devise a system for centrally handling events generated by controls in my application and passing these events to other controls who may be interested in them. For example say I have an application where a control can add an employee to the system. The control does the necessary and then raises an event which is then passed to two other controls who may have to process this event. I would like to define the event in one place and for the controls who want notification of the event to simply register this fact and then receive the events. This is what I have so far but perhaps there is a better way, or maybe there is a nice design pattern which someone can point me to. I have a common class called EventHandlerCommon which defines the EventArgs for the event and defines a public delegate: public delegate void EmployeeAddedEventHandler(object sender, EmployeeAddedEventArgs e) The class then has a static method: public static void RegisterEmployeeAddedEventHandler(EmployeeAddedEventHandler sourceMethod) which adds the the delegate to an array of methods to call. This class also has another static method: public static void ProcessEmployeeAddedEvent(object sender, EmployeeAddedEventArgs e) which can be called when the event is raised and will pass it to all the delegates in the array. My main application has two user controls. Each has a constructor which registers their interest in the employee added event by creating a delegate and passing it to the static class described above: EmployeeAddedEventHandler del = new EmployeeAddedEventHandler(MyLocalEmployeeAddedEventHandler); MyEventHandler.RegisterEmployeeAddedEventHandler(del); The first user control actually generates the event so has: public event EmployeeAddedEventHandler EmployeeAdded; and raises this event when a button is pressed. The main form for the application has an event handler to handle this event: this.userControl1.EmployeeAdded += new EventHandlerCommon.EmployeeAddedEventHandler(this.userControl1_EmployeeAdded); This calls the static method to pass this event to all the controls interested: private void userControl11_EmployeeAdded(object sender, EmployeeAddedEventArgs e) { MyEventHandler.ProcessEmployeeAddedEvent(sender, e); } This seems to work ok. Each of the user controls registers their interest in the event and is passed the event when it is raised. Perhaps this is n

    C# winforms design data-structures regex architecture

  • Getting the installation directory in a Deployment project
    G GazzaJ

    I am using a Deployment project to deploy my C# application (VS 2003). In the Uninstall event I want to get the installation directory that was selected by the user when they installed the program but can't seem to get this. Application.StartUp path returns the path to the msi file that is executing not the installation directory.

    C# csharp visual-studio sysadmin

  • Copying files with long path names
    G GazzaJ

    Yes - it throws the same exception.

    C# csharp question

  • Copying files with long path names
    G GazzaJ

    This is what I use but my path contains more than 248 characters which throws a System.IO.PathTooLongException exception. I was wondering if there was any way around this.

    C# csharp question

  • Copying files with long path names
    G GazzaJ

    Is it possible to copy a file using .NET where the path is greater than 248 characters? If not, are there any work arounds?

    C# csharp question

  • Setting the default button on a user control
    G GazzaJ

    Is it possible to set the default button on a user control in the same way you would set myForm.AcceptButton = button for a Form.

    C#

  • Where is the Customer Infomation Dialog information within a Deployment project saved?
    G GazzaJ

    I have a Deployment project which includes a Customer Information Dialog box. I want to use the information entered in my Custom Action class AfterInstall. Does anyone know how I can do this?

    C# sysadmin sales question

  • Determining whether DataRow values have changed
    G GazzaJ

    I have an application with a strongly typed Dataset which I populate and then transform the rows in the DataTable into objects used in my application. The application then updates the objects and I call code to update the appropriate DataRows before submitting the updates to the table. I originally wrote the method to update the DataRow to update each column in the row using the value in the object passed in. This however causes the RowState of the DataRow to change from Unchanged to Modified even if the value has not changed. Therefore I have logic to check the values in the DataRow with the value in the object and only update if there is a change, this logic incorporates checking for null values also. Is there any method of getting the DataRow to do this automatically?

    Database question announcement

  • Is there any way to debug a deployment project in the IDE
    G GazzaJ

    I am using a NET Custom Action and the technique in the link worked a treat. Thanks very much.

    .NET (Core and Framework) database visual-studio sysadmin debugging xml

  • Auto-generating SQL to fill a DataSet
    G GazzaJ

    I am writing an application where I am using strongly typed DataSets to define the DataTables and relations used in various parts of the application. I have code that takes these DataSets and converts the rows in the DataTables to objects which I then use in my application. The reason for using strongly typed DataSets is so if I change the database schema I only need to validate the DataSets to identify any mismatches at compilation time. I obviously need to fill the DataSets which is currently done by creating SqlAdapters which call stored procedures to populate the DataTables within the DataSet. This means I have to keep the stored procedures in sync with the DataSets when the schema is changed. I am trying to minimise any potential bugs and so I am looking at ways to ensure the database schema, DataSets and stored procedures are kept in sync. My current method is to use my own validation tool which performs tests on the DataSets to ensure the stored procedures correctly fill the DataSets. Given the information contained within the DataSet I was thinking that it should be possible to "auto-generate" the SQL from the DataTables and DataRelations definitions. For a simple situation like Customers and Orders this is not difficult but I was wondering if there are any libraries or tools out there which generate SQL code from a DataSet definition given the complexity that may be involved with many tables and their relationships.

    Database database algorithms tools xml

  • Is there any way to debug a deployment project in the IDE
    G GazzaJ

    I have a deployment project which runs Custom Actions before and after installation - these actions call a class to deal with backing up a database and then updating the schema to a current version. Is there anyway of debugging this class as the deployment is being executed? At present I write all actions out to a log and ensure everything is working that way. If I want to test something failing by inserting some code I need to rebuild the deployment each time.

    .NET (Core and Framework) database visual-studio sysadmin debugging xml
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups