예제 #1
0
 public TreeItemDTO(TreeGroup treeGroup)
 {
     Header     = treeGroup.Header;
     Children   = AsDTO(treeGroup.Children);
     Favourites = AsDTO(treeGroup.Favourites);
     Kind       = nameof(TreeGroup);
 }
예제 #2
0
        private void AddNewGroup(object obj)
        {
            var helperTreeGroup = new TreeGroup("helper");

            helperTreeGroup.AddGroupCommand.Execute(obj);

            Tree.Add(helperTreeGroup.Children.First());
        }
예제 #3
0
    public static GroupTree GetGroupsTree(String OrgID)
    {
        GroupTree groupTree = new GroupTree();
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int orgId = Convert.ToInt32(OrgID);
            dataBlock.OpenConnection();
            String name = dataBlock.organizationTable.GetOrganizationName(orgId);

            groupTree.OrgName = name;

            TreeGroup gr = new TreeGroup();
            gr.GroupName = "Водители";
            List<int> groupIds = dataBlock.cardsTable.GetAllGroupIds(orgId, dataBlock.cardsTable.driversCardTypeId);
            foreach (int grId in groupIds)
            {
                if (dataBlock.cardsTable.GetGroupCardTypeById(grId) != 0)
                {
                    String name1 = dataBlock.cardsTable.GetGroupNameById(grId);
                    gr.addValue(grId.ToString(), name1);
                }
            }
            gr.GroupId = 1;
            groupTree.addGroup(gr);

            gr = new TreeGroup();
            gr.GroupName = "Транспортные средства";
            gr.GroupId = 2;
            groupIds = dataBlock.cardsTable.GetAllGroupIds(orgId, dataBlock.cardsTable.vehicleCardTypeId);
            foreach (int grId in groupIds)
            {
                if (dataBlock.cardsTable.GetGroupCardTypeById(grId) != 0)
                {
                    String name1 = dataBlock.cardsTable.GetGroupNameById(grId);
                    gr.addValue(grId.ToString(), name1);
                }
            }
            groupTree.addGroup(gr);

            dataBlock.CloseConnection();
            return groupTree;
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
    }
예제 #4
0
        private void updateSelection()
        {
            tree.Clear();
            IGroup root     = AccountApi.Smartschool.GroupManager.Root.Find(Target);
            var    treeRoot = new TreeGroup(root);

            foreach (var child in treeRoot.Children)
            {
                tree.Add(child);
            }
            NumAccounts = treeRoot.CountAccount;

            PropertyChanged(this, new PropertyChangedEventArgs(nameof(Tree)));
        }
예제 #5
0
        protected override void RenderSolidObjects(SortedList list, bool doLightIteration,
                                                   List <Light> manualLightList)
        {
            if (renderingMainGroup)
            {
                if (!(renderingNoShadowQueue || (illuminationStage == IlluminationRenderStage.RenderModulativePass)))
                {
                    TreeGroup.RenderAllTrees(targetRenderSystem);
                }
            }

            baseRenderSolidMeter.Enter();
            base.RenderSolidObjects(list, doLightIteration, manualLightList);
            baseRenderSolidMeter.Exit();
        }
예제 #6
0
        public virtual bool IsTimeForPickupItem(GameUnit unit)
        {
            if (SecondaryGroundLvL.IsEmptyPos(unit.ChunkNumber, unit.CurrentPos))
            {
                return(false);
            }
            var item = SecondaryGroundLvL.GetGroundEnt(unit.ChunkNumber, unit.CurrentPos);

            return(item != null &&
                   item.CanBePickuped &&
                   !item.SoloEvolution &&
                   item.Group == "item" &&
                   unit.pickUped == null &&
                   TreeGroup.IsPickableTreeLog(item) &&
                   unit.GroupObj.GetLairPos() != ChunkUtil.GetDovvner(unit.CurrentPos));
        }
예제 #7
0
        public CustomTreeViewModel()
        {
            AddNewGroupCommand  = new RelayCommand(AddNewGroup);
            AddNewItemCommand   = new RelayCommand(p => AddNewItem(p as IValueTag));
            PersistTreeCommand  = new RelayCommand(PersistTree);
            RetrieveTreeCommand = new RelayCommand(controller => RetrieveTree(controller as IConnector));

            var helperTreeGroup = new TreeGroup("helper");

            helperTreeGroup.AddGroup("test group");

            if (Tree.Count() == 0)
            {
                Tree.Add(helperTreeGroup);
            }
        }
