
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 MultiLayout.MainEdit
{
    /// <summary>
    /// Window_MainEditDynAreaComponent.xaml 的交互逻辑
    /// </summary>
    public partial class WdMenuConfig : FLY.ControlLibrary.WindowBigClose
    {
        ObservableCollection<MeFlyComponent> Items;
        MeFlyComponent component;
        int Idx;
        public WdMenuConfig()
        {
            InitializeComponent();
        }
        public void Init(ObservableCollection<MeFlyComponent> items, int idx, List<string> serviceNames)
        {
            Items = items;
            Idx = idx;
            component = Items[idx];
            cbServiceNames.ItemsSource = serviceNames;
            this.DataContext = component;
        }


        private void btnNextClick(object sender, RoutedEventArgs e)
        {
            if (Idx < Items.Count() - 1)
            {
                Items.Move(Idx, Idx + 1);
                Idx++;
            }
        }

        private void btnPreClick(object sender, RoutedEventArgs e)
        {
            if (Idx > 0)
            {
                Items.Move(Idx, Idx - 1);
                Idx--;
            }
        }

        private void btnRemoveClick(object sender, RoutedEventArgs e)
        {
            if (FLY.ControlLibrary.MyMessageBox.Show("组件将要被删除,是否确定?") == true)
            {
                Items.Remove(component);
                this.Close();
            }
        }

    }
}
