using C1.Xaml.FlexGrid;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace FlexGridSamples
{
    public partial class ExcelStyleMerge : Page
    {
        ExcelStyleMergeManager _xlMergeManager;

        public ExcelStyleMerge()
        {
            InitializeComponent();
            _xlMergeManager = new ExcelStyleMergeManager(_flex);
            _flex.MergeManager = _xlMergeManager;
            _flex.AllowMerging = AllowMerging.Cells;

            for (int r = 0; r < 50; r++)
            {
                _flex.Rows.Add(new Row());
            }
            for (int c = 0; c < 10; c++)
            {
                _flex.Columns.Add(new Column());
            }
            for (int r = 0; r < _flex.Rows.Count; r++)
            {
                for (int c = 0; c < _flex.Columns.Count; c++)
                {
                    _flex[r, c] = string.Format("r{0}, c{1}", r, c);
                }
            }
        }

        void _btnMerge_Click(object sender, RoutedEventArgs e)
        {
            _xlMergeManager.AddMergedRange(_flex.Selection);
        }
        void _btnSplit_Click(object sender, RoutedEventArgs e)
        {
            _xlMergeManager.RemoveMergedRange(_flex.Selection);
        }
    }
}
