SaveSettings() public method

Save settings back to ini file.
public SaveSettings ( ) : void
return void
Exemplo n.º 1
0
        private void frmMain_Load(object sender, EventArgs e)
        {

            dataGridView1.DataSource = null;
            DataSet ds = YAMS.Database.ReturnLogRows();
            dataGridView1.DataSource = ds.Tables[0];

            this.checkBox1.Checked = YAMS.Util.HasJRE();
            this.checkBox2.Checked = YAMS.Util.HasJDK();

            this.textBox1.Text = YAMS.Util.JavaPath();
            this.textBox2.Text = YAMS.Util.JavaPath("jdk");

            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName;
            watcher.Filter = "*.sdf";
            //watcher.NotifyFilter = NotifyFilters.LastWrite;

            watcher.Changed += new FileSystemEventHandler(OnChanged);
            watcher.EnableRaisingEvents = true;

            IniParser parser = new IniParser(@"server.properties");
            txtIniCheck.Text = parser.GetSetting("ROOT", "level-name");

            parser.AddSetting("ROOT", "level-name", "world");
            parser.SaveSettings();

        }
Exemplo n.º 2
0
        public MCServer(int intServerID)
        {
            this.ServerID = intServerID;

            //Set this first so that we can use it right away
            this.ServerDirectory = Core.StoragePath + this.ServerID.ToString() + @"\";

            //If server is a pre-0.2.3 then we need to move everything back to default layout to support a lot of bukkit plugins
            if (Directory.Exists(Core.StoragePath + this.ServerID.ToString() + "\\config\\")) {
                //This is our old config and working dir, so we need everything out of it moved into the main dir
                try {
                    Util.Copy(Core.StoragePath + this.ServerID.ToString() + "\\config\\", this.ServerDirectory);
                    Directory.Delete(Core.StoragePath + this.ServerID.ToString() + "\\config\\", true);
                    //We also need to amend the properties file to include the new world path
                    IniParser parser = new IniParser(this.ServerDirectory + @"\server.properties");
                    parser.AddSetting("ROOT", "level-name", "world");
                    parser.SaveSettings("#Minecraft server properties\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n");
                }
                catch(Exception e) {
                    Database.AddLog("Unable to move config directory, this will have to be done manually to avoid losing settings: " + e.Message, "app", "error");
                }
            }

            //Set this here to catch any old references to it.
            this.strWorkingDir = this.ServerDirectory;

            this.bolEnableJavaOptimisations = Convert.ToBoolean(Database.GetSetting(this.ServerID, "ServerEnableOptimisations"));
            this.intAssignedMem = Convert.ToInt32(Database.GetSetting(this.ServerID, "ServerAssignedMemory"));
            this.ServerTitle = Convert.ToString(Database.GetSetting(this.ServerID, "ServerTitle"));
            this.ServerType = Convert.ToString(Database.GetSetting(this.ServerID, "ServerType"));
            this.LogonMode = Convert.ToString(Database.GetSetting(this.ServerID, "ServerLogonMode"));
            this.Port = Convert.ToInt32(this.GetProperty("server-port"));
        }
Exemplo n.º 3
0
        private void SaveProfile()
        {
            IniParser ini = new IniParser("teknogods.ini");

            ini.AddSetting("Settings", "ID", profile.ID);
            ini.AddSetting("Settings", "FOV", profile.FOV.ToString());
            ini.AddSetting("Settings", "Clantag", profile.Clantag);
            ini.AddSetting("Settings", "Title", profile.Title);
            ini.AddSetting("Settings", "ShowConsole", profile.ShowConsole.ToString().ToLower());
            ini.AddSetting("Settings", "Maxfps", profile.Maxfps.ToString());
            ini.AddSetting("Settings", "SkipUpdate", profile.SkipUpdate.ToString().ToLower());
            ini.SaveSettings();

            UpdateProfile();
        }
