﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using InhaMate.Sources_Core.InhaPlaza;

namespace InhaMate
{
    /// <summary>
    /// CommentWindow.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class CommentWindow
    {
        public CommentWindow(List<Comment> replies)
        {
            InitializeComponent();
            foreach (var reply in replies)
            {
                CommentListDataGrid.Items.Add(reply);
            }
            //foreach (DataGridColumn column in commentListDataGrid.Columns)
            //{
            //    if (column.Header.Equals("작성자"))
            //    {
            //    }
            //    else if(column.Header.Equals("댓글"))
            //    {

            //    }
            //    else if(column.Header.Equals("작성일"))
            //    {

            //    }
            //}
            //commentListDataGrid.DataContext = replies;
        }

        private void dialogExitButton_Click(object sender, RoutedEventArgs e)
        {
            var window = GetWindow(this);
            if (window != null) window.Close();
        }

        private void commentListDataGrid_AutoGeneratedColumns(object sender, EventArgs e)
        {

            foreach (DataGridColumn column in CommentListDataGrid.Columns)
            {
                if (column is DataGridTextColumn && column.Header.Equals("댓글"))
                {
                    column.MaxWidth = 400;
                    //DataGridTextColumn textColumn = column as DataGridTextColumn;
                    //Style style = commentListDataGrid.Resources["wordWrapStyle"] as Style;
                    //textColumn.ElementStyle = style;
                    //textColumn.EditingElementStyle = style;
                }
            }
        }

        private void submitComment()
        {
            MessageBox.Show("준비중입니다 ㅠ");
        }

        private void submitButton_Click(object sender, RoutedEventArgs e)
        {
            submitComment();
        }

        private void commentTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.Key.Equals(Key.Enter))
            {
                submitComment();
            }
        }

        private void commentWIndow_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton.Equals(MouseButton.XButton1))
            {
                var window = GetWindow(this);
                if (window != null) window.Close();
            }
        }
    }
}
