Example #1
0
 public static string getpassword()
 {
     string str;
     IniFile ini = new IniFile(Application.StartupPath + @"\模具维修记录配置文件.ini");
     str = ini.ReadString("config", "Password");
     return str;
 }
Example #2
0
 public void NewFile()
 {
     const string fileName = "NewFile.ini";
     using (IniFile ini = new IniFile(fileName)) {
         ini.WriteString("foo", "bar", "qux");
         Assert.AreEqual("qux", ini.ReadString("foo", "bar"));
     }
     Assert.IsTrue(File.Exists(fileName));
     File.Delete(fileName);
 }
Example #3
0
 public void DeleteKey()
 {
     using (IniFile ini = new IniFile(fileName)) {
         Assert.AreNotEqual(String.Empty,
                            ini.ReadString("Test", "b", String.Empty));
         Assert.AreNotEqual(String.Empty,
                            ini.ReadString("Test", "file",
                                           String.Empty));
         ini.DeleteKey("Test", "b");
         ini.DeleteKey("Test", "file");
         Assert.AreEqual(String.Empty,
                         ini.ReadString("Test", "b", String.Empty));
         Assert.AreEqual(String.Empty,
                         ini.ReadString("Test", "file", String.Empty));
     }
     using (IniFile ini = new IniFile(fileName)) {
         Assert.AreEqual(String.Empty,
                         ini.ReadString("Test", "b", String.Empty));
     }
 }
Example #4
0
        public FrmMain()
        {
            InitializeComponent();

            if (!File.Exists(Common.GetStartPath("ServerConfig.ini")))
            {
                AddShowMsg("配置文件:“ServerConfig.ini”不存在!");
                return;
            }

            string iniPath = Common.GetStartPath("ServerConfig.ini");
            _Ini = new IniFile(iniPath);
            GlobalOR.ServerExeName = _Ini.ReadString("Path", "InstallProgramName", "ReceiveTrapManagem.exe");
        }
Example #5
0
        private void timerLoadIni_Tick(object sender, EventArgs e)
        {
            // 初期化ファイルを読み込む
            IniFile iniFile = new IniFile(GetCurrentDirectory() + "\\PeerstPlayer.ini");

            #region デフォルト設定
            {
                // デフォルト
                string[] keys = iniFile.GetKeys("Player");

                for (int i = 0; i < keys.Length; i++)
                {
                    string data = iniFile.ReadString("Player", keys[i]);
                    switch (keys[i])
                    {
                        // 音量
                        case "Volume":
                            try
                            {
                                wmp.Volume = int.Parse(data);
                            }
                            catch
                            {
                            }
                            break;

                        // フレーム
                        case "Frame":
                            if (data == "False")
                            {
                                Frame = false;
                            }
                            break;
                    }
                }
            }
            #endregion

            // ウィンドウ表示
            Opacity = 100;

            // 初期化終了
            timerLoadIni.Enabled = false;
        }
Example #6
0
		/* Finds out the correct name for an animation palette to use with fire animations.
		 * Reason why this is so complicated is because NPatch & Ares, the YR logic extensions that support custom animation palettes
		 * use different name for the flag declaring the palette. (NPatch uses 'Palette' whilst Ares uses 'CustomPalette' to make it distinct
		 * from the custom object palettes).
		 */
		private Palette GetFireAnimPalette(IniFile.IniSection animation) {
            // Starkku: Altered as a part of a fix for crash that happened if custom palette was declared but file wasn't there.
            Palette pal = null;
            if (animation.ReadString("Palette") != "")
            {
                pal = OwnerCollection.Palettes.GetCustomPalette(animation.ReadString("Palette"));
                if (pal == null) pal = OwnerCollection.Palettes.AnimPalette;
            }
            else if (animation.ReadString("CustomPalette") != "")
            {
                pal = OwnerCollection.Palettes.GetCustomPalette(animation.ReadString("CustomPalette"));
                if (pal == null) pal = OwnerCollection.Palettes.AnimPalette;
            }
            else if (animation.ReadString("AltPalette") != "")
                pal = OwnerCollection.Palettes.UnitPalette;
            else
                pal = OwnerCollection.Palettes.AnimPalette;
            return pal;
		}
        /// <summary>
        /// デフォルト:高さ
        /// </summary>
        private void 高さToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
        {
            IniFile iniFile = new IniFile(GetCurrentDirectory() + "\\PeerstPlayer.ini");
            string[] keys = iniFile.GetKeys("Player");

            for (int i = 0; i < keys.Length; i++)
            {
                string data = iniFile.ReadString("Player", keys[i]);
                switch (keys[i])
                {
                    case "Height":
                        toolStripTextBox高さ.Text = data;
                        break;
                }
            }
        }