Exemplo n.º 4
0
        private void btnSetConn_Click(object sender, EventArgs e)
        {
            var sDbType = cmbType.SelectedItem.ToString();
            var sConn   = txtConnStr.Text.Trim();

            if (string.IsNullOrEmpty(sConn))
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }
            List <KeyValuePair> logs = null;

            try
            {
                logs = LoadLogs(sDbType);
            }
            catch (Exception)
            {
            }
            bool bExist = false;

            if (null != logs)
            {
                foreach (var log in logs)
                {
                    if (Md5Helper.VerifyMd5(sConn, log.Key))
                    {
                        bExist = true;
                        break;
                    }
                }
            }

            if (!bExist)
            {
                var oIni = new IniParser(AppCommon.IniFile);
                var sMd5 = Md5Helper.CalcMd5(sConn);
                oIni.AddSetting(sDbType, sMd5, sConn);
                oIni.SaveSettings();
            }
            ConnectType.ConnStr = sConn;
            this.DialogResult   = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 5
0
        public void SaveProperty(string strPropertyName, string strPropertyValue)
        {
            //If there is already a partially updated file, we want to put this value in the new file
            string strPathToRead;

            if (File.Exists(this.ServerDirectory + @"\server.properties.UPDATE"))
            {
                strPathToRead = this.ServerDirectory + @"\server.properties.UPDATE";
            }
            else
            {
                strPathToRead = this.ServerDirectory + @"\server.properties";
            }
            IniParser parser = new IniParser(strPathToRead);

            parser.AddSetting("ROOT", strPropertyName, strPropertyValue);
            parser.SaveSettings(this.ServerDirectory + @"\server.properties.UPDATE", "#Minecraft server properties\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n");
        }
Exemplo n.º 6
0
        public MainForm()
        {
            InitializeComponent();

            this.Text = this.Text + " [" + this.BUILD + "]";


            IniParser parser     = new IniParser(Environment.CurrentDirectory + "\\MDB2RNX.ini");
            string    storedArgs = parser.GetSetting("default", "TEQC_ARGUMENT");

            this.txtArguments.Text = (storedArgs == "" ? "-leica mdb +nav {FILENAME}.{YEAR}n,{FILENAME}.{YEAR}g +obs {FILENAME}.{YEAR}o {FILENAME}.m00;" : storedArgs);


            this.FormClosing += delegate {
                parser.AddSetting("default", "TEQC_ARGUMENT", this.txtArguments.Text);
                parser.SaveSettings();
            };
        }
Exemplo n.º 7
0
        public static void SaveConfigurationTWSProfileINI(string path)
        {
            IniParser ParserTWSProfileini = new IniParser(path);

            //ParserTWSProfileini.GetSetting("OPENWINDOW SETTINGS", "NORMALOEOPEN");
            ParserTWSProfileini.AddSetting("OE SETTINGS", "IsEqtShortClientIDChecked", UtilityOrderDetails.GETInstance.IsEqtShortClientIDChecked);
            ParserTWSProfileini.AddSetting("OE SETTINGS", "EqtShortClientID", UtilityOrderDetails.GETInstance.EqtShortClientID);

            ParserTWSProfileini.AddSetting("OE SETTINGS", "IsDervShortClientIDChecked", UtilityOrderDetails.GETInstance.IsDervShortClientIDChecked);
            ParserTWSProfileini.AddSetting("OE SETTINGS", "DervShortClientID", UtilityOrderDetails.GETInstance.DervShortClientID);

            ParserTWSProfileini.AddSetting("OE SETTINGS", "IsCurrShortClientIDChecked", UtilityOrderDetails.GETInstance.IsCurrShortClientIDChecked);
            ParserTWSProfileini.AddSetting("OE SETTINGS", "CurrShortClientID", UtilityOrderDetails.GETInstance.CurrShortClientID);

            ParserTWSProfileini.AddSetting("OE SETTINGS", "IsDebtShortClientIDChecked", UtilityOrderDetails.GETInstance.IsDebtShortClientIDChecked);
            ParserTWSProfileini.AddSetting("OE SETTINGS", "DebtShortClientID", UtilityOrderDetails.GETInstance.DebtShortClientID);

            ParserTWSProfileini.SaveSettings(path);
        }