예제 #8
0
        public void RealAddTreeType(String filename, float size, float sizeVariance, uint numInstances)
        {
            List <Vector3> locations = new List <Vector3>();

            // create random locations for trees
            for (int i = 0; i < numInstances; i++)
            {
                locations.Add(RandomLocation());
            }
            TreeGroup group = new TreeGroup(filename, size, sizeVariance, speedWind, this, locations);

            AddBounds(group.Bounds);

            group.WindStrength = WindStrength;

            groups.Add(group);
        }
예제 #9
0
        public Tree(TreeGroup group, SpeedTreeWrapper speedTree, Vector3 location)
        {
            this.group    = group;
            this.location = location;

            this.speedTree = speedTree;

            billboard0 = new float[20];
            billboard1 = new float[20];

            // set location for the instance
            speedTree.TreePosition = SpeedTreeUtil.ToSpeedTree(location);

            // set bounding box
            AxisAlignedBox stbox = SpeedTreeUtil.FromSpeedTree(speedTree.BoundingBox);

            this.bounds = new AxisAlignedBox(stbox.Minimum + location, stbox.Maximum + location);
        }
예제 #10
0
        public void DragDrop(object sender, DragEventArgs dragArgs)
        {
            DataContext = sender.As <FrameworkElement>().DataContext.As <TreeGroup>();

            dragArgs
            .GetFrom <ValueTag>()
            .TryAs <IValueTag>()
            ?.Let(AddNewItem);

            dragArgs
            .GetFrom <VortexObjectDataTemplate>()
            .TryAs <TreeWrapperObject>()
            ?.Let(AddNewItem);

            dragArgs
            .GetFrom <TreeItemTemplate>()
            .TryAs <IValueTag>()
            ?.Let(AddToFavourites);

            dragArgs.Handled = true;
        }
예제 #11
0
        public static void RecolorObject(GameEntity ent, bool trueCall)
        {
            if (ent == null || ((Recolor.IsHided(ent) && !trueCall) && ChunkManager.staticFogEnabled))
            {
                return;
            }


            var mod   = 3f;
            var upper = ChunkUtil.GetUpper(ent.CurrentPos);

            if ((ChunkUtil.IsAnyEntity(ent.ChunkNumber, upper) ||
                 !SecondaryGroundLvL.IsEmptyPos(ent.ChunkNumber, upper)) &&
                ent.CurrentPos.z + 1 != ChunkManager.MaxGroundsLvls)
            {
                mod += 2.5f;
            }


            var i     = 1f / ((ent.CurrentPos.z + mod) * 0.3f);
            var color = new Color(i, i, i);

            if (ChunkUtil.IsEntity(ent.ChunkNumber, upper) &&
                ent.CurrentPos.z + 1 != ChunkManager.MaxGroundsLvls)
            {
                var chunk    = ChunkManager.GetChunkByNum(ent.ChunkNumber);
                var upperEnt = chunk.GetGameObjectByIndex(upper);
                if (upperEnt != null)
                {
                    if (TreeGroup.IsTreeGroup(upperEnt.Group))
                    {
                        color.r = 0.5f;
                        color.b = 0.7f;
                        color.g = 0.3f;
                    }
                    else if (upperEnt.Group == "rock")
                    {
                        color.r = 0.3f;
                        color.b = 0.7f;
                        color.g = 0.2f;
                    }
                    else if (upperEnt is GameUnit)
                    {
                        var unit = upperEnt as GameUnit;
                        if (unit.IsEnemy(PlayersManager.GetMyPlayer()))
                        {
                            color.r = 1;
                            color.b = 0.3f;
                            color.g = 0.3f;
                        }
                        else
                        {
                            color.r = 0.1f;
                            color.b = 0.1f;
                            color.g = 0.6f;
                        }
                    }
                    else
                    {
                        color.r = 0.1f;
                        color.b = 0.1f;
                        color.g = 0.6f;
                    }
                }
            }

            if (!GroupUtil.isCreatureGroup(ent.Group) &&
                !GroupUtil.isBuilding(ent.Group))
            {
                var spriteRenderer = ent.GetComponent <SpriteRenderer>();
                spriteRenderer.color = color;
            }
        }
