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
L

Lars Niedziolka

@Lars Niedziolka
About
Posts
15
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Multimedia
    L Lars Niedziolka

    I belief, that most Webcams support TWAIN and/or WIA as interface. Here in CodeProject you finds Wrappers for TWAIN and WIA. TWAIN is a normed API to read still images like scanner and webcams. WIA is the newer API (and supported since Windows 2K). See: .NET TWAIN image scanner See: WIA Scripting and .NET Lars Niedziolka

    C# question

  • C# Project Integration
    L Lars Niedziolka

    Hi Barbar, if you create a common windows application, Microsoft Visual Studio create a project with one Form. And this form has a static Method Main. This Main is the entry point for your Application (the first called Method). All you have to do is to make sure that you have exactly one static Main method. For instance, create a new class and add a static Main method and delete all others Mains. It's unimportant where you define your Main method. Lars Niedziolka

    C# help csharp tutorial question

  • Frame Capturing From AVI Movie
    L Lars Niedziolka

    If you search here in CodeProject, you find a solution for it. See: http://www.codeproject.com/cs/media/aviFileWrapper.asp Lars Niedziolka

    C# c++ csharp graphics

  • Assemblies References
    L Lars Niedziolka

    A solution (but not the best) is to build a stupid MyLibrary.dll with the needed public class, but without implementation. public class MyLibraryClass { public int ComputeSomething(int l, int r) { throw new NotImplementedException(); } } Than build the exe against this stupid Library. Than build the real Library against the exe. I have not tested this solution. If you try it, please write your result. Good luck. Lars Niedziolka

    C# help tutorial question

  • Preserving comments with XmlDocument.Load
    L Lars Niedziolka

    Hi Lannie, XmlDocument contains all comments if you load an xml document. But the most access functions ignore comments. But following simple code shows message boxes with both comments:

    /\*
     <test>
       <!-- super tip -->
       <tip>Close a application with the cross in the right top corner of the window.</tip>
       <!-- stupid tip -->
       <tip>1+2=3</tip>
    </test>
    \*/
    string xmlstring = @**"<test><!-- super tip --><tip>Close a application with the cross in the right top corner of the window.</tip><!-- stupid tip --><tip>1+2=3</tip></test>"**;
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(xmlstring);
    XmlNode node = doc.SelectSingleNode("/test");
    for (XmlNode subnode = node.FirstChild; subnode != null; subnode = subnode.NextSibling)
    {
       XmlComment comment = subnode as XmlComment;
       if (comment != null)
         MessageBox.Show(comment.Value);
    }
    

    That the XmlDocument contains all comments you see if you look at the OuterXml property of the XmlDocument or save the document in a file. The Comment direct before a XmlElement you get with element.PreviousSibling as XmlComment. The Comment direct behind a XmlElement you get with element.NextSibling as XmlComment. Hope it's help Niedzi

    C# question xml tutorial

  • Removing Icon from a Form
    L Lars Niedziolka

    Hi Luis, the solution is very simple. Set the property ControlBox of the form to false. -- Niedzi

    C# winforms com tools question

  • Software Protection
    L Lars Niedziolka

    Hi Damir, Its realy difficult to protect a .NET Application, because the application is only IL-Code (with a win32 loader) and you can recreate the code of it really good. Try Lutz Roeder's Reflector[^], for instance with the System.dll (Framework Namespace System). One solution is to use a obfuscator. The obfuscator renames all variables and methodes in useless terms, like a12423. But a have no tip for a special product. A communication version (free for students and freeware authors) of the dotfuscator is part of visual studio 2003. See: http://preemptive.com/products/dotfuscator/Editions.html[^] A free alternative is the Aspose Obfuscator/[^]. An other idee is to pack all used dll's in one stream and embedded this stream as embedded resource in the application. Unpack this stream at runtime and load the dlls from this unpacked memory. Its simple possible to crypt the embedded stream. A example implementation is descript in the magazin Dr. Dobb's Journal March 2005. Reducing the Size of .NET Applications[^] Hope, it's help a bit Niedzi

    C# csharp dotnet question

  • Removing Icon from a Form
    L Lars Niedziolka

    There are two other ways: 1st way: It's most like the idea of Dave. Use a icon where all pixel are transparent. 2nd way: Set the borderstyle to sizeable Toolwindow. The caption bar is a bit smaller.

    C# winforms com tools question

  • Pattern matching Hashtable keys?
    L Lars Niedziolka

    Hi Dewclaws, A Hastable is not the right collection for your problem. How does a hashtable works A hashtable build a array with N bags: bag #0 .. bag #N-1. If you add a (key;value)-pair in the hashtable, the hashtable first compute the hashcode of you key. For this it uses key.GetHashCode(). Than its arrange the hashcode in one of the bags. In most cases if it uses the bag #(hashcode%N). In the bag, its store the pair of key and value. In a bag can be more than one pair. If you search a value of a key, the hashtable compute the hashcode again and looks only in this one bag. Example with 5 Bags:

    Key Hashcode Bag
    tommy 23 -> 3
    frang 43 -> 3
    fratiti 12 -> 2
    tom 45 -> 0
    eddtom 23 -> 3
    frankie 67 -> 2
    blue 56 -> 1

    bag #0: (tom;object)
    bag #1: (blue;object)
    bag #2: (fratiti;object)
    bag #3: (tommy;object) (frang;object) (eddtom;object)
    bag #4:

    If you select N large enough (about 1x..1.5x the number of keys) you have a mean search cost of O(n). Solution 1 A solution is to use one sorted list of pairs or two sorted list of keys respectively values.

    ArrayList keys = new ArrayList();
    ArrayList values = new ArrayList();

    public void Insert(string key, object value)
    {
    int index = keys.BinarySearch(key);
    if (index >= 0) // key already in the keys list
    {
    values[index] = value;
    }
    else
    {
    keys.Insert(~index, key);
    values.Insert(~index, value);
    }
    }

    If you search all (key;value)-pairs in which the key starts with a special string use binary search again.

    public struct Range { public int From; public To };

    public Range Find(string keyStart)
    {
    Range range;
    range.From = keys.BinarySearch(keyStart);
    range.To = keys.BinarySearch(keyStart + char.MaxValue);
    if (range.From < 0) range.From = ~range.From;
    if (range.To < 0) range.To = ~range.To - 1;
    return range;
    }

    Solution 2 Build a search tree. The root node contains for each letter (symbol) at the first position a subnode. Each subnode for each letter (symbol) at the second position a subnode. And so on. This solution is a bit faster than Solution 1, but a lot more complex to implement. Example:

    [ROOT]
    |- b
    | '-----------------> (blue;object)
    |- e
    | '-----------------> (eddtom;ob

    C# database data-structures regex performance tutorial

  • Visual Studio .NET 2003 hangs on startup
    L Lars Niedziolka

    Hi Will L Pittenger, sometimes it helps to start the IDE from command line with the argument /setup. This will reinitialize all plugins and the windows location, but no other stuff like keymapping. Good Luck! Niedzi

    C# csharp question visual-studio

  • Sorting Multiple Arraylists
    L Lars Niedziolka

    Example:

    // Use struct or class. class are a bit more efficient than struct.
    public struct My4Datas: IComparable
    {
    public DateTime DateOfBirth;
    public string FamilyName;
    public string FirstName;
    public bool Married;

    public My4Dates(DateTime dateOfBirth, string familyName, string firstName, bool married)
    {
    this.DateOfBirth = dateOfBirth;
    this.FamilyName = familyName;
    this.FirstName = firstName;
    this.Married = married;
    }

    public int CompareTo(object other)
    {
    return this.DateOfBirth.CompareTo(((My4Datas)other).DateOfBirth);
    }
    };

    Somewhere others:

    ArrayList myList = new ArrayList();
    myList.Add(new My4Datas(...));
    myList.Add(new My4Datas(...));
    myList.Sort();

    foreach (My4Datas data in myList)
    {
    string name = data.FirstName + " " + data.FamilyName;
    }

    Good Luck! Niedzi

    C# question algorithms data-structures

  • Parsing XML
    L Lars Niedziolka

    Hi Neel07, The Problem is the line: objXmlNS.AddNamespace("xmlns:OrigoNS","http://www.origoservices.com"); You register the namespace uri http://www.origoservices.com with the prefix xmlns:OrigoNS. But you request uses the prefix OrigoNS only. Simple use following line: objXmlNS.AddNamespace("OrigoNS","www.origoservices.com"); Good Luck! Niedzi PS: If you use xml code in your message, please use the Symbols < and > of the formating line (above the smilies) for the angle brackets. Or write simple < and > for < and >.

    C# help csharp database xml com

  • synchronized arrayList in C#
    L Lars Niedziolka

    Hi Swakswi, Use

    ArrayList mySyncArrayList = ArrayList.Synchronized(myArrayList);

    See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsarraylistclasssynchronizedtopic.asp

    C# question csharp

  • Algorithm for creating a list from a hierarchy?
    L Lars Niedziolka

    Hi Judah, It's not difficult. Use following call

    ArrayList = ListOfTree(myTree);

    and implement ListOfTree with this:

    static ArrayList ListOfTree(TreeView tree)
    {
    ArrayList list = new ArrayList();
    // Add 1st level:
    list.AddRange(tree.Nodes);

    // Add 2nd, 3rd, 4th,... level
    for (int idx = 0; idx < list.count; idx++)
    {
    list.AddRange(((TreeNode)list[idx]).Nodes);
    }

    // return the result list
    return list;
    }

    Example: You have this tree:

    Tree
    |-A1
    | |-B1
    | | |-C1
    | | +-C2
    | +-B2
    | +-C3
    +-A2
    +-B3

    First you add the Nodes of the tree:

    List := A1 A2 [from Tree]

    Second you add each child of the already listed nodes: A1 A2

    List := A1 A2 B1 B2 [from A1]
    List := A1 A2 B1 B2 B3 [from A2]

    And so on for each child of B1 .. B3

    List := A1 A2 B1 B2 B3 C1 C2 [from B1]
    List := A1 A2 B1 B2 B3 C1 C2 C3 [from B2]
    List := A1 A2 B1 B2 B3 C1 C2 C3 [from B3]

    And so on for each child of C1 .. C3

    List := A1 A2 B1 B2 B3 C1 C2 C3 [from C1]
    List := A1 A2 B1 B2 B3 C1 C2 C3 [from C2]
    List := A1 A2 B1 B2 B3 C1 C2 C3 [from C3]

    Have fun, Niedzi

    C# html com algorithms question

  • XmlTextReader - reading from a string?
    L Lars Niedziolka

    Hi Andrew, there are some solutions: 1st) If you only want an XmlDocument, use the methode LoadXml of the XmlDocument class. string myXmlContent = @"<GoodSides><Side name='CodeProject'>http://www.codeproject.com</Side></GoodSides>"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(myXmlContent); 2nd) Copy the bytes (or strings) to a MemoryStream. byte[] myContent = ...; MemoryStream memStream = new MemoryStream(myContent); XmlTextReader xmlReader = new XmlTextReader(memStream); or MemoryStream memStream = new MemoryStream(); StreamWriter memWriter = new StreamWriter(memStream); memWriter.Write(@"<GoodSides>"); memWriter.Write(@"<Side name='CodeProject'>http://www.codeproject.com</Side>"); memWriter.Write(@"</GoodSides>"); memStream.Position = 0; // Reset the position XmlTextReader xmlReader = new XmlTextReader(memStream); 3rd) Implement a own class with Stream as BaseClass. This class can read the datas direct from TCP/IP. class MyOwnStream: Stream { // especialy int Read(byte[] buffer, int offset, int count) { ... } }; MyOwnStream myStream = new MyOwnStream(...); XmlTextReader xmlReader = new XmlTextReader(myStream); 4th) Use the SocketStream direct. (If the stream contains only the xml data and no more.) NetworkStream myNetworkStream = new NetworkStream(mySocket); XmlTextReader xmlReader = new XmlTextReader(myStream); Hope, it helps Niedzi

    C# xml performance question
  • Login

  • Don't have an account? Register

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