Example #1
0
 /// <summary>
 /// Another constructor for lines
 /// </summary>
 /// <param name="lineEntity"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public AllPurpuseEntity(LineEntity lineEntity, int x, int y)
 {
     LineEntity = lineEntity;
     X          = x;
     Y          = y;
     TypeE      = EntityType.Line;
     ColorBrush = Brushes.Black;
 }
Example #2
0
 public PowerGrid(int x, int y)
 {
     _width        = x;
     _height       = y;
     Grid          = new PowerEntity[_width + 1, _height + 1];
     LineGrid      = new LineEntity[_width + 1, _height + 1];
     PowerEntities = new Dictionary <long, PowerEntity>();
     LineEntities  = new Dictionary <long, LineEntity>();
 }
Example #3
0
 public void AssignLine(LineEntity l)
 {
     /*
      * if (PowerEntities.Values.Where(x => x.Id == l.FirstEnd).Count() > 0 && PowerEntities.Values.Where(x => x.Id == l.SecondEnd).Count() > 0
      *  && LineEntities.Values.Where(x => x.FirstEnd == l.FirstEnd && x.SecondEnd == l.SecondEnd).Count() == 0)
      * {
      *  LineEntities.Add(l.Id, l);
      * }
      */
     LineEntities.Add(l.Id, l);
 }
Example #4
0
        private double GetLineLenght(LineEntity l)
        {
            PowerEntity start = PowerEntities[l.FirstEnd];
            PowerEntity end   = PowerEntities[l.SecondEnd];

            double diffX = start.GridPosition.Item1 - end.GridPosition.Item1;
            double diffY = start.GridPosition.Item2 - end.GridPosition.Item2;

            double lenght = Math.Sqrt((diffX) * (diffX) + (diffY) * (diffY));

            return(lenght);
        }
Example #5
0
 public void AddEdge(LineEntity edge)
 {
     foreach (var node in AdjacencyList.Keys)
     {
         if (node != null)                        // ako nije prazno polje matrice
         {
             if (node.Entity.Id == edge.FirstEnd) // ako im se poklapaju
             {
                 foreach (var node2 in AdjacencyList.Keys)
                 {
                     if (node2 != null)
                     {
                         if (node2.Entity.Id == edge.SecondEnd)
                         {
                             AdjacencyList[node].Add(node2);
                             AdjacencyList[node2].Add(node);
                         }
                     }
                 }
             }
         }
     }
 }
Example #6
0
 public AllPurpuseEntity(LineEntity lineEntity, EntityType typeE, Brush colorBrush)
 {
     LineEntity = lineEntity;
     TypeE      = typeE;
     ColorBrush = colorBrush;
 }