private void minuteHand_MouseMove(object sender, MouseEventArgs e) { if (isWritingShape) { checkPreview(); StrokeElement.changeStroke(strokePreview, indexToShape[shapeBox.SelectedIndex], xCliked, yCliked, e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y); } }
/// <summary> /// Handle everything related to a click on the canvas /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void clickCanvas(object sender, MouseButtonEventArgs e) { resetPreview(); if (allBoardElements.ContainsKey(selectedObject)) // update selected object if click somewhere else on the canvas { allBoardElements[selectedObject].updatePosition(inkCanvas); client.ask_modif(selectedObject, allBoardElements[selectedObject]); } if ((currentMode == "text") && ((DateTime.Now - lastClick) > new TimeSpan(0, 0, 1))) //add new text block if text mode { e.Handled = true; TextBox newTextBox = new TextBox { Width = 100, Height = 20, MaxLines = 100, }; newTextBox.LostFocus += new RoutedEventHandler(textBoxModified); inkCanvas.Children.Add(newTextBox); InkCanvas.SetLeft(newTextBox, e.GetPosition(this).X); InkCanvas.SetTop(newTextBox, e.GetPosition(this).Y); newTextBox.Focus(); isCreatingATextBox = true; lastClick = DateTime.Now; changeMode("select"); } if ((currentMode == "shape")) { e.Handled = true; if (indexToShape[shapeBox.SelectedIndex].Equals("Triangle")) { if (stylusPoints.Count < 2) { checkPreview(); stylusPoints.Add(new StylusPoint(e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y)); StrokeElement.changeStroke(strokePreview, stylusPoints); counTriangle++; } else { stylusPoints.Add(new StylusPoint(e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y)); client.ask_add(new StrokeElement(stylusPoints)); stylusPoints = new List <StylusPoint>(); } } else { isWritingShape = true; counTriangle = 0; stylusPoints = new List <StylusPoint>(); } } else { counTriangle = 0; } xPrevCliked = xCliked; yPrevCliked = yCliked; xCliked = e.GetPosition(inkCanvas).X; yCliked = e.GetPosition(inkCanvas).Y; }