Example #1
0
    public void AddToTable(ElementModel card)
    {
        if (TablePanel.GetComponent <TablePlaySystem>()._tableElements.Count < GlobalSettings.Maxtablecounter)
        {
            if (card._currentelement.Type == 3)
            {
                ElementModel checkcard = TablePanel.GetComponent <TablePlaySystem>()._tableElements.Find(delegate(ElementModel res)
                {
                    return(res._currentelement.Type == 2);
                });
                if (checkcard)
                {
                    card.gameObject.transform.parent = _tabletransform;
                    TablePanel.GetComponent <TablePlaySystem>()._tableElements.Add(card);

                    HandList.Remove(card.gameObject);
                }
            }
            else
            {
                card.gameObject.transform.parent = _tabletransform;
                TablePanel.GetComponent <TablePlaySystem>()._tableElements.Add(card);

                HandList.Remove(card.gameObject);
            }
        }
    }
        public CustomField CreateElement(ElementModel model)
        {
            List <CustomValue> options = new List <CustomValue>();

            foreach (var picklist in model.PickListValues)
            {
                CustomValue option = new CustomValue();
                option.label    = picklist.Text;
                option.fullName = picklist.Value;
                option.@default = picklist.IsDefault;
                options.Add(option);
            }

            ValueSet value = new ValueSet();

            value.valueSetDefinition = new ValueSetValuesDefinition()
            {
                sorted = true,
                value  = options.ToArray()
            };

            CustomField field = new CustomField();

            field.fullName                        = model.FullName;
            field.label                           = model.Label;
            field.type                            = FieldType.Picklist;
            field.valueSet                        = value;
            field.typeSpecified                   = true;
            field.securityClassification          = SecurityClassification.DataIntendedToBePublic;
            field.securityClassificationSpecified = true;

            return(field);
        }
