public ActionResult DoAction(IActionProperty actionProperty) { ActionResult actionResult = new ActionResult { Success = false }; if (actionProperty.DoAction) { var ap = (ActionProperty)actionProperty; Settings.Instance().CurrentAimPos = ap.AimPoint; Settings.Instance().PointsInfo = ap.PointsInfo; if (PixelClicker.Core.Keyboard.IsKeyDown(ap.Settings.Hotkey)) { var moveX = (int)((ap.AimPoint.X - ap.Settings.WidthOffset)); var heightAdjusted = ap.Settings.SearchMethod != SearchMethod.AnyWhere ? 1.75 : 1; var moveY = (int)(ap.AimPoint.Y - (ap.Settings.HeightOffset * heightAdjusted)); var divideby = Math.Ceiling(ap.Settings.Sensitivity * 2 / 7d); PixelClicker.Core.Mouse.Move((int)(moveX / divideby), (int)(moveY / divideby)); actionResult.Success = true; } } else { Settings.Instance().CurrentAimPos = new Point(0, 0); Settings.Instance().PointsInfo = null; } return(actionResult); }
public void Hook(IActionProperty property, Control control, string eventName, string controlProperty) { List<Control> controls = m_propertyToControls.ContainsKey(property) ? m_propertyToControls[property] : null; if (controls == null) { controls = new List<Control>(); m_propertyToControls[property] = controls; } controls.Add(control); ConnectControl(property, control, eventName, controlProperty); }
public void AssociateValidator(Control control, IActionProperty prop) { if (!(control is TextBox)) throw new Exception("Only textbox validators are currently supported"); m_validatorToPropMap.Add(control, prop); LinkControlToProperty(control, prop); InitializeControlState(control, prop); if (prop.Override) LinkEventHandler(control); else control.Enabled = false; }
private static bool tryConvertOrientation(IActionProperty targetOrientation, out float targetDegrees) { targetDegrees = 0; if (targetOrientation.Value.Value is float) { targetDegrees = (float)targetOrientation.Value.Value; if (targetOrientation.Range.Name == "x+degrees") { targetDegrees = targetDegrees.convertSourceEngineToUnityRotation(); } return(true); } return(false); }
public void Associate(Control control, IActionProperty prop) { if (!(control is TextBox || control is CheckBox || control is Label || control is DateTimePicker || control is ComboBox || control is CheckedListBox || control is LinkCheckBox || control is LabeledTextBox)) { throw new Exception("Only CheckBox, Label, TextBox, DateTimePicker, ComboBox, CheckedListBox, LinkCheckBox and LabeledTextBox controls are currently supported"); } if(!m_controlToPropMap.ContainsKey(control)) { m_controlToPropMap.Add(control, prop); } LinkControlToProperty(control, prop); InitializeControlState(control, prop); if (prop.Override) LinkEventHandler(control); else control.Enabled = false; }
private List<Control> GetControlsForProperty(IActionProperty property) { return (List<Control>) m_propToControlsMap[property]; }
private static void SetTextPropertyAccordingToValidationRules(List<Control> controls, IActionProperty property) { string value = null; foreach (Control control in controls) { string controlValue = TextFromControl(control); if (controlValue == null) { continue; } if (value == null) { value = controlValue; } else if (value != controlValue) { value = ""; break; // found mixed values } } property.Value = value; }
private static void InitializeControlState(Control control, IActionProperty prop) { control.Enabled = prop.Override; CheckBox checkbox = control as CheckBox; if (checkbox != null) { checkbox.Checked = Convert.ToBoolean(prop.Value, CultureInfo.CurrentCulture); return; } LinkCheckBox link = control as LinkCheckBox; if (link != null) { link.Checked = Convert.ToBoolean(prop.Value, CultureInfo.CurrentCulture); return; } TextBox textbox = control as TextBox; if (textbox != null) { textbox.Text = Convert.ToString(prop.Value, CultureInfo.CurrentCulture); return; } LabeledTextBox labeled = control as LabeledTextBox; if (labeled != null) { labeled.Text = Convert.ToString(prop.Value, CultureInfo.CurrentCulture); return; } Label label = control as Label; if (label != null) { label.Text = Convert.ToString(prop.Value, CultureInfo.CurrentCulture); return; } ComboBox combobox = control as ComboBox; if (combobox != null) { combobox.Text = Convert.ToString(prop.Value, CultureInfo.CurrentCulture); return; } DateTimePicker datetime = control as DateTimePicker; if (datetime != null) { if (DateTime.Today > datetime.MinDate && DateTime.Today < datetime.MaxDate) { datetime.Value = DateTime.Today; } else { datetime.Value = datetime.MinDate; } return; } CheckedListBox checkedListBox = control as CheckedListBox; if (checkedListBox != null) { checkedListBox.Tag = prop; var items = checkedListBox.Items; items.Clear(); string[] properties = prop.Value as string[]; foreach (string property in properties) { string[] propertyPair = property.Split(','); if (propertyPair.Length == 2) { items.Add(propertyPair[0], Convert.ToBoolean(propertyPair[1], CultureInfo.InvariantCulture)); } } } }
private void FindRemoveTrackChangesState(ContentTypeEnum contentType, IActionProperty removeTrackChangesProperty, bool execute, ref TriState tsWord, ref TriState tsExcel, ref TriState tsPPT, ref TriState tsDefault) { switch (contentType) { case ContentTypeEnum.WordDocument: case ContentTypeEnum.WordDocumentX: case ContentTypeEnum.WordDocumentMacroX: case ContentTypeEnum.WordDocumentTemplateX: case ContentTypeEnum.WordDocumentMacroTemplateX: SetRemoveTrackChangesState(ref tsWord, removeTrackChangesProperty, execute); break; case ContentTypeEnum.ExcelSheet: case ContentTypeEnum.ExcelSheetX: case ContentTypeEnum.ExcelSheetMacroX: case ContentTypeEnum.ExcelSheetTemplateX: case ContentTypeEnum.ExcelSheetMacroTemplateX: SetRemoveTrackChangesState(ref tsExcel, removeTrackChangesProperty, execute); break; case ContentTypeEnum.PowerPoint: case ContentTypeEnum.PowerPointX: case ContentTypeEnum.PowerPointMacroX: case ContentTypeEnum.PowerPointTemplateX: case ContentTypeEnum.PowerPointMacroTemplateX: case ContentTypeEnum.PowerPointShowX: case ContentTypeEnum.PowerPointMacroShowX: tsPPT = TriState.False; break; default: SetRemoveTrackChangesState(ref tsDefault, removeTrackChangesProperty, execute); break; } }
private void LinkControlToProperty(Control control, IActionProperty prop) { List<Control> controls = m_propToControlsMap[prop] as List<Control>; if (controls == null) { controls = new List<Control>(); m_propToControlsMap[prop] = controls; } if (!controls.Contains(control)) { controls.Add(control); } }
public bool TryGetValue(string key, out IActionProperty value) { return m_list.TryGetValue(key, out value); }
public static void Unhook(IActionProperty property) { DisconnectControl(property); }
private void ConnectControl(IActionProperty property, Control control, string eventName, string controlProperty) { // Save the control property name m_controlsToControlProperties[control] = controlProperty; // Save the action property m_controlsToProperties[control] = property; if (property.Override) { try { // Try and get the EventInfo based on the eventName EventInfo eventInfo = control.GetType().GetEvent(eventName); if (eventInfo != null) { // Create a delegate that points to our handler hooking upto the "named" event. Delegate dynDelegate = Delegate.CreateDelegate(eventInfo.EventHandlerType, this, "HandlerMethod"); m_propertyToDelegate[property] = dynDelegate; if (m_delegateToEventName.ContainsKey(dynDelegate)) { m_delegateToEventName[dynDelegate].Count++; } else { m_delegateToEventName[dynDelegate] = new RefCountedString(eventName); } // Attempt to bind the delegate. eventInfo.AddEventHandler(control, dynDelegate); PropertyInfo propertyInfo = control.GetType().GetProperty(controlProperty); if (propertyInfo != null) { propertyInfo.SetValue(control, property.Value, null); } } } catch (Exception ex) { Logger.LogError(ex); } } else { control.Enabled = property.Override; } }
private static void DisconnectControl(IActionProperty property) { List<Control> controls = m_propertyToControls[property]; foreach (Control control in controls) { if (m_controlsToProperties.ContainsKey(control)) { m_controlsToProperties.Remove(control); if (!m_propertyToDelegate.ContainsKey(property)) continue; Delegate dynDelegate = m_propertyToDelegate[property]; m_propertyToDelegate.Remove(property); if (!m_delegateToEventName.ContainsKey(dynDelegate)) continue; var rcs = m_delegateToEventName[dynDelegate]; var eventName = rcs.String; rcs.Count--; if (rcs.Count == 0) m_delegateToEventName.Remove(dynDelegate); try { EventInfo eventInfo = control.GetType().GetEvent(eventName); if (eventInfo != null) { eventInfo.RemoveEventHandler(control, dynDelegate); } } catch (Exception ex) { Logger.LogError(ex); } } } }
public bool IsPropertyHookedToControl(IActionProperty property, Control control) { return m_propertyToControls.ContainsKey(property); }
private void SetRemoveTrackChangesState(ref TriState ts, IActionProperty removeTrackChangesProperty, bool execute) { bool enabled = (execute && removeTrackChangesProperty != null && removeTrackChangesProperty.Override && removeTrackChangesProperty.Visible); ts = enabled ? TriState.True : TriState.False; }
/// <summary> /// This method ties a property's value to the trigggering of the 'ApplyToAll' event. /// </summary> /// <param name="property"></param> public void AssociateApplyToAll(IActionProperty property) { m_applyToAllProperty = property; }
public void Add(string key, IActionProperty value) { m_list.Add(key, value); }
protected void OnUserOptionChanged(IActionProperty property) { if (UserOptionChanged != null) UserOptionChanged(property, null); }
public bool Equals(IActionProperty other) { return(EqualityComparer <string> .Default.Equals(Name, other?.Name)); }
/// <summary> /// Populate the ResourceActionProperty from an ActionProperty /// </summary> /// <param name="actionProperty"></param> public void SetActionProperty(string name, IActionProperty actionProperty) { m_name = name; m_defaultDisplayName = actionProperty.DefaultDisplayName; m_dataType = actionProperty.DataType; m_propertyDisplayType = actionProperty.DisplayType; m_override = actionProperty.Override; m_visible = actionProperty.Visible; m_value = actionProperty.Value; //m_systemProperty = actionProperty.MappedSystemProperty; m_readOnly = actionProperty.ReadOnly; }
private void ConnectPropertyToControl(IActionProperty actionProperty, Control ctrl) { ctrl.Visible = actionProperty.Visible; if (actionProperty.Visible) { m_controller.Associate(ctrl, actionProperty); ctrl.Enabled = actionProperty.Override; m_propertyControlsVisible = true; } }