Exemplo n.º 8
0
        private void FrmImport_FormClosed(object sender, FormClosedEventArgs e)
        {
            var sLast = cmbTarTab.Text.Trim();

            if (string.IsNullOrEmpty(sLast))
            {
                return;
            }
            if (null == mLstImpHIs.Find(x =>
            {
                return(0 == string.Compare(x.Val, sLast, true));
            }))
            {
                var oIni = new IniParser(AppCommon.IniFile);
                var ds   = DateTime.Now.ToString("MMddHHmmss");
                oIni.AddSetting(AppCommon.SEC_IMPTABHIS, ds, sLast);
                oIni.SaveSettings();
            }
        }
Exemplo n.º 9
0
        public void SaveSettingsToFile()
        {
            IniParser parser = new IniParser(m_settingsPath);

            parser.DeleteSetting("NewTaskHotkey", "alt");
            parser.DeleteSetting("NewTaskHotkey", "ctrl");
            parser.DeleteSetting("NewTaskHotkey", "shift");
            parser.DeleteSetting("NewTaskHotkey", "win");
            parser.DeleteSetting("NewTaskHotkey", "key");
            parser.DeleteSetting("general", "startwithwindows");
            parser.DeleteSetting("general", "autoupdate");
            parser.DeleteSetting("general", "playsound");
            parser.DeleteSetting("CultureInfo", "name");
            parser.DeleteSetting("RemindMeLater", "default");
            parser.DeleteSetting("skin", "code");
            parser.DeleteSetting("skin", "themename");
            parser.DeleteSetting("sync", "id");
            parser.DeleteSetting("sync", "interval");
            parser.DeleteSetting("sync", "enable");

            parser.AddSetting("NewTaskHotkey", "alt", StaticData.Settings.NewTaskHotkey.Alt.ToString());
            parser.AddSetting("NewTaskHotkey", "ctrl", StaticData.Settings.NewTaskHotkey.Ctrl.ToString());
            parser.AddSetting("NewTaskHotkey", "shift", StaticData.Settings.NewTaskHotkey.Shift.ToString());
            parser.AddSetting("NewTaskHotkey", "win", StaticData.Settings.NewTaskHotkey.Win.ToString());
            parser.AddSetting("NewTaskHotkey", "key", StaticData.Settings.NewTaskHotkey.Key);

            parser.AddSetting("General", "startwithwindows", StaticData.Settings.StartWithWindows.ToString());
            parser.AddSetting("General", "autoupdate", StaticData.Settings.CheckUpdates.ToString());
            parser.AddSetting("General", "playsound", StaticData.Settings.PlaySound.ToString());
            parser.AddSetting("CultureInfo", "name", StaticData.Settings.CultureData.CultureInfo.Name.ToString());
            parser.AddSetting("RemindMeLater", "default", RemindLaterValue.Round(StaticData.Settings.RemindMeLaterDecimalValue).ToString());
            parser.AddSetting("skin", "code", StaticData.Settings.SkinsUniqueCodes.SelectedSkin);
            parser.AddSetting("skin", "themename", StaticData.Settings.ThemeUniqueCode);
            parser.AddSetting("sync", "id", StaticData.Settings.Sync.Id);
            parser.AddSetting("sync", "interval", StaticData.Settings.Sync.Interval.ToString());
            parser.AddSetting("sync", "enable", StaticData.Settings.Sync.Enable.ToString());

            parser.SaveSettings();
            m_log.Info("Settings were saved successfully");
        }
