public DialogSetting()
        {
            InitializeComponent();

            Config = new Configuration();
            if (!Config.Load()) Config.Default();

            this.WindowStartupLocation = WindowStartupLocation.Manual;

            Rect area = SystemParameters.WorkArea;
            Point position = new Point((area.Width - this.Width) / 2, (area.Height - this.Height) / 2);

            if (Config.PanelSetting.X != 0 || Config.PanelSetting.Y != 0) position = Config.PanelSetting;
            this.Left = position.X;
            this.Top = position.Y;
            this.Margin = new Thickness(position.X, position.Y, 0, 0);
            //Dialog = new OpenFileDialog();
        }
Ejemplo n.º 2
0
        private void WorkSentinelServices(object sender, DoWorkEventArgs e)
        {
            // this.WriteLineConsoleCheck();
            BackgroundWorker init = sender as BackgroundWorker;


            init.ReportProgress(0, StateTravox.InitReadConfig);
            Config = new Configuration();

            if (!Config.Load()) Config.Default();

            String IP = XHR.Connect("checkip.dyndns.com");
            if (MBOS.Null(IP)) IP = "IP Address: 127.0.0.1";

            Configuration.InternetIP = IPAddress.Parse(Regex.Match(IP, @"IP Address:.*?(?<ip>[\d|\.]+)").Groups["ip"].Value);
            if (App.DebugMode) TravoxIP = Configuration.NetworkIP; else TravoxIP = Configuration.InternetIP;

            TravoxPort = Config.SentinelPort;
            IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();

            TcpListener.Create(TravoxPort).Stop();
            foreach (TcpConnectionInformation tcpi in ipGlobalProperties.GetActiveTcpConnections())
            {
                if (tcpi.LocalEndPoint.Port == TravoxPort) throw new Exception("Port is Unavailable.");
            }
            Config.Save();

            init.ReportProgress(0, StateTravox.InitStartServer);

            // Crawler Sentinel for Client Connected 
            Console.WriteLine("{0} Server Starting...", TravoxIP.ToString());

            //Listen = new TcpListener(new IPEndPoint(TravoxIP, TravoxPort));
            //Listen.Start();
            //TaskListen = new Task()
            //App.ServerConnected = true;
            //while (App.ServerConnected)
            //{
            //    if (!Listen.Pending()) continue; 

            //    TcpClient client = Listen.AcceptTcpClient();
            //    Thread clientThread = new Thread(new ParameterizedThreadStart(OnClientConnect));
            //    clientThread.Start(client.GetStream());
            //    client.Close();
            //}
        }