Exemple #1
0
        public object Clone()
        {
            var kg = new KeiGuiOptions();

            kg.LocalIntranetAddress   = LocalIntranetAddress;
            kg.LocalKClientPort       = LocalKClientPort;
            kg.LocalTrackerServerPort = LocalTrackerServerPort;
            kg.ForceBroadcastTime     = ForceBroadcastTime;
            kg.AutoStartAndConnect    = AutoStartAndConnect;
            kg.EnableLogging          = EnableLogging;
            kg.IsPointInsertion       = IsPointInsertion;
            kg.UsePortMapping         = UsePortMapping;

            foreach (var item in TargetEndPoints)
            {
                kg.TargetEndPoints.Add(item);
            }

            return(kg);
        }
Exemple #2
0
        public static KeiGuiOptions Read(XmlReader reader)
        {
            var kg = new KeiGuiOptions();

            reader.ReadToFollowing("kei-gui");
            var versionString = reader.GetAttribute("config-version");
            var ver           = Version.Parse(versionString);

            reader.ReadStartElement("kei-gui");

            if (ver.Major >= 1)
            {
                kg.EnableLogging          = Convert.ToBoolean(reader.ReadElementString("EnableLogging"));
                kg.LocalIntranetAddress   = reader.ReadElementString("LocalIntranetAddress");
                kg.LocalKClientPort       = Convert.ToInt32(reader.ReadElementString("LocalKClientPort"));
                kg.LocalTrackerServerPort = Convert.ToInt32(reader.ReadElementString("LocalTrackerServerPort"));
                kg.ForceBroadcastTime     = TimeSpan.Parse(reader.ReadElementString("ForceBroadcastTime"));

                if (ver.Minor >= 1)
                {
                    kg.AutoStartAndConnect = Convert.ToBoolean(reader.ReadElementString("AutoStartAndConnect"));
                    kg.IsPointInsertion    = Convert.ToBoolean(reader.ReadElementString("IsPointInsertion"));
                    kg.UsePortMapping      = Convert.ToBoolean(reader.ReadElementString("UseUPnP"));
                }

                reader.ReadStartElement("TargetEndPoints");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    kg.TargetEndPoints.Add(reader.ReadElementString());
                }
                reader.ReadEndElement();
            }

            reader.ReadEndElement();

            return(kg);
        }
Exemple #3
0
        private void TryReadOptions()
        {
            var configFileName = Path.Combine(Application.StartupPath, KeiGuiOptions.DefaultConfigurationFileName);

            if (File.Exists(configFileName))
            {
                try
                {
                    using (var fs = new FileStream(configFileName, FileMode.Open, FileAccess.Read))
                    {
                        using (var xmlreader = new XmlTextReader(fs))
                        {
                            try
                            {
                                KeiGuiOptions.Current = KeiGuiOptions.Read(xmlreader);
                            }
                            catch (Exception)
                            {
                                KeiGuiOptions.Current = (KeiGuiOptions)KeiGuiOptions.Default.Clone();
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    KeiGuiOptions.Current = (KeiGuiOptions)KeiGuiOptions.Default.Clone();
                }
            }
            else
            {
                KeiGuiOptions.Current = (KeiGuiOptions)KeiGuiOptions.Default.Clone();
            }
            KeiGuiOptions.Modified = (KeiGuiOptions)KeiGuiOptions.Current.Clone();

            txtLocalKClientPort.Text       = KeiGuiOptions.Current.LocalKClientPort.ToString();
            txtLocalTrackerServerPort.Text = KeiGuiOptions.Current.LocalTrackerServerPort.ToString();
        }