using RFIDReaderTC.Model;
using RFIDReaderTC.ViewModel;
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 RFIDReaderTC
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            // 传递 MainWindow 的实例到 ViewModel
            this.DataContext = new MainWindowViewModel(this);
            var viewModel = (MainWindowViewModel)this.DataContext;
            Mesg.Document = viewModel.RichText;  // 将 FlowDocument 赋值给 RichTextBox 的 Document 属性
        }

        private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            // 获取第1行的RowDefinition
            var rowDefinition = MainGrid.RowDefinitions[1];

            // 计算新的行高度
            double newHeight = rowDefinition.Height.Value + e.VerticalChange;

            // 设置新的行高度，避免行高度为负数
            if (newHeight >= 0)
            {
                rowDefinition.Height = new GridLength(newHeight);
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}