// RadToggleMenuItem.cs
// Copyright (c) 2016 Bentley Systems, Incorporated. All Rights Reserved.

using System;
using Telerik.Windows.Controls;

namespace Haestad.Framework.UI.Integration
{
    /// <summary>
    /// Class that defines a menu item that is intended to be added to a context menu associated with a RadRibbonToggleSplitButton.
    /// </summary>
    public class RadToggleMenuItem : RadMenuItem
    {
        #region Constructor
        public RadToggleMenuItem(RadRibbonToggleSplitButton ownerButton)
        {
            OwnerButton = ownerButton;
        }
        #endregion

        #region Public Methods
        public void DoClick()
        {
            OnClick();
        }
        #endregion

        #region Protected Override Methods
        protected override void OnClick()
        {
            // Note: <whar> This logic is NOT in the command since it is intended ONLY to happen when using the menu.
            OwnerButton.SetDefaultCommand(Command as IRibbonUICommand);

            base.OnClick();
        }
        #endregion

        #region Private Properties
        private RadRibbonToggleSplitButton OwnerButton
        {
            get;
            set;
        }
        #endregion
    }
}
