public ActionController(IntPtr hookedInstance, IActionView actionView, RecordStrategies recordStrategy) { try { switch (recordStrategy) { case RecordStrategies.Mouse: actionStrategy = new MActionStrategy(); break; case RecordStrategies.Keyboard: actionStrategy = new KBActionStrategy(); break; case RecordStrategies.MouseAndKeyboard: actionStrategy = new KBMActionStrategy(); break; default: break; } this.actionView = actionView; } catch (Exception ex) { ExceptionLogger.LogException(ex); } }
public static LocalActionModel Build <T>(IActionView <T> view, Func <Task> localAction, Action onSuccess = null) { var result = new LocalActionModel(onSuccess, localAction); view.BindActionAndInitialize(result); return(result); }
public ActionCodeController(IActionView view, IList actionList)// { _view = view; _actioncodesList = actionList; view.SetController(this); actionCodeService = new ActionCodeService(); }
public static LocalActionModel Build <T>(IActionView <T> view, Action onSuccess) { var result = new LocalActionModel(onSuccess); view.BindActionAndInitialize(result); return(result); }
public LoginFormView(Func <LabelDescr, IActionView <HTMLElement> > customActionBuilder = null) { AttemptLogin = (customActionBuilder ?? Toolkit.DefaultActionBuilder) .Invoke(new LabelDescr { Label = I18n.Translate("Login") }) .With(x => x.MarkAsFormsDefaultButton()); }
public static RemoteActionModel <ResT> Build <WidgetT, ResT>( IActionView <WidgetT> view, Func <Task <ResT> > remOper, Action <ResT> onSuccessOrNull = null, Action <ResultHolder <ResT> > onFailureOrNull = null) { var result = new RemoteActionModel <ResT>(remOper, onSuccessOrNull, onFailureOrNull); view.BindActionAndInitialize(result); return(result); }
void Awake() { _acitionView = FindObjectOfType <ActionView>() as IActionView; _inputManagerPlayer = new PlayerInputManager(); _human = new Player(_inputManagerPlayer); InitInputManagers(); InitGameManager(); }
/// <summary> /// Builds a menu from the specified action model nodes. /// </summary> /// <param name="parentItemCollection"></param> /// <param name="nodes"></param> public static void BuildMenu(ToolStripItemCollection parentItemCollection, IEnumerable <ActionModelNode> nodes) { List <ActionModelNode> nodeList = CombineAdjacentSeparators(new List <ActionModelNode>(nodes)); foreach (ActionModelNode node in nodeList) { ToolStripItem toolstripItem; if (node is ActionNode) { // this is a leaf node (terminal menu item) ActionNode actionNode = (ActionNode)node; IAction action = actionNode.Action; IActionView view = CreateActionView(ToolStripKind.Menu, action, IconSize.Medium); toolstripItem = (ToolStripItem)view.GuiElement; toolstripItem.Tag = new ItemTag(node, view); parentItemCollection.Add(toolstripItem); // Determine whether we should check the parent menu items too IClickAction clickAction = actionNode.Action as IClickAction; if (clickAction != null && clickAction.CheckParents && clickAction.Checked) { CheckParentItems(toolstripItem); } } else if (node is SeparatorNode) { toolstripItem = new ToolStripSeparator(); toolstripItem.Tag = new ItemTag(node, null); parentItemCollection.Add(toolstripItem); } else { // this menu item has a sub menu toolstripItem = new ToolStripMenuItem(node.PathSegment.LocalizedText); toolstripItem.Tag = new ItemTag(node, null); parentItemCollection.Add(toolstripItem); BuildMenu(((ToolStripMenuItem)toolstripItem).DropDownItems, node.ChildNodes); } // When you get Visible, it refers to whether the object is really visible, as opposed to whether it _can_ be visible. // When you _set_ Visible, it affects whether it _can_ be visible. // For example, an item is really invisible but _can_ be visible before it is actually drawn. // This is why we use the Available property, which give us the information when we are interested in "_Could_ this be Visible?" ToolStripMenuItem parent = toolstripItem.OwnerItem as ToolStripMenuItem; if (parent != null) { SetParentAvailability(parent); toolstripItem.AvailableChanged += delegate { SetParentAvailability(parent); }; } } }
public InformationalMessageFormView( TextType inputType = TextType.TreatAsText, string customOkLabel = null, Func <LabelDescr, IActionView <HTMLElement> > customActionBuilder = null) { Message = new LabellessReadOnlyView("div", inputType); Confirm = (customActionBuilder ?? Toolkit.DefaultActionBuilder) .Invoke(new LabelDescr { Label = customOkLabel ?? I18n.Translate("OK") }) .With(x => x.MarkAsFormsDefaultButton()); }
private static IActionView CreateActionView(ToolStripKind kind, IAction action, IconSize iconSize) { IActionView view = null; // optimization: for framework-provided actions, we can just create the controls // directly rather than use the associated view, which is slower; // however, an AssociateViewAttribute should always take precedence. if (action.GetType().GetCustomAttributes(typeof(AssociateViewAttribute), true).Length == 0) { if (kind == ToolStripKind.Toolbar) { if (action is IDropDownAction) { if (action is IClickAction) { view = StandardWinFormsActionView.CreateDropDownButtonActionView(); } else { view = StandardWinFormsActionView.CreateDropDownActionView(); } } else if (action is ITextBoxAction) { view = StandardWinFormsActionView.CreateTextBoxActionView(); } else if (action is IClickAction) { view = StandardWinFormsActionView.CreateButtonActionView(); } } else { if (action is IClickAction) { view = StandardWinFormsActionView.CreateMenuActionView(); } } } if (view == null) { view = (IActionView)ViewFactory.CreateAssociatedView(action.GetType()); } view.Context = new ActionViewContext(action, iconSize); return(view); }
/// <summary> /// Builds a toolbar from the specified action model nodes, using the specified style and size. /// </summary> /// <param name="parentItemCollection"></param> /// <param name="nodes"></param> /// <param name="builderStyle"></param> /// <param name="iconSize"></param> public static void BuildToolbar(ToolStripItemCollection parentItemCollection, IEnumerable <ActionModelNode> nodes, ToolStripBuilderStyle builderStyle, IconSize iconSize) { List <ActionModelNode> nodeList = CombineAdjacentSeparators(new List <ActionModelNode>(nodes)); // reverse nodes if alignment is right if (builderStyle.ToolStripAlignment == ToolStripItemAlignment.Right) { nodeList.Reverse(); } foreach (ActionModelNode node in nodeList) { if (node is ActionNode) { IAction action = ((ActionNode)node).Action; IActionView view = CreateActionView(ToolStripKind.Toolbar, action, iconSize); ToolStripItem button = (ToolStripItem)view.GuiElement; button.Tag = new ItemTag(node, view); // By default, only display the image on the button button.DisplayStyle = builderStyle.ToolStripItemDisplayStyle; button.Alignment = builderStyle.ToolStripAlignment; button.TextImageRelation = builderStyle.TextImageRelation; parentItemCollection.Add(button); } else if (node is SeparatorNode) { ToolStripSeparator separator = new ToolStripSeparator(); separator.Tag = new ItemTag(node, null); parentItemCollection.Add(separator); } else { BuildToolbar(parentItemCollection, node.ChildNodes, builderStyle, iconSize); } } }
public ItemTag(ActionModelNode node, IActionView view) { _node = node; _view = view; }
// REVIEW: valuetuple public static Tuple <ValueChangedRich <bool>, Action> BindAction <WidgetT, T>(this IActionView <WidgetT> view, IActionModel <T> domain) { ValueChangedRich <bool> domainHandler = (sender, oldValue, newValue, errors, isUserAction) => { Logger.Debug(typeof(ActionViewExtensions), "BindAction: changing view to {0} and {1}", newValue, errors.PrettyToString()); view.Enabled = newValue; view.DisabledReason = new HashSet <string>(errors); }; domain.EnabledChanged += domainHandler; Action viewHandler = async() => { Logger.Debug(typeof(ActionViewExtensions), "BindAction: triggering enabled?={0} action {1} from view {2}", domain.Enabled, domain, view); if (!domain.Enabled) { return; } view.State = ActionViewState.CreateOperationRunning(); view.Enabled = false; view.DisabledReason = new HashSet <string> { I18n.Translate("Please wait while operation is running...") }; try { await domain.Trigger(); view.State = ActionViewState.CreateIdleOrSuccess(); } catch (Exception ex) { Logger.Error(typeof(ActionViewExtensions), "Bound action failed to execute {0}", ex); view.State = ActionViewState.CreateOperationFailed(ex); //should be handled by domain.ActionExecuted subscribers } finally { view.Enabled = domain.Enabled; view.DisabledReason = new HashSet <string>(domain.DisabledReasons); } }; view.Triggered += viewHandler; return(new Tuple <ValueChangedRich <bool>, Action>(domainHandler, viewHandler)); }
public ActionController(IActionView actionView, RecordStrategies recordStrategy) : this(Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), actionView,recordStrategy) { }
public ItemTag(ActionModelNode node, IActionView view) { _node = node; _view = view; }
public static Tuple <ValueChangedRich <bool>, Action> BindActionAndInitialize <WidgetT, T>(this IActionView <WidgetT> view, IActionModel <T> domain) { view.OpensNewTab = domain.ResultInNewTab; var handlers = view.BindAction(domain); handlers.Item1(domain, domain.Enabled, domain.Enabled, domain.DisabledReasons, false); return(handlers); }
public static void MarkAsFormsDefaultButton(this IActionView <HTMLElement> action) { action.Widget.SetAttribute(Magics.AttrDataFormDefaultAction, ""); }