Exemplo n.º 1
0
        static void Main(string[] args)
        {
            BinaryFormatter bFormatter = new BinaryFormatter();

            FileStream inPut = new FileStream("C:\\Users\\DEVELOPER4\\Desktop\\savefile\\lolblackjagged.yup", FileMode.Open, FileAccess.Read);
            States state = new States();

            state.gridSize = (Size)bFormatter.Deserialize(inPut);

            state.innerRectColor = (Color[][])bFormatter.Deserialize(inPut);
            state.innerShapeColor = (Color[][])bFormatter.Deserialize(inPut);
            state.rectColor = (Color[][])bFormatter.Deserialize(inPut);
            state.shapeColor = (Color[][])bFormatter.Deserialize(inPut);
            state.types = (int[][])bFormatter.Deserialize(inPut);
            state.rotation = (int[][])bFormatter.Deserialize(inPut);
            state.values = (int[][])bFormatter.Deserialize(inPut);
            state.circleGrid = (Rectangle[][])bFormatter.Deserialize(inPut);
            state.rectangleGrid = (Rectangle[][])bFormatter.Deserialize(inPut);
            state.lvls = Converter.ToJagged(new int[state.gridSize.Height,state.gridSize.Width]);
            state.owned = new List<Location>[4];

            for (int i = 0; i < state.owned.Length; i++) {
                state.owned[i] = new List<Location>();
            }

            inPut.Close();

            Console.WriteLine("Number of Players?");
            state.numOfPlayers = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Total Value?");
            state.totalValue = Convert.ToInt32(Console.ReadLine());

            //ICommandBoardService proxy;
            using (ServiceHost host = new ServiceHost(typeof(CommandBoardServiceLibrary.CommandBoardService)))
            {
                NetTcpBinding ntb = new NetTcpBinding();
                NetTcpSecurity nts = new NetTcpSecurity();
                nts.Mode = SecurityMode.None;
                ntb.Security = nts;

                host.AddServiceEndpoint(typeof(
                    CommandBoardServiceLibrary.ICommandBoardService),
                    new NetTcpBinding(),"net.tcp://localhost:9000/commandboard");
                host.Open();

                ICommandBoardService proxy = ChannelFactory<ICommandBoardService>.CreateChannel(
                             new NetTcpBinding(),
                            new EndpointAddress("net.tcp://localhost:9000/commandboard"));

                proxy.setState(state);

                Console.WriteLine("Good to go");
                Console.ReadLine();

            }
        }
Exemplo n.º 2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                BinaryFormatter bFormatter = new BinaryFormatter();

                FileStream inPut = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
                States state = new States();

                state.gridSize = (Size)bFormatter.Deserialize(inPut);

                state.innerRectColor = (Color[][])bFormatter.Deserialize(inPut);
                state.innerShapeColor = (Color[][])bFormatter.Deserialize(inPut);
                state.rectColor = (Color[][])bFormatter.Deserialize(inPut);
                state.shapeColor = (Color[][])bFormatter.Deserialize(inPut);
                state.types = (int[][])bFormatter.Deserialize(inPut);
                state.rotation = (int[][])bFormatter.Deserialize(inPut);
                state.values = (int[][])bFormatter.Deserialize(inPut);

                inPut.Close();

                Form2 players1 = new Form2();
                players1.ShowDialog();
                state.numOfPlayers = players1.numberOfPlayer;
                state.totalValue = players1.totalValue;

                //ICommandBoardService proxy;
                using (ServiceHost host = new ServiceHost(typeof(CommandBoardServiceLibrary.CommandBoardService)))
                {
                    host.AddServiceEndpoint(typeof(
                        CommandBoardServiceLibrary.ICommandBoardService),
                        new NetTcpBinding(),
                        "net.tcp://localhost:9000/commandboard");
                    host.Open();

                  //  ICommandBoardService proxy = ChannelFactory<ICommandBoardService>.CreateChannel(
                  //               new NetTcpBinding(),
                  //              new EndpointAddress(
                  //              "net.tcp://localhost:9001/CommandBoardEndPoint"));

                  //  proxy.setConnected(0);
                  ////  proxy.setState(state);
                  //  Label l = new Label();
                  //  l.Text = proxy.setConnected(0);
                  //  listBox1.Controls.Add(l);
                    Console.ReadLine();

                }

            }
        }
