/// <summary> /// Insert text /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TextBoxInsertText_KeyDown(object sender, KeyEventArgs e) { double r; double b; r = SelectedPoints.TextBoxPoint.X + TextBoxInsertText.ActualWidth; b = SelectedPoints.TextBoxPoint.Y + TextBoxInsertText.ActualHeight; if (r > ImageTextCanvas.ActualWidth - 10) { try { TextBoxInsertText.Width = TextBoxInsertText.ActualWidth; } catch { } } if (b > ImageTextCanvas.ActualHeight - 10) { try { TextBoxInsertText.Text = TextBoxInsertText.Text.Remove(TextBoxInsertText.Text.Length - 1); TextBoxInsertText.Text = TextBoxInsertText.Text.Remove(TextBoxInsertText.Text.Length - 1); TextBoxInsertText.Height = Double.NaN; } catch { } } try { TextBoxInsertText.Select(TextBoxInsertText.Text.Length, 0); } catch { } }
private void paintSurface_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (VisibilityProperties.Instance.TextButtonChecked == true && VisibilityProperties.Instance.InsertTextVisibility == false && Images.Instance.CurrentBitmap != null && check == 1) { SelectedPoints.TextBoxPoint = e.GetPosition(ImageOp); if (SelectedPoints.TextBoxPoint.X > 0 && SelectedPoints.TextBoxPoint.Y > 0 && SelectedPoints.TextBoxPoint.X < ImageOp.Width - 10 - TextBoxInsertText.ActualWidth && SelectedPoints.TextBoxPoint.Y < ImageOp.ActualHeight - 20 && check == 1) { if (VisibilityProperties.Instance.TextButtonChecked == true) { VisibilityProperties.Instance.TextPanelIsSelected = true; VisibilityProperties.Instance.NotifyProperties(); } TextBoxInsertText.IsEnabled = true; VisibilityProperties.Instance.InsertTextVisibility = true; VisibilityProperties.Instance.NotifyProperties(); Canvas.SetTop(TextBoxInsertText, SelectedPoints.TextBoxPoint.Y); Canvas.SetLeft(TextBoxInsertText, SelectedPoints.TextBoxPoint.X); TextBoxInsertText.Focusable = true; TextBoxInsertText.Width = Double.NaN; TextBoxInsertText.Height = Double.NaN; if (TextBoxInsertText.IsFocused == false) { Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (System.Threading.ThreadStart) delegate() { TextBoxInsertText.Focus(); }); } check = 2; } } }
private void SetTextStyle(object aSender, EventArgs aEventArgs) { string a = (aSender).ToString(); if (a == "1") { TextBoxInsertText.FontWeight = FontWeights.Bold; } if (a == "-1") { TextBoxInsertText.FontWeight = FontWeights.Normal; } if (a == "2") { TextBoxInsertText.SetValue(TextElement.FontStyleProperty, FontStyles.Italic); } if (a == "-2") { TextBoxInsertText.SetValue(TextElement.FontStyleProperty, FontStyles.Normal); } if (a == "3") { if (strike == 1) { TextDecorationCollection textDecor = new TextDecorationCollection(); textDecor.Add(TextDecorations.Strikethrough); textDecor.Add(TextDecorations.Underline); TextBoxInsertText.TextDecorations = textDecor; under = 1; } else { TextDecorationCollection textDecor = new TextDecorationCollection(); textDecor.Add(TextDecorations.Underline); TextBoxInsertText.TextDecorations = textDecor; under = 1; } } if (a == "-3") { if (strike == 1) { TextDecorationCollection textDecor = new TextDecorationCollection(); textDecor.Add(TextDecorations.Strikethrough); TextBoxInsertText.TextDecorations = textDecor; under = 0; } else { TextBoxInsertText.TextDecorations = null; under = 0; strike = 0; } } if (a == "4") { if (under == 1) { TextDecorationCollection textDecor = new TextDecorationCollection(); textDecor.Add(TextDecorations.Strikethrough); textDecor.Add(TextDecorations.Underline); TextBoxInsertText.TextDecorations = textDecor; strike = 1; } else { TextDecorationCollection textDecor = new TextDecorationCollection(); textDecor.Add(TextDecorations.Strikethrough); TextBoxInsertText.TextDecorations = textDecor; strike = 1; } } if (a == "-4") { if (under == 1) { TextDecorationCollection textDecor = new TextDecorationCollection(); textDecor.Add(TextDecorations.Underline); TextBoxInsertText.TextDecorations = textDecor; strike = 0; } else { TextBoxInsertText.TextDecorations = null; under = 0; strike = 0; } } if (a == "TH1") { inkDA.Height = 5; inkDA.Width = 5; InkCan.DefaultDrawingAttributes = inkDA; } if (a == "TH2") { inkDA.Height = 15; inkDA.Width = 15; InkCan.DefaultDrawingAttributes = inkDA; } if (a == "TH3") { inkDA.Height = 25; inkDA.Width = 25; InkCan.DefaultDrawingAttributes = inkDA; } if (a == "TH4") { inkDA.Height = 35; inkDA.Width = 35; InkCan.DefaultDrawingAttributes = inkDA; } }