Exemplo n.º 10
0
        void tLogin_FormClosed(object sender, FormClosedEventArgs e)
        {
            tParser = new IniParser(tFileIO.GetSettingsFilePath());
            tParser.AddSetting("UserSettings", "GmailAddress", tLogin.tGmailAddress);
            tParser.AddSetting("UserSettings", "GmailPassword", tLogin.tGmailPassword);
            tParser.AddSetting("UserSettings", "FacebookId", tLogin.tFacebookId);
            tParser.AddSetting("UserSettings", "FacebookPin", tLogin.tFacebookPIN);
            tParser.AddSetting("UserSettings", "SpreadsheetName", tLogin.tSpreadsheetName);
            tParser.SaveSettings();

            HookManager.KeyPress += new KeyPressEventHandler(HookManager_KeyPress);
            tUserName             = tLogin.tGmailAddress;
            tPassword             = tLogin.tGmailPassword;
            tFacebookId           = tLogin.tFacebookId;
            tFacebookPin          = tLogin.tFacebookPIN;
            tSheetName            = tLogin.tSpreadsheetName;

            LoadComboBoxValues(comboBox1);
            LoadComboBoxValues(comboBox2);
            LoadComboBoxValues(comboBox3);
            try
            {
                tService.setUserCredentials(tUserName, tPassword);

                tDicingSpreadsheet = GetDicingSheet();
                tWorksheetEntry    = GetWorksheet(tDicingSpreadsheet);
                tWorksheetFeed     = GetWorksheetFeed(tWorksheetEntry);
            }
            catch {
                MessageBox.Show("There was an error logging you into Google or loading your spreadsheets. Check the info.",
                                "Google Error", MessageBoxButtons.OK);
            }

            tTextReplacementDictionary.Add("{player1}", "");
            tTextReplacementDictionary.Add("{player2}", "");
            tTextReplacementDictionary.Add("{bet}", "");
            tTextReplacementDictionary.Add("{pot}", "");
            this.Show();
        }
Exemplo n.º 11
0
 public void CreateDefaultSettingsFile()
 {
     StreamWriter writer = new StreamWriter(m_settingsPath);
     writer.Close();
     IniParser iniParser = new IniParser(m_settingsPath);
     iniParser.AddSetting("NewTaskHotkey", "Ctrl", "false");
     iniParser.AddSetting("NewTaskHotkey", "Alt", "true");
     iniParser.AddSetting("NewTaskHotkey", "Win", "false");
     iniParser.AddSetting("NewTaskHotkey", "Shift", "false");
     iniParser.AddSetting("NewTaskHotkey", "Key", "N");
     iniParser.AddSetting("General", "startwithwindows", "true");
     iniParser.AddSetting("General", "autoupdate", "true");
     iniParser.AddSetting("General", "playsound", "true");
     iniParser.AddSetting("CultureInfo", "name", "lt-Lt");
     iniParser.AddSetting("RemindMeLater", "Default", RemindLaterValue.Round(10.0m/60.0m).ToString());
     iniParser.AddSetting("Skin", "code", BlackSkin.SKIN_UNIQUE_CODE);
     iniParser.AddSetting("Skin", "themename", _defaultThemeName);
     iniParser.AddSetting("Sync", "enable", "false");
     iniParser.AddSetting("Sync", "ID", "");
     iniParser.AddSetting("Sync", "interval", "30");
     iniParser.SaveSettings();
     m_log.Info("New settings file was created successfully");
 }
Exemplo n.º 12
0
        private void SaveHotkeys()
        {
            IniParser parser = new IniParser(IniFile);

            parser.AddSetting("Pitch", "IncreaseHotkey", pitchIncreaseHotkey.Text);
            parser.AddSetting("Pitch", "DecreaseHotkey", pitchDecreaseHotkey.Text);

            parser.AddSetting("Yaw", "IncreaseHotkey", yawIncreaseHotkey.Text);
            parser.AddSetting("Yaw", "DecreaseHotkey", yawDecreaseHotkey.Text);

            parser.AddSetting("Height", "IncreaseHotkey", cameraHeightIncreaseHotkey.Text);
            parser.AddSetting("Height", "DecreaseHotkey", cameraHeightDecreaseHotkey.Text);

            parser.AddSetting("Speed", "IncreaseHotkey", speedIncreaseHotkey.Text);
            parser.AddSetting("Speed", "DecreaseHotkey", speedDecreaseHotkey.Text);

            parser.AddSetting("ViewDistance", "IncreaseHotkey", drawDistanceIncreaseHotkey.Text);
            parser.AddSetting("ViewDistance", "DecreaseHotkey", drawDistanceDecreaseHotkey.Text);

            parser.AddSetting("RestoreDefaults", "Hotkey", restoreDefaultsHotkey.Text);

            parser.SaveSettings();
        }
