private ElementNode FindOrCreateElementNode(ElementModel elementModel, ElementNode parentNode) { ElementNode node; if (!_elementModelMap.TryGetValue(elementModel.Id, out node)) { //We have not created our element yet node = ElementNodeService.Instance.CreateSingle(parentNode, NamingUtilities.Uniquify(_elementNames, TokenizeName(elementModel.Name))); _elementModelMap.Add(elementModel.Id, node); _elementNames.Add(node.Name); if (elementModel.IsLightNode) { var order = node.Properties.Add(OrderDescriptor.ModuleId) as OrderModule; if (order != null) { order.Order = elementModel.Order; } _leafNodes.Add(node); PreviewCustomProp.AddLightNodes(elementModel, node); } } else { //Our element exists, so add this one as a child. parentNode.AddChild(node); } return(node); }
public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (_treename.Length == 0) { Logging.Error("treename is null"); return(result); } if (_stringcount < 0) { Logging.Error("negative count"); return(result); } //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode head = ElementNodeService.Instance.CreateSingle(null, NamingUtilities.Uniquify(elementNames, _treename), true, false); result.Add(head); int ii = 0; //Grabs the individual string sizes and removes any empty ones just in case the user entered something like 4,5,,9 string[] pixelsPerStringArray = _pixelsPerStringPattern.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); //Loops through the number of Strings to be added. for (int i = 0; i < _stringcount; i++) { if (i % pixelsPerStringArray.Count() == 0) { ii = 0; } else { ii++; } int pixelsPerString = Convert.ToInt16(pixelsPerStringArray[ii]); string stringname = head.Name + " " + textBoxStringPrefix.Text + (i + 1); ElementNode stringnode = ElementNodeService.Instance.CreateSingle(head, NamingUtilities.Uniquify(elementNames, stringname), true, false); result.Add(stringnode); //Loops through the and add each pixel to the String. Number of Pixels is determined by the String Pattern values. for (int j = 0; j < pixelsPerString; j++) { string pixelname = stringnode.Name + " " + textBoxPixelPrefix.Text + (j + 1); ElementNode pixelnode = ElementNodeService.Instance.CreateSingle(stringnode, NamingUtilities.Uniquify(elementNames, pixelname), true, false); result.Add(pixelnode); } } return(result); }
public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (treename.Length == 0) { Logging.Error("starburst is null"); return(result); } if (stringcount < 0) { Logging.Error("negative count"); return(result); } if (pixeltree && pixelsperstring < 0) { Logging.Error("negative pixelsperstring"); return(result); } //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode head = ElementNodeService.Instance.CreateSingle(null, NamingUtilities.Uniquify(elementNames, treename), true, false); result.Add(head); for (int i = 0; i < stringcount; i++) { string stringname = head.Name + " " + textBoxSpokePrefix.Text + (i + 1); ElementNode stringnode = ElementNodeService.Instance.CreateSingle(head, NamingUtilities.Uniquify(elementNames, stringname), true, false); result.Add(stringnode); if (pixeltree) { for (int j = 0; j < pixelsperstring; j++) { string pixelname = stringnode.Name + " " + textBoxPixelPrefix.Text + (j + 1); ElementNode pixelnode = ElementNodeService.Instance.CreateSingle(stringnode, NamingUtilities.Uniquify(elementNames, pixelname), true, false); result.Add(pixelnode); } } } return(result); }
public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (groupname.Length == 0) { Logging.Error("groupname is null"); return(result); } if (prefix.Length == 0) { Logging.Error("prefix is null"); return(result); } if (count < 0) { Logging.Error("negative count"); return(result); } // changed my mind; always make the group at the root level. //ElementNode parent = null; //if (selectedNodes != null) { // parent = selectedNodes.First(); // if (selectedNodes.Count() > 0) { // Logging.Warn("multiple parent nodes selected; creating new nodes under first parent: " + parent.Name); // } //} //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode grouphead = ElementNodeService.Instance.CreateSingle(null, NamingUtilities.Uniquify(elementNames, groupname), true, false); result.Add(grouphead); for (int i = 0; i < count; i++) { string newname = prefix + "-" + (i + 1); ElementNode newnode = ElementNodeService.Instance.CreateSingle(grouphead, NamingUtilities.Uniquify(elementNames, newname), true, false); result.Add(newnode); } return(result); }
/// <summary> /// Creates <see cref="LogAccessRule"/> from this attribute /// </summary> /// <param name="memberInfo"> /// The member Info. /// </param> /// <returns> /// The <see cref="LogAccessRule"/> /// </returns> public LogAccessRule CreateRule(MemberInfo memberInfo) { var logMessage = this.LogMessage; if (this.LogMessage == null) { logMessage = $"The property {memberInfo.Name} of {NamingUtilities.ToCSharpRepresentation(memberInfo.DeclaringType)} with id {{id}} was accessed"; } return(new LogAccessRule { Type = this.Type, ConnectionActions = this.ConnectionActions, Severity = this.Severity, LogMessage = logMessage }); }
public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (GroupName.Length == 0) { Logging.Error("groupname is null"); return(result); } if (Prefix.Length == 0) { Logging.Error("prefix is null"); return(result); } if (Count < 0) { Logging.Error("negative count"); return(result); } //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode grouphead = ElementNodeService.Instance.CreateSingle(null, NamingUtilities.Uniquify(elementNames, GroupName), true, false); result.Add(grouphead); for (int i = 0; i < Count; i++) { string newname = Prefix + "-" + (i + 1); ElementNode newnode = ElementNodeService.Instance.CreateSingle(grouphead, NamingUtilities.Uniquify(elementNames, newname), true, false); result.Add(newnode); } return(result); }
public async Task <ElementNode> CreateAsync() { return(await Task.Factory.StartNew(() => { _elementModelMap = new Dictionary <Guid, ElementNode>(); //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently _elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); var rootNode = _prop.RootNode; ElementNode rootElementNode = ElementNodeService.Instance.CreateSingle(null, NamingUtilities.Uniquify(_elementNames, TokenizeName(rootNode.Name)), true, false); PreviewCustomProp.Name = rootElementNode.Name; _elementNames.Add(rootElementNode.Name); _elementModelMap.Add(rootNode.Id, rootElementNode); CreateElementsForChildren(rootElementNode, rootNode); var parent = Application.OpenForms["VixenPreviewSetup3"]; if (parent != null) { //Get on the UI thread parent.Invoke((MethodInvoker) delegate { var question = new MessageBoxForm("Would you like to configure a dimming curve for this element?", "Dimming Curve Setup", MessageBoxButtons.YesNo, SystemIcons.Question); var ans = question.ShowDialog(parent); if (ans == DialogResult.OK) { DimmingCurveHelper dimmingHelper = new DimmingCurveHelper(true); dimmingHelper.Owner = parent; dimmingHelper.Perform(_leafNodes); } if (_prop.PhysicalMetadata.ColorMode != ColorMode.Other) { //Now lets setup the color handling. ColorSetupHelper helper = new ColorSetupHelper(); helper.Owner = parent; switch (_prop.PhysicalMetadata.ColorMode) { case ColorMode.FullColor: helper.SetColorType(ElementColorType.FullColor); helper.SilentMode = true; break; case ColorMode.Multiple: helper.SetColorType(ElementColorType.MultipleDiscreteColors); break; default: helper.SetColorType(ElementColorType.SingleColor); break; } helper.Perform(_leafNodes); if (helper.GetColorType() != ElementColorType.FullColor) { EnsureFaceMapColors(rootElementNode); } } }); } PreviewCustomProp.UpdateColorType(); PreviewCustomProp.Layout(); return rootElementNode; })); }
private ElementNode FindOrCreateElementNode(ElementModel elementModel, ElementNode parentNode) { ElementNode node; if (!_elementModelMap.TryGetValue(elementModel.Id, out node)) { //Validate we have a name if (string.IsNullOrEmpty(elementModel.Name)) { elementModel.Name = @"Unnamed"; } //We have not created our element yet node = ElementNodeService.Instance.CreateSingle(parentNode, NamingUtilities.Uniquify(_elementNames, TokenizeName(elementModel.Name))); _elementModelMap.Add(elementModel.Id, node); _elementNames.Add(node.Name); if (elementModel.FaceComponent != FaceComponent.None) { FaceModule fm = null; if (node.Properties.Contains(FaceDescriptor.ModuleId)) { fm = node.Properties.Get(FaceDescriptor.ModuleId) as FaceModule; } else { fm = node.Properties.Add(FaceDescriptor.ModuleId) as FaceModule; } if (ElementModel.IsPhoneme(elementModel.FaceComponent)) { fm.PhonemeList.Add(elementModel.FaceComponent.ToString(), true); } else { switch (elementModel.FaceComponent) { case FaceComponent.EyesOpen: fm.FaceComponents.Add(Property.Face.FaceComponent.EyesOpen, true); break; case FaceComponent.EyesClosed: fm.FaceComponents.Add(Property.Face.FaceComponent.EyesClosed, true); break; case FaceComponent.Outlines: fm.FaceComponents.Add(Property.Face.FaceComponent.Outlines, true); break; } } } if (elementModel.IsLightNode) { if (node.Properties.Add(OrderDescriptor.ModuleId) is OrderModule order) { order.Order = elementModel.Order; } _leafNodes.Add(node); PreviewCustomProp.AddLightNodes(elementModel, node); } } else { //Our element exists, so add this one as a child. VixenSystem.Nodes.AddChildToParent(node, parentNode); } return(node); }
public async Task CreateAsync() { Task t = Task.Factory.StartNew(() => { _elementModelMap = new Dictionary <Guid, ElementNode>(); //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently _elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); var rootNode = _prop.RootNode; ElementNode rootElementNode = ElementNodeService.Instance.CreateSingle(null, NamingUtilities.Uniquify(_elementNames, TokenizeName(rootNode.Name)), true, false); PreviewCustomProp.Name = rootElementNode.Name; _elementNames.Add(rootElementNode.Name); _elementModelMap.Add(rootNode.Id, rootElementNode); CreateElementsForChildren(rootElementNode, rootNode); if (_prop.PhysicalMetadata.ColorMode != ColorMode.Other) { //Now lets setup the color handling. ColorSetupHelper helper = new ColorSetupHelper(); switch (_prop.PhysicalMetadata.ColorMode) { case ColorMode.FullColor: helper.SetColorType(ElementColorType.FullColor); helper.SilentMode = true; break; case ColorMode.Multiple: helper.SetColorType(ElementColorType.MultipleDiscreteColors); break; default: helper.SetColorType(ElementColorType.SingleColor); break; } helper.Perform(_leafNodes); } PreviewCustomProp.UpdateColorType(); PreviewCustomProp.Layout(); }); await t; }
public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (gridname.Length == 0) { Logging.Error("gridname is null"); return(result); } if (rows < 0) { Logging.Error("negative rows"); return(result); } if (columns < 0) { Logging.Error("negative columns"); return(result); } //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode head = ElementNodeService.Instance.CreateSingle(null, NamingUtilities.Uniquify(elementNames, gridname), true, false); result.Add(head); int firstlimit, secondlimit; if (rowsfirst) { firstlimit = rows; secondlimit = columns; } else { firstlimit = columns; secondlimit = rows; } string firstprefix = " " + textBoxFirstPrefix.Text; string secondprefix = " " + textBoxSecondPrefix.Text; for (int i = 0; i < firstlimit; i++) { string firstname = head.Name + firstprefix + (i + 1); ElementNode firstnode = ElementNodeService.Instance.CreateSingle(head, NamingUtilities.Uniquify(elementNames, firstname), true, false); result.Add(firstnode); for (int j = 0; j < secondlimit; j++) { string secondname = firstnode.Name + secondprefix + (j + 1); ElementNode secondnode = ElementNodeService.Instance.CreateSingle(firstnode, NamingUtilities.Uniquify(elementNames, secondname), true, false); result.Add(secondnode); } } return(result); }
/// <summary> /// Process collection requests /// </summary> /// <typeparam name="TObject"> /// The type of ef object /// </typeparam> /// <typeparam name="TId"> /// The type of object identity field /// </typeparam> /// <param name="collectionRequest">Collection request</param> /// <returns>The list of objects</returns> protected virtual async Task OnCollectionRequest <TObject, TId>(CollectionRequest <TObject> collectionRequest) where TObject : class { try { using (var ds = this.GetContext()) { int maxLimit; if (!this.classQueryLimits.TryGetValue( NamingUtilities.ToCSharpRepresentation(typeof(TObject)), out maxLimit)) { maxLimit = this.defaultQueryLimit; } var limit = maxLimit != 0 && (!collectionRequest.Count.HasValue || collectionRequest.Count.Value > maxLimit) ? maxLimit : collectionRequest.Count; var factory = DataFactory <TContext, TObject, TId> .CreateFactory(this.ComponentContext, ds); var response = await factory.GetList( collectionRequest.Filter, collectionRequest.Sort, collectionRequest.Skip, limit, collectionRequest.ApiRequest); if (collectionRequest.AcceptAsParcel) { Context.GetParcelManager().Tell( new Parcel { Payload = response, Recipient = this.Sender }, this.Self); } else { this.Sender.Tell(response); } } } catch (Exception exception) { try { Context.GetLogger().Error( exception, "{Type}: Exception on processing CollectionRequest\n\t filter: {FilterExpression}\n\t sort: {SortExpression}\n\t limit: {Limit}\n\t offset: {Offset}", $"BaseCrudActor<{typeof(TObject).Name}>", collectionRequest.Filter?.ToString(), collectionRequest.Sort?.ToString(), collectionRequest.Count, collectionRequest.Skip); } catch { Context.GetLogger().Error( exception, "{Type}: Exception on processing CollectionRequest", $"BaseCrudActor<{typeof(TObject).Name}>"); } var response = new CollectionResponse <TObject> { Items = new List <TObject>() }; if (collectionRequest.AcceptAsParcel) { Context.GetParcelManager().Tell( new Parcel { Payload = response, Recipient = this.Sender }, this.Self); } else { this.Sender.Tell(response); } } }