Limiting a controls parent.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew

    #1

    Limiting a controls parent.

    I want to create a set of Activity Diagram controls for process control.

    I need to create a base Diagram control that acts as a container for the
    Activity controls ( StartPoint, EndPoint, Actvity, Decision, Message,...).

    How do I implement it such that the only place I can drop an Activity
    control is on a Activity Diagram?

    I'm an experienced Delphi developer and I'm just getting started in C#.
    There appears to be significant crossover between the two languages.


  • Ignacio Machin ( .NET/ C# MVP )

    #2
    Re: Limiting a controls parent.

    On Aug 1, 9:46 am, "Andrew" <and...@yahoo.c omwrote:
    I want to create a set of Activity Diagram controls for process control.
    >
    I need to create a base Diagram control that acts as a container for the
    Activity controls ( StartPoint, EndPoint, Actvity, Decision, Message,...)..
    >
    How do I implement it such that the only place I can drop an Activity
    control is on a Activity Diagram?
    >
    I'm an experienced Delphi developer and I'm just getting started in C#.
    There appears to be significant crossover between the two languages.
    hi

    I do not undersstand your question, are you asking how to design your
    classes or your interface?

    Comment

    • Andrew

      #3
      Re: Limiting a controls parent.

      Please understand I'm just getting started in C# but have 10+ years of
      experience in Delphi, so if I'm not clear it's mostlikely because I don't
      have C# on my fingertips yet.

      I'm quite sure I can design the underlying class structure for the
      implementation I'm looking for. It's the details on how Visual Studio
      creates components and assigns them to parent controls during the design
      process.

      What I'd do in Delphi is create the Diagram control first from a TPanel
      control. I would then write the Activity controls from TComponents. In the
      constructor for the Activity controls I would check and see if the partent
      was a Diagram control. If it was not, I would display a message then have
      the Activity control commit suiside.

      I'm just not sure when the parent is assigned if C# and if the constructor
      is the best place to check the parent class in C#.

      This is all just for completeness. I want to design a set of controls I can
      use over and over again and pass on to others in our group.

      "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin @gmail.comwrote in
      message
      news:9778a422-1378-4e69-8a6c-fa997cba093d@c5 8g2000hsc.googl egroups.com...
      On Aug 1, 9:46 am, "Andrew" <and...@yahoo.c omwrote:
      I want to create a set of Activity Diagram controls for process control.
      >
      I need to create a base Diagram control that acts as a container for the
      Activity controls ( StartPoint, EndPoint, Actvity, Decision, Message,...).
      >
      How do I implement it such that the only place I can drop an Activity
      control is on a Activity Diagram?
      >
      I'm an experienced Delphi developer and I'm just getting started in C#.
      There appears to be significant crossover between the two languages.
      hi

      I do not undersstand your question, are you asking how to design your
      classes or your interface?


      Comment

      • Peter Duniho

        #4
        Re: Limiting a controls parent.

        On Fri, 01 Aug 2008 07:31:51 -0700, Andrew <andnan@yahoo.c omwrote:
        [...]
        What I'd do in Delphi is create the Diagram control first from a TPanel
        control. I would then write the Activity controls from TComponents. In
        the
        constructor for the Activity controls I would check and see if the
        partent
        was a Diagram control. If it was not, I would display a message then
        have
        the Activity control commit suiside.
        >
        I'm just not sure when the parent is assigned if C# and if the
        constructor
        is the best place to check the parent class in C#.
        I question the wisdom of designing the control so that it may only have
        some specific type of control as its parent. IMHO, it's much better to
        define some specific set of functionality that the parent is required to
        have and check for that as needed.

        That said, in .NET, the control's parent is not known during construction,
        and in fact the parent can change over time (that is, some code could
        specifically move the control).

        The most appropriate place to check for some qualification of the
        control's parent would be in the OnParentChanged () method. Override that,
        and respond in whatever way is appropriate for your code if the new parent
        isn't qualified. IMHO, all you really should do is throw an exception
        (e.g. InvalidOperatio nException), but I suppose you could actually have
        the control remove itself from the new parent and dispose itself (but
        there's not really a good way for the control to inform its parent,
        especially a parent that wasn't the right parent, to be aware of this...so
        I'd really recommend against it).
        This is all just for completeness. I want to design a set of controls I
        can
        use over and over again and pass on to others in our group.
        Personally, I'd avoid trying to enforce a specific parent. But if you
        really insist, hopefully the above would be helpful information.

        Pete

        Comment

        • AJ

          #5
          Re: Limiting a controls parent.

          I've a feeling that you _can_ do what you want to... the example code
          I'm thinking of comes from

          so have a look through that. But it was a while ago I tried this, so I
          might be mis-remembering.


          In article <4893131f$0$402 2$9a566e8b@news .aliant.net>, andnan@yahoo.co m
          says...
          I want to create a set of Activity Diagram controls for process control.
          >
          I need to create a base Diagram control that acts as a container for the
          Activity controls ( StartPoint, EndPoint, Actvity, Decision, Message,...).
          >
          How do I implement it such that the only place I can drop an Activity
          control is on a Activity Diagram?
          >
          I'm an experienced Delphi developer and I'm just getting started in C#.
          There appears to be significant crossover between the two languages.
          >
          >
          >

          Comment

          Working...