Exemplo n.º 13
0
        private void ServerExited(object sender, EventArgs e)
        {
            DateTime datTimeStamp = DateTime.Now;

            Database.AddLog(datTimeStamp, "Server Exited", "server", "warn", false, this.ServerID);
            this.Running = false;
            Util.RemovePID(this.PID);
            //Close firewall
            if (Database.GetSetting("EnableOpenFirewall", "YAMS") == "true")
            {
                Networking.CloseFirewallPort(this.Port);
            }
            if (Database.GetSetting("EnablePortForwarding", "YAMS") == "true")
            {
                Networking.CloseUPnP(this.Port);
            }

            //Server has stopped, so clear out any entries in the user list
            this.Players.Clear();

            //Did the server stop safely?
            if (!this.SafeStop)
            {
                System.Threading.Thread.Sleep(10000);

                if (this.AgreeEULA)
                {
                    //It's the EULA message, let's clear it.
                    string    strPathToRead = this.ServerDirectory + @"\eula.txt";
                    IniParser parser        = new IniParser(strPathToRead);
                    parser.AddSetting("ROOT", "eula", "true");
                    parser.SaveSettings(this.ServerDirectory + @"\eula.txt", "#Minecraft EULA file\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n");
                }

                this.Start();
            }
        }
Exemplo n.º 14
0
 private void changeLanguageResolution()
 {
     parserSettings.AddSetting("Language", "Default", language.Text);
     //parserSettings.AddSetting("Options", "Resolution", resolution.SelectedIndex.ToString());
     parserSettings.SaveSettings();
 }
Exemplo n.º 15
0
 public void SaveProperty(string strPropertyName, string strPropertyValue)
 {
     //If there is already a partially updated file, we want to put this value in the new file
     string strPathToRead;
     if (File.Exists(this.ServerDirectory + @"\server.properties.UPDATE")) strPathToRead = this.ServerDirectory + @"\server.properties.UPDATE";
     else strPathToRead = this.ServerDirectory + @"\server.properties";
     IniParser parser = new IniParser(strPathToRead);
     parser.AddSetting("ROOT", strPropertyName, strPropertyValue);
     parser.SaveSettings(this.ServerDirectory + @"\server.properties.UPDATE", "#Minecraft server properties\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n");
 }
