本文整理汇总了C#中IniFile.ReadValue方法的典型用法代码示例。如果您正苦于以下问题:C# IniFile.ReadValue方法的具体用法?C# IniFile.ReadValue怎么用?C# IniFile.ReadValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IniFile
的用法示例。
在下文中一共展示了IniFile.ReadValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CoreLocations
/// <summary>
/// Checks if the core locations exist
/// </summary>
/// <returns>True if all locations exist</returns>
public bool CoreLocations()
{
using (IniFile iniFile = new IniFile())
{
/// <switch>current profile</switch>
iniFile.IniPath = Application.StartupPath + @"\locations.ini";
if (Directory.Exists(iniFile.ReadValue("LOCATIONS", "exe")) && Directory.Exists(iniFile.ReadValue("LOCATIONS", "cfg")) && Directory.Exists(iniFile.ReadValue("LOCATIONS", "self")))
return true;
return false;
}
}
示例2: CurrentProfile
/// <summary>
/// Checks if the current profile exists
/// </summary>
/// <returns>True if the profile exists</returns>
public bool CurrentProfile()
{
using (IniFile iniFile = new IniFile())
{
/// <switch>current profile</switch>
iniFile.IniPath = Application.StartupPath + @"\locations.ini";
if (File.Exists(Application.StartupPath + iniFile.ReadValue("PROFILES", "0")))
return true;
return false;
}
}
示例3: init
public void init(string configToUse, string npcID)
{
isValid = false;
if (!File.Exists(configToUse)) return;
npcConfig = new IniFile(configToUse);
// [npc-1]
id = ulong.Parse(npcID);
// name="Goomba"
name = npcConfig.ReadValue(npcID, "name");
if (name.Length == 0) return;
// group="Enemy" ;The sort category
group = npcConfig.ReadValue(npcID, "group");
// category="Enemy" ;The sort category
category = npcConfig.ReadValue(npcID, "category");
// image="npc-1.gif" ;NPC Image file
image_n = npcConfig.ReadValue(npcID, "image");
mask_n = npcConfig.ReadValue(npcID, "image");
//You should append "m" letter into basename of filename
//
//
//Bitmap image;
//Bitmap mask;
// algorithm="0" ;NPC's alhorytm. Alhoritm have states and events (onDie, onTail, onCollisionWithFlyBlock...)
algorithm = int.Parse(npcConfig.ReadValue(npcID, "algorithm"));
// ;If algorithm = 0, will using basic parametric alhorythm.
// ;Else, get alhorythm from list
// default-effect=2 ;Spawn effect ID on jump-die
effect_1 = ulong.Parse(npcConfig.ReadValue(npcID, "default-effect"));
// shell-effect=4 ;effect on kick by shell or other NPC
effect_2 = ulong.Parse(npcConfig.ReadValue(npcID, "shell-effect"));
// ; graphics
gfx_offset_x = int.Parse(npcConfig.ReadValue(npcID, "gfx-offst-x"));
// gfx-offst-x=0
gfx_offset_y = int.Parse(npcConfig.ReadValue(npcID, "gfx-offst-y"));
// gfx-offst-y=2
gfx_h = int.Parse(npcConfig.ReadValue(npcID, "gfx-height"));
// gfx-height-y=32
gfx_w = int.Parse(npcConfig.ReadValue(npcID, "gfx-width"));
// gfx-width-y=32
custom_physics_to_gfx = bool.Parse(npcConfig.ReadValue(npcID, "physics-to-gfx")); //The GFX size defining by physics size in the custom configs
grid = int.Parse(npcConfig.ReadValue(npcID, "grid"));
// grid=32
// grid-offset-x=0
grid_offset_x = int.Parse(npcConfig.ReadValue(npcID, "grid-offset-x"));
// grid-offset-y=0
grid_offset_y = int.Parse(npcConfig.ReadValue(npcID, "grid-offset-y"));
//grid-attachement-style
grid_attach_style = int.Parse(npcConfig.ReadValue(npcID, "grid-attachement-style")); //0 - middle, 1 - left side
// frame-style=0 ; (0-2) This option in some alhoritmes can be ignored
framestyle = int.Parse(npcConfig.ReadValue(npcID, "frame-style"));
// frames=2
frames = int.Parse(npcConfig.ReadValue(npcID, "frames"));
// frame-speed=128
framespeed = int.Parse(npcConfig.ReadValue(npcID, "frame-speed"));
// foreground=0
foreground = bool.Parse(npcConfig.ReadValue(npcID, "foreground"));
// background=0
background = bool.Parse(npcConfig.ReadValue(npcID, "background"));
// animation-bidirectional=0
ani_bidir = bool.Parse(npcConfig.ReadValue(npcID, "animation-bidirectional"));
// animation-direction=0
ani_direct = bool.Parse(npcConfig.ReadValue(npcID, "animation-direction"));
ani_directed_direct = bool.Parse(npcConfig.ReadValue(npcID, "animation-directed-direction")); //Animation direction will be gotten from NPC's direction
// ; for editor
// custom-animation=0
custom_animate = bool.Parse(npcConfig.ReadValue(npcID, "custom-animation"));
// ; this option useful for non-standart algorithmic sprites (for example, bosses)
// ;custom-animation-alg=0 ; Custom animation algorithm
// 0 simple frame range, 1 - frame Jump; 2 - custom animation sequances
custom_ani_alg = int.Parse(npcConfig.ReadValue(npcID, "custom-animation-alg"));
// ;custom-animation-fl=0 ; First frame for LEFT
custom_ani_fl = int.Parse(npcConfig.ReadValue(npcID, "custom-animation-fl"));
// ;custom-animation-el=0 ; end frame for LEFT / Jump step
custom_ani_el = int.Parse(npcConfig.ReadValue(npcID, "custom-animation-el"));
// ;custom-animation-fr=0 ; first frame for RIGHT
custom_ani_fr = int.Parse(npcConfig.ReadValue(npcID, "custom-animation-fr"));
// ;custom-animation-er=0 ; end frame for RIGHT / Jump step
custom_ani_er = int.Parse(npcConfig.ReadValue(npcID, "custom-animation-er"));
List<string> tmp;
frames_left.Clear();
string framesListLeft = npcConfig.ReadValue(npcID, "ani-frames-left");
if (framesListLeft.Length > 0)
{
framesListLeft = framesListLeft.Replace(" ", "");
tmp = new List<string>(framesListLeft.Split(','));
for (int i = 0; i < tmp.Count(); i++)
frames_left.Add(int.Parse(tmp[i])); //Frame srquence for left
}
frames_right.Clear();
//.........这里部分代码省略.........
示例4: homeExePath_MouseHover
/// <summary>
/// Displays a tooltip on mouse hover
/// </summary>
private void homeExePath_MouseHover(object sender, EventArgs e)
{
using (IniFile iniFile = new IniFile())
{
// Switch: Default profile
iniFile.IniPath = Application.StartupPath + @"\locations.ini";
iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");
if (iniFile.ReadValue("MISCELLANEOUS", "tooltips") == "1")
{
// Show the tool tip
homeToolTip.Show(homeExePath.Text, homeExePath);
}
}
}
示例5: homeExePath_Click
/// <summary>
/// Opens a folder browser dialog to find the fsx.exe path
/// The path is then stored in locations.ini
/// </summary>
private void homeExePath_Click(object sender, EventArgs e)
{
// Set the folder browser description
homeBrowser.Description = homeBrowser.Description.Replace("[0]", "Flight Simulator X executable");
using (IniFile iniFile = new IniFile())
{
// Switch: locations.ini
iniFile.IniPath = Application.StartupPath + @"\locations.ini";
// Set the current selected path to the one in the ini
homeBrowser.SelectedPath = iniFile.ReadValue("LOCATIONS", "exe");
// Show the folder browser
homeBrowser.ShowDialog();
// Write the new value to the ini file
iniFile.WriteValue("LOCATIONS", "exe", homeBrowser.SelectedPath.ToString());
// Update the textbox
homeExePath.Text = iniFile.ReadValue("LOCATIONS", "exe");
}
// Reset the folder browser description
homeBrowser.Description = homeBrowser.Description.Replace("Flight Simulator X executable", "[0]");
}
示例6: homeApplyButton_ButtonClick
/// <summary>
/// Applies the current selected resolution to fsx.cfg
/// </summary>
private void homeApplyButton_ButtonClick()
{
using (IniFile iniFile = new IniFile())
{
/// <switch>current profile</switch>
iniFile.IniPath = Application.StartupPath + @"\locations.ini";
iniFile.IniPath = Application.StartupPath + iniFile.ReadValue("PROFILES", "0");
// Ding var
bool ding = false;
// Check for the secret ding switch
if (iniFile.ReadValue("MISCELLANEOUS", "ding") == "1")
ding = true;
/// <switch>fsx.cfg</switch>
iniFile.IniPath = Application.StartupPath + @"\locations.ini";
if (System.IO.File.Exists(iniFile.ReadValue("LOCATIONS", "cfg") + @"\fsx.cfg"))
{
if (System.IO.File.Exists(iniFile.ReadValue("LOCATIONS", "exe") + @"\fsx.exe"))
{
iniFile.IniPath = iniFile.ReadValue("LOCATIONS", "cfg") + @"\fsx.cfg";
if (homeResolution.SelectedItem != null)
{
// Ding!
if (ding)
using (Sound.TmleSound sound = new Sound.TmleSound())
sound.Play(Application.StartupPath + @"\Resources\apply.resource", sound.SND_FILENAME | sound.SND_ASYNC);
// Split the selected item up into a new array
string[] selectedItem = homeResolution.SelectedItem.ToString().Split(' ');
// Write the value to fsx.cfg
iniFile.WriteValue("GRAPHICS", "TEXTURE_MAX_LOAD", selectedItem[0].ToString());
// Null the form owner (.Net 1.1 -> 2.0 workaround)
Form formOwner = this.Owner;
this.Owner = null;
// Show the apply box
Apply apply = new Apply(selectedItem[0].ToString());
apply.ShowDialog();
// Reset the form owner
this.Owner = formOwner;
}
else
{
MessageBox.Show("Please select a resolution to apply from the resolutions drop down box",
"Unable to set resolution", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
else
{
MessageBox.Show("Your fsx.exe file could not be located. Please make sure you have selected your correct fsx.exe folder.",
"Unable to find fsx.exe", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
else
{
MessageBox.Show("Your fsx.cfg file could not be located. Please make sure you have run FSX at least once before trying to apply a resolution.",
"Unable to find fsx.cfg", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
示例7: Main
//.........这里部分代码省略.........
"Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
// Require an exit
requireExit = true;
}
}
else
{
// Show an error
MessageBox.Show("The file core.resource could not be found. Please reinstall the Texture Max Load Editor.",
"Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
// Require an exit
requireExit = true;
}
}
#endregion
#region Check INI Files
using (IniFile iniFile = new IniFile())
{
/// <switch>current profile</switch>
iniFile.IniPath = Application.StartupPath + @"\locations.ini";
if (!File.Exists(Application.StartupPath + @"\locations.ini"))
{
// Copy the locations resource
File.Copy(Application.StartupPath + @"\Resources\locations.resource",
Application.StartupPath + @"\locations.ini", false);
}
if (!File.Exists(Application.StartupPath + iniFile.ReadValue("PROFILES", "0")))
{
try
{
if (!Directory.Exists(Application.StartupPath + @"\Profiles\"))
{
Directory.CreateDirectory(Application.StartupPath + @"\Profiles\");
}
if (!File.Exists(Application.StartupPath + @"\Profiles\default.ini"))
{
// Copy the resource
File.Copy(Application.StartupPath + @"\Resources\profile.resource",
Application.StartupPath + @"\Profiles\default.ini", false);
}
// Write the new path value
iniFile.WriteValue("PROFILES", "0", @"\Profiles\default.ini");
// Success message
MessageBox.Show("The default profile specified in 'locations.ini' could not be found. A new one has been automatically generated.",
"Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch
{
// Error message
MessageBox.Show("The default profile specified in 'locations.ini' could not be found and a new profile could not be generated. Please reinstall the Texture Max Load Editor.",
"Integrity Check", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#endregion