Example #8
0
        /// <summary>
        /// 初期化ファイル設定
        /// </summary>
        // TODO Settingsクラスへ移行
        private void LoadInitFile()
        {
            string iniFileName = GetCurrentDirectory() + "\\PeerstPlayer.ini";
            IniFile iniFile = new IniFile(iniFileName);

            // INIファイルの読み込み
            settings.LoadIniFile(iniFile, iniFileName);

            // TODO Settingsクラスへ移行
            #region デフォルト設定
            {
                // デフォルト
                string[] keys = iniFile.GetKeys("Player");

                for (int i = 0; i < keys.Length; i++)
                {
                    string data = iniFile.ReadString("Player", keys[i]);
                    switch (keys[i])
                    {
                        // レスボックス
                        case "ResBox":
                            panelResBox.Visible = (data == "True");
                            break;

                        // ステータスラベル
                        case "StatusLabel":
                            panelStatusLabel.Visible = (data == "True");
                            break;

                        // 最前列表示
                        case "TopMost":
                            TopMost = (data == "True");
                            break;

                        // 初期位置X
                        case "X":
                            try
                            {
                                Left = int.Parse(data);
                            }
                            catch
                            {
                            }
                            break;

                        // 初期位置Y
                        case "Y":
                            try
                            {
                                Top = int.Parse(data);
                            }
                            catch
                            {
                            }
                            break;

                        // 初期Width
                        case "Width":
                            try
                            {
                                Width = int.Parse(data);
                            }
                            catch
                            {
                            }
                            break;

                        // 初期Height
                        case "Height":
                            try
                            {
                                Height = int.Parse(data);
                            }
                            catch
                            {
                            }
                            break;

                        // ボリューム
                        case "Volume":
                            try
                            {
                                wmp.Volume = int.Parse(data);
                            }
                            catch
                            {
                            }
                            break;

                        // フォント名
                        case "FontName":
                            SetFont(data, labelDetail.Font.Size);
                            break;

                        // フォントのサイズ
                        case "FontSize":
                            try
                            {
                                SetFont(labelDetail.Font.Name, float.Parse(data));
                            }
                            catch
                            {
                            }
                            break;

                        case "FontColorR":
                            try
                            {
                                int R = int.Parse(data);
                                Color color = Color.FromArgb(255, R, labelDetail.ForeColor.G, labelDetail.ForeColor.B);
                                labelDetail.ForeColor = color;
                                labelDuration.ForeColor = color;
                                labelVolume.ForeColor = color;
                            }
                            catch
                            {
                            }
                            break;

                        case "FontColorG":
                            try
                            {
                                int G = int.Parse(data);
                                Color color = Color.FromArgb(255, labelDetail.ForeColor.R, G, labelDetail.ForeColor.B);
                                labelDetail.ForeColor = color;
                                labelDuration.ForeColor = color;
                                labelVolume.ForeColor = color;
                            }
                            catch
                            {
                            }
                            break;

                        case "FontColorB":
                            try
                            {
                                int B = int.Parse(data);
                                Color color = Color.FromArgb(255, labelDetail.ForeColor.R, labelDetail.ForeColor.G, B);
                                labelDetail.ForeColor = color;
                                labelDuration.ForeColor = color;
                                labelVolume.ForeColor = color;
                            }
                            catch
                            {
                            }
                            break;

                        case "MouseGestureInterval":
                            try
                            {
                                wmp.mouseGesture.Interval = int.Parse(data);
                            }
                            catch
                            {
                            }
                            break;
                    }
                }
            }

            #endregion
        }
        /// <summary>
        /// 終了時
        /// </summary>
        private void 終了時ToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
        {
            IniFile iniFile = new IniFile(GetCurrentDirectory() + "\\PeerstPlayer.ini");
            string[] keys = iniFile.GetKeys("Player");

            for (int i = 0; i < keys.Length; i++)
            {
                string data = iniFile.ReadString("Player", keys[i]);
                switch (keys[i])
                {
                    case "SaveLocationOnClose":
                        位置を保存するToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "SaveSizeOnClose":
                        サイズを保存するToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "SaveVolumeOnClose":
                        音量を保存するToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "RlayCutOnClose":
                        リレーを切断するToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "CloseViewerOnClose":
                        スレッドビューワを終了するToolStripMenuItem.Checked = (data == "True");
                        break;
                }
            }
        }
        /// <summary>
        /// 設定
        /// </summary>
        private void 設定ToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
        {
            IniFile iniFile = new IniFile(GetCurrentDirectory() + "\\PeerstPlayer.ini");
            string[] keys = iniFile.GetKeys("Player");

            for (int i = 0; i < keys.Length; i++)
            {
                string data = iniFile.ReadString("Player", keys[i]);
                switch (keys[i])
                {
                    case "UseScreenMagnet":
                        スクリーン吸着ToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "CloseResBoxOnWrite":
                        書き込み時にレスボックスを非表示ToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "ResBoxAutoVisible":
                        レスボックスを自動的に隠すToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "AspectRate":
                        アスペクト比を維持ToolStripMenuItem.Checked = (data == "True");
                        break;
                    case "CloseResBoxOnBackSpace":
                        bSでレスボックスを閉じるToolStripMenuItem.Checked = (data == "True");
                        break;
                }
            }
        }
