Пример #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);
        }
Пример #2
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 QAction WrapAction(Moai.Platform.Menus.Action action)
        {
            m_Log.Debug("Wrapping action " + action.GetType().FullName + ".");
            QSyncableAction mi = new QSyncableAction(action);

            LinuxNativePool.Instance.Retain(mi);
            if (action == null)
            {
                mi.Text    = "ERROR! UNKNOWN ACTION";
                mi.Enabled = false;
                return(mi);
            }
            action.SyncDataChanged += (sender,e) =>
            {
                mi.Resync();
            };
            action.OnInitialize();
            mi.Resync();
            return(mi);
        }