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
  1. Home
  2. General Programming
  3. C#
  4. connecting user controls in c sharp

connecting user controls in c sharp

Scheduled Pinned Locked Moved C#
helpcsharpwinforms
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samithas
    wrote on last edited by
    #1

    I have created a smalll prototype like Ms visio. In my program i can add controls(rectangle, ellipse,..) to the panel and move them with mouse. But the problem is connecting them with lines so that the objects and lines should move together. Can anybody help me... :confused: samitha

    E H 2 Replies Last reply
    0
    • S samithas

      I have created a smalll prototype like Ms visio. In my program i can add controls(rectangle, ellipse,..) to the panel and move them with mouse. But the problem is connecting them with lines so that the objects and lines should move together. Can anybody help me... :confused: samitha

      E Offline
      E Offline
      etfintnick
      wrote on last edited by
      #2

      You could traverse your "control"-collection/array/etc and use the center of each "control" as the start/end-point of your line? R.a.m

      1 Reply Last reply
      0
      • S samithas

        I have created a smalll prototype like Ms visio. In my program i can add controls(rectangle, ellipse,..) to the panel and move them with mouse. But the problem is connecting them with lines so that the objects and lines should move together. Can anybody help me... :confused: samitha

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        A common approach is to define a base class from which all shapes derive. You would define a property on this class that is either a collection or array (which is actually a static collection and list) that stores points. If you want, you could define this property as virtual and provide default connection points. If you declare it as abstract, then every derivative must override it. For any classes where you want to return a custom list of connection points, override the property (assuming it's optionally using a virtual property) and return coordinates of connection points. Then, these connection point classes that you store maintain a list of other controls' connection points (which should have a member that returns the control they're a connection point for). When painting the container/surface, you draw a line between each connection point that is related to another. This is the reason you define a base class - so you can refer to every shape through it's abstract base class. This is polymorphism. If you search CodeProject, you should find a couple examples, IIRC.

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

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