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 }
internal void DlgLineEntity_MouseEnter(object sender, MouseEventArgs e) { if (mouseMode == MouseMode.None) { DlgLineEntity convertedSender = sender as DlgLineEntity; convertedSender.ShowConnects(); } }
internal void DlgLineEntity_MouseLeave(object sender, MouseEventArgs e) { DlgLineEntity convertedSender = sender as DlgLineEntity; if (mouseMode == MouseMode.None) { convertedSender.HideConnects(); } }
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); } }
private void moveDlgLineEntity(DlgLineEntity dle, Point moveTo) { Point newPos = SnapToGrid(moveTo, new Point(0, 0), new Point(mapCanvas.ActualWidth - dle.ActualWidth, mapCanvas.ActualHeight - dle.ActualHeight)); dle.Margin = new Thickness(newPos.X, newPos.Y, 0, 0); foreach (Dlg.InteractionConnection ic in dle.interaction.interactionFrom) { //Changing End position Point rectPos = dle.lineConnectPos(ic.endRect); ic.arrow.endPoint = new Point(newPos.X + rectPos.X, newPos.Y + rectPos.Y); } foreach (Dlg.InteractionConnection ic in dle.interaction.interactionTo) { //Changing start position Point relPos = GetRelativeLocation(ic.startRect, mapCanvas); ic.arrow.startPoint = new Point(relPos.X + ic.startRect.ActualWidth / 2, relPos.Y + ic.startRect.ActualHeight / 2); } }