Пример #1
0
        private void fullList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                this.SelectedMatrix = ((VisualSignMatrix)fullList.SelectedItem).signmatrix;
                List <VisualNgon> ngons     = new List <VisualNgon>();
                List <Canvas>     ngonsvizs = new List <Canvas>();
                if (SelectedMatrix != null)
                {
                    foreach (var rawngon in SelectedMatrix.Ngons)
                    {
                        VisualNgon ngon = new VisualNgon(rawngon);

                        ngons.Add(ngon);
                        double width = 300, height = 200;
                        Canvas box = new Canvas()
                        {
                            Height = height, Width = width
                        };
                        ngon.draw(box, width, height);
                        ngonsvizs.Add(box);
                    }
                }
                panel_ngons.ItemsSource = ngonsvizs;
            }
            catch (Exception ex)
            {
            }
        }
        private void but_randomNgon_Click(object sender, RoutedEventArgs e)
        {
            frame.Children.Clear();

            int dimensions = Int32.Parse(text_dimensions.Text);

            currentNgon = Program.generateRandomNgon(dimensions);
            but_ngonPermutations.IsEnabled = true;
            VisualNgon n = new VisualNgon(currentNgon);

            lab_PluckerMatrix.Content = (new SignMatrix(new PluckerMatrix(currentNgon))).ToString();
            n.draw(frame);
            displayAngleSum(currentNgon);
            displayType(currentNgon);
        }
Пример #3
0
        private void updateCollection()
        {
            try
            {
                sampleSize = permutations.Count();
                dimensions = modelNgon.Edges.Count();

                ngons = new List <VisualNgon>((int)sampleSize);
                foreach (Ngon modelNgon in permutations)
                {
                    VisualNgon ngon = new VisualNgon(modelNgon);

                    ngons.Add(ngon);
                    double width = 300, height = 200;
                    Canvas box = new Canvas()
                    {
                        Height = height, Width = width
                    };
                    ngon.draw(box, width, height);

                    if (ngon.ngonModel.Type == NgonType.Convex)
                    {
                        panel_convex.Items.Add(box);
                    }
                    if (ngon.ngonModel.Type == NgonType.Reflex)
                    {
                        panel_reflex.Items.Add(box);
                    }
                    if (ngon.ngonModel.Type == NgonType.Self_Intersecting)
                    {
                        panel_selfintersecting.Items.Add(box);
                    }
                }

                lab_convex.Content           = "Convex: " + panel_convex.Items.Count;
                lab_reflex.Content           = "Reflex: " + panel_reflex.Items.Count;
                lab_selfintersecting.Content = "Self-Intersecting: " + panel_selfintersecting.Items.Count;
            }
            catch (Exception)
            {
            }
        }
        private void but_generate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                sampleSize = Int64.Parse(text_sampleSize.Text);
                dimensions = Int32.Parse(text_dimensions.Text);

                ngons = new List <VisualNgon>((int)sampleSize);
                for (long i = sampleSize; i > 0; i--)
                {
                    VisualNgon ngon = new VisualNgon(Program.generateRandomNgon(dimensions));

                    ngons.Add(ngon);
                    double width = 300, height = 200;
                    Canvas box = new Canvas()
                    {
                        Height = height, Width = width
                    };
                    ngon.draw(box, width, height);

                    if (ngon.ngonModel.Type == NgonType.Convex)
                    {
                        panel_convex.Items.Add(box);
                    }
                    if (ngon.ngonModel.Type == NgonType.Reflex)
                    {
                        panel_reflex.Items.Add(box);
                    }
                    if (ngon.ngonModel.Type == NgonType.Self_Intersecting)
                    {
                        panel_selfintersecting.Items.Add(box);
                    }
                }
            }
            catch (Exception)
            {
                text_sampleSize.Text = "";
                text_dimensions.Text = "";
            }
        }