Exemplo n.º 1
0
        public bool SaveNetworkSetting(String envIpAddr, int envPort, String flyIpAddr, int flyPort, int maxDisplayPoint)
        {
            NetworkSetting networkSetting = new NetworkSetting
            {
                EnvIpAddress    = envIpAddr,
                EnvPort         = envPort,
                FlyIpAddress    = flyIpAddr,
                FlyPort         = flyPort,
                MaxDisplayPoint = maxDisplayPoint
            };

            try
            {
                using (FileStream file = File.Create(NetworkSettingFile))
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(file, networkSetting);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
 public bool LoadNetworkSetting(out String envIpAddr, out int envPort, out String flyIpAddr, out int flyPort, out int maxDisplayPoint)
 {
     try
     {
         using (FileStream file = File.Open(NetworkSettingFile, FileMode.Open))
         {
             BinaryFormatter formatter      = new BinaryFormatter();
             NetworkSetting  networkSetting = (NetworkSetting)formatter.Deserialize(file);
             envIpAddr       = networkSetting.EnvIpAddress;
             envPort         = networkSetting.EnvPort;
             flyIpAddr       = networkSetting.FlyIpAddress;
             flyPort         = networkSetting.FlyPort;
             maxDisplayPoint = networkSetting.MaxDisplayPoint;
         }
     }
     catch (Exception)
     {
         envIpAddr       = flyIpAddr = String.Empty;
         envPort         = flyPort = 0;
         maxDisplayPoint = 1000;
         return(false);
     }
     return(true);
 }