using System;
using System.Collections.Generic;
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 MultiLayout.MainEdit
{
    /// <summary>
    /// Window_MainEditGraphComponent.xaml 的交互逻辑
    /// </summary>
    public partial class WdGraphConfig : FLY.ControlLibrary.WindowBigClose
    {
        public GraphComponentEditResult Result;
        public WdGraphConfig()
        {
            InitializeComponent();
        }
        public void Init(MeGraphComponent component, List<string> serviceNames)
        {
            Result = new GraphComponentEditResult();
            Result.Header = component.Type.Header;
            Result.Rect = component.Rect;
            Result.ServiceContainerName = component.ServiceContainerName;
            this.DataContext = Result;
            this.cbServiceNames.ItemsSource = serviceNames;
        }
        private void button_apply_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }
    }
    public class GraphComponentEditResult:INotifyPropertyChanged
    {
        public string Header { get; set; }
        public int X { get; set; }
        public int Y { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }
        public string ServiceContainerName { get; set; }
        public System.Drawing.Rectangle Rect
        {
            get { return new System.Drawing.Rectangle(X,Y,Width,Height); }
            set
            {
                X = (int)value.X;
                Y = (int)value.Y;
                Width = (int)value.Width;
                Height = (int)value.Height;
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}