public void EndEdit() { if (Edit.Text.Trim().IsEmpty()) { return; } double left = Canvas.GetLeft(Edit); double top = Canvas.GetTop(Edit); if (Label == null) { PBLabel label = new PBLabel() { Coordinates = ToLogical(new Point(left, top)), Text = Edit.Text, }; Drawing.Add(label, true); } else { Label.Text = Edit.Text; } CancelEdit(); }
public void CancelEdit() { Drawing.Canvas.Children.Remove(Edit); Drawing.SetDefaultBehavior(); Edit.KeyDown -= new System.Windows.Input.KeyEventHandler(tb_KeyDown); if (Label != null) { Label.Visible = true; Label.UpdateVisual(); Label = null; } if (Edit != null) { Edit.FontSize = 14; Edit.FontFamily = new FontFamily("Arial"); Edit.Foreground = Brushes.Black; } }
private void listBoxTool_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (Mouse.DirectlyOver is FrameworkElement) { Tool selectedTool = (Mouse.DirectlyOver as FrameworkElement).DataContext as Tool; if (selectedTool != null) { switch (selectedTool.Command) { case Commands.Label: { string file = AppDomain.CurrentDomain.BaseDirectory + "Labels\\" + selectedTool.Text; if (System.IO.File.Exists(file)) { PBLabel label = new PBLabel(); Drawing.Add(label); label.LoadLabel(file); label.Coordinates = new Point(-8, 5); label.UpdateVisual(); this.DialogResult = false; this.CloseWindow(); } } break; case Commands.CreateNewLabel: { this.DialogResult = true; this.CloseWindow(); } break; } } } }