public Player(BattleArena arena, ControlSet Controls, int ID, PlayerDef definition) { this.World = arena; PokemonName = definition.Pokemon.Name; anim = new Animation(Pokemon.Animation); anim.state.SetAnimation("idle", true); foreach (MixItem item in Pokemon.MixQueue) { anim.stateData.SetMix(item.From, item.To, item.Time); } this.Controls = Controls; this.HP = Pokemon.HP; this.Attack = Pokemon.Attack; this.Defense = Pokemon.Defense; this.SpecialAttack = Pokemon.SpecialAttack; this.SpecialDefense = Pokemon.SpecialDefense; this.Speed = Pokemon.Speed; this.ID = (short)ID; for (int i = 0; i < 4; i++) { Move[i] = new MoveInstance(definition.Moves[i]); } InitPhysics(arena); }
// Use this for initialization public QuickStartManager(GameManager gm, ControlSet i) { m_Manager = gm; m_Controllers = i; m_Heads_Holder = GameObject.Find("HeadsHolder").GetComponent <Menu_Heads>(); DisableUnusedHeads(); }
protected override void BeginWork() { BootParameters.ShouldNotBe(null); base.BeginWork(); _jobParameter = (ControlSet)XmlUtility.DeserializeObject(BootParameters, typeof(ControlSet)); }
private ControlSet FilterByPropertyQuery(ControlSet superSet) { ControlSet matchedControls = new ControlSet(); //prepare query-string string queryString = string.Concat((from token in this.Tokens select token.Content).ToArray()); queryString = queryString.Replace("[", ""); queryString = queryString.Replace("]", ""); queryString = queryString.Replace("!=", "!"); queryString = queryString.Replace("^=", "^"); queryString = queryString.Replace("$=", "$"); queryString = queryString.Replace("~=", "~"); Common.AddToLog("clean filter-query: " + queryString); //find controls using property-details FilterType filterType = ResolveFilterType(queryString); string[] propertyParts = queryString.Split(Parser.PropertyValueDelimiterSymbols.ToCharArray()); if (propertyParts.Length > 0) { string propertyNameDescriptor = propertyParts[0]; string propertyRawValue = propertyParts.Length > 1 ? propertyParts[1] : string.Empty; ControlSet subSet = FilterByDependencyProperty(superSet, filterType, propertyParts.Length, propertyNameDescriptor, propertyRawValue); if (subSet == null) //if not dependency property, check normal property { subSet = FilterByNormalProperty(superSet, filterType, propertyParts.Length, propertyNameDescriptor, propertyRawValue); } matchedControls.AddRange(subSet); } return(matchedControls); }
/// <summary> /// Finds all parents of a control, until a parent of specified type is found. /// </summary> /// <typeparam name="T">The type of parent control where the traversal stops.</typeparam> /// <param name="control">Dependency object whose parents are found.</param> /// <returns>The ControlSet object containing all the parents found.</returns> public static ControlSet ParentsUpto <T>(DependencyObject control) { ControlSet allParents = new ControlSet(); while (true) { DependencyObject parent = VisualTreeHelper.GetParent(control); if (parent == null) { break; } else if (parent is T) { allParents.Add(parent); break; } else { allParents.Add(parent); control = parent; } } return(allParents); }
/// <summary> /// Finds all parents of a control, until the parent with a specified name is found. /// </summary> /// <param name="control">Dependency object whose parents are found.</param> /// <param name="parentName">The name of the parent control where the traversal stops.</param> /// <returns>The ControlSet object containing all the parents found.</returns> public static ControlSet ParentsUpto(DependencyObject control, string parentName) { ControlSet allParents = new ControlSet(); while (true) { DependencyObject parent = VisualTreeHelper.GetParent(control); if (parent == null) { break; } else if (parent is FrameworkElement && ((FrameworkElement)parent).Name.Equals(parentName)) { allParents.Add(parent); break; } else { allParents.Add(parent); control = parent; } } return(allParents); }
public void Test_ControlSetWithDataIsValid() { ControlSet cs = new ControlSet(); cs.id = Guid.NewGuid(); cs.family = "Program Management"; cs.number = "PM-12"; cs.title = "Program Mgmt Title"; cs.priority = "P1"; cs.lowimpact = true; cs.moderateimpact = true; cs.highimpact = false; cs.supplementalGuidance = "My supplemental text"; cs.subControlDescription = "my description"; cs.subControlNumber = "1.1.1.1.1"; // test things out Assert.True(cs != null); Assert.True(!string.IsNullOrEmpty(cs.family)); Assert.True(!string.IsNullOrEmpty(cs.number)); Assert.True(!string.IsNullOrEmpty(cs.title)); Assert.True(!string.IsNullOrEmpty(cs.priority)); Assert.True(!string.IsNullOrEmpty(cs.supplementalGuidance)); Assert.True(!string.IsNullOrEmpty(cs.subControlDescription)); Assert.True(!string.IsNullOrEmpty(cs.subControlNumber)); Assert.True(cs.lowimpact); Assert.True(cs.moderateimpact); Assert.False(cs.highimpact); Assert.True(Guid.Empty != cs.id); // it is not empty }
public static void CubicToLine(IPathRender output, PointF cur, PointF c1, PointF c2, PointF pt, double resolution) { int k = 0; int l = 0; var tempSet = new ControlSet[64]; var controlSet = new ControlSet[64]; tempSet[l++] = new ControlSet(cur, c1, c2, pt); while (l > 0) { var control1 = tempSet[--l]; double b = control1.CalcBreadth(resolution); if (b > resolution) { var control3 = control1.Bisect(); tempSet[l++] = control1; tempSet[l++] = control3; } else { controlSet[k++] = control1; } } while (k > 0) { var control2 = controlSet[--k]; var p = control2.getPoint(); output.Line(cur, p); cur = p; } }
public void Test_NewControlIsValid() { ControlSet ctrl = new ControlSet(); Assert.True(ctrl != null); Assert.True(ctrl.id != Guid.Empty); }
protected override void BeginWork() { BootParameters.ShouldNotBe(null); base.BeginWork(); _jobParameter = (ControlSet)XmlUtility.DeserializeObject(BootParameters, typeof(ControlSet)); }
public void InitializePlayer(int playerNum, int controllerNum, Vector3 vecColor) { PlayerNum = playerNum; ControllerNum = controllerNum; SetColor(new Color(vecColor.x, vecColor.y, vecColor.z, 1)); CustomControls = ControlSet.MouseKeyboardControlSet(); }
private static Dictionary <string, Style> GetAllStyles(DependencyObject control) { //find all user-controls and pages ControlSet allUserControls = XamlQuery.ParentsByType <UserControl>(control); ControlSet allPages = XamlQuery.ParentsByType <Page>(control); Common.AddToLog(allUserControls.Count + " user-controls"); Common.AddToLog(allPages.Count + " pages"); ControlSet allContainers = new ControlSet(); allContainers.AddRange(allUserControls); allContainers.AddRange(allPages); //get styles from all user-controls and pages and their merged-dictionaries Dictionary <string, Style> allStyles = new Dictionary <string, Style>(); foreach (UserControl container in allContainers) { List <ResourceDictionary> allDictionaries = GetResourceDictionaryTree(container.Resources); foreach (ResourceDictionary dictionary in allDictionaries) { foreach (object key in dictionary.Keys) { object resource = container.Resources[key]; if (key is string && resource is Style) { allStyles.Add((string)key, (Style)resource); } } } } //get styles defined in App and its merged-dictionaries if (Application.Current != null) { List <ResourceDictionary> allDictionaries = GetResourceDictionaryTree(Application.Current.Resources); foreach (ResourceDictionary dictionary in allDictionaries) { foreach (object key in dictionary.Keys) { object resource = Application.Current.Resources[key]; if (key is string && resource is Style) { allStyles.Add((string)key, (Style)resource); } } } } Common.AddToLog(allStyles.Count + " styles"); foreach (string key in allStyles.Keys) { Common.AddToLog("found-style: " + key + ", " + allStyles[key].TargetType); } return(allStyles); }
/// <summary> /// Return a control based on the search term sent /// </summary> /// <param name="term">The control title or search to get a control record back.</param> /// <returns></returns> public static ControlSet GetControlRecord(string term) { // get the result ready to receive the info and send on ControlSet control = new ControlSet(); // Create a new connection factory to create a connection. ConnectionFactory cf = new ConnectionFactory(); var logger = LogManager.GetLogger("openrmf_api_controls"); // add the options for the server, reconnecting, and the handler events Options opts = ConnectionFactory.GetDefaultOptions(); opts.MaxReconnect = -1; opts.ReconnectWait = 1000; opts.Name = "openrmf-api-controls"; opts.Url = Environment.GetEnvironmentVariable("NATSSERVERURL"); opts.AsyncErrorEventHandler += (sender, events) => { logger.Info("NATS client error. Server: {0}. Message: {1}. Subject: {2}", events.Conn.ConnectedUrl, events.Error, events.Subscription.Subject); }; opts.ServerDiscoveredEventHandler += (sender, events) => { logger.Info("A new server has joined the cluster: {0}", events.Conn.DiscoveredServers); }; opts.ClosedEventHandler += (sender, events) => { logger.Info("Connection Closed: {0}", events.Conn.ConnectedUrl); }; opts.ReconnectedEventHandler += (sender, events) => { logger.Info("Connection Reconnected: {0}", events.Conn.ConnectedUrl); }; opts.DisconnectedEventHandler += (sender, events) => { logger.Info("Connection Disconnected: {0}", events.Conn.ConnectedUrl); }; // Creates a live connection to the NATS Server with the above options IConnection c = cf.CreateConnection(opts); // send the message with data of the filter serialized Msg reply = c.Request("openrmf.controls.search", Encoding.UTF8.GetBytes(term), 10000); // save the reply and get back the checklist to score if (reply != null) { control = JsonConvert.DeserializeObject <ControlSet>(Compression.DecompressString(Encoding.UTF8.GetString(reply.Data))); c.Close(); return(control); } c.Close(); return(control); }
public ControlSet Execute(ControlSet superSet) { Common.AddToLog("executing filter-q: " + this.Query); if (Tokens.Count < 2) { return(new ControlSet()); //filter-selector should have minimum two tokens, the first one being the filter-delimiter symbol } ControlSet matchedControls = new ControlSet(); if (Type == FilterSelectorType.Style) { string styleName = Tokens[1].Content; Style styleObject = ControlUtility.GetStyleByName(styleName); if (styleObject != null) { foreach (DependencyObject control in superSet) //find controls by style { if (control is FrameworkElement) { FrameworkElement element = (FrameworkElement)control; if (element.Style != null) { //if (element.Style.Equals(styleObject)) if (ControlUtility.IsStyleEqualsOrBasedOn(element.Style, styleObject)) { Common.AddToLog("matched-by-style: " + element.Name + " based on style"); matchedControls.Add(control); } } } } } } else if (Type == FilterSelectorType.Name) { string name = Tokens[1].Content; foreach (DependencyObject control in superSet) //find control by name { if (control is FrameworkElement) { if (((FrameworkElement)control).Name.Equals(name)) { Common.AddToLog("matched-by-name: " + ((FrameworkElement)control).Name); matchedControls.Add(control); } } } } else if (Type == FilterSelectorType.Property) { matchedControls.AddRange(FilterByPropertyQuery(superSet)); } return(matchedControls); }
public PlayerCursor(int playernumber, CursorPosition pos, ControlSet contr, string tokenloc, string slotloc, Vector2 corner) { this.Position = pos; this.control = contr; Token = new Texture(tokenloc); Slot = new Texture(slotloc, false); this.Corner = corner; this.PlayerNumber = playernumber; State = CursorState.PokemonSelect; }
public void Test_NewControlSetIsValid() { ControlSet cs = new ControlSet(); Assert.True(cs != null); Assert.True(cs.id != null); Assert.False(cs.lowimpact); Assert.False(cs.moderateimpact); Assert.False(cs.highimpact); }
private ControlSet AddItem(string tag, string text, Image img = null, string exclusive = null, bool disableuncheck = false) { ControlSet c = new ControlSet(); panelscroll.SuspendLayout(); c.tag = tag; c.exclusivetags = exclusive; c.disableuncheck = disableuncheck; ExtCheckBox cb = new ExtCheckBox(); cb.BackColor = this.BackColor; cb.CheckBoxColor = this.CheckBoxColor; cb.CheckBoxInnerColor = this.CheckBoxInnerColor; cb.CheckColor = this.CheckColor; cb.MouseOverColor = this.MouseOverColor; cb.FlatStyle = FlatStyle; cb.TickBoxReductionRatio = TickBoxReductionRatio; cb.CheckedChanged += CheckedIconListBoxForm_CheckedChanged; c.checkbox = cb; panelscroll.Controls.Add(cb); Label lb = new Label() { AutoSize = false, // don't autosize here, it seems to take forever. Text = (string)text, Tag = controllist.Count, ForeColor = this.ForeColor, TextAlign = ContentAlignment.MiddleLeft, }; lb.MouseDown += Text_MouseDown; c.label = lb; panelscroll.Controls.Add(lb); if (img != null) { PanelNoTheme ipanel = new PanelNoTheme() { BackgroundImage = img, Tag = controllist.Count, BackgroundImageLayout = ImageLayout.Stretch, }; ipanel.MouseDown += Ipanel_MouseDown; c.icon = ipanel; panelscroll.Controls.Add(ipanel); } panelscroll.ResumeLayout(); return(c); }
public IntegerTypeEditor() { InitializeComponent(); using (Graphics g = CreateGraphics()) { var textSize = g.MeasureString(TEXT, Font); m_textHeight = textSize.Height; m_textWidth = textSize.Width; m_minLabelWidth = MyMath.Ceiling(g.MeasureString(MIN_LABEL, Font).Width); m_maxLabelWidth = MyMath.Ceiling(g.MeasureString(MAX_LABEL, Font).Width); m_defaultLabelWidth = MyMath.Ceiling(g.MeasureString(DEFAULT_LABEL, Font).Width); } m_name = new MyTextBox(drawWindow1, NameArea, MyTextBox.InputFormEnum.Text); m_name.Colors.BorderPen = Colors.ControlBorder; m_name.RequestedAreaChanged += ResetSize; m_min = new MyNumericUpDown <int>(drawWindow1, MinNumericArea, false); m_min.RequestedAreaChanged += ResetSize; m_min.Colors.BorderPen = Colors.ControlBorder; m_min.Minimum = int.MinValue; m_min.Maximum = int.MaxValue; m_max = new MyNumericUpDown <int>(drawWindow1, MaxNumericArea, false); m_max.RequestedAreaChanged += ResetSize; m_max.Colors.BorderPen = Colors.ControlBorder; m_max.Minimum = int.MinValue; m_max.Maximum = int.MaxValue; m_default = new MyNumericUpDown <int>(drawWindow1, DefaultNumericArea, false); m_default.RequestedAreaChanged += ResetSize; m_default.Colors.BorderPen = Colors.ControlBorder; m_default.Minimum = int.MinValue; m_default.Maximum = int.MaxValue; drawWindow1.MouseDown += (a, args) => drawWindow1.Focus(); //TODO: is this redundant? drawWindow1.Paint += (a, args) => Paint(args.Graphics); drawWindow1.GotFocus += (a, b) => { forwardTab.TabStop = false; backwardTab.TabStop = false; }; forwardTab.GotFocus += (a, b) => { MyControls.ForwardFocus(); drawWindow1.Focus(); }; //Focus draw window so we dont keep giving focus to forwardTab backwardTab.GotFocus += (a, b) => { MyControls.BackwardFocus(); drawWindow1.Focus(); }; //Focus draw window so we dont keep giving focus to backwardTab this.Leave += (a, b) => { forwardTab.TabStop = true; backwardTab.TabStop = true; }; forwardTab.Size = Size.Empty; forwardTab.Location = new Point(-1, -1); backwardTab.Size = Size.Empty; backwardTab.Location = new Point(-1, -1); MyControls = new ControlSet(m_name, m_min, m_max, m_default); MyControls.RegisterCallbacks(drawWindow1); ResetSize(); }
/// <summary> /// Load the internal database in memory from the XML file of all NIST controls. /// </summary> /// <param name="context">The database in memory</param> /// <returns></returns> public static void LoadControlsXML(ControlsDBContext context) { List <Control> controls = LoadControls(); // for each one, load into the in-memory DB ControlSet cs; string formatNumber; // setup the database record to store foreach (Control c in controls) { cs = new ControlSet(); // the flattened controls table listing for the in memory DB cs.family = c.family; cs.number = c.number; cs.priority = c.priority; cs.title = c.title; if (!string.IsNullOrEmpty(c.supplementalGuidance)) { cs.supplementalGuidance = c.supplementalGuidance.Replace("\\r", "").Replace("\\n", ""); } if (c.childControls.Count > 0) { foreach (ChildControl cc in c.childControls) { cs.id = Guid.NewGuid(); // need a new PK ID for each record saved if (!string.IsNullOrEmpty(cc.description)) { cs.subControlDescription = cc.description.Replace("\r", "").Replace("\n", ""); } formatNumber = cc.number.Replace(" ", ""); // remove periods and empty space for searching later if (formatNumber.EndsWith(".")) { formatNumber = formatNumber.Substring(0, formatNumber.Length - 1); // take off the trailing period } cs.subControlNumber = formatNumber; cs.highimpact = cc.highimpact; cs.moderateimpact = cc.moderateimpact; cs.lowimpact = cc.lowimpact; context.ControlSets.Add(cs); // for each sub control, do a save on the whole thing Console.WriteLine("Adding number " + cs.subControlNumber); context.SaveChanges(); } } else { cs.id = Guid.NewGuid(); cs.highimpact = c.highimpact; cs.moderateimpact = c.moderateimpact; cs.lowimpact = c.lowimpact; context.ControlSets.Add(cs); // for some reason no sub controls context.SaveChanges(); } } context.SaveChanges(); }
public void Update(ControlSet input, Vector2 draw_offset = default(Vector2)) { if (input.HasEnumFlag(ControlSet.Buttons)) { update_input(); } foreach (var node in Nodes) { node.Update(this, input, draw_offset); } }
public void Update(ControlSet input, IEnumerable <int> range, Vector2 draw_offset = default(Vector2)) { if (input.HasEnumFlag(ControlSet.Buttons)) { update_input(); } foreach (int index in range) { Nodes[index].Update(this, input, draw_offset); } }
public void AddItem(string tag, string text, Image img = null, bool attop = false, string exclusive = null, bool disableuncheck = false) { ControlSet c = AddItem(tag, text, img, exclusive, disableuncheck); if (attop) { controllist.Insert(0, c); } else { controllist.Add(c); } }
public void AddItem(string tag, string text, Image img = null, bool attop = false) { ControlSet c = AddItem(tag, text, img); if (attop) { controllist.Insert(0, c); } else { controllist.Add(c); } }
private void UpdateButtons <T>(ControlSet input) where T : UINode { if (input.HasEnumFlag(ControlSet.Buttons)) { foreach (Inputs key in this.ValidInputs) { if (Global.Input.triggered(key)) { Triggers.Add(key); } } } }
public void AddItem(string tag, string text, Image img = null) { ControlSet c = new ControlSet(); c.tag = tag; ExtCheckBox cb = new ExtCheckBox(); cb.BackColor = this.BackColor; cb.CheckBoxColor = this.CheckBoxColor; cb.CheckBoxInnerColor = this.CheckBoxInnerColor; cb.CheckColor = this.CheckColor; cb.MouseOverColor = this.MouseOverColor; cb.FlatStyle = FlatStyle; cb.TickBoxReductionSize = TickBoxReductionSize; cb.CheckedChanged += CheckedIconListBoxForm_CheckedChanged; cb.Tag = controllist.Count; c.checkbox = cb; panelscroll.Controls.Add(cb); Label lb = new Label() { Text = (string)text, Tag = controllist.Count, Font = this.Font, ForeColor = this.ForeColor, TextAlign = ContentAlignment.MiddleLeft, }; lb.MouseDown += Text_MouseDown; c.label = lb; panelscroll.Controls.Add(lb); panelscroll.Controls.Add(lb); if (img != null) { PanelNoTheme ipanel = new PanelNoTheme() { BackgroundImage = img, Tag = controllist.Count, BackgroundImageLayout = ImageLayout.Stretch, }; ipanel.MouseDown += Ipanel_MouseDown; c.icon = ipanel; panelscroll.Controls.Add(ipanel); } controllist.Add(c); }
private void FrmLog_Load(object sender, EventArgs e) { ICreateValidateCode genericCode = new CreateGenericCode(); ISetValidateControlConfig setValidateControlConfig = new ControlSet(); var code = genericCode.CreateMemoryValidateCode(); txtMemCode.Text = code; setValidateControlConfig.SetValidateControl(txtAcc, verAccountValidate, @"^[0-9]{8,15}$", "请输入正确的用户名"); verPwdValidate.SetVerificationErrorMsg(txtPwd, "请输入正确的密码"); setValidateControlConfig.SetValidateControl(txtPwd, verPwdValidate, @"^(?=.*[a-z]).{8,}$", "请输入正确的密码"); setValidateControlConfig.SetValidateControl(txtValidateCode, verValidateCode, string.Format(@"^({0}|{1})$", code, code.ToLower()), "请输入正确的验证码"); }
public static ControlSet MouseKeyboardControlSet() { ControlSet result = new ControlSet(); result.MOVE_X = "KEY_MOVE_X"; result.MOVE_Y = "KEY_MOVE_Y"; result.SHOOT1 = "MOUSE_LEFTCLICK"; result.SHOOT2 = "MOUSE_RIGHTCLICK"; result.MOUSEAIM = true; result.START = "KEY_START"; result.BACK = "KEY_BACK"; return(result); }
private void UpdateMouse <T>( UINodeSet <T> nodes, ControlSet input, Vector2 draw_offset) where T : UINode { if (input.HasEnumFlag(ControlSet.MouseButtons)) { bool input_used = update_mouse_input( ref LeftMouseDown, MouseButtons.Left, draw_offset); if (RightClickActive && !input_used) { update_mouse_input( ref RightMouseDown, MouseButtons.Right, draw_offset); } } if (input.HasEnumFlag(ControlSet.MouseMove)) { if (OnScreenBounds(draw_offset).Contains( (int)Global.Input.mousePosition.X, (int)Global.Input.mousePosition.Y)) { if (nodes != null) { nodes.MouseMove(this as T); } if (LeftMouseDown || RightMouseDown) { mouse_click_graphic(); } else { mouse_highlight_graphic(); } } } if (input.HasEnumFlag(ControlSet.Mouse)) { if (IsSlider && LeftMouseDown && OnScreenBounds(draw_offset).Contains( (int)Global.Input.mousePosition.X, (int)Global.Input.mousePosition.Y)) { TouchTriggers.Add(TouchGestures.Scrubbing); SliderValue = slide(Global.Input.mousePosition, draw_offset); } } }
public ControlSet Execute(DependencyObject sourceControl) { Common.AddToLog("executing selector: " + this.Query); SourceControl = sourceControl; ControlSet superSet = XamlQuery.All(sourceControl); ControlSet matchedControls = new ControlSet(); if (SimpleSelectors.Count == 1) //if only one simple-selector, then execute it and return the result { return(SimpleSelectors[0].Execute(superSet)); } else if (SimpleSelectors.Count > 1) //if more than one simple-selectors, then apply combinators while executing { //apply each combinator to result of simple-selector that precedes it ControlSet currentSet = new ControlSet(); currentSet.AddRange(superSet); for (int index = 0; index < SimpleSelectors.Count; index++) { if (index > 0) { Common.AddToLog("**Executing Combinator: " + Combinators[index - 1].Token.Content); currentSet = Combinators[index - 1].Execute(currentSet); Common.AddToLog("**Combinator-Result: " + currentSet.Count + " controls"); if (Combinators[index - 1].Type == CombinatorType.Adjacent) { //for adjacent combinator // get first-set by executing simple-selector before + with result of combinator // get second-set by executing simple-selector after + with result of combinator // combine first and second sets as result of combinator and its simple-selectors ControlSet firstSet = SimpleSelectors[index - 1].Execute(currentSet); ControlSet secondSet = SimpleSelectors[index].Execute(currentSet); currentSet.Clear(); currentSet.AddRange(firstSet); currentSet.AddRange(secondSet); Common.AddToLog("**First-Set-Result: " + firstSet.Count + " controls. " + string.Join(",", (from c in firstSet select c.GetType().ToString()).ToArray())); Common.AddToLog("**Second-Set-Result: " + secondSet.Count + " controls. " + string.Join(",", (from c in secondSet select c.GetType().ToString()).ToArray())); Common.AddToLog("**Simple-Selector-Result: " + currentSet.Count + " controls"); continue; } } Common.AddToLog("**Executing Simple-Selector: " + SimpleSelectors[index].Query); currentSet = SimpleSelectors[index].Execute(currentSet); Common.AddToLog("**Simple-Selector-Result: " + currentSet.Count + " controls"); } matchedControls.AddRange(currentSet); } return(matchedControls); }
public ControlSet Bisect() { var p0 = MidPoint(point0, point1); var p1 = MidPoint(point1, point2); var p2 = MidPoint(point2, point3); var p3 = MidPoint(p0, p1); var p4 = MidPoint(p1, p2); var p5 = MidPoint(p3, p4); var controlset = new ControlSet(p5, p4, p2, point3); point1 = p0; point2 = p3; point3 = p5; return(controlset); }
public ControlSet Execute(ControlSet superSet) { Common.AddToLog("executing simple-query: " + this.Query); if (Type == SimpleSelectorType.None) { return(new ControlSet()); } //set main controls ControlSet mainControls = new ControlSet(); if (Type == SimpleSelectorType.Universal) { mainControls.AddRange(superSet); } else if (Type == SimpleSelectorType.Element) { Type givenControlType = ControlUtility.ResolveControlType(MainToken.Content); if (givenControlType != null) { foreach (DependencyObject control in superSet) { //if (givenControlType.IsAssignableFrom(control.GetType())) //if (givenControlType.IsSubclassOf(control.GetType())) //if (givenControlType.FullName.Equals(control.GetType().FullName)) if (givenControlType.IsInstanceOfType(control)) { mainControls.Add(control); } } } } //apply filter-selectors if (this.FilterSelectors.Count == 0) { return(mainControls); } else { foreach (FilterSelector filterSelector in this.FilterSelectors) { mainControls = filterSelector.Execute(mainControls); } return(mainControls); } }
public ControlSet Execute(ControlSet superSet) { Common.AddToLog("executing filter-q: " + this.Query); if (Tokens.Count < 2) return (new ControlSet()); //filter-selector should have minimum two tokens, the first one being the filter-delimiter symbol ControlSet matchedControls = new ControlSet(); if (Type == FilterSelectorType.Style) { string styleName = Tokens[1].Content; Style styleObject = ControlUtility.GetStyleByName(styleName); if (styleObject != null) { foreach (DependencyObject control in superSet) //find controls by style { if (control is FrameworkElement) { FrameworkElement element = (FrameworkElement)control; if (element.Style != null) { //if (element.Style.Equals(styleObject)) if (ControlUtility.IsStyleEqualsOrBasedOn(element.Style, styleObject)) { Common.AddToLog("matched-by-style: " + element.Name + " based on style"); matchedControls.Add(control); } } } } } } else if (Type == FilterSelectorType.Name) { string name = Tokens[1].Content; foreach (DependencyObject control in superSet) //find control by name { if (control is FrameworkElement) { if (((FrameworkElement)control).Name.Equals(name)) { Common.AddToLog("matched-by-name: " + ((FrameworkElement)control).Name); matchedControls.Add(control); } } } } else if (Type == FilterSelectorType.Property) { matchedControls.AddRange(FilterByPropertyQuery(superSet)); } return (matchedControls); }
private ControlSet FilterByPropertyQuery(ControlSet superSet) { ControlSet matchedControls = new ControlSet(); //prepare query-string string queryString = string.Concat((from token in this.Tokens select token.Content).ToArray()); queryString = queryString.Replace("[", ""); queryString = queryString.Replace("]", ""); queryString = queryString.Replace("!=", "!"); queryString = queryString.Replace("^=", "^"); queryString = queryString.Replace("$=", "$"); queryString = queryString.Replace("~=", "~"); Common.AddToLog("clean filter-query: " + queryString); //find controls using property-details FilterType filterType = ResolveFilterType(queryString); string[] propertyParts = queryString.Split(Parser.PropertyValueDelimiterSymbols.ToCharArray()); if (propertyParts.Length > 0) { string propertyNameDescriptor = propertyParts[0]; string propertyRawValue = propertyParts.Length > 1 ? propertyParts[1] : string.Empty; ControlSet subSet = FilterByDependencyProperty(superSet, filterType, propertyParts.Length, propertyNameDescriptor, propertyRawValue); if (subSet == null) //if not dependency property, check normal property { subSet = FilterByNormalProperty(superSet, filterType, propertyParts.Length, propertyNameDescriptor, propertyRawValue); } matchedControls.AddRange(subSet); } return (matchedControls); }
private ControlSet FilterByNormalProperty(ControlSet superSet, FilterType filterType, int propertyPartsLength, string propertyName, string propertyRawValue) { Common.AddToLog("checking for property: " + propertyName); ControlSet matchedControls = new ControlSet(); foreach (DependencyObject control in superSet) { PropertyInfo propertyInfo = control.GetType().GetProperty(propertyName); if (propertyInfo != null) { object propertyValue = propertyInfo.GetValue(control, null); if (propertyPartsLength == 1) { object defaultValue = propertyInfo.PropertyType.IsValueType ? Activator.CreateInstance(propertyInfo.PropertyType) : null; if (propertyValue != defaultValue) { Common.AddToLog("matched-by-property-name: " + control.ToString()); matchedControls.Add(control); } } else if (propertyPartsLength == 2) { if (ControlSet.CheckPropertyValue(propertyValue, propertyRawValue, filterType)) { Common.AddToLog("matched-by-property-value: " + control.ToString()); matchedControls.Add(control); } else { Common.AddToLog("not-matched: " + propertyValue + ", " + propertyRawValue); } } } else { Common.AddToLog("property-null: " + propertyName); } } return (matchedControls); }
private ControlSet FilterByDependencyProperty(ControlSet superSet, FilterType filterType, int propertyPartsLength, string propertyNameDescriptor, string propertyRawValue) { Common.AddToLog("checking for dependency-property: " + propertyNameDescriptor); FieldInfo dependencyPropertyField = ControlUtility.ResolveDependencyProperty(propertyNameDescriptor); if (dependencyPropertyField != null) //if it is a dependency property { ControlSet matchedControls = new ControlSet(); foreach (DependencyObject control in superSet) { object dependencyPropertyObject = dependencyPropertyField.GetValue(control); if (dependencyPropertyObject is DependencyProperty) { DependencyProperty dependencyProperty = (DependencyProperty)dependencyPropertyObject; object dependencyPropertyValue = control.GetValue(dependencyProperty); if (propertyPartsLength == 1) { object defaultValue = dependencyProperty.GetType().IsValueType ? Activator.CreateInstance(dependencyProperty.GetType()) : null; if (dependencyPropertyValue != defaultValue) { Common.AddToLog("matched by dependency-property-name: " + control.ToString()); matchedControls.Add(control); } } else if (propertyPartsLength == 2) { if (ControlSet.CheckPropertyValue(dependencyPropertyValue, propertyRawValue, filterType)) { Common.AddToLog("matched by dependency-property-value: " + control.ToString()); matchedControls.Add(control); } } } } return (matchedControls); } else { Common.AddToLog("dependency-property-null: " + propertyNameDescriptor); } return (null); }
private static Dictionary<string, Style> GetAllStyles(DependencyObject control) { //find all user-controls and pages ControlSet allUserControls = XamlQuery.ParentsByType<UserControl>(control); ControlSet allPages = XamlQuery.ParentsByType<Page>(control); Common.AddToLog(allUserControls.Count + " user-controls"); Common.AddToLog(allPages.Count + " pages"); ControlSet allContainers = new ControlSet(); allContainers.AddRange(allUserControls); allContainers.AddRange(allPages); //get styles from all user-controls and pages and their merged-dictionaries Dictionary<string, Style> allStyles = new Dictionary<string, Style>(); foreach (UserControl container in allContainers) { List<ResourceDictionary> allDictionaries = GetResourceDictionaryTree(container.Resources); foreach (ResourceDictionary dictionary in allDictionaries) { foreach (object key in dictionary.Keys) { object resource = container.Resources[key]; if (key is string && resource is Style) { allStyles.Add((string)key, (Style)resource); } } } } //get styles defined in App and its merged-dictionaries if (Application.Current != null) { List<ResourceDictionary> allDictionaries = GetResourceDictionaryTree(Application.Current.Resources); foreach (ResourceDictionary dictionary in allDictionaries) { foreach (object key in dictionary.Keys) { object resource = Application.Current.Resources[key]; if (key is string && resource is Style) { allStyles.Add((string)key, (Style)resource); } } } } Common.AddToLog(allStyles.Count + " styles"); foreach (string key in allStyles.Keys) { Common.AddToLog("found-style: " + key + ", " + allStyles[key].TargetType); } return (allStyles); }
/// <summary> /// iView.NET subroutine. Shows the processing editor dialog. Allows the user to specifiy the settings /// and preview the changes when apply a filter. /// </summary> /// <param name="nControlSet">Specifies the control set to load when the dialog has been initialized.</param> /// <returns></returns> private SResult SubShowProcessingEditor(ControlSet nControlSet) { Image oImage = imgbx_MainImage.ImageBoxImage; if (oImage == null) return SResult.NullDisplayImage; using (ProcessingDialog oForm = new ProcessingDialog(oImage, nControlSet)) { if (oForm.ShowDialog(this) == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; using (ImageProcessing oProcessing = new ImageProcessing(oImage)) { // Update the image edited status. ImageHasBeenEdited = true; // No elements in the list? Save the original state first. if (m_oUndoRedo.Count == 0) m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage); switch (nControlSet) { case ControlSet.BrightnessContrast: if (oForm.Contrast != 0) oProcessing.AdjustContrast(oForm.Contrast); if (oForm.Brightness != 0) oProcessing.AdjustBrightness(oForm.Brightness); break; case ControlSet.ColourBalance: oProcessing.AdjustColour(oForm.Red, oForm.Green, oForm.Blue); break; case ControlSet.Gamma: oProcessing.AdjustGamma(oForm.Gamma, oForm.Gamma, oForm.Gamma); break; case ControlSet.Transparency: oProcessing.AdjustTransparency(oForm.Transparency, oForm.Threshold); break; case ControlSet.Noise: oProcessing.ApplyNoiseFilter(oForm.Noise); break; } // Update the main image. imgbx_MainImage.ImageBoxImage = oProcessing.GetProcessedImage(); // Save the current image state. m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage); } Cursor.Current = Cursors.Default; return SResult.Completed; } } return SResult.Canceled; }
public ControlSet Execute(ControlSet superSet) { Common.AddToLog("executing simple-query: " + this.Query); if (Type == SimpleSelectorType.None) return (new ControlSet()); //set main controls ControlSet mainControls = new ControlSet(); if (Type == SimpleSelectorType.Universal) { mainControls.AddRange(superSet); } else if (Type == SimpleSelectorType.Element) { Type givenControlType = ControlUtility.ResolveControlType(MainToken.Content); if (givenControlType != null) { foreach (DependencyObject control in superSet) { //if (givenControlType.IsAssignableFrom(control.GetType())) //if (givenControlType.IsSubclassOf(control.GetType())) //if (givenControlType.FullName.Equals(control.GetType().FullName)) if (givenControlType.IsInstanceOfType(control)) { mainControls.Add(control); } } } } //apply filter-selectors if (this.FilterSelectors.Count == 0) { return (mainControls); } else { foreach (FilterSelector filterSelector in this.FilterSelectors) { mainControls = filterSelector.Execute(mainControls); } return (mainControls); } }
/// <summary> /// /// </summary> /// <param name="oImage"></param> /// <param name="nControlSet"></param> public ProcessingDialog(Image oImage, ControlSet nControlSet) { InitializeComponent(); tc_Main.TabPages.Clear(); switch (nControlSet) { case ControlSet.BrightnessContrast: tc_Main.TabPages.Add(tp_BrightnessContrast); break; case ControlSet.ColourBalance: tc_Main.TabPages.Add(tp_ColourBalance); break; case ControlSet.Gamma: tc_Main.TabPages.Add(tp_Gamma); break; case ControlSet.Transparency: tc_Main.TabPages.Add(tp_Transparency); break; case ControlSet.Noise: tc_Main.TabPages.Add(tp_Noise); break; } if (oImage != null) { m_nControlSet = nControlSet; m_oBitmap = DrawingTools.CreateThumbnail(oImage, pan_Before.Size, false, ThumbnailEffect.None); pan_Before.BackgroundImage = new Bitmap(m_oBitmap, m_oBitmap.Size); pan_After.BackgroundImage = new Bitmap(m_oBitmap, m_oBitmap.Size); } else { pan_Before.BackgroundImage = DrawingTools.CreateTextBitmap("No Preview.", this.Font, Color.Black, Color.White); pan_After.BackgroundImage = DrawingTools.CreateTextBitmap("No Preview.", this.Font, Color.Black, Color.White); } }
public ControlSet Execute(DependencyObject sourceControl) { Common.AddToLog("executing selector: " + this.Query); SourceControl = sourceControl; ControlSet superSet = XamlQuery.All(sourceControl); ControlSet matchedControls = new ControlSet(); if (SimpleSelectors.Count == 1) //if only one simple-selector, then execute it and return the result { return (SimpleSelectors[0].Execute(superSet)); } else if (SimpleSelectors.Count > 1) //if more than one simple-selectors, then apply combinators while executing { //apply each combinator to result of simple-selector that precedes it ControlSet currentSet = new ControlSet(); currentSet.AddRange(superSet); for (int index = 0; index < SimpleSelectors.Count; index++) { if (index > 0) { Common.AddToLog("**Executing Combinator: " + Combinators[index - 1].Token.Content); currentSet = Combinators[index - 1].Execute(currentSet); Common.AddToLog("**Combinator-Result: " + currentSet.Count + " controls"); if (Combinators[index - 1].Type == CombinatorType.Adjacent) { //for adjacent combinator // get first-set by executing simple-selector before + with result of combinator // get second-set by executing simple-selector after + with result of combinator // combine first and second sets as result of combinator and its simple-selectors ControlSet firstSet = SimpleSelectors[index - 1].Execute(currentSet); ControlSet secondSet = SimpleSelectors[index].Execute(currentSet); currentSet.Clear(); currentSet.AddRange(firstSet); currentSet.AddRange(secondSet); Common.AddToLog("**First-Set-Result: " + firstSet.Count + " controls. " + string.Join(",", (from c in firstSet select c.GetType().ToString()).ToArray())); Common.AddToLog("**Second-Set-Result: " + secondSet.Count + " controls. " + string.Join(",", (from c in secondSet select c.GetType().ToString()).ToArray())); Common.AddToLog("**Simple-Selector-Result: " + currentSet.Count + " controls"); continue; } } Common.AddToLog("**Executing Simple-Selector: " + SimpleSelectors[index].Query); currentSet = SimpleSelectors[index].Execute(currentSet); Common.AddToLog("**Simple-Selector-Result: " + currentSet.Count + " controls"); } matchedControls.AddRange(currentSet); } return (matchedControls); }
public ControlSet Execute(ControlSet superSet) { Common.AddToLog("executing combinator: " + this.Type); ControlSet result = new ControlSet(); switch (this.Type) { case CombinatorType.Descendant: //get descendants (children in visual-tree) of all controls in superset foreach (DependencyObject control in superSet) { ControlSet controlSet = XamlQuery.All(control); foreach (DependencyObject c in controlSet) { if (!result.Contains(c)) { result.Add(c); } } } break; case CombinatorType.Child: //get children of all Panel controls in superset foreach (DependencyObject control in superSet) { if (control is Panel) { foreach (var child in ((Panel)control).Children) { result.Add((DependencyObject)child); } } } break; case CombinatorType.Adjacent: //get children of all parent Panels of all controls in superset //if a parent is not a Panel, then it is ignored foreach (DependencyObject control in superSet) { if (control is FrameworkElement) { DependencyObject parent = ((FrameworkElement)control).Parent; if (parent is Panel) { foreach (var child in ((Panel)control).Children) { result.Add((DependencyObject)child); } } } } //include original controls also in result result.AddRange(superSet); Common.AddToLog("adj-superset-added"); break; } //remove duplicate-controls ControlSet uniqueControls = new ControlSet(); foreach (DependencyObject c in result) { if (!uniqueControls.Contains(c)) { uniqueControls.Add(c); } } return (uniqueControls); }
public ControlSet CreateControlset(string matterId, string dataSetId, string projectId, ControlSet project) { var resourceName = string.Format(CultureInfo.InvariantCulture, "{0}.matter_{1}-dataset_{2}-analytic-project_{3}-create-controlset.json", MockDataNameSpace, matterId, dataSetId, projectId); var mockData = GetEmbeddedResource(resourceName); var result = JsonConvert.DeserializeObject<ControlSet>(mockData); //Reset Mock Documents mockDocuments = null; MockWorkflowState.UpdateState(name: State.ControlSet, createStatus: Status.Completed, reviewStatus: Status.NotStarted, isCurrent: true); return result; }