using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
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.Shapes;

namespace ThickTcpUiInWindow.MainEdit
{
    /// <summary>
    /// Window_MainEditGraphTabItem.xaml 的交互逻辑
    /// </summary>
    public partial class Window_MainEditGraphTabItem : FLY.ControlLibrary.WindowBigClose
    {
        ObservableCollection<GraphTabItem> Items;
        int Idx;
        GraphTabItem_RC ItemRC;
        public Window_MainEditGraphTabItem()
        {
            InitializeComponent();
        }
        public void Init(ObservableCollection<GraphTabItem> items, int idx)
        {
            Items = items;
            Idx = idx;
            ItemRC = new GraphTabItem_RC();
            ItemRC.ColCnt = Items[Idx].ColCnt;
            ItemRC.RowCnt = Items[Idx].RowCnt;
            this.grid_graphTabItem.DataContext = Items[Idx];
            this.grid_RC.DataContext = ItemRC;
        }
        private void button_pre_Click(object sender, RoutedEventArgs e)
        {
            if (Idx > 0)
            {
                Items.Move(Idx, Idx - 1);
                Idx--;
            }
        }
        private void button_next_Click(object sender, RoutedEventArgs e)
        {
            if (Idx < Items.Count()-1)
            {
                Items.Move(Idx, Idx + 1);
                Idx++;
            }
        }

        private void button_apply_Click(object sender, RoutedEventArgs e)
        {
            Items[Idx].RefreshRC(ItemRC.RowCnt, ItemRC.ColCnt);
        }
    }
    public class GraphTabItem_RC : INotifyPropertyChanged
    {

        private int colcnt = 1;

        public int ColCnt
        {
            get { return colcnt; }
            set
            {
                colcnt = value;
                NotifyPropertyChanged("ColCnt");
            }
        }
        private int rowcnt = 1;

        public int RowCnt
        {
            get { return rowcnt; }
            set
            {
                rowcnt = value;
                NotifyPropertyChanged("RowCnt");
            }
        }
        protected void NotifyPropertyChanged(string propertyname)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyname));
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
