Ejemplo n.º 1
0
 public InitMatrixCommand(IMatrix matrix, IDrawer drawer, ADecorator decorator, Graphics graphics)
 {
     matrix1    = matrix;
     drawer1    = drawer;
     decorator1 = decorator;
     graphics1  = graphics;
 }
Ejemplo n.º 2
0
        private void bt_SpareMatr_Click(object sender, EventArgs e)
        {
            graphics.Clear(BackColor);
            graphics = pictureBox1.CreateGraphics();
            WinFormDrawer drawer1 = new WinFormDrawer(graphics, new Pen(Color.Red));

            drawer1.Frame = checkBox1.Checked;
            drawer        = drawer1;
            if ((last_f == "") || !(matrix.GetType() == typeof(SparseMatrix)))
            {
                matrix = new SparseMatrix(Convert.ToInt32(tb_Col.Text), Convert.ToInt32(tb_Row.Text));
                InitiatorMatrix.RandomMatr(matrix, Convert.ToInt32(tb_NoNull.Text), Convert.ToInt32(tb_MaxVal.Text));
                renumDecorator = new RenumDecorator(matrix);
                Dec            = renumDecorator;
                ICommand command = new InitMatrixCommand(matrix, drawer, Dec, graphics);
                command.Execute(ref matrix, ref drawer, ref Dec, ref graphics);
                position++;
                commands.Add(command);
                inits_comm_indx.Add(position);
            }
            else if (matrix.GetType() == typeof(SparseMatrix))
            {
                renumDecorator.Draw(drawer);
            }
            last_f = "bt_SpareMatr";
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            A aClass = new A();

            B bClass = new B();

            C cClass = new C(); //Subtype of A (which implements interface1)


            TakesInterface test1 = new TakesInterface(aClass);

            TakesInterface test2 = new TakesInterface(bClass);

            TakesInterface test3 = new TakesInterface(cClass);

            ADecorator adecorator = new ADecorator(aClass);

            Console.WriteLine(test1.printInterface1());

            Console.WriteLine(test2.printInterface1());

            Console.WriteLine(test3.printInterface1());

            Console.WriteLine(adecorator.test1());
        }
Ejemplo n.º 4
0
 public void Execute(ref IMatrix matrix, ref IDrawer drawer, ref ADecorator decorator, ref Graphics graphics)
 {
     matrix    = matrix1;
     drawer    = drawer1;
     decorator = decorator1;
     graphics  = graphics1;
     matrix.Draw(drawer);
 }
Ejemplo n.º 5
0
        public void Execute(ref IMatrix matrix, ref IDrawer drawer, ref ADecorator decorator, ref Graphics graphics)
        {
            if (matrix is HGMatrix.HGMatrix)
            {
                gMatrix = matrix as HGMatrix.HGMatrix;
                gMatrix.SetMatrix(matrix1);
                matrix = gMatrix;
            }

            matrix.Draw(drawer);
        }
Ejemplo n.º 6
0
        private void bt_Restore_Click(object sender, EventArgs e)
        {
            graphics.Clear(BackColor);
            graphics = pictureBox1.CreateGraphics();
            renumDecorator.Cancel();
            ICommand command = new CancelRenum();

            Dec = renumDecorator;
            command.Execute(ref matrix, ref drawer, ref Dec, ref graphics);
            commands.Add(command);
            position++;
            //SwitchPrev(sender, e);
        }
Ejemplo n.º 7
0
        private void bt_Renum_Click(object sender, EventArgs e)
        {
            graphics.Clear(BackColor);
            graphics = pictureBox1.CreateGraphics();
            Random random = new Random();

            renumDecorator.RenumThis(random.Next(0, renumDecorator.Row_count), random.Next(0, renumDecorator.Row_count), random.Next(0, renumDecorator.Column_count), random.Next(0, renumDecorator.Column_count));
            Dec = renumDecorator;
            ICommand command = new RenumCommand(renumDecorator);

            command.Execute(ref matrix, ref drawer, ref Dec, ref graphics);
            commands.Add(command);
            position++;
            //SwitchPrev(sender, e);
        }
Ejemplo n.º 8
0
 public void Execute(ref IMatrix matrix, ref IDrawer drawer, ref ADecorator decorator, ref Graphics graphics)
 {
     gMatrix = new HGMatrix.HGMatrix();
     matrix  = gMatrix;
 }
Ejemplo n.º 9
0
 public void Execute(ref IMatrix matrix, ref IDrawer drawer, ref ADecorator decorator, ref Graphics graphics)
 {
     decorator.Cancel();
     decorator.Draw(drawer);
 }
Ejemplo n.º 10
0
 public RenumCommand(RenumDecorator renum)
 {
     decorator1 = renum;
 }