Example #1
0
        private void Target_Click(Microsoft.Office.Core.CommandBarButton control, ref bool cancelDefault)
        {
            var button = new CommandBarButton(control);

            var handler = _clickHandler;

            if (handler == null || IsWrappingNullReference)
            {
                button.Dispose();
                return;
            }

            System.Diagnostics.Debug.Assert(handler.GetInvocationList().Length == 1, "Multicast delegate is registered more than once.");

            //note: event is fired for every parent the command exists under. not sure why.
            using (var parent = Parent)
            {
                _logger.Trace($"Executing handler for: {parent.GetType().Name} '{Target.Caption}' (tag: {Tag}, hashcode:{Target.GetHashCode()})");
            }

            var args = new CommandBarButtonClickEventArgs(button);

            handler.Invoke(this, args);
            cancelDefault = args.Cancel;
            //button.Release(final:true);
        }
Example #2
0
        private void Target_Click(Microsoft.Office.Core.CommandBarButton ctrl, ref bool cancelDefault)
        {
            var handler = _clickHandler;

            if (handler == null || IsWrappingNullReference)
            {
                return;
            }

            System.Diagnostics.Debug.Assert(handler.GetInvocationList().Length == 1, "Multicast delegate is registered more than once.");

            //note: event is fired for every parent the command exists under. not sure why.
            System.Diagnostics.Debug.WriteLine("Executing handler for: {0} '{1}' (tag: {2}, hashcode:{3})", Parent.GetType().Name, Target.Caption, Tag, Target.GetHashCode());

            var button = new CommandBarButton(ctrl);
            var args   = new CommandBarButtonClickEventArgs(button);

            handler.Invoke(this, args);
            cancelDefault = args.Cancel;
            //button.Release(final:true);
        }