private void CreateLatticeData() { LatticeData l = new LatticeData(1); l.Layout.ToolPosition = 60; l.Rows = 10; l.Columns = 10; l.Layout.RepeatX = 10; l.Layout.RepeatY = 10; l.Layout.Width = 30; l.Layout.Height = 30; l.Layout.Clip = true; l.Layout.ClipRange.Start = 50; l.Layout.ClipRange.End = 200; l.PropertyChanged += l_PropertyChanged; l.Add(new Line2D(0, 0, 5, 0)); l.Add(new Line2D(0, 5, 5, 5)); l.Add(new Line2D(0, 0, 0, 5)); l.Add(new Line2D(5, 0, 5, 5)); l.Add(new Line2D(0, 0, 5, 5)); l.Add(new Line2D(5, 0, 0, 5)); l.LineChanged += l_LineChanged; l.LineRemoved += l_LineChanged; LatticePatterns.Add(l); }
public async void ImportPattern(PatternType typ) { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; if (typ == PatternType.wheels) { openPicker.FileTypeFilter.Add(".wheel"); } else if (typ == PatternType.ross) { openPicker.FileTypeFilter.Add(".ross"); } else if (typ == PatternType.bazley) { openPicker.FileTypeFilter.Add(".baz"); } else if (typ == PatternType.barrel) { openPicker.FileTypeFilter.Add(".bar"); } else if (typ == PatternType.latticeRim) { openPicker.FileTypeFilter.Add(".lattice"); } else if (typ == PatternType.braid) { openPicker.FileTypeFilter.Add(".braid"); } openPicker.FileTypeFilter.Add(".xml"); StorageFile file = await openPicker.PickSingleFileAsync(); XmlSerializer ser; if (file != null) { var stream = await file.OpenStreamForReadAsync(); if (typ == PatternType.wheels) { ser = new XmlSerializer(typeof(WheelsData)); WheelsData wd = (WheelsData)ser.Deserialize(stream); wd.PatternIndex = WheelsPatterns.Count; wd.FixUp(); WheelsPatterns.Add(wd); SelectedPathIndex = wd.PatternIndex; } else if (typ == PatternType.ross) { ser = new XmlSerializer(typeof(RossData)); RossData rd = (RossData)ser.Deserialize(stream); rd.PatternIndex = RossPatterns.Count; RossPatterns.Add(rd); SelectedPathIndex = rd.PatternIndex; } else if (typ == PatternType.bazley) { ser = new XmlSerializer(typeof(BazelyChuck)); BazelyChuck bd = (BazelyChuck)ser.Deserialize(stream); bd.PatternIndex = BazeleyPatterns.Count; BazeleyPatterns.Add(bd); SelectedPathIndex = bd.PatternIndex; } else if (typ == PatternType.barrel) { ser = new XmlSerializer(typeof(Barrel)); Barrel bd = (Barrel)ser.Deserialize(stream); bd.PatternIndex = BarrelPatterns.Count; BarrelPatterns.Add(bd); SelectedPathIndex = bd.PatternIndex; } else if (typ == PatternType.latticeRim) { ser = new XmlSerializer(typeof(LatticeData)); LatticeData bd = (LatticeData)ser.Deserialize(stream); if (LatticePatterns.Select(p => p.PatternIndex == bd.PatternIndex).Count() > 0) { bd.PatternIndex = LatticePatterns.Count + 1; } LatticePatterns.Add(bd); SelectedPathIndex = bd.PatternIndex; } else if (typ == PatternType.braid) { ser = new XmlSerializer(typeof(BraidData)); BraidData bd = (BraidData)ser.Deserialize(stream); bd.PatternIndex = BraidPatterns.Count; BraidPatterns.Add(bd); SelectedPathIndex = bd.PatternIndex; } } else { } }