Beispiel #1
0
        public ToolPath CreateToolPath(PathData pd, double inc)
        {
            ToolPath  tp;
            BraidData b = pd as BraidData;

            tp = new ToolPath(); //.BarrelOutline((int)(1 / inc)));
            return(tp);
        }
Beispiel #2
0
 public ViewModel()
 {
     NeedsInitialising  = true;
     LastBazleyPattern  = new BazelyChuck();
     LastRossPattern    = new RossData();
     LastWheelsPattern  = new WheelsData();
     LastBarrelPattern  = new Barrel();
     LastLatticePattern = new LatticeData();
     LastBraidPattern   = new BraidData();
 }
Beispiel #3
0
        private void Add_Perm_Click(object sender, RoutedEventArgs e)
        {
            BraidData   bc = viewModel.CurrentPathData as BraidData;
            Permutation p  = Permutation.CreateID(bc.NumStrands);

            p.Index = bc.Perms.Count;
            bc.Perms.Add(p);
            ReCalculate();
            BraidDisplay.Braid = bc;
        }
Beispiel #4
0
 private void PatternChoices_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (PatternChoices.SelectedValue != null)
     {
         BraidData bc = (BraidData)PatternChoices.SelectedValue;
         viewModel.CurrentPathData = bc;
         BraidDisplay.Braid        = bc;
         if (Bigdisplay.IsOpen)
         {
             PopupDisplay.Braid = bc;
         }
         ReCalculate();
     }
 }
Beispiel #5
0
        public ShapeCollection CreatePaths(PathData pd, double increment)
        {
            bd = pd as BraidData;
            ShapeCollection pc = new ShapeCollection();

            pc.PatternName = pd.Name;
            repeatAngle    = 2 * Math.PI / bd.Repeats;
            colAngle       = (repeatAngle - rad * bd.Margin) / bd.Perms.Count;

            rowHeight = bd.Width / (bd.NumStrands - 1);
            colWidth  = bd.Length / bd.Perms.Count;
            origin    = new Point(bd.ToolPosition, 0);

            for (int indx = 0; indx < bd.Repeats; indx++)
            {
                pc.AddShape(MkPath(indx, increment));
            }
            return(pc);
        }
Beispiel #6
0
        private void CreateBraidData()
        {
            BraidData b = new BraidData();

            b.Repeats = 4;
            Permutation p = new Permutation();

            p.SetPermOf(0, 1);
            p.SetPermOf(1, 0);
            b.Add(p);
            p = new Permutation();
            b.Add(p);
            p = new Permutation();
            p.SetPermOf(0, 1);
            p.SetPermOf(1, 0);
            b.Add(p);
            BraidPatterns.Add(b);
            b.PropertyChanged += b_PropertyChanged;
        }
Beispiel #7
0
        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
            {
            }
        }
Beispiel #8
0
        private void Remove_Perm_Click(object sender, RoutedEventArgs e)
        {
            BraidData bc = viewModel.CurrentPathData as BraidData;

            bc.RemoveLastPerm();
        }