AnimatorClient.AnimatorClient.DeleteAnimation C# (CSharp) Method

DeleteAnimation() public method

public DeleteAnimation ( int index ) : void
index int
return void
        public void DeleteAnimation(int index)
        {
            TcpClient tcpClient = new TcpClient();

            try
            {
                tcpClient.Connect(this.ServerAddress, this.ServerPort);

                CommandHandler.SendCommand(tcpClient.GetStream(), Command.DeleteAnimation);

                tcpClient.GetStream().WriteByte(Convert.ToByte(index));

                tcpClient.Close();
            }
            catch (SocketException se)
            {
                tcpClient.Close();
                throw new InvalidOperationException("Could not delete animation", se);
            }
        }

Usage Example

Example #1
0
        public void TestDeleteAnimation()
        {
            AnimationServer server = new AnimationServer();

            server.Port = 1334;

            AnimatorClient.AnimatorClient client = new AnimatorClient.AnimatorClient();

            client.ServerAddress = "localhost";
            client.ServerPort    = 1334;

            server.IsListening = true;

            Animation testAnimation = new Animation(10, 10);

            testAnimation.Name = "Test Animation 1";

            client.UploadAnimation(testAnimation);
            testAnimation.Name = "Test Animation 2";
            client.UploadAnimation(testAnimation);

            // while (server.Status != ServerStatus.Listening) ;

            Assert.AreEqual(2, server.Animations.Count);

            client.DeleteAnimation(0);

            Assert.AreEqual(1, server.Animations.Count);
            Assert.AreEqual("Test Animation 2", server.Animations[0].Name);

            server.IsListening = false;
        }
All Usage Examples Of AnimatorClient.AnimatorClient::DeleteAnimation