using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.UserDesigner;
using System;

namespace RibbonReportDesigner {
    public delegate void SaveReport(XRDesignPanel designPanel);
    public partial class OfficeInspiredMainForm : MainFormBase, ICommandHandler
    {
        public event SaveReport OnSave;
        public OfficeInspiredMainForm() {
            InitializeComponent();
            reportDesigner1.AddCommandHandler(this);
        }

        public override XRDesignPanel ActiveXRDesignPanel { get { return reportDesigner1.ActiveDesignPanel; } }


        public override void OpenReport(XtraReport report) {
            reportDesigner1.OpenReport(report);
        }


        public void HandleCommand(ReportCommand command, object[] args)
        {
            OnSave?.Invoke(this.ActiveXRDesignPanel);
        }

        public bool CanHandleCommand(ReportCommand command, ref bool useNextHandler)
        {
            switch (command)
            {
                case ReportCommand.SaveFile:
                    useNextHandler = false;
                    return true;
                default:
                    useNextHandler = true;
                    return false;
            }
        }

    }
}