Example #3
0
        public async Task <IActionResult> PutElementModel([FromRoute] int id, [FromBody] ElementModel elementModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != elementModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(elementModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ElementModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #4
0
        public void InitFakeViewModel(MainWindow mainWindow)
        {
            var random = new Random();

            for (int i = 0; i < 10; i++)
            {
                var element = new ElementModel();
                element.Identifier           = i;
                element.Importance           = random.NextDouble();
                element.MaxLevelOfDetail     = random.Next(2, 6);
                element.CurrentLevelOfDetail = random.Next(1, element.MaxLevelOfDetail + 1);
                element.MaxCognitiveLoad     = Constants.INITIAL_ELEMENT_MAX_COG_LOAD_OFFSET + (1.0 - Constants.INITIAL_ELEMENT_MAX_COG_LOAD_OFFSET) * random.NextDouble();
                element.Visibility           = 0;

                _appModel.Elements.Add(element);
            }

            _appModel.User.CognitiveCapacity = Constants.INITIAL_COGNITIVE_CAPACITY;

            _appModel.OptimizationModel.NumMinPlacementSlots           = Constants.MIN_PLACEMENT_SLOTS;
            _appModel.OptimizationModel.NumMaxPlacementSlots           = Constants.TOTAL_NUM_VIEW_SLOTS;
            _appModel.OptimizationModel.VisibilityReward               = Constants.INITIAL_VISIBILITY_REWARD;
            _appModel.OptimizationModel.CognitiveLoadOnsetPenalty      = Constants.INITIAL_COGNITIVE_LOAD_ONSET_PENALTY;
            _appModel.OptimizationModel.CognitiveLoadOnsetPenaltyDecay = Constants.INITIAL_COGNITIVE_LOAD_ONSET_PENALTY_DECAY_TIMESTEPS;
        }
		public async Task<ActionResult> SetElementStatus([FromBody] ElementModel revelement)
		{

			db = new ConnectionStrings();
			var uriBuilder = db.GetCouchUrl();
			List<ElementModel> element = new List<ElementModel>();
			DateTime currentTimestamp = DateTime.Now;
			using (var client = new MyCouchClient(uriBuilder))
			{

				// updating the revised element status
				var notifications = await client.Entities.PutAsync(revelement);

				//Configuring the view that has to be queried
				//var query = new QueryViewRequest("elementList", "element-list").Configure(query1 => query1
				//.Limit(5)
				//.Key(elementId)
				//.Keys("1","111")
				//.Reduce(false));


				//var notifications = await client.Views.QueryAsync<ElementModel>(query);
				//element = notifications.Rows.Select(r => r.Value).ToList();

			}
			return Json(element);

		}
Example #6
0
        private void DataGridElementView_LoadingRowGroup(object sender, Microsoft.Toolkit.Uwp.UI.Controls.DataGridRowGroupHeaderEventArgs e)
        {
            ICollectionViewGroup group = e.RowGroupHeader.CollectionViewGroup;
            ElementModel         item  = group.GroupItems[0] as ElementModel;

            e.RowGroupHeader.PropertyValue = item.Position.ToString();
        }
Example #7
0
 private void DoSupport(ElementModel atackcard, bool atackfail)
 {
     if (_supportCardList.Count > 0)
     {
         foreach (ElementModel suppcard in _supportCardList)
         {
             if (suppcard._currentelement.Stage == 1)
             {
                 if (_damage == 0)
                 {
                     _damage += suppcard._currentelement.Effect;
                 }
             }
             if (suppcard._currentelement.Stage == 2 && atackfail)
             {
                 _damage += atackcard._currentelement.Effect * suppcard._currentelement.PercentEffect;
             }
             if (suppcard._currentelement.Stage == 3 && !atackfail)
             {
                 _damage += _damage * suppcard._currentelement.PercentEffect;
             }
             CardReturnToChanger(suppcard);
         }
     }
 }
Example #8
0
        public void Dodanie_1_forntu_o_zadanych_wymiarach()
        {
            var cabinet = new Cabinet();

            var frontList = new List <ElementModel>();

            var front = new ElementModel(
                description: "Front",
                height: 600,
                width: 300,
                depth: 22,
                x: 12,
                y: 12,
                z: 513,
                enumCabinet: EnumCabinetElement.Front,
                horizontal: false
                );

            frontList.Add(front);

            Assert.Equal(600, front.Height);
            Assert.Equal(22, front.Depth);
            Assert.Equal(12, front.X);
            Assert.Equal(12, front.Y);
            Assert.Equal(513, front.Z);
        }
Example #9
0
        /// <summary>
        /// Сортирует элементы по уровням
        /// </summary>
        /// <param name="listRooms"></param>
        /// <param name="listElements"></param>
        /// <returns></returns>
        private Dictionary <string, List <ElementModel> > GroupElement(Dictionary <string, List <Room> > roomGroup, List <Element> listElements)
        {
            Dictionary <string, List <ElementModel> > elementGroup = new Dictionary <string, List <ElementModel> >();

            foreach (var lv in roomGroup.Keys)
            {
                elementGroup.Add(lv, new List <ElementModel>());
            }
            foreach (var level in roomGroup.Keys)
            {
                foreach (var elem in listElements)
                {
                    ElementId levelId = elem.LevelId;
                    string    lv      = Math.Round(((Level)_doc.GetElement(levelId)).Elevation).ToString();
                    if (level == lv)
                    {
                        var elementModel = new ElementModel()
                        {
                            level = lv, element = elem, hasRoom = false, room = null, part = 100000.0
                        };
                        elementGroup[level].Add(elementModel);
                        ListElementModel.Add(elementModel);
                    }
                }
            }
            return(elementGroup);
        }
Example #10
0
 public ForceCancelCommand(bool isAll, ElementModel RefElement)
 {
     this.isAll      = isAll;
     this.RefElement = RefElement;
     InitializeCommandByElement();
     //GenerateCommand();
 }
        private ElementModel GetElement(string elementCode)
        {
            var pElement = _permissionList.Where(c => c.Type == PermissionType.Element.ToString() && c.Code == elementCode).FirstOrDefault();

            if (pElement == null)
            {
                return(null);
            }

            ElementModel result = new ElementModel()
            {
                Id = pElement.PermissionId, Code = pElement.Code, Name = pElement.Name
            };

            result.RuleList = new List <RuleModel>();

            var pRuleList = _permissionList.Where(c => c.Type == PermissionType.Rule.ToString() && c.ParentId == result.Id).ToList();

            pRuleList.ForEach(c =>
            {
                result.RuleList.Add(new RuleModel()
                {
                    Priority = c.Seq, Value = c.TypeValue
                });
            });

            return(result);
        }
Example #12
0
        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);
        }
Example #13
0
        public ElementModel FindOrCreateElementModelTree(ElementModel elementModel, ElementModel parent)
        {
            var em = GetModel(elementModel.Id);

            if (em == null)
            {
                em = CreateNode(elementModel.Name, elementModel.Id, parent);
                if (elementModel.IsLightNode)
                {
                    em.LightSize = elementModel.LightSize;
                    em.Lights    = elementModel.Lights;
                    em.Order     = OrderExists(elementModel.Order) ? GetNextOrder() : elementModel.Order;
                }

                foreach (var child in elementModel.Children)
                {
                    FindOrCreateElementModelTree(child, em);
                }
            }
            else
            {
                AddToParent(em, parent);
            }
            return(em);
        }
 public MainViewModel()
 {
     First = new ResistorModel
     {
         Value    = 0,
         IsEnable = true
     };
     Second = new ResistorModel
     {
         Value    = 0,
         IsEnable = true
     };
     Third = new ResistorModel
     {
         Value    = 0,
         IsEnable = true
     };
     FirstElement = new ElementModel
     {
         Value = 0,
     };
     SecondElement = new ElementModel
     {
         Value = 0,
     };
 }
