This is a migrated thread and some comments may be shown as answers.

Disable Drag & Drop at Design Time

1 Answer 90 Views
Panel
This is a migrated thread and some comments may be shown as answers.
Troy
Top achievements
Rank 1
Troy asked on 19 Sep 2014, 11:35 PM
I might be going down the wrong path here but here is some
background to why I am asking about disabling drag and drop at design time and
am open to other solutions to my problem.

I am looking to add multiple shapes to create a representation of a piece of
equipment and while it operates have the shapes move on the screen in
coordination with the equipment. The visual studio power pack shapes was an
option but had a problem they had to be placed on the form in the exact order
you wanted them you could not use bring to front or send to back. This caused a
major problem as the equipment is complex and needs many shapes and to add each
item in the exact sequence is un feasible.

I noticed while doing some other work Telerik had a shape designer and this
feature seemed like a good option to create all different shapes for my
equipment representation. I tried to find the least complex telerik component
such as a label or panel to apply the shape to. The problem I am having is when
I drag shapes on top of each other the Design time Designer adds the shape to
the other shape as if it were a control container. If I could stop them from
acting as control containers this would be a workable solution to my problem.



If anyone has any suggestions to this problem or a different solution I would appreciate
it.



My requirements.

1. Able to design multiple different shapes and layer them on top of each other.
The control needs to clip its region around the shape so you can see the shapes
behind.

2. The shapes need a boarder

3. The fill and boarder colors need to be able to change at run time

4. The shape needs to be able to move and its visibility changed at run time



Not required but a nice to have is a way to group the shapes together as one
larger shape collection able to be placed on top of other shapes or collections
maintaining the ability to see shapes underneath.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 Sep 2014, 02:26 PM
Hi Troy,

I am copying my answer from the ticket you have posted here as well, so the community can benefit from it:

We do not offer shape control, however, implementing such should be be a tough task. Below you can find a sample demonstrating how to do that. The control can be dropped at design time, and it will automatically open the shape editor. Once you are done with the shape and close the window, the shape is applied to the control. A custom shape component will also be created at design time. 
<ToolboxItem(True), DesignTimeVisible(True), Designer(GetType(ShapeControlDesigner))> _
Public Class ShapeControl
    Inherits RadControl
    Private m_editor As New CustomShapeEditorForm()
  
    Public Property Editor() As CustomShapeEditorForm
        Get
            Return Me.m_editor
        End Get
        Set
            Me.m_editor = value
        End Set
    End Property
  
    Public Property Shape() As ElementShape
        Get
            Return Me.RootElement.Shape
        End Get
        Set
            Me.RootElement.Shape = value
        End Set
    End Property
  
    Public Sub New()
        Me.BackColor = Color.Black
        Me.RootElement.ApplyShapeToControl = True
    End Sub
End Class
  
Public Class ShapeControlDesigner
    Inherits RadControlDesignerLite
    Public Overrides Sub InitializeNewComponent(defaultValues As System.Collections.IDictionary)
        MyBase.InitializeNewComponent(defaultValues)
  
        Dim shapeControl As ShapeControl = DirectCast(Me.RadControl, ShapeControl)
        Dim shape As ElementShape = EditShape()
  
        Dim cs As CustomShape = DirectCast(DesignerHost.CreateComponent(GetType(CustomShape)), CustomShape)
        cs.CopyFrom(DirectCast(shape, CustomShape))
        shapeControl.Shape = cs
    End Sub
  
    Public Function EditShape() As ElementShape
        Dim shapeControl As ShapeControl = DirectCast(Me.RadControl, ShapeControl)
  
        If shapeControl.Shape Is Nothing Then
            Return shapeControl.Editor.CreateShape()
        Else
            Return shapeControl.Editor.EditShape(DirectCast(shapeControl.Shape, CustomShape))
        End If
    End Function
  
    Protected Overrides Function CreateActionList() As RadControlDesignerLiteActionList
        Return New ShapeActionList(Me)
    End Function
End Class
  
Class ShapeActionList
    Inherits RadControlDesignerLiteActionList
    Public Sub New(designer As RadControlDesignerLite)
  
        MyBase.New(designer)
    End Sub
  
    Protected Overrides Sub AddHelpActions(actionItems As DesignerActionItemCollection)
        actionItems.Clear()
  
        actionItems.Add(New DesignerActionMethodItem(Me, "OpenShapeEditor", "Open Shape Editor", "Common"))
    End Sub
  
    Public Sub OpenShapeEditor()
        Dim designer As ShapeControlDesigner = DirectCast(Me.Designer, ShapeControlDesigner)
        Me.Designer.InitializeNewComponent(Nothing)
    End Sub
End Class
Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Panel
Asked by
Troy
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or