Example #11
0
        // TODO iniFileをSettings内で生成するように修正
        /// <summary>
        /// ショートカットの読み込み
        /// </summary>
        private void LoadShortcut(IniFile iniFile)
        {
            // ショートカット
            string[] keys = iniFile.GetKeys("PlayerShortcut");

            for (int i = 0; i < keys.Length; i++)
            {
                string data = iniFile.ReadString("PlayerShortcut", keys[i]);

                string[] shortcut = new string[2];
                shortcut[0] = keys[i];
                shortcut[1] = data;
                ShortcutList.Add(shortcut);
            }
        }
        /// <summary>
        /// レスボックスの操作
        /// </summary>
        private void レスボックスの操作ToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
        {
            IniFile iniFile = new IniFile(GetCurrentDirectory() + "\\PeerstPlayer.ini");
            string[] keys = iniFile.GetKeys("Player");

            for (int i = 0; i < keys.Length; i++)
            {
                string data = iniFile.ReadString("Player", keys[i]);
                switch (keys[i])
                {
                    case "ResBoxType":
                        enter改行ShiftEnter書き込みToolStripMenuItem.Checked = (data == "True");
                        enter書き込みShiftEnter改行ToolStripMenuItem.Checked = !(data == "True");
                        break;
                }
            }
        }
Example #13
0
        public static void Init()
        {
            iniFile = new IniFile (iniFileName, false);

            MigrateIfNecessary ();

            // Read settings
            SvnPath = iniFile.ReadString ("Settings", "SVN_path", @"C:\Program Files\Sliksvn\bin\svn.exe");
            TortoiseSvnPath = iniFile.ReadString ("Settings", "TortoiseSVN_path", @"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe");
            GitPath = iniFile.ReadString("Settings", "GIT_path", @"C:\Program Files (x86)\git\bin\git.exe");
            GitUIPath = iniFile.ReadString("Settings", "TortoiseGIT_path", @"C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe");

            DefaultActiveStatusUpdateInterval = iniFile.ReadInteger ("Settings", "DefaultActiveStatusUpdateInterval", 5);
            DefaultIdleStatusUpdateInterval = iniFile.ReadInteger ("Settings", "DefaultIdleStatusUpdateInterval", 60);

            PauseAfterApplicationStartupInterval = iniFile.ReadInteger("Settings", "PauseAfterApplicationStartupInterval", 15);
            DoPauseAfterApplicationStartup = iniFile.ReadBoolean("Settings", "DoPauseAfterApplicationStartup", true);
            PauseAfterWindowsResumeInterval = iniFile.ReadInteger("Settings", "PauseAfterWindowsResumeInterval", 15);
            DoPauseAfterWindowsResume = iniFile.ReadBoolean("Settings", "DoPauseAfterWindowsResume", true);

            ItemDoubleClickAction = (Action) iniFile.ReadInteger ("Settings", "ItemDoubleClickAction", 0);
            ShowBalloonInterval = iniFile.ReadInteger ("Settings", "ShowBallonInterval", 10000);
            HideOnStartup = iniFile.ReadBoolean ("Settings", "HideOnStartup", false);
            ShowInTaskbar = iniFile.ReadBoolean ("Settings", "ShowInTaskbar", false);
            CheckForNewVersion = iniFile.ReadBoolean ("Settings", "CheckForNewVersion", true);
            UpdateAllSilently = iniFile.ReadBoolean ("Settings", "UpdateAllSilently", true);
            UpdateWindowAction = iniFile.ReadInteger ("Settings", "UpdateWindowAction", 2);

            ChangeLogBeforeUpdate = IsTortoiseVersion_1_5_orHigher() && iniFile.ReadBoolean ("Settings", "ChangeLogBeforeUpdate", false);
        }
