private void BtnSolveClick(object sender, RoutedEventArgs e)
        {
            List<Solver.Colorizer> colors = GenerateColorPalette();
            var slvr = new Solver(_charges, _surfaces, _imageHieght, _imageWidth);

            slvr.SolveIt();

            SolverOutput solvedutput;
            if (chkBoxDrawLines.IsChecked != null && chkBoxDrawLines.IsChecked == true)
            {
                BitmapSource outputData = slvr.CustomeColorizerSolverWithLines(colors,
                                                                               colorPickerLineColors.SelectedColor);

                solvedutput = new SolverOutput(outputData, colors, _charges);
            }
            else
            {
                BitmapSource outputData = slvr.CustomeColorizerSolver(colors);

                solvedutput = new SolverOutput(outputData, colors, _charges);
            }

            solvedutput.lblMarker.Visibility = Visibility.Hidden;
            solvedutput.recMarker.Visibility = Visibility.Hidden;
            solvedutput.gridMarker.Visibility = Visibility.Hidden;

            solvedutput.Show();
            Close();
        }
        private void BtnSolveClick(object sender, RoutedEventArgs e)
        {
            bool allowMark = false;
            allowMark = chkMarker.IsChecked != null && (bool) chkMarker.IsChecked;

            int clampvalue = 100;
            if (integerUDClamp.Value.HasValue)
            {
                clampvalue = integerUDClamp.Value.Value;
            }

            var slvr = new Solver(_charges, _surfaces, _imageHieght, _imageWidth);

            slvr.SolveIt();

            if (integerUDThreshold.Value == null)
                integerUDThreshold.Value = 50;

            SolverOutput solvedutput;
            if (chkBoxDrawLines.IsChecked != null && chkBoxDrawLines.IsChecked == true)
            {
                BitmapSource outputData = slvr.GetImageRgb24WithLines(colorPickerMaxColor.SelectedColor,
                                                                      colorPickerMinColor.SelectedColor, clampvalue,
                                                                      allowMark, integerUDThreshold.Value.Value,
                                                                      colorPickerThreshold.SelectedColor);

                //solvedutput = new SolverOutput(outputData, colorPickerMinColor.SelectedColor,
                //                               colorPickerMaxColor.SelectedColor,
                //                               _charges);
            }
            else
            {
                BitmapSource outputData = slvr.GetImageRgb24(colorPickerMaxColor.SelectedColor,
                                                             colorPickerMinColor.SelectedColor, clampvalue,
                                                             allowMark, integerUDThreshold.Value.Value,
                                                             colorPickerThreshold.SelectedColor);

                //solvedutput = new SolverOutput(outputData, colorPickerMinColor.SelectedColor,
                //                               colorPickerMaxColor.SelectedColor,
                //                               _charges);
            }

            if (allowMark)
            {
                //solvedutput.lblMarker.Visibility = Visibility.Visible;
                //solvedutput.recMarker.Visibility = Visibility.Visible;
                //solvedutput.gridMarker.Visibility = Visibility.Visible;
                //solvedutput.recMarker.Fill = new SolidColorBrush(colorPickerThreshold.SelectedColor);
                //solvedutput.lblMarker.Content = "This color is a Marker for the points which had Value : " +
                //                                integerUDThreshold.Value.Value;
            }
            else
            {
                //solvedutput.lblMarker.Visibility = Visibility.Hidden;
                //solvedutput.recMarker.Visibility = Visibility.Hidden;
                //solvedutput.gridMarker.Visibility = Visibility.Hidden;
            }

            //solvedutput.Show();
            Close();
        }
示例#3
0
        private void GenerateGray8BitmapClick(object sender, RoutedEventArgs e)
        {
            var dialog = new SaveFileDialog {Title = "Choose location ...", Filter = "JPEG Image File (*.jpg)|*.jpg"};

            List<Surface> surfacelist =
                gridField.Children.Cast<object>().Where(uiElement => uiElement.GetType() == typeof (Surface)).Cast
                    <Surface>().ToList();

            bool? result = dialog.ShowDialog();
            if (result == true)
            {
                var slvr = new Solver(_charges, surfacelist, (int) gridField.Height, (int) gridField.Width);

                slvr.SolveIt();
                slvr.DrawGray8Image(dialog.FileName);

                if (
                    MessageBox.Show(
                        "Image file has been generated and saved Successfully!" + Environment.NewLine +
                        "Do you want to open it now ?", "Write file Completed", MessageBoxButton.YesNo) ==
                    MessageBoxResult.Yes)
                {
                    Process.Start(dialog.FileName);
                }
            }
        }
