Exemple #1
0
        private void menuItemSetup_Click(object sender, EventArgs e)
        {
            ServerAddress serverAddress = new ServerAddress(_serverHost);

            if (serverAddress.ShowDialog() == DialogResult.OK)
            {
                _serverHost = serverAddress.ServerHost;
                SaveSettings();
            }
        }
Exemple #2
0
        private void changeServerHostToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Program.StopClient();

            ServerAddress serverAddress = new ServerAddress(Program.ServerHost);

            serverAddress.ShowDialog(this);

            Program.ServerHost = serverAddress.ServerHost;

            IPAddress  serverIP = Network.GetIPFromName(Program.ServerHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

            Program.StartClient(endPoint);
        }
Exemple #3
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(_serverHost))
            {
                ServerAddress serverAddress = new ServerAddress();
                serverAddress.ShowDialog();

                _serverHost = serverAddress.ServerHost;
            }

            IPAddress  serverIP = IPAddress.Parse(_serverHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, ServerPort);

            StartClient(endPoint);
        }
Exemple #4
0
        private void menuItemSetup_Click(object sender, EventArgs e)
        {
            StopClient();

            ServerAddress serverAddress = new ServerAddress(_serverHost);

            if (serverAddress.ShowDialog() == DialogResult.OK)
            {
                _serverHost = serverAddress.ServerHost;
                SaveSettings();
            }

            IPAddress  serverIP = IPAddress.Parse(_serverHost);
            IPEndPoint endPoint = new IPEndPoint(serverIP, 24000);

            StartClient(endPoint);
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="FormMain"/> class.
    /// </summary>
    public FormMain()
    {
      InitializeComponent();

      _Notification = Notification;

      LoadSettings();

      if (!File.Exists(ConfigurationFile))
      {
        ServerAddress serverAddress = new ServerAddress(_serverHost);
        if (serverAddress.ShowDialog() == DialogResult.OK)
        {
          _serverHost = serverAddress.ServerHost;
          SaveSettings();
        }
      }
    }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormMain"/> class.
        /// </summary>
        public FormMain()
        {
            InitializeComponent();

            _Notification = Notification;

            LoadSettings();

            if (!File.Exists(ConfigurationFile))
            {
                ServerAddress serverAddress = new ServerAddress(_serverHost);
                if (serverAddress.ShowDialog() == DialogResult.OK)
                {
                    _serverHost = serverAddress.ServerHost;
                    SaveSettings();
                }
            }
        }
    private void FormMain_Load(object sender, EventArgs e)
    {
      if (String.IsNullOrEmpty(_serverHost))
      {
        ServerAddress serverAddress = new ServerAddress();
        serverAddress.ShowDialog();

        _serverHost = serverAddress.ServerHost;
      }

      IPAddress serverIP = IPAddress.Parse(_serverHost);
      IPEndPoint endPoint = new IPEndPoint(serverIP, ServerPort);

      StartClient(endPoint);
    }
    private void menuItemSetup_Click(object sender, EventArgs e)
    {
      StopClient();

      ServerAddress serverAddress = new ServerAddress(_serverHost);
      if (serverAddress.ShowDialog() == DialogResult.OK)
      {
        _serverHost = serverAddress.ServerHost;
        SaveSettings();
      }

      IPAddress serverIP = IPAddress.Parse(_serverHost);
      IPEndPoint endPoint = new IPEndPoint(serverIP, 24000);

      StartClient(endPoint);
    }
Exemple #9
0
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            IrssLog.LogLevel = IrssLog.Level.Debug;
            IrssLog.Open("Virtual Remote.log");

            Application.ThreadException += Application_ThreadException;

            LoadSettings();

            if (args.Length > 0) // Command Line Start ...
            {
                List <string> virtualButtons = new List <string>();

                try
                {
                    for (int index = 0; index < args.Length; index++)
                    {
                        if (args[index].Equals("-host", StringComparison.OrdinalIgnoreCase))
                        {
                            _serverHost = args[++index];
                            continue;
                        }
                        else
                        {
                            virtualButtons.Add(args[index]);
                        }
                    }
                }
                catch (Exception ex)
                {
                    IrssLog.Error("Error processing command line parameters: {0}", ex.ToString());
                }

                IPAddress  serverIP = Network.GetIPFromName(_serverHost);
                IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

                if (virtualButtons.Count != 0 && StartClient(endPoint))
                {
                    Thread.Sleep(250);

                    // Wait for registered ... Give up after 10 seconds ...
                    int attempt = 0;
                    while (!_registered)
                    {
                        if (++attempt >= 10)
                        {
                            break;
                        }
                        else
                        {
                            Thread.Sleep(1000);
                        }
                    }

                    if (_registered)
                    {
                        foreach (string button in virtualButtons)
                        {
                            if (button.StartsWith("~", StringComparison.OrdinalIgnoreCase))
                            {
                                Thread.Sleep(button.Length * 500);
                            }
                            else
                            {
                                IrssMessage message = new IrssMessage(MessageType.ForwardRemoteEvent, MessageFlags.Notify, button);
                                _client.Send(message);
                            }
                        }

                        Thread.Sleep(500);
                    }
                    else
                    {
                        IrssLog.Warn("Failed to register with server host \"{0}\", custom message(s) not sent", ServerHost);
                    }
                }
            }
            else // GUI Start ...
            {
                if (String.IsNullOrEmpty(_serverHost))
                {
                    ServerAddress serverAddress = new ServerAddress();
                    serverAddress.ShowDialog();

                    _serverHost = serverAddress.ServerHost;
                }

                bool clientStarted = false;

                IPAddress  serverIP = Network.GetIPFromName(_serverHost);
                IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort);

                try
                {
                    clientStarted = StartClient(endPoint);
                }
                catch (Exception ex)
                {
                    IrssLog.Error(ex);
                    clientStarted = false;
                }

                if (clientStarted)
                {
                    Application.Run(new MainForm());
                }

                SaveSettings();
            }

            StopClient();

            Application.ThreadException -= Application_ThreadException;

            IrssLog.Close();
        }