home *** CD-ROM | disk | FTP | other *** search
- //==========================================================================
- // File: MyRemoteControl.cs
- //
- // Summary: This file implements client side of NGWS Remoting.
- // It illustrates COM+ Remoting
- //
- // Classes: MyRemoteControl
- //
- //--------------------------------------------------------------------------
- // This file is part of the Microsoft NGWS Samples.
- //
- // Copyright (C) 1999 Microsoft Corporation. All rights reserved.
- //==========================================================================
-
- using System;
- using System.IO;
- using System.Runtime.Remoting;
- using Homenet;
- using System.Threading;
-
- public class MyRemoteControl
- {
-
- public static ManualResetEvent Done = new ManualResetEvent(false);
-
- public static void Main(String[] args)
- {
- int ret = Initialize(args);
- Console.WriteLine("MyRemoteControl Sample\n");
-
- if (ret != -1)
- {
- RemoteControl remoteControl = new RemoteControl();
- remoteControl.Scenario2();
-
- NullRemoteControl(out remoteControl);
-
- Console.WriteLine("\nEnd\n");
- }
- }
-
- private static void NullRemoteControl(out RemoteControl rc)
- {
- rc = null;
- }
-
-
-
- //---------------------------------------------------
- public static int scenario = 1;
-
- public static int Initialize(String[] args)
- {
- if (args.Length == 0)
- {
- RemotingServices.ConfigureRemoting("MyRemoteControl.cfg");
- return 0;
- }
-
-
- for (int i=0;i<args.Length;i++)
- {
- if (
- String.Compare(args[i],"HELP", true) == 0 ||
- String.Compare(args[i],"?", true) == 0 ||
- String.Compare(args[i],"/h", true) == 0 ||
- String.Compare(args[i],"-h", true) == 0 ||
- String.Compare(args[i],"-?", true) == 0 ||
- String.Compare(args[i],"/?", true) == 0
- )
- {
- Usage();
- return -1;
- }
-
- if (args[i].CompareTo("-cfg")==0)
- {
- RemotingServices.ConfigureRemoting(args[i+1]);
- }
- }
-
- return 0;
- }
-
- public static void Usage()
- {
- Console.WriteLine("Usage: MyRemoteControl [-cfg Configfile.cfg]\n");
- Console.WriteLine("Examples : MyRemoteControl");
- Console.WriteLine("Examples : MyRemoteControl-cfg MyRemoteControl.cfg");
- }
- }
-
- //public class RemoteControl : MarshalByRefObject, IMediaStatus
- public class RemoteControl : BaseRemoteControl
- {
-
- public bool Scenario0()
- {
- bool ret=true;
- Console.WriteLine("Scenario 1");
- Console.WriteLine("new VCR()");
- VCR vcr = new VCR();
-
- String title = "clock.avi";
- Console.WriteLine("Calling VCR.Play " + title);
- ret = vcr.Play(title);
-
- return ret;
- }
-
-
- public bool Scenario1()
- {
- bool ret=true;
- Console.WriteLine("Scenario 1");
- Console.WriteLine("new VCR()");
- VCR vcr = new VCR();
-
- String title = "clock.avi";
- Console.WriteLine("Calling VCR.PlayWithStatus " + title);
- ret = vcr.PlayWithStatus(title, this);
-
- return ret;
- }
-
-
- //------------------------------------------------------
-
- public bool Scenario2()
- {
- bool ret=true;
- Console.WriteLine("Scenario 2");
- Console.WriteLine("new VCR()");
- VCR vcr = new VCR();
-
- String title = "file://C:/winnt/clock.avi";
-
- String keyState = "";
- while (String.Compare(keyState,"0", true) != 0)
- {
- Console.WriteLine("Press PT=Play Title, P=Play, A=Pause, S=Stop,0=Exit");
- keyState = Console.ReadLine();
-
- Console.WriteLine("Pressed: " + keyState);
-
- if (String.Compare(keyState,"PT", true) == 0)
- {
- /*
- Console.WriteLine("Calling VCR.PlayWithStatus - MBV with embedded MBR" + title);
- MediaRequest mediaRequest = new MediaRequest(title, this);
- ret = vcr.PlayWithStatus(mediaRequest);
- */
- ret = vcr.Play(title);
- }
-
- if (String.Compare(keyState,"P", true) == 0)
- vcr.PlaySimple();
-
- if (String.Compare(keyState,"A", true) == 0)
- vcr.Pause();
-
- if (String.Compare(keyState,"S", true) == 0)
- vcr.Stop();
- }
-
- return ret;
- }
-
- public bool Scenario3()
- {
- bool ret=true;
- Console.WriteLine("Scenario 3");
- Console.WriteLine("new VCR()");
- VCR vcr = new VCR();
-
- String title = "clock.avi";
- Console.WriteLine("Calling VCR.PlayWithStatus - delegate " + title);
-
- StatusUpdateCallback callback = new StatusUpdateCallback(this.StatusUpdate);
- ret = vcr.PlayWithStatus(title, callback);
- return ret;
- }
-
- public override bool StatusUpdate(String title)
- {
- Console.WriteLine("StatusUpdate: " + title);
- return true;
- }
-
- public bool Scenario4()
- {
- bool ret=true;
- Console.WriteLine("new VCR()");
- VCR vcr = new VCR();
-
- String title = "clock.avi";
- Console.WriteLine("Calling VCR.Play " + title);
- ret = vcr.Play(title);
-
- return ret;
- }
-
- protected override void Finalize()
- {
- MyRemoteControl.Done.Set();
- }
-
- }
-
-
-
-