Example #15
0
        public static double GetTimeDependentCognitiveLoadOnsetPenalty(ElementModel element, OptimizationModel model)
        {
            var cogLoadOnsetPenalty = model.CognLoadOnsetPenalty *
                                      Math.Exp(-element.TimeVisible / model.CognLoadOnsetPenaltyDecay);

            return(cogLoadOnsetPenalty);
        }
Example #16
0
 public GeneralWriteCommand(byte[] data, ElementModel RefElement)
 {
     data1 = data;
     RefElements_A.Add(RefElement);
     InitializeCommandByElement();
     GenerateCommand();
 }
Example #17
0
        public static float GetCurrentCognitiveLoadForElement(ElementModel element)
        {
            var load = (float)element.CurrentLevelOfDetail / element.MaxLevelOfDetail * element.MaxCognitiveLoadNorm;

            load /= 3f;
            return(load);
        }
Example #18
0
        /// <summary>
        /// Создать модель элемент.
        /// </summary>
        /// <param name="type">Тип элемента</param>
        /// <returns>Модель элемента</returns>
        public ElementModel CreateElement(ElementType type)
        {
            var element = new ElementModel(type, _settings);

            element.MovementFinishEvent += Element_OnMovementFinishEvent;
            return(element);
        }
 public IntrasegmentWriteCommand(byte[] data, ElementModel RefElement)
 {
     this.data       = data;
     this.RefElement = RefElement;
     InitializeCommandByElement();
     GenerateCommand();
 }
Example #20
0
        public ElementModel AddLightNode(ElementModel target, Point p, int?order = null, int?size = null)
        {
            if (target == null || target.IsRootNode)
            {
                target = FindOrCreateTargetGroupForLight();
            }
            else if (target.Lights.Any())
            {
                throw new ArgumentException("Cannot add light node to leaf element with lights.");
            }

            if (order == null)
            {
                order = GetNextOrder();
            }

            ElementModel em = new ElementModel(Uniquify($"{target.Name}", 1), order.Value, target);

            target.AddChild(em);
            _models.Add(em.Id, em);
            if (size == null)
            {
                size = em.LightSize;
            }
            else
            {
                em.LightSize = size.Value;
            }

            var light = CreateLight(p, size.Value, em.Id);

            em.AddLight(light);

            return(em);
        }
        public List <ElementModel.Element> GetSessionVisualization(string id)
        {
            ElementModel    model        = new ElementModel();
            List <PathNode> pnCollection = new List <PathNode>();

            using (SwarmData context = new SwarmData())
            {
                pnCollection = context.PathNodes
                               .Where(pn => pn.Session.Id.ToString() == id).OrderBy(pn => pn.Created).ToList();
            }

            //load nodes
            foreach (PathNode pn in pnCollection)
            {
                model.ElementCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id        = pn.Id.ToString(),
                        parent_id = pn.Parent_Id.ToString(),
                        method    = pn.Method,
                        nodeinfo  = new ElementModel.NodeInfo()
                        {
                            name_space = pn.Namespace,
                            type       = pn.Type,
                            method     = pn.Method,
                            returntype = pn.ReturnType,
                            origin     = pn.Origin,
                            created    = pn.Created.ToShortDateString()
                        }
                    }
                });
            }

            //load edges
            List <ElementModel.Element> edgesCollection = new List <ElementModel.Element>();

            foreach (ElementModel.Element element in model.ElementCollection)
            {
                if (element.data.parent_id == Guid.Empty.ToString())
                {
                    continue;
                }

                edgesCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id     = element.data.id + "-" + element.data.id,
                        source = element.data.parent_id,
                        target = element.data.id
                    }
                });
            }

            model.ElementCollection.AddRange(edgesCollection);

            return(model.ElementCollection);
        }
Example #22
0
        public static double GetObjectiveForElement(ElementModel element, int lod, OptimizationModel model)
        {
            var importance       = Math.Pow(element.ImportanceNorm, 2);
            var utility          = GetUtilityForElement(element, lod);// (double)lod / element.MaxLevelOfDetail * importance;
            var visibilityReward = 1.0 + model.VisibilityReward * element.Visibility;

            return((importance * model.WeightImportance + utility * model.WeightUtility) * visibilityReward);
        }
Example #23
0
 /// <summary>
 /// Установить элемент.
 /// </summary>
 /// <param name="element">Элемент</param>
 public void SetElement(ElementModel element)
 {
     Element = element;
     if (Element != null)
     {
         Element.Cell = this;
     }
 }
