Beispiel #1
0
        /// <summary>
        /// Wraps the specified action by assigning it's handlers and returning
        /// the menu item related to it.
        /// </summary>
        /// <param name="action">The action to wrap.</param>
        /// <returns>The menu item for the action.</returns>
        private static T WrapAction <T>(Moai.Platform.Menus.Action action) where T : ToolStripItem, new()
        {
            T mi = new T();

            if (action == null)
            {
                mi.Text    = "ERROR! UNKNOWN ACTION";
                mi.Enabled = false;
                return(mi);
            }
            action.SyncDataChanged += (sender, e) =>
            {
                ActionWrapper.ActionSyncDataChanged(action.GetSyncData() as Moai.Platform.Menus.Action.ActionSyncData, mi);
            };
            action.OnInitialize();
            ActionWrapper.ActionSyncDataChanged(action.GetSyncData() as Moai.Platform.Menus.Action.ActionSyncData, mi);
            mi.Click += new EventHandler((sender, e) => { action.OnActivate(); });
            return(mi);
        }