Click here to Skip to main content
15,892,298 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 5:51
sitebuilderLuc Pattyn26-May-10 5:51 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 8:29
Jacob Dixon26-May-10 8:29 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 5:06
Jacob Dixon26-May-10 5:06 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 5:27
sitebuilderLuc Pattyn26-May-10 5:27 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 6:21
Jacob Dixon26-May-10 6:21 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 6:42
sitebuilderLuc Pattyn26-May-10 6:42 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 6:52
Jacob Dixon26-May-10 6:52 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 7:39
sitebuilderLuc Pattyn26-May-10 7:39 
OK, so you have the real image as digital artwork, and you did not mention having a digitizer. This is what you could do:

- choose an app you feel comfortable with, that lets you draw straight lines as well as freehand lines, on top of (without including) an existing image. A lot of apps work with layers, where you can see several layers at once, modify only one layer at a time, and finally save the superposition of any set of layers you choose.
- open said app, let it display the floor plan in one layer; now put an empty layer on top of it, and in that layer, paint the outline of a single room in black. Make sure it is a closed figure.
- when done, fill it black; then fill it again in red. (I have chosen to work in black for best contrast, then switch to the final color; you could also directly work in the final color).
- repeat for a second room, but choose a different final color.
- do a couple of rooms; don't do them all before everything turns out satisfactorily!
- now save the one layer you have drawn in an uncompressed format, say GIF (you don't want the colors to get damaged at all).
Hint: perform several saves while doing this, into different files; you may want to return to an earlier situation when something went wrong...

Now create (part of) your app, temporarily show the shadow image instead of the real one. Mouse over room 1 and display the RGB color values you are getting (they should be absolutely constant within each single room).

Use this tool to sample the colors you need to create your data structure; it could be something like:

class Room {
    string name;
    string comment;
    Color color;

    public Room(string name, string comment, int R, int G, int B) {
        this.name=name;
        this.comment=comment;
        this.color=Color.FromRGB(R,G,B);
    }
}

class MyApp {
    void CreateRooms() {
        List<Room> rooms=new List<Room>();
        rooms.Add("Kitchen", "check smoke alarm once a year", 255, 0, 0); // <<< hovered color
        rooms.Add(...);
        ...
    }
    ...
    void Image_MouseMove(...) {
        // don't forget to add boundary checks and error handling
        Color color=shadowImage.GetPixel(e.X, e.Y);
        Room room=null;
        if (rooms==null) CreateRooms();
        foreach(Room r in rooms) if (r.Color == color) room=r;
        if (room!=null) {
            // you are inside this room! go tell the user
            ...
        }
    }
}


that is the zest of it. It probably needs syntax fixes and refinements, but should get you started.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read formatted code with indentation, so please use PRE tags for code snippets.

I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).

GeneralRe: C# Image hot spots? Pin
DaveyM6926-May-10 7:49
professionalDaveyM6926-May-10 7:49 
GeneralRe: C# Image hot spots? [modified] Pin
Luc Pattyn26-May-10 7:58
sitebuilderLuc Pattyn26-May-10 7:58 
GeneralRe: C# Image hot spots? Pin
DaveyM6926-May-10 13:07
professionalDaveyM6926-May-10 13:07 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 13:33
sitebuilderLuc Pattyn26-May-10 13:33 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 8:02
Jacob Dixon26-May-10 8:02 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 8:17
sitebuilderLuc Pattyn26-May-10 8:17 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 8:27
Jacob Dixon26-May-10 8:27 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 8:38
sitebuilderLuc Pattyn26-May-10 8:38 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 10:41
Jacob Dixon26-May-10 10:41 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 10:51
sitebuilderLuc Pattyn26-May-10 10:51 
GeneralRe: C# Image hot spots? Pin
Jacob Dixon26-May-10 11:11
Jacob Dixon26-May-10 11:11 
GeneralRe: C# Image hot spots? Pin
Luc Pattyn26-May-10 11:51
sitebuilderLuc Pattyn26-May-10 11:51 
Questionread from serial port Pin
genieabdo26-May-10 3:41
genieabdo26-May-10 3:41 
AnswerRe: read from serial port Pin
Alaric_26-May-10 4:09
professionalAlaric_26-May-10 4:09 
GeneralRe: read from serial port Pin
genieabdo27-May-10 22:13
genieabdo27-May-10 22:13 
QuestionStreaming images using TCP help Pin
TimSWatson26-May-10 3:32
TimSWatson26-May-10 3:32 
AnswerRe: Streaming images using TCP help Pin
Luc Pattyn26-May-10 10:47
sitebuilderLuc Pattyn26-May-10 10:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.