Пример #1
0
        public void addGroup(WebGroup grp)
        {
            Image mainArtwork = new Image();
            mainArtwork.Source = new BitmapImage(new Uri(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/" + @grp.Filename, UriKind.Absolute));
            int groups = 0;
            List<Image> groupThumb = new List<Image>();

            List<Image> temp = null;
            if ((temp = grp.getGroup("A")).Count > 0)
            {
                groups++;
                groupThumb.Add(temp[0]);
            }

            temp = null;
            if ((temp = grp.getGroup("B")).Count > 0)
            {
                groups++;
                groupThumb.Add(temp[0]);
            }

            temp = null;
            if ((temp = grp.getGroup("C")).Count > 0)
            {
                groups++;
                groupThumb.Add(temp[0]);
            }

            temp = null;
            if ((temp = grp.getGroup("D")).Count > 0)
            {
                groups++;
                groupThumb.Add(temp[0]);
            }

            bool exists = false;

            if (vertexList.Count > 0)
            {
                foreach (SingleWeb i in vertexList)
                {
                    if (i.file.Equals(grp.Filename))
                    {
                        exists = true;
                        break;
                    }
                }
            }

            if(!exists)
            {
                Random rnd = new Random();
                int h = 0;
                int w = 0;

                h = (int)(centerStartY - moveLayer.Center.Y) + (int)(moveLayer.Height/2);
                w = (int)(centerStartX - moveLayer.Center.X) + (int)(moveLayer.Width/2);

                bool check = false;

                while(!check)
                {
                    bool cont = false;

                    foreach (SingleWeb i in vertexList)
                    {
                        if (i.centerX - sides / 2 <= w && w <= i.centerX + sides / 2 &&
                            i.centerY - sides / 2 <= h && h <= i.centerY + sides / 2)
                        {
                            cont = true;
                            break;
                        }
                    }

                    if (cont)
                    {
                        w = (int)(centerStartX - moveLayer.Center.X) + (int)(moveLayer.Width / 2) - (int)(screenW / 2) + (int)(screenW * 0.1) + rnd.Next((int)(screenW * 0.6));
                        h = (int)(centerStartY - moveLayer.Center.Y) + (int)(moveLayer.Height / 2) - (int)(screenH/2) + (int)(screenH * 0.1) + rnd.Next((int)(screenH * 0.6));
                        continue;
                    }
                    check = true;
                }

                SingleWeb current = new SingleWeb(innerLayer, w, h, currentIndex++, sides, groupThumb, mainArtwork, groups, lineCanvas, grp.Filename, this, grp.Filename, grp, artwork);
                vertexList.Add(current);

                if (vertexList.Count > 1)
                {
                    for (int i = 0; i < currentIndex - 1; i++)
                    {
                        if (grp.hasAnyKeywordOf(vertexList[i].webGroup.Keywords()))
                        {
                            Line newLine = new Line();
                            newLine.StrokeThickness = 1;
                            newLine.Stroke = Brushes.Black;

                            BindLineToScatterViewItems(newLine, vertexList[i].mainArtwork, current.mainArtwork);
                            lineCanvas.Children.Add(newLine);
                        }
                    }
                }
            }
        }