示例#4
0
        private void BtnQuickSolveClick(object sender, RoutedEventArgs e)
        {
            List<Surface> surfacelist =
                gridField.Children.Cast<object>().Where(uiElement => uiElement.GetType() == typeof (Surface)).Cast
                    <Surface>().ToList();
            var slvr = new Solver(_charges, surfacelist, (int) gridField.Height, (int) gridField.Width);

            slvr.SolveIt();
            var imagebrush = new ImageBrush();
            //imagebrush.ImageSource = slvr.GetImageRgb24();

            var ListofColors = new List<Solver.Colorizer>();

            var color00 = new Solver.Colorizer();
            var color0 = new Solver.Colorizer();
            var color1 = new Solver.Colorizer();
            var color2 = new Solver.Colorizer();
            var color3 = new Solver.Colorizer();
            var color4 = new Solver.Colorizer();
            var color5 = new Solver.Colorizer();

            color00.Color = Colors.DarkRed;
            color00.Min = 1001;
            color00.Max = int.MaxValue;

            color0.Color = Colors.DarkRed;
            color0.Min = 400;
            color0.Max = 1000;

            color1.Color = Colors.Red;
            color1.Min = 100;
            color1.Max = 399;

            color2.Color = Colors.OrangeRed;
            color2.Min = 60;
            color2.Max = 99;

            color3.Color = Colors.Yellow;
            color3.Min = 30;
            color3.Max = 59;

            color4.Color = Colors.YellowGreen;
            color4.Min = 10;
            color4.Max = 29;

            color5.Color = Colors.Black;
            color5.Min = 0;
            color5.Max = 9;

            ListofColors.Add(color00);
            ListofColors.Add(color0);
            ListofColors.Add(color1);
            ListofColors.Add(color2);
            ListofColors.Add(color3);
            ListofColors.Add(color4);
            ListofColors.Add(color5);

            ListofColors.Add(new Solver.Colorizer());
            imagebrush.ImageSource = slvr.CustomeColorizerSolver(ListofColors);
            gridField.Background = imagebrush;
        }
示例#5
0
        private void BtnQuckDrawFieldLinesClick(object sender, RoutedEventArgs e)
        {
            List<Surface> surfacelist =
                gridField.Children.Cast<object>().Where(uiElement => uiElement.GetType() == typeof (Surface)).Cast
                    <Surface>().ToList();
            var slvr = new Solver(_charges, surfacelist, (int) gridField.Height, (int) gridField.Width);

            slvr.SolveIt();
            var imagebrush = new ImageBrush();
            imagebrush.ImageSource = slvr.GenerateFieldLines(true);
            gridField.Background = imagebrush;
        }
示例#6
0
        public static Solver.Colorizer ConvertToColorizer(Solver.ColorRange data)
        {
            var returnItem = new Solver.Colorizer {Min = (int) data.Min, Max = (int) data.Max, Color = data.Color};

            return returnItem;
        }
示例#7
0
        public static Solver.Colorizer GetPrevColor(List<Solver.Colorizer> listOfColors, Solver.Colorizer afterThis)
        {
            Solver.Colorizer returnValue = afterThis;

            foreach (Solver.Colorizer colorizer in listOfColors)
            {
                if (IsInBetween(afterThis.Min - 1, colorizer.Min, colorizer.Max))
                {
                    returnValue = colorizer;
                }
            }
            return returnValue;
        }
        private void BtnDrawClick(object sender, RoutedEventArgs e)
        {
            if (cmbFloat.SelectedIndex == -1 || cmbStatic.SelectedIndex == -1)
            {
                MessageBox.Show("Fill all fields!!");
                return;
            }

            int duration = 10;
            var startloc = new Point((double) integerUDStartX.Value, (double) integerUDStartY.Value);

            if (integerUDDuration.Value != null)
            {
                duration = (int) integerUDDuration.Value;
            }

            var slver = new Solver(_charges, _surfaces, ImageHieght, ImageWidth);
            slver.SolveIt();

            FreeCharge freeCharge = null;
            PositiveCharge positiveCharge = null;
            NegativeCharge negativeCharge = null;

            IEnumerable<UIElement> allitems = MainWindow.Instance.GetListOfItems();
            foreach (UIElement chargeitem in allitems)
            {
                if (chargeitem.GetType() == typeof (FreeCharge))
                {
                    string name = ((FreeCharge) chargeitem).MyCharge.Name;
                    if ((string) cmbFloat.SelectedValue == name)
                    {
                        freeCharge = ((FreeCharge) chargeitem);
                    }
                }
                else if (chargeitem.GetType() == typeof (PositiveCharge))
                {
                    string name = ((PositiveCharge) chargeitem).MyCharge.Name;
                    if ((string) cmbStatic.SelectedValue == name)
                    {
                        positiveCharge = ((PositiveCharge) chargeitem);
                    }
                }
                else if (chargeitem.GetType() == typeof (NegativeCharge))
                {
                    string name = ((NegativeCharge) chargeitem).MyCharge.Name;
                    if ((string) cmbStatic.SelectedValue == name)
                    {
                        negativeCharge = ((NegativeCharge) chargeitem);
                    }
                }
            }

            if (freeCharge != null)
            {
                var Orgins = new Point();
                if (positiveCharge != null)
                {
                    Orgins = new Point(positiveCharge.RenderTransform.Value.OffsetX,
                                       positiveCharge.RenderTransform.Value.OffsetY);
                }
                else if (negativeCharge != null)
                {
                    Orgins = new Point(negativeCharge.RenderTransform.Value.OffsetX,
                                       negativeCharge.RenderTransform.Value.OffsetY);
                }

                var returnedData = (List<Point>) slver.ChargeChargeDistance(freeCharge, Orgins, duration, startloc);

                var graphOutput = new GraphWindow("Distance", "Time");
                graphOutput.DrawThis(returnedData, Brushes.DarkRed, Brushes.DarkMagenta, "Distance");

                if (returnedData != null)
                {
                    IEnumerable<Point> velcocity = Helper.CalculateVelocity(returnedData);
                    graphOutput.DrawThis(velcocity, Brushes.DodgerBlue, Brushes.LightSkyBlue, "Velocity");
                }

                graphOutput.Show();
            }

            Close();
        }