public WebStack(ScatterView sv, Point origin, WebGroup gr, String group, KnowledgeWeb knowledge, LADSArtworkMode.ArtworkModeWindow art, int g) { groupNo = g; artwork = art; kw = knowledge; _sv = sv; _images = gr.getGroupBitmap(group); if (_images == null) return; foreach (BitmapImage i in _images) { ScatterViewItem svi = new ScatterViewItem(); svi.MinHeight = 1; svi.MinWidth = 1; Image img = new Image(); img.Source = i; sviContent content = new sviContent(); content.g = new Grid(); content.g.Height = INITIAL_THUMB_HEIGHT; content.g.Width = INITIAL_THUMB_HEIGHT; content.im = img; content.r = new Rectangle(); content.r.Height = INITIAL_THUMB_HEIGHT; content.r.Width = INITIAL_THUMB_HEIGHT; content.r.Visibility = Visibility.Collapsed; content.g.Children.Add(content.r); content.g.Children.Add(content.im); content.used = false; svi.Content = content.g; svi.Tag = content; svi.Height = INITIAL_THUMB_HEIGHT; svi.Width = INITIAL_THUMB_HEIGHT; svi.Orientation = 0; svi.CanRotate = false; svi.CanMove = false; svi.CanScale = false; svi.PreviewTouchUp += new EventHandler<System.Windows.Input.TouchEventArgs>(svi_PreviewTouchUp); svi.PreviewTouchDown += new EventHandler<TouchEventArgs>(svi_PreviewTouchDown); svi.SizeChanged += new SizeChangedEventHandler(svi_SizeChanged); knowledge.sviList.Add(svi); _svis.Add(svi); _sv.Items.Add(svi); } PositionScatterViewItems(origin); }
public static List<WebGroup> LoadFromXML(String filename, String pathPrefix = "", String metaPrefix = "") { List<WebGroup> groups = new List<WebGroup>(); XmlDocument doc = new XmlDocument(); doc.Load(filename); if (doc.HasChildNodes) { foreach (XmlNode docNode in doc.ChildNodes) { if (docNode.Name == "Collection") { foreach (XmlNode imageNode in docNode.ChildNodes) { String thumb = pathPrefix + imageNode.Attributes.GetNamedItem("path").InnerText; String title = imageNode.Attributes.GetNamedItem("title").InnerText; WebGroup group = new WebGroup(@thumb, title); foreach (XmlNode imageDetail in imageNode.ChildNodes) { if (imageDetail.Name == "Keywords") { foreach (XmlNode keyword in imageDetail.ChildNodes) { group.addKeyword(keyword.Attributes.GetNamedItem("Value").InnerText); } } else if (imageDetail.Name == "Metadata") { foreach (XmlNode pile in imageDetail.ChildNodes) { String groupName = pile.Attributes.GetNamedItem("name").InnerText; foreach (XmlNode groupItem in pile.ChildNodes) { if (groupItem.Name == "Item") { String itemThumb = pathPrefix + metaPrefix + groupItem.Attributes.GetNamedItem("Filename").InnerText; group.AddToGroup(groupName, @itemThumb); } } } } } groups.Add(group); } } } } return groups; }
public SingleWeb(ScatterView parent, double xStart, double yStart, int index, double sides, List<Image> ims, Image main, int group, Canvas lineCanvas, String fileName, KnowledgeWeb web, string path, WebGroup g, LADSArtworkMode.ArtworkModeWindow art) { artwork = art; webGroup = g; filePath = path; kw = web; file = fileName; centerX = xStart; centerY = yStart; groupNo = group; vertIndex = index; int counter = 0; mainArtwork.Content = mainGrid; mainArtwork.Center = new Point(xStart, yStart); mainArtwork.MinHeight = 1; mainArtwork.MinWidth = 1; mainArtwork.SizeChanged += new SizeChangedEventHandler(mainArtwork_SizeChanged); mainArtwork.PreviewTouchDown += new EventHandler<TouchEventArgs>(mainArtwork_PreviewTouchDown); mainArtwork.PreviewTouchUp += new EventHandler<TouchEventArgs>(mainArtwork_PreviewTouchUp); mainArtwork.PreviewTouchMove += new EventHandler<TouchEventArgs>(mainArtwork_PreviewTouchMove); double xDist = sides * 0.4; double yDist = sides * 0.4; mainArtwork.Width = xDist; mainArtwork.Height = yDist; kw.sviList.Add(mainArtwork); main.Width = mainArtwork.Width - 10; main.Height = mainArtwork.Height - 10; mainIm = main; WebStack.sviContent content = new WebStack.sviContent(); content.g = mainGrid; content.im = main; content.r = mainRect; content.r.Width = main.ActualWidth + 10; content.r.Height = main.ActualHeight + 10; content.r.Visibility = Visibility.Collapsed; content.r.Fill = Brushes.Green; content.g.Children.Add(content.r); content.g.Children.Add(content.im); content.used = false; mainArtwork.Tag = content; startHeight = mainArtwork.Height; startWidth = mainArtwork.Width; mainArtwork.CanRotate = false; mainArtwork.Orientation = 0; DependencyPropertyDescriptor dpd1 = DependencyPropertyDescriptor.FromProperty(ScatterViewItem.CenterProperty, typeof(ScatterViewItem)); dpd1.AddValueChanged(mainArtwork, ScatterviewMainChanged); parent.Items.Add(mainArtwork); String[] enumerate = { "A", "B", "C", "D" }; for(int j = 0; j < group; j++) { Image i = ims[j]; groupArtwork current = new groupArtwork(); current.sv = new ScatterViewItem(); current.sv.MinHeight = 1; current.sv.MinWidth = 1; current.groupGrid = new Grid(); current.sv.Width = sides * 0.05; current.sv.Height = sides * 0.05; current.angle = 225 + counter * 90; current.sv.Center = new Point(xStart + Math.Cos((current.angle/180.0)*Math.PI) * xDist, yStart + Math.Sin((current.angle/180.0)*Math.PI)*yDist); current.sv.CanRotate = false; current.sv.Orientation = 0; //current.sv.SizeChanged += new SizeChangedEventHandler(sv_SizeChanged); //current.sv.PreviewTouchDown += new EventHandler<TouchEventArgs>(sv_TouchDown); //current.sv.PreviewTouchUp += new EventHandler<TouchEventArgs>(sv_PreviewTouchUp); //current.sv.PreviewTouchMove += new EventHandler<TouchEventArgs>(sv_PreviewTouchMove); timerAndRect temp2 = new timerAndRect(); temp2.rect = new Rectangle(); i.Height = current.sv.Height - 10; i.Width = current.sv.Width - 10; temp2.ind = counter+1; temp2.rect.Height = i.ActualHeight + 10; temp2.rect.Width = i.ActualWidth + 10; current.sv.Tag = temp2; current.sv.Content = current.groupGrid; current.groupGrid.Children.Add(temp2.rect); current.groupGrid.Children.Add(i); current.im = i; DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(ScatterViewItem.CenterProperty, typeof(ScatterViewItem)); //dpd.AddValueChanged(current.sv, ScatterViewCenterChanged); current.st = new WebStack(parent, current.sv.Center, webGroup, enumerate[j],kw,artwork,j); //parent.Items.Add(current.sv); groupList.Add(current); counter++; } height = sides; width = sides; parentScatter = parent; }
public void addKeyWords(WebGroup g) { bx.SearchOnGroup(g); toggleSearchOn(); }
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); } } } } }
public void SearchOnGroup(WebGroup group) { _keywords.Clear(); keywordList.Items.Clear(); foreach (String k in group.Keywords()) { if (!_keywords.Contains(k)) { _keywords.Add(k); keywordList.Items.Add(k); } } }
internal ItemSelectedArgs(WebGroup grp, KnowledgeWeb w) { SelectedGroup = grp; w.addGroup(grp); }