コード例 #1
0
ファイル: ClientForm.cs プロジェクト: philscrace2/NModel
        static void Main(string[] args)
        {
            IDictionary props = new Hashtable();

            props["port"] = 0;
            BinaryClientFormatterSinkProvider clientFormatterProvider = new BinaryClientFormatterSinkProvider();
            BinaryServerFormatterSinkProvider serverFormatterProvider = new BinaryServerFormatterSinkProvider();

            serverFormatterProvider.TypeFilterLevel = TypeFilterLevel.Full;
            TcpChannel chan = new TcpChannel(props, clientFormatterProvider, serverFormatterProvider);

            ChannelServices.RegisterChannel(chan, false);
            string clientName = args.Length > 0 ? args[0] : ("client#" + new Random().Next().ToString());
            Client client     = new Client(clientName);

            if (args.Length > 2)
            {
                string uri = args[2];
                ClientCreationNotifier notifier = (ClientCreationNotifier)Activator.GetObject(
                    typeof(ClientCreationNotifier),
                    uri);
                try
                {
                    //System.Diagnostics.Debugger.Break();//---
                    notifier.Notify(client);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }

            using (ClientForm clientForm = new ClientForm(client))
            {
                if (args.Length > 1)
                {
                    int       pos    = int.Parse(args[1]);
                    Rectangle screen = Screen.PrimaryScreen.WorkingArea;

                    clientForm.Location = new Point(
                        8 + screen.Left + screen.Width / 2 * (pos & 1),
                        8 + screen.Top + screen.Height / 2 * ((pos & 2) >> 1));
                    //clientForm.Size = new Size(screen.Width/2-16, screen.Height/2-16);
                    clientForm.StartPosition = FormStartPosition.Manual;
                }

                Application.Run(clientForm);
            }
        }
コード例 #2
0
ファイル: ClientForm.cs プロジェクト: juhan/NModel
        static void Main(string[] args)
        {
            IDictionary props = new Hashtable();
            props["port"] = 0;
            BinaryClientFormatterSinkProvider clientFormatterProvider = new BinaryClientFormatterSinkProvider();
            BinaryServerFormatterSinkProvider serverFormatterProvider = new BinaryServerFormatterSinkProvider();
            serverFormatterProvider.TypeFilterLevel = TypeFilterLevel.Full;
            TcpChannel chan = new TcpChannel(props, clientFormatterProvider, serverFormatterProvider);
            ChannelServices.RegisterChannel(chan,false);
            string clientName = args.Length>0 ? args[0] : ("client#" + new Random().Next().ToString());
            Client client = new Client(clientName);

            if (args.Length>2)
            {
                string uri = args[2];
                ClientCreationNotifier notifier = (ClientCreationNotifier)Activator.GetObject(
                    typeof(ClientCreationNotifier),
                    uri);
                try
                {
                    //System.Diagnostics.Debugger.Break();//---
                    notifier.Notify(client);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }

            using (ClientForm clientForm = new ClientForm(client))
            {
                if (args.Length>1)
                {
                    int pos = int.Parse(args[1]);
                    Rectangle screen = Screen.PrimaryScreen.WorkingArea;

                    clientForm.Location = new Point(
                        8+screen.Left + screen.Width/2*(pos&1),
                        8+screen.Top + screen.Height/2*((pos&2)>>1));
                    //clientForm.Size = new Size(screen.Width/2-16, screen.Height/2-16);
                    clientForm.StartPosition = FormStartPosition.Manual;
                }

                Application.Run(clientForm);
            }
        }