Example #14
0
 public void ReadString()
 {
     using (IniFile ini = new IniFile(fileName)) {
         Assert.AreEqual("bar", ini.ReadString("Section1", "foo"));
         Assert.AreEqual("23", ini.ReadString("Test", "i"));
         Assert.AreEqual("acme payroll.dat",
                         ini.ReadString("Test", "file"));
     }
 }
Example #15
0
 private static void WriteStringKey(string key, string value,
                             string firstvalue)
 {
     using (IniFile ini = new IniFile(fileName)) {
         Assert.AreEqual(firstvalue, ini.ReadString("Section1", key));
         ini.WriteString("Section1", key, value);
         Assert.AreEqual(value, ini.ReadString("Section1", key));
     }
     using (IniFile ini = new IniFile(fileName)) {
         Assert.AreEqual(value, ini.ReadString("Section1", key));
     }
 }
Example #16
0
 public void WriteStringNoSection()
 {
     using (IniFile ini = new IniFile(fileName)) {
         Assert.IsFalse(ini.SectionExists("doesnotexist"));
         ini.WriteString("doesnotexist", "foo", "bar");
         Assert.IsTrue(ini.SectionExists("doesnotexist"));
         Assert.AreEqual("bar", ini.ReadString("doesnotexist", "foo"));
     }
     using (IniFile ini = new IniFile(fileName)) {
         Assert.IsTrue(ini.SectionExists("doesnotexist"));
         Assert.AreEqual("bar", ini.ReadString("doesnotexist", "foo"));
     }
 }
Example #17
0
 public void WriteAndRead()
 {
     using (IniFile ini = new IniFile(fileName)) {
         ini.WriteString("foo", "bar", "qux");
         Assert.AreEqual("qux", ini.ReadString("foo", "bar"));
     }
     using (IniFile ini = new IniFile(fileName)) {
         ini.WriteString("foo", "bar", "qux");
         Assert.AreEqual("qux", ini.ReadString("foo", "bar"));
     }
     using (IniFile ini = new IniFile(fileName)) {
         Assert.AreEqual("qux", ini.ReadString("foo", "bar"));
     }
 }
        /// <summary>
        /// デフォルト
        /// </summary>
        private void デフォルトToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
        {
            IniFile iniFile = new IniFile(GetCurrentDirectory() + "\\PeerstPlayer.ini");
            string[] keys = iniFile.GetKeys("Player");

            for (int i = 0; i < keys.Length; i++)
            {
                string data = iniFile.ReadString("Player", keys[i]);
                switch (keys[i])
                {
                    case "TopMost":
                        最前列表示ToolStripMenuItem2.Checked = (data == "True");
                        break;
                    case "ResBox":
                        レスボックスToolStripMenuItem2.Checked = (data == "True");
                        break;
                    case "StatusLabel":
                        ステータスバーToolStripMenuItem2.Checked = (data == "True");
                        break;
                    case "Frame":
                        フレームToolStripMenuItem2.Checked = (data == "True");
                        break;
                    case "FitSizeMovie":
                        動画サイズに合わせるToolStripMenuItem1.Checked = (data == "True");
                        break;
                }
            }
        }
