Exemplo n.º 1
0
        private int FindRoomControlIndex(RoomControl control)
        {
            for (int i = 0; i < this.parentPanel.Controls.Count; i++)
            {
                RoomControl target = this.parentPanel.Controls[i] as RoomControl;

                if (control == target)
                {
                    return(i);
                }
            }
            return(-1);
        }
Exemplo n.º 2
0
        private void RoomControl_DragDrop(object sender, DragEventArgs e)
        {
            RoomControl target = sender as RoomControl;

            if (target != null)
            {
                int targetIndex = FindRoomControlIndex(target);
                if (targetIndex != -1)
                {
                    string roomControlFormat = typeof(RoomControl).FullName;
                    if (e.Data.GetDataPresent(roomControlFormat))
                    {
                        RoomControl source = e.Data.GetData(roomControlFormat) as RoomControl;

                        if (null != source)
                        {
                            if (target != source)
                            {
                                int sourceIndex = this.FindRoomControlIndex(source);

                                if (sourceIndex != -1)
                                {
                                    this.parentPanel.Controls.SetChildIndex(source, targetIndex);
                                }

                                source.BorderStyle = BorderStyle.FixedSingle;
                            }
                            else
                            {
                                source.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                            }
                        }
                    }
                }
            }
        }