﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using MyMVVMFramework.BaseCommands;

namespace Klausur_Tool.AppDesign.CustomControls
{
    /// <summary>
    /// Interaktionslogik für PrintableConentControl.xaml
    /// </summary>
    public partial class PrintableContentControl
    {
      /// <summary>
        ///PrintCommand Property
        /// </summary>
        public static readonly DependencyProperty PrintCommandProperty = DependencyProperty.Register(
            nameof(PrintCommand), typeof(ICommand), typeof(PrintableContentControl),new PropertyMetadata(default(ICommand)));

        /// <summary>
        ///PrintCommand
        /// </summary>
        public ICommand PrintCommand
        {
            get {return (ICommand)GetValue(PrintCommandProperty); }
            set {SetValue(PrintCommandProperty,value); }
        }

        private void OnPrint(string titel)
        {
            var dialog = new PrintDialog();
            if (dialog.ShowDialog() == true)
            {
                dialog.PrintVisual(this, titel);
            }
        }

        /// <summary>
        /// Printable ConentControl
        /// </summary>
        public PrintableContentControl()
        {
            InitializeComponent();
            PrintCommand=new DelegateCommand<string>(OnPrint);
        }
    }
}
