/// <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); }
/// <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); }
/// <summary> /// Gets the action for function. /// </summary> /// <param name="rengaApplication">The renga application.</param> /// <param name="actionEventSources">The action event sources.</param> /// <param name="loadedFunction">The loaded function.</param> /// <param name="isForContextMenu">if set to <c>true</c> [is for context menu].</param> /// <param name="isForDropDownMenu">if set to <c>true</c> [is for dropdown menu]</param> private static IAction GetActionForFunction( IApplication rengaApplication, List <ActionEventSource> actionEventSources, LoadedFunction loadedFunction, bool isForContextMenu, bool isForDropDownMenu) { var f = GetImplementRengaFunctionFromLoadedFunction(loadedFunction); if (f != null) { var action = rengaApplication.UI.CreateAction(); var extractedImageResource = isForContextMenu || isForDropDownMenu ? ExtractResource(loadedFunction.FunctionAssembly, loadedFunction.Name + "_16x16.png") : ExtractResource(loadedFunction.FunctionAssembly, loadedFunction.Name + "_24x24.png"); if (extractedImageResource != null) { var icon = rengaApplication.UI.CreateImage(); icon.LoadFromData(extractedImageResource, ImageFormat.ImageFormat_PNG); action.Icon = icon; } action.DisplayName = isForContextMenu ? "MP:" + loadedFunction.LName : loadedFunction.LName; var actionEventSource = new ActionEventSource(action); actionEventSource.Triggered += (s, a) => { try { f.Start(); } catch (Exception exception) { rengaApplication.UI.ShowMessageBox(MessageIcon.MessageIcon_Error, "ModPlus", exception.Message + Environment.NewLine + exception.StackTrace); } }; actionEventSources.Add(actionEventSource); return(action); } return(null); }
private static IAction GetActionForButtonInActionPanel(IApplication rengaApplication, List <ActionEventSource> actionEventSources, LoadedFunction loadedFunction) { var f = GetImplementRengaFunctionFromLoadedFunction(loadedFunction); if (f != null) { var action = rengaApplication.UI.CreateAction(); var extractedImageResource = ExtractResource(loadedFunction.FunctionAssembly, loadedFunction.Name + "_24x24.png"); if (extractedImageResource != null) { var icon = rengaApplication.UI.CreateImage(); icon.LoadFromData(extractedImageResource, ImageFormat.ImageFormat_PNG); action.Icon = icon; } action.ToolTip = loadedFunction.LName; var actionEventSource = new ActionEventSource(action); actionEventSource.Triggered += (s, a) => { try { f.Start(); } catch (Exception exception) { rengaApplication.UI.ShowMessageBox(MessageIcon.MessageIcon_Error, "ModPlus", exception.Message + Environment.NewLine + exception.StackTrace); } }; actionEventSources.Add(actionEventSource); return(action); } return(null); }