Click here to Skip to main content
15,896,063 members
Articles / Operating Systems / Windows

Convertion of Xdock VB to CS by C-Sharpener For VB.

Rate me:
Please Sign up or sign in to vote.
2.56/5 (5 votes)
18 Sep 20073 min read 29.8K   286   10  
Convertion VB to CS by C-Sharpener For VB of the XDock projet
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace XDock
{
    // TRANSMISSINGCOMMENT: Class Common
    // following class was VB module
    [Microsoft.VisualBasic.CompilerServices.StandardModule]
    sealed public class Common 
    { 
        
        // TRANSMISSINGCOMMENT: Method LoadSaveData
        public static bool LoadSaveData( bool LoadData, string pSection, string pKey, object pDefValue, ref object pValue, ref IniFile pIniFile ) 
        { 
            if ( LoadData ) 
            { 
                return LoadIniData( pSection, pKey, pDefValue, ref pValue, ref pIniFile ); 
            } 
            else 
            { 
                SaveIniData( pSection, pKey, pDefValue, ref pValue, ref pIniFile ); 
                return true; 
            } 
        } 
        
        
        // TRANSMISSINGCOMMENT: Method LoadIniData
        private static bool LoadIniData( string pSection, string pKey, object pDefValue, ref object pValue, ref IniFile pIniFile ) 
        { 
            Key pIniKey = null; 
            bool pChanged = false; 
            pIniKey = pIniFile.GetKey( pKey, pSection ); 
            if ( pIniKey == null ) 
            { 
                pChanged = pIniFile.AddKey( pKey, Cast( pDefValue, pValue ).ToString(), pSection, false, null ); 
                pValue = Cast( pDefValue, pValue ); 
            } 
            else 
            { 
                pValue = Cast( pIniKey.Value, pValue ); 
            } 
            return pChanged; 
        } 
        
        
        // TRANSMISSINGCOMMENT: Method Cast
        private static object Cast( object Value, object Variable ) 
        { 
            object pReturnObject = null; 
            try 
            { 
                if ( Variable.GetType().Equals( System.Drawing.Color.Black.GetType() ) ) 
                { 
                    pReturnObject = Color.FromName( Value.ToString() ); 
                } 
                else if ( Information.IsNumeric( Value ) ) 
                { 
                    pReturnObject = long.Parse( Value.ToString() ); 
                } 
                else 
                { 
                    pReturnObject = Value.ToString(); 
                } 
            } 
            catch ( Exception ex ) 
            { 
                pReturnObject = Convert.ChangeType( Value, Variable.GetType() ); 
                // MessageBox.Show(ex.Message)
            } 
            return pReturnObject; 
        } 
        
        
        // TRANSMISSINGCOMMENT: Method SaveIniData
        private static void SaveIniData( string pSection, string pKey, object pDefValue, ref object pValue, ref IniFile pIniFile ) 
        { 
            Key pIniKey = null; 
            bool pChanged = false; 
            pIniKey = pIniFile.GetKey( pKey, pSection ); 
            if ( pIniKey == null ) 
            { 
                pIniFile.AddKey( pKey, Cast( pValue, pDefValue ).ToString(), pSection, false, null ); 
            } 
            else 
            { 
                pIniFile.ChangeValue( pKey, pSection, Cast( pValue, pDefValue ).ToString() ); 
            } 
        } 
        
        
    } 
    
    
} 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) http://www.cmb-soft.com/
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions