Exemple #1
0
        //#pragma warning restore 0649

        internal DlgLineEntity(Dlg.DlgLine DlgLine)
        {
            InitializeComponent();

            interaction = new Dlg.Interaction();
            this.interaction.dlgLine = DlgLine;

            this.textBlockId.Text    = DlgLine.id;
            this.textBlockValue.Text = DlgLine.text;

            connectArray[0] = NorthConnect;
            connectArray[1] = WestConnect;
            connectArray[2] = EastConnect;
            connectArray[3] = SouthConnect;
            connectArray[4] = NortEastConnect;
            connectArray[5] = NorthWestConnect;
            connectArray[6] = SouthWestConnect;
            connectArray[7] = SouthEastConnect;

            dropArray[0] = NorthDrop;
            dropArray[1] = WestDrop;
            dropArray[2] = EastDrop;
            dropArray[3] = SouthDrop;
            dropArray[4] = NorthWestDrop;
            dropArray[5] = NorthEastDrop;
            dropArray[6] = SouthWestDrop;
            dropArray[7] = SouthEastDrop;

            for (int i = 0; i < 8; i++)
            {
                connectArray[i].Tag = this;
                dropArray[i].Tag    = this;
            }
        }
        private void createDlgLineEntity(Dlg.DlgLine dlgLine, Point p)
        {
            //Create DlgLineEntity
            DlgLineEntity newDlgLineEntity = new DlgLineEntity(dlgLine);

            newDlgLineEntity.PreviewMouseDown += DlgLineEntity_PreviewMouseDown;
            newDlgLineEntity.MouseEnter       += DlgLineEntity_MouseEnter;
            newDlgLineEntity.MouseLeave       += DlgLineEntity_MouseLeave;

            //Create interaction
            Dlg.Interaction newInteraction = newDlgLineEntity.interaction;
            newInteraction.dlgLine       = dlgLine;
            newInteraction.dlgLineEntity = newDlgLineEntity;
            newInteraction.dialogue      = Dlg.Dialogue.Selected;

            Dlg.Dialogue.Selected.InteractionList.Add(newInteraction);
            mapCanvas.Children.Add(newDlgLineEntity);
            //newDlgLineEntity.Margin = new Thickness(p.X, p.Y, 0, 0);
            moveDlgLineEntity(newDlgLineEntity, p);

            #region drops and connects
            for (int i = 0; i < 8; i++)
            {
                newDlgLineEntity.dropArray[i].DragEnter += DlgLineEntityDrops_DragEnter;
                newDlgLineEntity.dropArray[i].DragLeave += DlgLineEntityDrops_DragLeave;
                newDlgLineEntity.dropArray[i].Drop      += DlgLineEntityDrops_Drop;

                newDlgLineEntity.connectArray[i].PreviewMouseDown += DlgLineEntityConnect_PreviewMouseDown;
            }
            #endregion
        }
        private void removeDlgLineEntity(DlgLineEntity dle)
        {
            Console.WriteLine("b");
            mapCanvas.Children.Remove(dle);                           //Remove visually
            Dlg.Interaction interaction = dle.interaction;
            interaction.dialogue.InteractionList.Remove(interaction); //Remove from Dialogue
            interaction.dlgLine.interactions.Remove(interaction);     //Remove from Line

            //Remove interactionConnections
            foreach (Dlg.InteractionConnection ic in interaction.interactionFrom)
            {
                removeConnection(ic, false, true);
            }
            foreach (Dlg.InteractionConnection ic in interaction.interactionTo)
            {
                removeConnection(ic, true);
            }
        }