Example #24
0
        public UpsertResult[] CreateCustomField(ElementModel model)
        {
            ElementFactory factory = new ElementFactory();
            IElement       element = factory.CreateInstance(model.Type.ToString());
            CustomField    field   = element.CreateElement(model);

            return(UpsertCustomField(field));
        }
 private void CreateElementsForChildren(ElementNode parentNode, ElementModel model)
 {
     foreach (var elementModel in model.Children)
     {
         var newnode = FindOrCreateElementNode(elementModel, parentNode);
         CreateElementsForChildren(newnode, elementModel);
     }
 }
        //TODO: review later, probaly delete
        //public List<PathNode> MountTreeByType(List<PathNode> pnCollection)
        //{
        //    List<PathNode> tree = new List<PathNode>();

        //    List<PathNode> roots = pnCollection.Where(pn => pn.Parent_Id == Guid.Empty).ToList();

        //    tree.AddRange(roots);

        //    foreach (PathNode root in roots)
        //    {
        //        foreach (PathNode child in pnCollection.Where(pn => pn.Parent_Id == root.Id).ToList())
        //        {
        //            if (tree.Any(pn => pn.Type == child.Type))
        //                continue;

        //            tree.Add(child);

        //            PathNode parent = tree
        //        }
        //    }
        //}

        public List <ElementModel.Element> GetTaskVisualization(string id)
        {
            ElementModel      model        = new ElementModel();
            List <PathNode>   pnCollection = new List <PathNode>();
            List <Breakpoint> bCollection  = new List <Breakpoint>();

            using (SwarmData context = new SwarmData())
            {
                var    sessionFilter = context.Sessions.Where(s => s.Id.ToString() == id).Select(s => new { TaskName = s.TaskName, ProjectName = s.ProjectName }).FirstOrDefault();
                Guid[] sessionIds    = context.Sessions.Where(s => s.TaskName == sessionFilter.TaskName && s.ProjectName == sessionFilter.ProjectName).Select(s => s.Id).ToArray();

                pnCollection = context.PathNodes.Where(pn => sessionIds.Contains(pn.Session.Id)).GroupBy(pn => pn.Type).Select(pn => pn.FirstOrDefault()).OrderBy(pn => pn.Created).ToList();
                bCollection  = context.Breakpoints.Where(b => sessionIds.Contains(b.Session.Id)).GroupBy(b => new { b.Namespace, b.Type, b.LineNumber }).Select(b => b.FirstOrDefault()).ToList();
            }

            NodeColor nodeColor = new NodeColor(bCollection);

            //load nodes
            foreach (PathNode pn in pnCollection)
            {
                model.ElementCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id        = pn.Id.ToString(),
                        parent_id = model.ElementCollection.Count() == 0 ? null : model.ElementCollection.Last().data.id,
                        method    = pn.Type + " - " + bCollection.Where(b => b.Type == pn.Type).Count().ToString(),
                        size      = bCollection.Where(b => b.Type == pn.Type).Count() + 10,
                        color     = nodeColor.GetColor(pn.Type)
                    }
                });
            }

            //load edges
            List <ElementModel.Element> edgesCollection = new List <ElementModel.Element>();

            foreach (ElementModel.Element element in model.ElementCollection)
            {
                if (String.IsNullOrWhiteSpace(element.data.parent_id))
                {
                    continue;
                }

                edgesCollection.Add(new ElementModel.Element()
                {
                    data = new ElementModel.Data()
                    {
                        id     = element.data.id + "-" + element.data.id,
                        source = element.data.parent_id,
                        target = element.data.id
                    }
                });
            }

            model.ElementCollection.AddRange(edgesCollection);

            return(model.ElementCollection);
        }
Example #27
0
 public ElementModelViewModel(ElementModel model, ElementModelViewModel parent)
 {
     ElementModel       = model;
     ChildrenViewModels = new ElementViewModelCollection(model.Children, this);
     ElementModelLookUpService.Instance.AddModel(model.Id, this);
     ((IRelationalViewModel)this).SetParentViewModel(parent);
     DeferValidationUntilFirstSaveCall = false;
     AlwaysInvokeNotifyChanged         = true;
 }
Example #28
0
        public void MoveWithinParent(ElementModel parent, ElementModel model, int newIndex)
        {
            int oldIndex = parent.Children.IndexOf(model);

            if (oldIndex >= 0)
            {
                parent.Children.Move(oldIndex, newIndex);
            }
        }
        public void RemoveElement()
        {
            ElementModel tempElement = this.SelectedElement.ParentElement;

            this.SelectedElement.ParentElement.Elements.Remove(this.SelectedElement);
            this.SelectElement(tempElement);

            this.BuildDocument();
        }
Example #30
0
 public void RemoveFromParent(ElementModel model, ElementModel parentToLeave)
 {
     model.RemoveParent(parentToLeave);
     parentToLeave.RemoveChild(model);
     if (!model.Parents.Any())
     {
         _models.Remove(model.Id);
     }
 }