Example #19
0
        // TODO iniFileをSettings内で生成するように修正
        /// <summary>
        /// INIファイルから設定読み込み
        /// </summary>
        private void LoadPlayerSettings(IniFile iniFile)
        {
            // デフォルト
            string[] keys = iniFile.GetKeys("Player");

            for (int i = 0; i < keys.Length; i++)
            {
                string data = iniFile.ReadString("Player", keys[i]);
                switch (keys[i])
                {
                    /*
                    // レスボックス
                    case "ResBox":
                        panelResBox.Visible = (data == "True");
                        break;

                    // ステータスラベル
                    case "StatusLabel":
                        panelStatusLabel.Visible = (data == "True");
                        break;

                    // 最前列表示
                    case "TopMost":
                        TopMost = (data == "True");
                        break;
                     */

                    case "AspectRate":
                        AspectRate = (data == "True");
                        break;

                    // レスボックスの操作方法
                    case "ResBoxType":
                        ResBoxType = (data == "True");
                        break;

                    // レスボックスを自動表示
                    case "ResBoxAutoVisible":
                        ResBoxAutoVisible = (data == "True");
                        break;

                    // 終了時にリレーを終了
                    case "RlayCutOnClose":
                        RlayCutOnClose = (data == "True");
                        break;

                    // 書き込み後にレスボックスを閉じる
                    case "CloseResBoxOnWrite":
                        CloseResBoxOnWrite = (data == "True");
                        break;

                    case "UseScreenMagnet":
                        UseScreenMagnet = (data == "True");
                        break;

                    // 終了時に一緒にビューワも終了するか
                    case "CloseViewerOnClose":
                        CloseViewerOnClose = (data == "True");
                        break;

                    // バックスペースでレスボックスを閉じるか
                    case "CloseResBoxOnBackSpace":
                        CloseResBoxOnBackSpace = (data == "True");
                        break;

                    // クリックした時にレスボックスを閉じるか
                    case "ClickToResBoxClose":
                        ClickToResBoxClose = (data == "True");
                        break;

                    // 終了時に位置を保存するか
                    case "SaveLocationOnClose":
                        SaveLocationOnClose = (data == "True");
                        break;

                    // 終了時にボリュームを保存するか
                    case "SaveVolumeOnClose":
                        SaveVolumeOnClose = (data == "True");
                        break;

                    // 終了時にサイズを保存するか
                    case "SaveSizeOnClose":
                        SaveSizeOnClose = (data == "True");
                        break;

                    // 再生時に動画サイズに合わせる
                    case "FitSizeMovie":
                        FitSizeMovie = (data == "True");
                        break;

                    /*
                    // 初期位置X
                    case "X":
                        try
                        {
                            Left = int.Parse(data);
                        }
                        catch
                        {
                        }
                        break;

                    // 初期位置Y
                    case "Y":
                        try
                        {
                            Top = int.Parse(data);
                        }
                        catch
                        {
                        }
                        break;

                    // 初期Width
                    case "Width":
                        try
                        {
                            Width = int.Parse(data);
                        }
                        catch
                        {
                        }
                        break;

                    // 初期Height
                    case "Height":
                        try
                        {
                            Height = int.Parse(data);
                        }
                        catch
                        {
                        }
                        break;

                    // ボリューム
                    case "Volume":
                        try
                        {
                            wmp.Volume = int.Parse(data);
                        }
                        catch
                        {
                        }
                        break;
                     */

                    // 拡大率
                    case "Scale":
                        try
                        {
                            if (data == "")
                                DefaultScale = -1;

                            DefaultScale = int.Parse(data);

                            if (DefaultScale < 0)
                                DefaultScale = -1;
                        }
                        catch
                        {
                        }
                        break;

                    /*
                    // フォント名
                    case "FontName":
                        SetFont(data, labelDetail.Font.Size);
                        break;

                    // フォントのサイズ
                    case "FontSize":
                        try
                        {
                            SetFont(labelDetail.Font.Name, float.Parse(data));
                        }
                        catch
                        {
                        }
                        break;

                    case "FontColorR":
                        try
                        {
                            int R = int.Parse(data);
                            Color color = Color.FromArgb(255, R, labelDetail.ForeColor.G, labelDetail.ForeColor.B);
                            labelDetail.ForeColor = color;
                            labelDuration.ForeColor = color;
                            labelVolume.ForeColor = color;
                        }
                        catch
                        {
                        }
                        break;

                    case "FontColorG":
                        try
                        {
                            int G = int.Parse(data);
                            Color color = Color.FromArgb(255, labelDetail.ForeColor.R, G, labelDetail.ForeColor.B);
                            labelDetail.ForeColor = color;
                            labelDuration.ForeColor = color;
                            labelVolume.ForeColor = color;
                        }
                        catch
                        {
                        }
                        break;

                    case "FontColorB":
                        try
                        {
                            int B = int.Parse(data);
                            Color color = Color.FromArgb(255, labelDetail.ForeColor.R, labelDetail.ForeColor.G, B);
                            labelDetail.ForeColor = color;
                            labelDuration.ForeColor = color;
                            labelVolume.ForeColor = color;
                        }
                        catch
                        {
                        }
                        break;
                     */

                    case "ScreenMagnetDockDist":
                        try
                        {
                            ScreenMagnetDockDist = int.Parse(data);
                        }
                        catch
                        {
                        }
                        break;

                    /*
                    case "MouseGestureInterval":
                        try
                        {
                            wmp.mouseGesture.Interval = int.Parse(data);
                        }
                        catch
                        {
                        }
                        break;
                     */

                    case "BrowserAddress":
                        BrowserAddress = data;
                        break;

                    case "ThreadBrowserAddress":
                        ThreadBrowserAddress = data;
                        break;
                }
            }
        }