示例#1
0
        /// <summary>
        /// Получить IAction для кнопки запуска настроек
        /// </summary>
        /// <param name="ui">The UI.</param>
        /// <param name="actionEventSources">The action event sources.</param>
        private static IAction GetActionForPersonalAccountCommand(IUI ui, ICollection <ActionEventSource> actionEventSources)
        {
            var action = ui.CreateAction();

            var extractedImageResource = ExtractResource(Assembly.GetExecutingAssembly(), "PersonalAccount_16x16.png");

            if (extractedImageResource != null)
            {
                var icon = ui.CreateImage();
                icon.LoadFromData(extractedImageResource, ImageFormat.ImageFormat_PNG);
                action.Icon = icon;
            }

            action.DisplayName = Language.GetItem(LangItem, "h7");

            var actionEventSource = new ActionEventSource(action);

            actionEventSource.Triggered += (s, e) =>
            {
                ModPlusAPI.UserInfo.UserInfoService.ShowUserInfo();
            };

            actionEventSources.Add(actionEventSource);

            return(action);
        }
示例#2
0
        /// <summary>
        /// Получить IAction для кнопки запуска настроек
        /// </summary>
        /// <param name="ui">The UI.</param>
        /// <param name="actionEventSources">The action event sources.</param>
        private static IAction GetActionForSettingsCommand(IUI ui, ICollection <ActionEventSource> actionEventSources)
        {
            var action = ui.CreateAction();

            var extractedImageResource = ExtractResource(Assembly.GetExecutingAssembly(), "Settings_16x16.png");

            if (extractedImageResource != null)
            {
                var icon = ui.CreateImage();
                icon.LoadFromData(extractedImageResource, ImageFormat.ImageFormat_PNG);
                action.Icon = icon;
            }

            action.DisplayName = Language.GetItem(LangItem, "h9");

            var actionEventSource = new ActionEventSource(action);

            actionEventSource.Triggered += (s, e) =>
            {
                var settings  = new SettingsWindow();
                var viewModel = new SettingsViewModel(settings);
                settings.DataContext = viewModel;
                settings.Closed     += (sender, args) => viewModel.ApplySettings();
                settings.ShowDialog();
            };

            actionEventSources.Add(actionEventSource);

            return(action);
        }