1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/akwkevin-aistudio.-wpf.-diagram

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Это зеркальный репозиторий, синхронизируется ежедневно с исходного репозитория.
Клонировать/Скачать
TextControl.xaml.cs 4.6 КБ
Копировать Редактировать Исходные данные Просмотреть построчно История
艾竹 Отправлено 2 лет назад 5ee0c1c
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace AIStudio.Wpf.DiagramDesigner
{
/// <summary>
/// TextControl.xaml 的交互逻辑
/// </summary>
public partial class TextControl : UserControl
{
//public static readonly DependencyProperty DoubleEditProperty = DependencyProperty.Register(
// nameof(DoubleEdit), typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(
// true));
//public bool DoubleEdit
//{
// get => (bool)GetValue(DoubleEditProperty);
// set => SetValue(DoubleEditProperty, value);
//}
public TextControl()
{
InitializeComponent();
this.Loaded += TextControl_Loaded;
}
private void TextControl_Loaded(object sender, RoutedEventArgs e)
{
this.Loaded -= TextControl_Loaded;
PART_ShowText.Visibility = Visibility.Visible;
PART_TextBlock.Visibility = Visibility.Collapsed;
PART_ShowText.Focus();
if (!string.IsNullOrEmpty(PART_ShowText.Text))
{
PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
}
if (this.DataContext is ISelectable selectable)
{
selectable.PropertyChanged -= TextControl_PropertyChanged;
selectable.PropertyChanged += TextControl_PropertyChanged;
}
TextControl_PropertyChanged(this.DataContext, new System.ComponentModel.PropertyChangedEventArgs("IsSelected"));
}
private void TextControl_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsSelected")
{
if (sender is ISelectable selectable)
{
if (selectable.IsSelected == false)
{
PART_ShowText.Visibility = Visibility.Collapsed;
PART_TextBlock.Visibility = Visibility.Visible;
}
}
}
else if (e.PropertyName == "ShowText")
{
PART_ShowText.Visibility = Visibility.Visible;
PART_TextBlock.Visibility = Visibility.Collapsed;
PART_ShowText.Focus();
if (!string.IsNullOrEmpty(PART_ShowText.Text))
{
PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
}
}
}
//protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
//{
// base.OnPreviewMouseDown(e);
// if (DoubleEdit == false)
// {
// PART_ShowText.Visibility = Visibility.Visible;
// PART_TextBlock.Visibility = Visibility.Collapsed;
// PART_ShowText.Focus();
// if (!string.IsNullOrEmpty(PART_ShowText.Text))
// {
// PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
// }
// }
//}
//protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e)
//{
// base.OnPreviewMouseDoubleClick(e);
// if (DoubleEdit == true)
// {
// PART_ShowText.Visibility = Visibility.Visible;
// PART_TextBlock.Visibility = Visibility.Collapsed;
// PART_ShowText.Focus();
// if (!string.IsNullOrEmpty(PART_ShowText.Text))
// {
// PART_ShowText.SelectionStart = PART_ShowText.Text.Length;
// }
// }
//}
}
public class ControlAttachProperty
{
#region WatermarkProperty 水印
/// <summary>
/// 水印
/// </summary>
public static readonly DependencyProperty WatermarkProperty = DependencyProperty.RegisterAttached(
"Watermark", typeof(string), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(""));
public static string GetWatermark(DependencyObject d)
{
return (string)d.GetValue(WatermarkProperty);
}
public static void SetWatermark(DependencyObject obj, string value)
{
obj.SetValue(WatermarkProperty, value);
}
#endregion
}
}

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/akwkevin-aistudio.-wpf.-diagram.git
git@gitlife.ru:oschina-mirror/akwkevin-aistudio.-wpf.-diagram.git
oschina-mirror
akwkevin-aistudio.-wpf.-diagram
akwkevin-aistudio.-wpf.-diagram
1.0.7Demo