Exemplo n.º 16
0
 /// <summary>
 /// Save all parameters to the config file
 /// </summary>
 public static void Save()
 {
     iniPsr.SaveSettings();
 }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            byte[]     byteBuff = new byte[256];
            byte[]     cmdx     = new byte[1];
            byte[]     len      = new byte[1];
            const byte INIT_TAB = 0x00;
            byte       retVal;

            byte[] byteRdBuff  = new byte[256];
            byte[] byteRddBuff = new byte[256];
            int    count       = 256;

            string[]  cmPort;
            int       pos, pIndex = 0;
            IniParser ini_file;
            string    sComPort;
            int       speed;
            //System.Timers.Timer myTimer = new System.Timers.Timer();
            StopWatch   sTimer;
            SerialQueue Q = new SerialQueue();

            //IntPtr windowHandle = (new WindowInteropHelper(this)).Handle;
            //HwndSource src = HwndSource.FromHwnd(windowHandle);
            //src.AddHook(new HwndSourceHook(WndProc));

            // Starts library
            fixed_lib.lStart();

            for (int i = 0; i < 256; i++)
            {
                Q.PushRxByte((byte)i);
                byteBuff[i] = (byte)(i);
                //System.Console.WriteLine("bytes={0}\r\n",Q.PullRxByte());
            }

            // Initialize tag by passing first argument as zero
            fixed_lib.lPushTag(INIT_TAB, ref byteBuff, 0);
            fixed_lib.lPushTag(0xf, ref byteBuff, 0);
            fixed_lib.TransmitTag();
            fixed_lib.WaitTag(1000);

            do
            {
                retVal = fixed_lib.lPullTag(ref cmdx, ref len, ref byteBuff);
                if (retVal > 0)
                {
                    System.Console.WriteLine("cmdx={0} len={1}\r\n", cmdx[0], len[0]);
                }
            }while(retVal > 0);
            //

            fixed_lib.lStop();

            return;

            myTimer          = new System.Timers.Timer();
            myTimer.Elapsed += OnTimedEvent;
            myTimer.Interval = 10;
            myTimer.Enabled  = false;



            for (int i = 0; i < 256; i++)
            {
                Q.PushRxByte((byte)i);
                byteBuff[i] = (byte)(i + 10);
                //System.Console.WriteLine("bytes={0}\r\n",Q.PullRxByte());
            }

            //System.Console.WriteLine("-----------------------------\r\n");
            //Q.PullRx(byteRddBuff,80);
            //System.Console.WriteLine(ByteArrayToHexString(byteRddBuff));
            //Serial_Comm.encodeATEMsg(100,ref byteBuff,10);
            //return;


            const string iniFileName = @"serial.ini";

            using (StreamWriter w = File.AppendText(iniFileName));
            ini_file = new IniParser(iniFileName);

            sTimer = new StopWatch();
            sTimer.Start();

            ini_file.AddSetting("PORTSETTINGS", "COM", "1");
            ini_file.AddSetting("PORTSETTINGS", "SPEED", "115200");

            ini_file.SaveSettings();

            sComPort = ini_file.GetSetting("PORTSETTINGS", "COM");

            System.Console.WriteLine(args.Length);

            cmPort = SerialPort.GetPortNames();
            if (cmPort.Length == 0)
            {
                System.Console.WriteLine("No Serial Port Found");
            }
            else
            {
                System.Console.Write("One COM PORT found on system");
                System.Console.Write("Serial Port={0}", cmPort[0]);

                myTimer.Start();
            }

            Thread.Sleep(10000);
            Thread.Sleep(10000);
            Thread.Sleep(10000);
            Thread.Sleep(10000);


            StdOut.WriteLine("This is Main program\r\n");
            StdOut.WriteLine("This is Main program\r\n");
            StdOut.WriteLine("This is Main program\r\n");
            StdOut.WriteLine("This is Main program\r\n");
            StdOut.WriteLine("This is Main program\r\n");

            sTimer.Stop();
            StdOut.WriteLine("StopWatch Timer Val={0}\r\n", sTimer.GetElapsedTime());

            ini_file.SaveSettings();
        }
