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
J

jamie550

@jamie550
About
Posts
38
Topics
11
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Ugly, ugly, ugly!
    J jamie550

    I was digging around some code I wrote three years ago, looking for the cause of a bug some reported, when I found this. And no wonder - the full code is so full of holes that I'm surprised it works as expected.

    /// <summary>
    ///
    /// </summary>
    /// <param name="adjancies"></param>
    /// <param name="regions"></param>
    /// <returns>True if was a special case.</returns>
    private static bool CheckSpecialCases(List<List<int>> adjancies, Dictionary<int, Region> regions)
    {
    if (regions.Count < 2) return true;
    if (regions.Count == 2)
    {
    int key1 = 0, key2 = 0, inc = 0;
    foreach (KeyValuePair<int, Region> kvp in regions)
    {
    if (inc == 0)
    {
    inc++;
    key1 = kvp.Key;
    }
    else
    key2 = kvp.Key;
    }

    	lock (listLock)
    	{
    		if (adjancies\[key1\].Contains(key2))
    			return true;
    
    		adjancies\[key1\].Add(key2);
    		adjancies\[key2\].Add(key1);
    		return true;
    	}
    }
    return false;
    

    }

    Hmm, where to start. How about that comment "True if it was a special case". Yes, because it is obvious what a special case is. Then the whole looping over a collection of two items, with a flag to set two items to specific values (instead of say, asking for the keys of the Dictionary). Oh, and the whole reason for the reported bug is that the indices of key1 and key2 were not checked for being in bounds somewhere prior in the code, which would have saved user trouble from this. Plus, the redundancy of using lists to specify connections, while matching the underlying implementation of data that I was working with, makes things unnecessarily complicated.

    The Weird and The Wonderful c++ help

  • Custom markup extensions in the VS wpf designer
    J jamie550

    It looks like someone has already done it here.[^]

    WPF csharp visual-studio html wpf question

  • Custom markup extensions in the VS wpf designer
    J jamie550

    I have no idea why I didn't begin using Blend a long time ago, for it is so much better in many cases. I think I'll never use the vs wpf designer again, except for editing xaml.

    WPF csharp visual-studio html wpf question

  • Custom markup extensions in the VS wpf designer
    J jamie550

    I am using VS2008 SP1. I have a solution with two projects. Project A is a class library, and has a markup extension.

    public class BadExtension : MarkupExtension
    {
    	public string A { get; set; }
    	public string B { get; set; }
    
    	public BadExtension() { }
    	public BadExtension(string a) { this.A = a; }
    	public BadExtension(string a, string b) { this.A = a; this.B = b; }
    
    	public override object ProvideValue(IServiceProvider serviceProvider) { return A + B; }
    }
    

    Project B is a wpf project. Part of the code of a window is

    Now, the WPF designer refuses to load, saying that no constructor for BadExtension has 1 parameter. However, when I run the app, it loads perfectly and both button texts display perfectly. This is the kicker: In the BadExtension.cs file, if I switch the (string) and (string, string) constructors, the designer now complains about no constructor having 2 parameters. p.s. Or should this be in the Visual Studio forum?

    WPF csharp visual-studio html wpf question

  • ref keyword bad communication between .net languages!
    J jamie550

    Form blah = this; Obj.SetFormrivilage(ref blah); Of course, if blah changes, "this" will not. But that would be strange anyways This also happens in pure C#, iirc, as it should

    Clever Code csharp business help

  • evil hexadecimal numbers formatting
    J jamie550

    I prefer to avoid doubles when possible, even if it's a stupid idea. And why wastefully calculate the log when you already have the actual length of the number right in your hands?

    The Weird and The Wonderful

  • evil hexadecimal numbers formatting
    J jamie550

    string s = number.ToString(); if (s.Length >= placesWanted) return s; return new string(' ', placesWanted - s.Length) + s; Because I still dislike the failure of 1.5 + 1.5 == 3

    The Weird and The Wonderful

  • evil hexadecimal numbers formatting
    J jamie550

    Once, in the long-ago murky past, before learning the wonders of Int32.ToString("Dx"), and still being relatively new, I wrote something like this public string Pad(int val, int places) { int realplaces=0; if (val < 10) // notice that this includes all negatives, so FAIL realplaces=1; else if (val < 100) realplaces=2; else if (val < 1000) realplaces=3; ... if (realplaces >= places) return val.ToString(); return new string(' ', places - realplaces) + val.ToString(); }

    The Weird and The Wonderful

  • This is just for the laugh of it.
    J jamie550

    Race? Age? Country of origin? Religion?

    The Weird and The Wonderful regex csharp

  • Why do people tells that IE sucks? [modified]
    J jamie550

    Because it's addon system, if any, is so hidden that most never find it. No adblocking stuff, which was my original reason for switching IE7 to FF2

    The Lounge com help question

  • Headline on CNN...
    J jamie550

    I'll take your word for it :confused:

    The Lounge question announcement

  • Headline on CNN...
    J jamie550

    But they found the corpses, not the living people. And the corpses had bullet holes in them. "24 corpses found shot in Mexico", not "24 corpses shot in Mexico"

    The Lounge question announcement

  • Headline on CNN...
    J jamie550

    Maybe the corpses were alive when they were shot?

    The Lounge question announcement

  • Calling an embedded unmanaged dll
    J jamie550

    I have a dll written in unmanaged c++ that I need to call. Currently, it is embedded inside the main assembly as an resource, and is extracted when it needs to be called. This call is done by using DllImport, for example:

    	\[DllImport("CppImplementation.dll")\]
    	public unsafe static extern bool AreEqual(byte\* lhs, byte\* rhs, int len);
    

    Is there any way to tell DllImport to look inside the main assembly's resources, so that it is not necessary to extract the unmanaged assembly into a file before calling? Or is there some other efficient method to call these unmanaged functions?

    C# c++ hardware tutorial question learning

  • It's horrible
    J jamie550

    Yes, but closing tags in order and closing all tags is not complicated at all, and no technical skills are required to do so.

    The Weird and The Wonderful javascript html tools question

  • It's horrible
    J jamie550

    :-O Fixed

    The Weird and The Wonderful javascript html tools question

  • It's horrible
    J jamie550

    HTML :(( Please, who decided that tags like
    didn't have to be closed. Now parsers have to waste their time checking for a closing tag. Also, how could people think that is ok? And what about

    ? And what about JavaScript and the like? Why consider ' and " only within a script tag, and then allow <, but outside a script tag treat any instance of < as a tag opener? People's laziness in writing HTML slows down my computer by wasting processing. But seriously, why did people decide that HTMLers would be too stupid/lazy to close tags and layer them correctly?

    The Weird and The Wonderful javascript html tools question

  • read file from bottom
    J jamie550

    :laugh:

    The Weird and The Wonderful help question

  • Errors appear sometimes [modified]
    J jamie550

    OK, this is a small WPF application that I am working on. While testing, no problem appeared. Even when using the exe that would be released to everyone. Now, in one of the text boxes I had put UndoLimit=-1, to avoid the problems with the undo limit. This worked perfectly on my machine. But a user reported this:

    Exception: System.Windows.Markup.XamlParseException
    28/06/2008 14:01:28
    Message: Cannot find DependencyProperty or PropertyInfo for property named 'UndoLimit'.
    Property names are case sensitive. Error at object 'txtDNA' in markup file 'Origones;component/mainwindow.xaml'.
    Source: PresentationFramework

    STACK TRACE
    Void ThrowException(System.String, System.Exception, Int32, Int32, System.Uri,
    System.Windows.Markup.XamlObjectIds, System.Windows.Markup.XamlObjectIds, System.Type)
    at System.Windows.Markup.XamlParseException.ThrowExce ption(String message,
    Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri,
    XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
    [Note: Some newlines added]
    [Snipped]

    Strangely enough, simply removing the UndoLimit fixed it. Another problem with the same application: One of the users reported that the "portrait" had a purple tint. That problem is in this screenshot.[^] Now, viewing the same files on my computer, and apparently everybody else's resulted in the correct coloring. Has anybody had any experience with these strange small inexplicable problems?

    modified on Sunday, June 29, 2008 9:44 AM

    WPF wpf help csharp html data-structures

  • Horizontal Listview
    J jamie550

    Does anybody have any help on this? The best I can currently get is: Given obj1 with info ABC, obj2 with DEF, and obj3 with GHI, when it was previously ABC DEF GHI Now it is ABCDEFGHI By overriding ItemsPanel with a VirtualizingStackPanel with orientation set to horizontal. But I still cannot find how to cause the GridView to move its columns (which is apparently actually ListView's job). When extracting ListView's default template, putting it back in results in the column headers being missing. So, do any experts have any pertinent information? EDIT: Adding a view changed the template. Why did I not try this before :doh: Time to see if this holds the answers... EDIT: Making the items vertical can be done by setting the template for ListViewItem in a implied style. But the data for columns is stored in {DynamicResource {x:Static GridView.GridViewScrollViewerStyleKey}}. How to get to that...

    modified on Friday, June 20, 2008 8:27 AM

    WCF and WF 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