Exemplo n.º 3
0
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            remoteFactory = new ChannelFactory<ICommandBoardService>("CommandBoard");
            proxy = remoteFactory.CreateChannel();

            state = proxy.getState();
            int row = state.gridSize.Height;
            int col = state.gridSize.Width;
            visible = 1;

            SuspendLayout();

            if ((col * 50) + col > flowLayoutPanel1.Width) {
                flowLayoutPanel1.Width = (col * 50) + col;
                panel2.Location = new Point((col * 50) + col + 50, panel2.Location.Y);
                columnPanel.Width = (col * 50) + col;

                //Just to fill the columnPanel
                for (int i = 0; i < col; i++) {
                    Label l = new Label();
                    l.AutoSize = true;
                    l.Font = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
                    l.Location = new Point(18 + 51 * i, 1);
                    l.Name = "label" + i;
                    l.Size = new Size(16, 16);
                    l.TabIndex = 17;
                    l.Text = i.ToString();

                    columnPanel.Controls.Add(l);
                }
            }

            if ((row * 50) + row > flowLayoutPanel1.Height) {
                flowLayoutPanel1.Height = (row * 50) + row;
                rowPanel.Height = (row * 50) + row;
                cardPanel.Location = new Point(cardPanel.Location.X, (row * 50) + row + 50);
                turnLabel.Location = new Point(turnLabel.Location.X, (row * 50) + row + 50);
                personsTurn.Location = new Point(personsTurn.Location.X, (row * 50) + row + 117);

                for (int i = 0; i < row; i++) {
                    Label l = new Label();
                    l.AutoSize = true;
                    l.Font = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
                    l.Location = new Point(4, 18 + 51 * i);
                    l.Name = "label" + i;
                    l.Size = new Size(18, 16);
                    l.TabIndex = 18;
                    l.Text = ((char)((int)'A' + i)).ToString();

                    rowPanel.Controls.Add(l);
                }
            }

            this.Size = new Size(flowLayoutPanel1.Width + playerPanels.Size.Width + propertiesPanel.Width + selectionBox.Width + 150, flowLayoutPanel1.Height + cardPanel.Size.Height + 100);

            CreatePlayers();

            Panel[] playerPanel = new Panel[state.numOfPlayers];
            playerPanels.Height = state.numOfPlayers * 97 + (state.numOfPlayers + 2) * 2 + 2 - (4 - state.numOfPlayers);

            for (int i = 0; i < state.numOfPlayers; i++) {
                playerPanel[i] = setUpPanels(i + 1);
                playerPanel[i].Paint += new System.Windows.Forms.PaintEventHandler(playerPanel_paint);
                playerPanels.Controls.Add(playerPanel[i]);
            }

            turnLabel.Visible = true;
            personsTurn.Visible = true;

            turnLabel.Text = "Turn " + turns;
            personsTurn.Text = "Player 1's turn";

            flowLayoutPanel1_Paint(new Object(), new PaintEventArgs(flowLayoutPanel1.CreateGraphics(), new Rectangle()));

            for (int i = 0; i < 5; i++) {
                cardPanel.Controls.Add(CreateCard(i + 1));
            }
            ResumeLayout();
            MessageBox.Show(proxy.setConnected(1));
            playerNumber = proxy.getConnected();
        }
Exemplo n.º 4
0
 private void updateButton_Click(object sender, EventArgs e)
 {
     state = proxy.getState();
     for (int i = 0; i < state.numOfPlayers; i++) {
         players[i] = proxy.getPlayer(i);
     }
     turns = proxy.getTurns();
 }
 public void setState(States s)
 {
     state = s;
 }