Exemplo n.º 18
0
        private void LoadProfile()
        {
            try
            {
                if (File.Exists("teknogods.ini"))
                {
                    bool      AutoChanged = false;
                    bool      NeedChange  = false;
                    IniParser ini         = new IniParser("teknogods.ini");
                    profile = new Proflie();

                    profile.Name = ini.GetSetting("Settings", "Name");
                    if ((string.IsNullOrEmpty(profile.Name) || string.IsNullOrWhiteSpace(profile.Name)) || (profile.Name.Length > 15 || profile.Name.Length < 3))
                    {
                        profile.Name = "CHN_TeknoPlayer";
                        NeedChange   = true;
                    }

                    profile.ID = Convert.ToInt64(ini.GetSetting("Settings", "ID"));
                    if (string.IsNullOrWhiteSpace(profile.ID.ToString()) || profile.ID.ToString() == "0")
                    {
                        var low  = (long)rng.Next(0x1000, 0xFFFF);
                        var high = (long)rng.Next(0x1000, 0xFFFF);
                        profile.ID  = Convert.ToInt64(low + string.Empty + high);
                        AutoChanged = true;
                    }

                    profile.FOV = Convert.ToInt32(ini.GetSetting("Settings", "FOV"));
                    if (profile.FOV > 90 || profile.FOV < 65)
                    {
                        profile.FOV = 75;
                        AutoChanged = true;
                    }

                    profile.Clantag = ini.GetSetting("Settings", "Clantag");
                    if (string.IsNullOrWhiteSpace(profile.Clantag) || profile.Clantag.Length > 4)
                    {
                        profile.Clantag = "SXXM";
                        AutoChanged     = true;
                    }

                    profile.Title = ini.GetSetting("Settings", "Title");
                    if (profile.Title.Length > 25)
                    {
                        profile.Title = "";
                        AutoChanged   = true;
                    }

                    string showconsole = ini.GetSetting("Settings", "ShowConsole");
                    if (string.IsNullOrEmpty(showconsole))
                    {
                        profile.ShowConsole = false;
                        AutoChanged         = true;
                        goto LABEL_001;
                    }
                    profile.ShowConsole = Convert.ToBoolean(showconsole);

LABEL_001:

                    if (NeedChange)
                    {
                        MessageBox.Show("你的玩家名称似乎有问题,请重新调整你的玩家信息。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                        Settings st = new Settings(profile);
                        st.ShowDialog();
                        UpdateProfile();
                    }
                    else if (AutoChanged)
                    {
                        ini.AddSetting("Settings", "FOV", profile.FOV.ToString());
                        ini.AddSetting("Settings", "Clantag", profile.Clantag);
                        ini.AddSetting("Settings", "ShowConsole", profile.ShowConsole.ToString().ToLower());
                        ini.SaveSettings();
                    }
                    else
                    {
                    }
                }
                else
                {
                    MessageBox.Show("未检测到配置文件,你需要先设置你的玩家信息。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    CreateNewProfile();

                    Settings st = new Settings(profile);
                    st.ShowDialog();
                    UpdateProfile();
                }
            }
            catch (Exception)
            {
                File.Delete("teknogods.ini");
                MessageBox.Show("读取配置文件时遇到问题,你的配置文件可能已损坏,请重新调整你的玩家信息。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                CreateNewProfile();

                Settings st = new Settings(profile);
                st.ShowDialog();
                UpdateProfile();
            }
        }
 private void SaveResetPwdINI()
 {
     parser.AddSetting("Password Settings", "DEFAULTPWD", DefaultPwd);
     parser.SaveSettings(ResetPwdINIPath.ToString());
 }
Exemplo n.º 20
0
        private void ServerExited(object sender, EventArgs e)
        {
            DateTime datTimeStamp = DateTime.Now;
            Database.AddLog(datTimeStamp, "Server Exited", "server", "warn", false, this.ServerID);
            this.Running = false;
            Util.RemovePID(this.PID);
            //Close firewall
            if (Database.GetSetting("EnableOpenFirewall", "YAMS") == "true") Networking.CloseFirewallPort(this.Port);
            if (Database.GetSetting("EnablePortForwarding", "YAMS") == "true") Networking.CloseUPnP(this.Port);

            //Server has stopped, so clear out any entries in the user list
            this.Players.Clear();

            //Did the server stop safely?
            if (!this.SafeStop)
            {
                System.Threading.Thread.Sleep(10000);

                if (this.AgreeEULA)
                {
                    //It's the EULA message, let's clear it.
                    string strPathToRead = this.ServerDirectory + @"\eula.txt";
                    IniParser parser = new IniParser(strPathToRead);
                    parser.AddSetting("ROOT", "eula", "true");
                    parser.SaveSettings(this.ServerDirectory + @"\eula.txt", "#Minecraft EULA file\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n");
                }
                
                this.Start();
            }
        }
Exemplo n.º 21
0
        public void SaveSettingsToFile()
        {
            IniParser parser = new IniParser(m_settingsPath);
            parser.DeleteSetting("NewTaskHotkey", "alt");
            parser.DeleteSetting("NewTaskHotkey", "ctrl");
            parser.DeleteSetting("NewTaskHotkey", "shift");
            parser.DeleteSetting("NewTaskHotkey", "win");
            parser.DeleteSetting("NewTaskHotkey", "key");
            parser.DeleteSetting("general", "startwithwindows");
            parser.DeleteSetting("general", "autoupdate");
            parser.DeleteSetting("general", "playsound");
            parser.DeleteSetting("CultureInfo", "name");
            parser.DeleteSetting("RemindMeLater", "default");
            parser.DeleteSetting("skin", "code");
            parser.DeleteSetting("skin", "themename");
            parser.DeleteSetting("sync", "id");
            parser.DeleteSetting("sync", "interval");
            parser.DeleteSetting("sync", "enable");

            parser.AddSetting("NewTaskHotkey", "alt", StaticData.Settings.NewTaskHotkey.Alt.ToString());
            parser.AddSetting("NewTaskHotkey", "ctrl", StaticData.Settings.NewTaskHotkey.Ctrl.ToString());
            parser.AddSetting("NewTaskHotkey", "shift", StaticData.Settings.NewTaskHotkey.Shift.ToString());
            parser.AddSetting("NewTaskHotkey", "win", StaticData.Settings.NewTaskHotkey.Win.ToString());
            parser.AddSetting("NewTaskHotkey", "key", StaticData.Settings.NewTaskHotkey.Key);

            parser.AddSetting("General", "startwithwindows", StaticData.Settings.StartWithWindows.ToString());
            parser.AddSetting("General", "autoupdate", StaticData.Settings.CheckUpdates.ToString());
            parser.AddSetting("General", "playsound", StaticData.Settings.PlaySound.ToString());
            parser.AddSetting("CultureInfo", "name", StaticData.Settings.CultureData.CultureInfo.Name.ToString());
            parser.AddSetting("RemindMeLater", "default", RemindLaterValue.Round(StaticData.Settings.RemindMeLaterDecimalValue).ToString());
            parser.AddSetting("skin", "code", StaticData.Settings.SkinsUniqueCodes.SelectedSkin);
            parser.AddSetting("skin", "themename", StaticData.Settings.ThemeUniqueCode);
            parser.AddSetting("sync", "id", StaticData.Settings.Sync.Id);
            parser.AddSetting("sync", "interval", StaticData.Settings.Sync.Interval.ToString());
            parser.AddSetting("sync", "enable", StaticData.Settings.Sync.Enable.ToString());

            parser.SaveSettings();
            m_log.Info("Settings were saved successfully");
        }
Exemplo n.º 22
0
        public static int Main(String[] args)
        {
            Console.WriteLine("{0}  アリーナサーバー バージョン: {1}", ApplicationConstants.APP_NAME, ApplicationConstants.VERSION);

            IniParser p = new IniParser();

            int port;

            if (!int.TryParse(p.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_PORT), out port))
            {
                port = 30000;
            }

            int maxUsers;

            if (!int.TryParse(p.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_USERS), out maxUsers))
            {
                maxUsers = 20;
            }

            int maxRooms;

            if (!int.TryParse(p.GetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_ROOMS), out maxRooms))
            {
                maxRooms = 3;
            }

            switch (args.Length)
            {
            case 2:
                maxUsers = Int32.Parse(args[1]);
                port     = Int32.Parse(args[0]);
                break;

            case 1:
                port = Int32.Parse(args[0]);
                break;

            default:
                break;
            }

            p.SetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_PORT, port.ToString());
            p.SetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_USERS, maxUsers.ToString());
            p.SetSetting(IniConstants.SECTION_SETTINGS, IniConstants.SERVER_MAX_ROOMS, maxRooms.ToString());
            p.SaveSettings();

            Protocol1ArenaEngine engine = new Protocol1ArenaEngine();

            try
            {
                engine.MaxPlayers = maxUsers;
                engine.MaxRooms   = maxRooms;

                engine.StartListening(new IPEndPoint(IPAddress.Any, port));

                while (true)
                {
                    //Console.Write(">");
                    string cmd = Console.ReadLine();
                    //if (cmd == "") break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.ReadLine();
            }
            finally
            {
                engine.StopListening();
            }

            return(0);
        }
Exemplo n.º 23
0
        private void savePrefs()
        {
            IniParser parser = new IniParser(@"CP1252Fixer.ini");

            for (int i = 0; i < CMOptions.Length; ++i)
            {
                parser.AddSetting("options", CMOptions[i].text, (CMOptions[i].active ? "true" : "false"));
            }
            parser.SaveSettings();
        }
Exemplo n.º 24
0
 public void Save()
 {
     settingsParser.SaveSettings();
 }