public override IPopup GetResult()
        {
            int extraMargin = 5;

            SuperCustomMatrixPopup result = new SuperCustomMatrixPopup
            {
                form = new Form(),
                //Histogram = Histogram_Builder.GetResult(Color.White),
                choice       = new ComboBox(),
                matrixpanel1 = MatrixPanel_Builder.GetResult(3),
                matrixpanel2 = MatrixPanel_Builder.GetResult(5),
                matrixpanel3 = MatrixPanel_Builder.GetResult(7),
                Ok_Button    = new Button()
                {
                    Text = "ok"
                },
                Cancel_Button = new Button()
                {
                    Text = "cancel"
                },
                Aply_Button = new Button()
                {
                    Text = "apply"
                },

                value = new TrackBar()
            };

            // ---------------------------------------------
            result.choice.Items.AddRange(new string[] {
                "3x3",
                "5x5",
                "7x7"
            });

            result.choice.Top  = 3 * extraMargin;
            result.choice.Left = 3 * extraMargin;

            result.matrixpanel1.Top = 3 * extraMargin + result.choice.Height;
            result.matrixpanel2.Top = 3 * extraMargin + result.choice.Height;
            result.matrixpanel3.Top = 3 * extraMargin + result.choice.Height;

            result.matrixpanel1.Left = extraMargin * 3;
            result.matrixpanel2.Left = extraMargin * 3;
            result.matrixpanel3.Left = extraMargin * 3;

            result.matrixpanel1.Visible = false;
            result.matrixpanel2.Visible = false;
            result.matrixpanel3.Visible = false;



            FlowLayoutPanel ButtonContainer = new FlowLayoutPanel()
            {
                Dock          = DockStyle.Bottom,
                Height        = result.Ok_Button.Height + extraMargin,
                FlowDirection = FlowDirection.RightToLeft,
                WrapContents  = false
            };

            //result.Histogram.Top = extraMargin;
            //result.Histogram.Left = extraMargin;
            result.value.Left = extraMargin;

            result.form.FormClosing += result.Form_FormClosing;

            result.Ok_Button.Click     += result.Ok_Button_Click;
            result.Cancel_Button.Click += result.Cancel_Button_Click;
            result.Aply_Button.Click   += result.Aply_Button_Click;

            result.value.Height = ButtonContainer.Height / 2;
            result.value.Width  = result.matrixpanel3.Left + result.matrixpanel3.Width - extraMargin * 6;
            result.value.Top    = result.matrixpanel3.Top + result.matrixpanel3.Height + extraMargin;

            result.value.Maximum = 2;
            result.value.Value   = 1;
            result.value.Minimum = 0;

            result.choice.SelectedValueChanged += result.Value_ValueChanged;

            foreach (var row in result.matrixpanel1.panels)
            {
                foreach (var sth in row)
                {
                    sth.TextChanged += result.Value_ValueChanged;
                }
            }
            foreach (var row in result.matrixpanel2.panels)
            {
                foreach (var sth in row)
                {
                    sth.TextChanged += result.Value_ValueChanged;
                }
            }
            foreach (var row in result.matrixpanel3.panels)
            {
                foreach (var sth in row)
                {
                    sth.TextChanged += result.Value_ValueChanged;
                }
            }

            result.form.Height = result.value.Width / 2
                                 + ButtonContainer.Height
                                 + 64;
            result.form.Width = result.value.Width
                                //extraMargin * 3
                                //+ result.matrixpanel1.Width
                                + extraMargin * 3;

            //result.form.Controls.Add(result.Histogram);
            result.form.Controls.Add(result.choice);

            result.form.Controls.Add(result.matrixpanel1);
            result.form.Controls.Add(result.matrixpanel2);
            result.form.Controls.Add(result.matrixpanel3);
            //result.form.Controls.Add(result.value);

            result.form.Controls.Add(ButtonContainer);
            ButtonContainer.Controls.Add(result.Aply_Button);
            ButtonContainer.Controls.Add(result.Cancel_Button);
            ButtonContainer.Controls.Add(result.Ok_Button);
            //result.form.Show();

            return(result);
        }
        public override IPopup GetResult()
        {
            int extraMargin = 5;

            CustomMatrixPopup result = new CustomMatrixPopup
            {
                form = new Form(),
                //Histogram = Histogram_Builder.GetResult(Color.White),
                matrixpanel1 = MatrixPanel_Builder.GetResult(3),
                matrixpanel2 = MatrixPanel_Builder.GetResult(3),
                matrixpanel3 = MatrixPanel_Builder.GetResult(3),
                Ok_Button    = new Button()
                {
                    Text = "ok"
                },
                Cancel_Button = new Button()
                {
                    Text = "cancel"
                },
                Aply_Button = new Button()
                {
                    Text = "apply"
                },

                value = new TrackBar()
            };


            result.matrixpanel1.DisablePanels();
            result.matrixpanel2.DisablePanels();
            result.matrixpanel3.DisablePanels();

            // ---------------------------------------------

            result.matrixpanel1.panels[0][0].Text = "0";
            result.matrixpanel1.panels[0][1].Text = "-1";
            result.matrixpanel1.panels[0][2].Text = "0";

            result.matrixpanel1.panels[1][0].Text = "-1";
            result.matrixpanel1.panels[1][1].Text = "4";
            result.matrixpanel1.panels[1][2].Text = "-1";

            result.matrixpanel1.panels[2][0].Text = "0";
            result.matrixpanel1.panels[2][1].Text = "-1";
            result.matrixpanel1.panels[2][2].Text = "0";

            // ---------------------------------------------

            result.matrixpanel2.panels[0][0].Text = "-1";
            result.matrixpanel2.panels[0][1].Text = "-1";
            result.matrixpanel2.panels[0][2].Text = "-1";

            result.matrixpanel2.panels[1][0].Text = "-1";
            result.matrixpanel2.panels[1][1].Text = "8";
            result.matrixpanel2.panels[1][2].Text = "-1";

            result.matrixpanel2.panels[2][0].Text = "-1";
            result.matrixpanel2.panels[2][1].Text = "-1";
            result.matrixpanel2.panels[2][2].Text = "-1";

            // ---------------------------------------------

            result.matrixpanel3.panels[0][0].Text = "1";
            result.matrixpanel3.panels[0][1].Text = "-2";
            result.matrixpanel3.panels[0][2].Text = "1";

            result.matrixpanel3.panels[1][0].Text = "-2";
            result.matrixpanel3.panels[1][1].Text = "4";
            result.matrixpanel3.panels[1][2].Text = "-2";

            result.matrixpanel3.panels[2][0].Text = "1";
            result.matrixpanel3.panels[2][1].Text = "-2";
            result.matrixpanel3.panels[2][2].Text = "1";

            // ---------------------------------------------

            result.matrixpanel1.Top = extraMargin;
            result.matrixpanel2.Top = extraMargin;
            result.matrixpanel3.Top = extraMargin;

            result.matrixpanel1.Left = extraMargin;
            result.matrixpanel2.Left = result.matrixpanel1.Left + result.matrixpanel1.Width + extraMargin;
            result.matrixpanel3.Left = result.matrixpanel2.Left + result.matrixpanel2.Width + extraMargin;



            /*
             * float[,] k;
             *
             * k = new float[,] { { 0, -1,  0},
             *                  {-1,  4, -1},
             *                  { 0, -1,  0} };
             *
             * foreach (var v in k)
             *  Console.WriteLine(v);
             */



            FlowLayoutPanel ButtonContainer = new FlowLayoutPanel()
            {
                Dock          = DockStyle.Bottom,
                Height        = result.Ok_Button.Height + extraMargin,
                FlowDirection = FlowDirection.RightToLeft,
                WrapContents  = false
            };

            //result.Histogram.Top = extraMargin;
            //result.Histogram.Left = extraMargin;
            result.value.Left = extraMargin;

            result.form.FormClosing += result.Form_FormClosing;

            result.Ok_Button.Click     += result.Ok_Button_Click;
            result.Cancel_Button.Click += result.Cancel_Button_Click;
            result.Aply_Button.Click   += result.Aply_Button_Click;

            result.value.Height = ButtonContainer.Height / 2;
            result.value.Width  = result.matrixpanel3.Left + result.matrixpanel3.Width - extraMargin * 6;
            result.value.Top    = result.matrixpanel3.Top + result.matrixpanel3.Height + extraMargin;

            result.value.Maximum = 2;
            result.value.Value   = 1;
            result.value.Minimum = 0;

            result.value.ValueChanged += result.Value_ValueChanged;

            result.form.Height = result.matrixpanel1.Height
                                 + ButtonContainer.Height
                                 + result.value.Height
                                 + 64;
            result.form.Width = result.matrixpanel1.Width * 3
                                + extraMargin * 3;

            //result.form.Controls.Add(result.Histogram);
            result.form.Controls.Add(result.matrixpanel1);
            result.form.Controls.Add(result.matrixpanel2);
            result.form.Controls.Add(result.matrixpanel3);
            result.form.Controls.Add(result.value);

            result.form.Controls.Add(ButtonContainer);
            ButtonContainer.Controls.Add(result.Aply_Button);
            ButtonContainer.Controls.Add(result.Cancel_Button);
            ButtonContainer.Controls.Add(result.Ok_Button);
            //result.form.Show();

            return(result);
        }