예제 #12
0
        private List <TreePart> SolveSimpleGraph(Dictionary <ushort, Dictionary <ushort, int> > graph, IEnumerable <ushort> solveSet, int maxSize)
        {
            BucketQueue <TreeGroup> groups = new BucketQueue <TreeGroup>();

            List <TreePart> initialParts = new List <TreePart>();
            {
                foreach (ushort node in solveSet)
                {
                    initialParts.Add(new TreePart(node));
                }
            }

            TreeGroup initialGroup = new TreeGroup(initialParts.ToArray());

            groups.Enqueue(initialGroup, initialGroup.Size);

            int generation = 0;

            HashSet <TreePart> solutions = new HashSet <TreePart>(EqualityComparer <TreePart> .Default);

            // DO WORK.
            while (!groups.IsEmpty())
            {
                generation++;
                TreeGroup group = groups.Dequeue();

                if (group.Size > maxSize)
                {
                    break;
                }

                if (generation % 100000 == 0)
                {
                    Console.WriteLine(generation + " " + group.Size);
                }

                TreePart smallest = group.Smallest;

                foreach (ushort node in smallest.Nodes.ToList())
                {
                    int remaining = maxSize - group.Size;
                    foreach (var next in graph[node])
                    {
                        if (smallest.Nodes.Contains(next.Key))
                        {
                            continue;
                        }

                        if (next.Value > remaining)
                        {
                            continue;
                        }

                        TreePart part = new TreePart(smallest);
                        Edge     edge = new Edge(node, next.Key);

                        part.Nodes.Add(next.Key);
                        part.Edges.Add(edge);
                        part.Size += next.Value;

                        TreePart  mergePart = group.Containing(next.Key);
                        TreeGroup newGroup;
                        if (mergePart != null)
                        {
                            part.merge(mergePart);

                            TreePart[] other = new TreePart[group.Parts.Length - 1];
                            int        index = 0;
                            for (int i = 0; i < group.Parts.Length; ++i)
                            {
                                if (group.Parts[i] != mergePart)
                                {
                                    other[index++] = group.Parts[i];
                                }
                            }
                            newGroup = new TreeGroup(part, other);
                        }
                        else
                        {
                            newGroup = new TreeGroup(part, group.Parts);
                        }

                        if (newGroup.Parts.Length == 0)
                        {
                            if (newGroup.Size < maxSize)
                            {
                                solutions.Clear();
                                maxSize = newGroup.Size;
                            }

                            solutions.Add(newGroup.Smallest);
                            //	groups.CapPriority(maxSize);
                            continue;
                        }

                        if (newGroup.Size >= maxSize)
                        {
                            continue;
                        }

                        groups.Enqueue(newGroup, newGroup.Size);
                    }
                }
                group.Recycle();
            }

            return(solutions.ToList());
        }
예제 #13
0
    public static GroupTree GetOverlookVehiclesTree(String OrgID)
    {
        GroupTree vehTree = new GroupTree();
        try
        {
            string connectionString = ConfigurationManager.AppSettings["fleetnetbaseConnectionString"];
            DataBlock dataBlock = new DataBlock(connectionString, ConfigurationManager.AppSettings["language"]);
            int orgId = Convert.ToInt32(OrgID);
            dataBlock.OpenConnection();
            String name = dataBlock.organizationTable.GetOrganizationName(orgId);

            vehTree.OrgName = name;

            List<int> groupIds = dataBlock.cardsTable.GetAllGroupIds(orgId, dataBlock.cardsTable.vehicleCardTypeId);
            for (int i = 0; i < groupIds.Count; i++)
            {
                TreeGroup gr = new TreeGroup();
                string grName = dataBlock.cardsTable.GetGroupNameById(groupIds[i]);
                gr.GroupName = grName;
                gr.GroupId = groupIds[i];
                List<int> values = dataBlock.cardsTable.GetAllCardIdsByGroupId(orgId, dataBlock.cardsTable.vehicleCardTypeId, groupIds[i]);

                for (int j = 0; j < values.Count; j++)
                {
                    String veh_name = dataBlock.cardsTable.GetCardHolderNameByCardId(values[j]);
                    gr.addValue(values[j].ToString(), veh_name);
                }
                vehTree.addGroup(gr);
            }
            dataBlock.CloseConnection();
        }
        catch (Exception ex)
        {
            throw ex;
            //return null;
        }
        return vehTree;
    }
예제 #14
0
    // returns the height of a tree based on some noise
    public static int treeHeightNoise(int x, int y, int seed, TreeGroup treeGroup)
    {
        float noise = (terrainNoise(x, y, seed, treeGroup.scale, treeGroup.offset) + terrainNoise(-x, -y, -seed, treeGroup.scale, -treeGroup.offset)) / 2f;

        return(Mathf.RoundToInt((treeGroup.tree.maxHeight - treeGroup.tree.minHeight) * noise));
    }