Ejemplo n.º 1
0
 public MainWindow()
 {
     InitializeComponent();
     BoxView.ItemsSource           = Boxes.GetBoxList();
     UnusedBoxesView.ItemsSource   = UnusedBoxes.GetBoxList();
     CalculatedBoxView.ItemsSource = CalculatedBoxes.GetBoxList();
     GridView           = new GridViewModel();
     this.DataContext   = GridView;
     GridView.IsVisible = false;
 }
Ejemplo n.º 2
0
        public void TestLoad()
        {
            string filename = @"C:\Users\Mike\Desktop\t.txt";

            System.IO.StreamReader file = new System.IO.StreamReader(filename);
            string line = file.ReadToEnd();


            var BoxesTmp = InputOutput.InitializeList(line);
            var Boxes    = new BoxList();

            Boxes.CzyscListe();
            Boxes.DodajPudelka(BoxesTmp);
            Boxes.UstawPionowo();

            foreach (var item in Boxes.ListBox)
            {
                Assert.IsTrue(item.Width <= item.Height);
            }



            BoxList A = new BoxList();
            BoxList B = new BoxList();

            A.DodajPudelka(Boxes.GetBoxList());
            B.DodajPudelka(Boxes.GetBoxList());

            A.SortujPudelka(true);
            B.SortujPudelka(false);


            for (int i = 0; i < A.ListBox.Count - 2; i++)
            {
                Assert.IsTrue(A.ListBox[i].Height <= A.ListBox[i + 1].Height);
            }

            for (int i = 0; i < B.ListBox.Count - 2; i++)
            {
                Assert.IsTrue(B.ListBox[i].Width <= B.ListBox[i + 1].Width);
            }
        }
Ejemplo n.º 3
0
        private void _Start_Click(object sender, RoutedEventArgs e)
        {
            if (IsCalculated)
            {
                return;
            }
            if (Boxes.GetBoxNumber() == 0)
            {
                return;
            }



            Boxes.UstawPionowo();

            BoxList A = new BoxList();
            BoxList B = new BoxList();

            A.DodajPudelka(Boxes.GetBoxList());
            B.DodajPudelka(Boxes.GetBoxList());

            A.SortujPudelka(true);
            B.SortujPudelka(false);

            var watch = Stopwatch.StartNew();



            var tmp = Algorithm.NajdluzszyWspolnyPodciag(A.GetBoxList(), B.GetBoxList());

            watch.Stop();
            IsCalculated = true;
            FillData(watch.ElapsedMilliseconds.ToString(), tmp);
            SortedBoxes.ListBox = tmp;
            fillCanvas(SortedCanvas, SortedBoxes);
        }