Here are the examples of the csharp api System.Collections.Generic.List.IndexOf(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
591 Examples
19
Source : JSONObject.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
public void GetField(ref bool field, string name, FieldNotFound fail) {
if(type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = list[index].b;
return;
}
}
if(fail != null) fail.Invoke(name);
}
19
Source : JSONObject.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
public void GetField(ref float field, string name, FieldNotFound fail) {
#else
// Default parameters fix
public void GetField(ref double field, string name) { GetField(ref field, name, null); }
public void GetField(ref double field, string name, FieldNotFound fail) {
#endif
if(type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = list[index].n;
return;
}
}
if(fail != null) fail.Invoke(name);
}
19
Source : JSONObject.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
public void GetField(ref int field, string name, FieldNotFound fail) {
if(type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (int)list[index].n;
return;
}
}
if(fail != null) fail.Invoke(name);
}
19
Source : JSONObject.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
public void GetField(ref uint field, string name, FieldNotFound fail) {
if(type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (uint)list[index].n;
return;
}
}
if(fail != null) fail.Invoke(name);
}
19
Source : JSONObject.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
public void GetField(ref string field, string name, FieldNotFound fail) {
if(type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = list[index].str;
return;
}
}
if(fail != null) fail.Invoke(name);
}
19
Source : JSONObject.cs
with MIT License
from bonzaiferroni
with MIT License
from bonzaiferroni
public void GetField(string name, GetFieldResponse response, FieldNotFound fail) {
if(response != null && type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
response.Invoke(list[index]);
return;
}
}
if(fail != null) fail.Invoke(name);
}
19
Source : ListHelper.cs
with GNU General Public License v3.0
from BornToBeRoot
with GNU General Public License v3.0
from BornToBeRoot
public static List<string> Modify(List<string> list, string entry, int length)
{
var index = list.IndexOf(entry);
if (index != -1)
list.RemoveAt(index);
else if (list.Count == length)
list.RemoveAt(length - 1);
list.Insert(0, entry);
return list;
}
19
Source : SearchForm.cs
with MIT License
from botman99
with MIT License
from botman99
private void SaveConfig()
{
Config.Set(Config.KEY.SearchRegularExpression, RegExCheckBox.Checked);
Config.Set(Config.KEY.SearchMatchCase, MatchCaseCheckBox.Checked);
Config.Set(Config.KEY.SearchRecursive, RecurseFolderCheckBox.Checked);
// get the list of search text items from the combo box
List<string> SearchForComboBoxList = SearchForComboBox.Items.Cast<string>().ToList();
// if the combo box SearchFor text is already in that list, remove it from the list
int searchForIndex = SearchForComboBoxList.IndexOf(SearchFor);
if( searchForIndex != -1 )
{
SearchForComboBoxList.RemoveAt(searchForIndex); // remove duplicate
}
// if the combo box SearchFor text is already at the maximum number of elements, remove the last one
if( SearchForComboBoxList.Count >= NUM_SEARCH_HISTORY )
{
SearchForComboBoxList.RemoveAt(NUM_SEARCH_HISTORY - 1); // prune the list
}
// add the new SearchFor text to the start of the combo box list
SearchForComboBoxList.Insert(0, SearchFor);
// add the double quotes around the search text list
List<string> SearchTextList = new List<string>();
for( int i = 0; i < SearchForComboBoxList.Count; i++ )
{
SearchTextList.Add("\"" + SearchForComboBoxList[i] + "\"");
}
// save the search text list to the config file
Config.Set(Config.KEY.SearchText, SearchTextList);
// do the same for the FileSpec combo box
List<string> FileSpecComboBoxList = FileSpecComboBox.Items.Cast<string>().ToList();
int fileSpecIndex = FileSpecComboBoxList.IndexOf(FileSpec);
if( fileSpecIndex != -1 )
{
FileSpecComboBoxList.RemoveAt(fileSpecIndex); // remove duplicate
}
if( FileSpecComboBoxList.Count >= NUM_FILESPEC_HISTORY )
{
FileSpecComboBoxList.RemoveAt(NUM_FILESPEC_HISTORY - 1); // prune the list
}
FileSpecComboBoxList.Insert(0, FileSpec);
// we don't need to add double quotes to file specs
Config.Set(Config.KEY.SearchFileSpec, FileSpecComboBoxList);
// do the same for the Folder combo box
List<string> FolderComboBoxList = FolderComboBox.Items.Cast<string>().ToList();
int folderIndex = FolderComboBoxList.IndexOf(FolderName);
if( folderIndex != -1 )
{
FolderComboBoxList.RemoveAt(folderIndex); // remove duplicate
}
if( FolderComboBoxList.Count >= NUM_FOLDER_HISTORY )
{
FolderComboBoxList.RemoveAt(NUM_FOLDER_HISTORY - 1); // prune the list
}
FolderComboBoxList.Insert(0, FolderName);
// we don't need to add double quotes to folder names
Config.Set(Config.KEY.SearchFolder, FolderComboBoxList);
}
19
Source : MMRViewModel.cs
with MIT License
from Bphots
with MIT License
from Bphots
public void FillMMR(Game game)
{
int autoCloseSec = App.CustomConfigurationSettings.MMRAutoCloseTime;
if (autoCloseSec > 0)
{
_eventAggregator.PublishOnUIThread(new InvokeScriptMessage
{
ScriptName = "setAutoCloseSeconds",
Args = new[] { autoCloseSec.ToString() }
}, "MMRChanel");
}
_eventAggregator.PublishOnUIThread(new InvokeScriptMessage
{
ScriptName = "setLanguageForMessage",
Args = new[] { App.CustomConfigurationSettings.LanguageForMessage }
}, "MMRChanel");
// 取得地区ID
var regionId = ((int) game.Region).ToString();
// 玩家BattleTags
var battleTags = string.Join("|", game.Players
.Select(p => p.Tag + "#" + p.SelectedHero));
Players = game.Players.Select(p => p.Tag).ToList();
string defaultPlayer = Players.First();
if (App.UserDataSettings.PlayerTags.Any(p => Players.Contains(p)))
{
defaultPlayer = App.UserDataSettings.PlayerTags.First(p => Players.Contains(p));
App.UserDataSettings.PlayerTags.Remove(defaultPlayer);
App.UserDataSettings.PlayerTags.Insert(0, defaultPlayer);
}
else if (LastMatchPlayers.Count(p => Players.Contains(p)) == 1)
{
defaultPlayer = LastMatchPlayers.First(p => Players.Contains(p));
App.UserDataSettings.PlayerTags.Insert(0, defaultPlayer);
}
int defaultPlayerIndex = Players.IndexOf(defaultPlayer);
LastMatchPlayers.Clear();
LastMatchPlayers.AddRange(Players);
_eventAggregator.PublishOnUIThread(new InvokeScriptMessage
{
ScriptName = "setMap",
Args = new[] { game.Map }
}, "MMRChanel");
_eventAggregator.PublishOnUIThread(new InvokeScriptMessage
{
ScriptName = "setPlayers",
Args = new[] {regionId, defaultPlayerIndex.ToString(), battleTags}
}, "MMRChanel");
}
19
Source : TCP2_Utils.cs
with GNU General Public License v3.0
from brownhci
with GNU General Public License v3.0
from brownhci
public static void ShaderVariantUpdate(string feature, List<string> featuresList, List<bool> featuresEnabled, bool enable, ref bool update)
{
var featureIndex = featuresList.IndexOf(feature);
if(featureIndex < 0)
{
EditorGUILayout.HelpBox("Couldn't find shader feature in list: " + feature, MessageType.Error);
return;
}
if(featuresEnabled[featureIndex] != enable)
{
featuresEnabled[featureIndex] = enable;
update = true;
}
}
19
Source : Node.cs
with MIT License
from BrunoS3D
with MIT License
from BrunoS3D
public void RegisterPorts() {
recently_modified = new List<string>();
ports = ports ?? new Dictionary<string, Port>();
inputs = inputs ?? new Dictionary<string, Port>();
outputs = outputs ?? new Dictionary<string, Port>();
List<string> old_port_keys = new List<string>(ports.Keys);
List<string> old_inputs_keys = new List<string>(inputs.Keys);
List<string> old_outputs_keys = new List<string>(outputs.Keys);
if (this is IRegisterDefaultPorts) {
((IRegisterDefaultPorts)this).OnRegisterDefaultPorts();
}
if (this is IRegisterPorts) {
((IRegisterPorts)this).OnRegisterPorts();
}
foreach (string key in old_port_keys) {
if (!recently_modified.Contains(key)) {
ports.Remove(key);
}
}
foreach (string key in old_inputs_keys) {
if (!recently_modified.Contains(key)) {
inputs.Remove(key);
}
}
foreach (string key in old_outputs_keys) {
if (!recently_modified.Contains(key)) {
outputs.Remove(key);
}
}
var ports_sorted = ports.OrderBy(key => recently_modified.IndexOf(key.Key));
ports = ports_sorted.ToDictionary((key_item) => key_item.Key, (value_item) => value_item.Value);
var inputs_sorted = inputs.OrderBy(key => recently_modified.IndexOf(key.Key));
inputs = inputs_sorted.ToDictionary((key_item) => key_item.Key, (value_item) => value_item.Value);
var outputs_sorted = outputs.OrderBy(key => recently_modified.IndexOf(key.Key));
outputs = outputs_sorted.ToDictionary((key_item) => key_item.Key, (value_item) => value_item.Value);
port_keys = ports.Keys.ToList();
input_keys = inputs.Keys.ToList();
output_keys = outputs.Keys.ToList();
port_values = ports.Values.ToList();
input_values = inputs.Values.ToList();
output_values = outputs.Values.ToList();
}
19
Source : BlueprintBrowser.cs
with MIT License
from cabarius
with MIT License
from cabarius
public static IEnumerable OnGUI() {
if (blueprints == null) {
blueprints = BlueprintLoader.Shared.GetBlueprints();
if (blueprints != null) UpdateSearchResults();
}
// Stackable browser
using (UI.HorizontalScope(UI.Width(350))) {
var remainingWidth = UI.ummWidth;
// First column - Type Selection Grid
using (UI.VerticalScope(GUI.skin.box)) {
UI.ActionSelectionGrid(ref settings.selectedBPTypeFilter,
blueprintTypeFilters.Select(tf => tf.name).ToArray(),
1,
(selected) => { UpdateSearchResults(); },
UI.buttonStyle,
UI.Width(200));
}
remainingWidth -= 350;
var collationChanged = false;
if (collatedBPs != null) {
using (UI.VerticalScope(GUI.skin.box)) {
var selectedKey = collationKeys.ElementAt(selectedCollationIndex);
if (UI.VPicker<string>("Categories", ref selectedKey, collationKeys, null, s => s, ref collationSearchText, UI.Width(300))) {
collationChanged = true; BlueprintListUI.needsLayout = true;
}
if (selectedKey != null)
selectedCollationIndex = collationKeys.IndexOf(selectedKey);
#if false
UI.ActionSelectionGrid(ref selectedCollationIndex, collationKeys.ToArray(),
1,
(selected) => { collationChanged = true; BlueprintListUI.needsLayout = true; },
UI.buttonStyle,
UI.Width(200));
#endif
}
remainingWidth -= 450;
}
// Section Column - Main Area
using (UI.VerticalScope(UI.MinWidth(remainingWidth))) {
// Search Field and modifiers
using (UI.HorizontalScope()) {
UI.ActionTextField(
ref settings.searchText,
"searhText",
(text) => { },
() => UpdateSearchResults(),
UI.Width(400));
UI.Space(50);
UI.Label("Limit", UI.AutoWidth());
UI.Space(15);
UI.ActionIntTextField(
ref settings.searchLimit,
"searchLimit",
(limit) => { },
() => UpdateSearchResults(),
UI.Width(75));
if (settings.searchLimit > 1000) { settings.searchLimit = 1000; }
UI.Space(25);
if (UI.Toggle("Search Descriptions", ref settings.searchesDescriptions, UI.AutoWidth())) UpdateSearchResults();
UI.Space(25);
if (UI.Toggle("Attributes", ref settings.showAttributes, UI.AutoWidth())) UpdateSearchResults();
UI.Space(25);
UI.Toggle("Show GUIDs", ref settings.showreplacedetIDs, UI.AutoWidth());
UI.Space(25);
UI.Toggle("Components", ref settings.showComponents, UI.AutoWidth());
UI.Space(25);
UI.Toggle("Elements", ref settings.showElements, UI.AutoWidth());
}
// Search Button and Results Summary
using (UI.HorizontalScope()) {
UI.ActionButton("Search", () => {
UpdateSearchResults();
}, UI.AutoWidth());
UI.Space(25);
if (firstSearch) {
UI.Label("please note the first search may take a few seconds.".green(), UI.AutoWidth());
}
else if (matchCount > 0) {
var replacedle = "Matches: ".green().bold() + $"{matchCount}".orange().bold();
if (matchCount > settings.searchLimit) { replacedle += " => ".cyan() + $"{settings.searchLimit}".cyan().bold(); }
UI.Label(replacedle, UI.ExpandWidth(false));
}
UI.Space(130);
UI.Label($"Page: ".green() + $"{Math.Min(currentPage + 1, pageCount + 1)}".orange() + " / " + $"{pageCount + 1}".cyan(), UI.AutoWidth());
UI.ActionButton("-", () => {
currentPage = Math.Max(currentPage -= 1, 0);
UpdatePaginatedResults();
}, UI.AutoWidth());
UI.ActionButton("+", () => {
currentPage = Math.Min(currentPage += 1, pageCount);
UpdatePaginatedResults();
}, UI.AutoWidth());
UI.Space(25);
var pageNum = currentPage + 1;
if (UI.Slider(ref pageNum, 1, pageCount + 1, 1)) UpdatePaginatedResults();
currentPage = pageNum - 1;
}
UI.Space(10);
if (filteredBPs != null) {
CharacterPicker.OnGUI();
UnitReference selected = CharacterPicker.GetSelectedCharacter();
var bps = filteredBPs;
if (selectedCollationIndex == 0) {
selectedCollatedBPs = null;
matchCount = uncolatedMatchCount;
UpdatePageCount();
}
if (selectedCollationIndex > 0) {
if (collationChanged) {
UpdateCollation();
}
bps = selectedCollatedBPs;
}
BlueprintListUI.OnGUI(selected, bps, 0, remainingWidth, null, selectedTypeFilter, (keys) => {
if (keys.Length > 0) {
var changed = false;
//var bpTypeName = keys[0];
//var newTypeFilterIndex = blueprintTypeFilters.FindIndex(f => f.type.Name == bpTypeName);
//if (newTypeFilterIndex >= 0) {
// settings.selectedBPTypeFilter = newTypeFilterIndex;
// changed = true;
//}
if (keys.Length > 1) {
var collationKey = keys[1];
var newCollationIndex = collationKeys.FindIndex(ck => ck == collationKey);
if (newCollationIndex >= 0) {
selectedCollationIndex = newCollationIndex;
UpdateCollation();
}
}
if (changed) {
UpdateSearchResults();
}
}
}).ForEach(action => action());
}
UI.Space(25);
}
}
return null;
}
19
Source : CustomEventsContainer.cs
with GNU General Public License v2.0
from Caeden117
with GNU General Public License v2.0
from Caeden117
private void RefreshTrack()
{
foreach (var t in customEventScalingOffsets)
{
var localScale = t.localScale;
if (customEventTypes.Count == 0)
{
t.gameObject.SetActive(false);
}
else
{
t.gameObject.SetActive(true);
t.localScale = new Vector3((customEventTypes.Count / 10f) + 0.01f, localScale.y, localScale.z);
}
}
for (var i = 0; i < customEventLabelTransform.childCount; i++)
Destroy(customEventLabelTransform.GetChild(i).gameObject);
foreach (var str in customEventTypes)
{
var newreplaced = Instantiate(customEventLabelPrefab.gameObject, customEventLabelTransform)
.GetComponent<TextMeshProUGUI>();
newreplaced.rectTransform.localPosition = new Vector3(customEventTypes.IndexOf(str), 0.25f, 0);
newreplaced.text = str;
}
foreach (var obj in LoadedContainers.Values) obj.UpdateGridPosition();
}
19
Source : SongInfoEditUI.cs
with GNU General Public License v2.0
from Caeden117
with GNU General Public License v2.0
from Caeden117
public static int GetDirectionalEnvironmentIDFromString(string platforms) =>
vanillaDirectionalEnvironments.IndexOf(platforms);
19
Source : SilverlightSerializer.cs
with MIT License
from CalciumFramework
with MIT License
from CalciumFramework
private static ushort GetPropertyDefinitionId(string name)
{
lock (_propertyIds)
{
var ret = _propertyIds.IndexOf(name);
if (ret >= 0)
return (ushort)ret;
_propertyIds.Add(name);
return (ushort)(_propertyIds.Count - 1);
}
}
19
Source : UnityBuild.cs
with The Unlicense
from CarlHalstead
with The Unlicense
from CarlHalstead
public static void BuildPlatforms()
{
List<string> arguments = Environment.GetCommandLineArgs().ToList();
string buildLocation = string.Empty;
if (arguments.Contains("-buildPath"))
buildLocation = arguments[arguments.IndexOf("-buildPath") + 1];
else
throw new ArgumentException("Project must be launched with a -buildPath argument! Where would we build the project too otherwise?");
if (arguments.Contains("-windows32"))
BuildWindows32(buildLocation);
if (arguments.Contains("-windows64"))
BuildWindows64(buildLocation);
if (arguments.Contains("-linux64"))
BuildLinux64(buildLocation);
if (arguments.Contains("-macos"))
BuildMacOS(buildLocation);
if (arguments.Contains("-android"))
BuildAndroid(buildLocation);
if (arguments.Contains("-ios"))
BuildiOS(buildLocation);
if (arguments.Contains("-webgl"))
BuildWebGL(buildLocation);
}
19
Source : ModbusRegistorConfigModel.cs
with Apache License 2.0
from cdy816
with Apache License 2.0
from cdy816
public void ParseRegistorInfo(string info)
{
string[] ss = info.Split(new char[] { ':' });
if (ss.Length == 3)
{
RegistorType = mInnerRegistorTypes.IndexOf(ss[0]);
StartAddress = int.Parse(ss[1]);
DataLen = int.Parse(ss[2]);
}
else
{
RegistorType = 0;
DataLen = GetDataSize();
}
}
19
Source : OptionValueCollection.cs
with GNU General Public License v3.0
from chaincase-app
with GNU General Public License v3.0
from chaincase-app
public int IndexOf(string item)
{
return Values.IndexOf(item);
}
19
Source : momiji_preferences.cs
with BSD 2-Clause "Simplified" License
from chengse66
with BSD 2-Clause "Simplified" License
from chengse66
internal static void initialize()
{
idenreplacedies = new List<string>()
{
"general_explorer_style",
"general_top_most",
"general_application_language",
"advance_output_location",
"advance_output_frames",
"advance_output_maxcolor",
"advance_output_backcolor",
"advance_display_items",
"advance_display_backcolor",
"palette_default_colors",
};
values = new List<object>()
{
true, false, "", Application.StartupPath + "\\gallery", false, 256, 0x00000000, 30, 0x00ffff80, "",
};
if (File.Exists(location))
foreach (string entry in File.ReadAllLines(location))
{
string[] sections = entry.Split(new char[] { '=', }, 2);
if (2 == sections.Length)
{
int index = idenreplacedies.IndexOf(sections[0].Trim().ToLower());
if (-1 < index)
values[index] = Convert.ChangeType(sections[1].Trim(), values[index].GetType());
}
}
apply();
}
19
Source : momiji_preferences.cs
with BSD 2-Clause "Simplified" License
from chengse66
with BSD 2-Clause "Simplified" License
from chengse66
internal static void alter(string ietf)
{
string language = string.Concat(location, "\\", "momiji", "." + ietf + ".", "language");
if (File.Exists(language))
foreach (string entry in File.ReadAllLines(language))
{
string[] sections = entry.Split(new char[] { '=', }, 2);
if (2 == sections.Length)
{
int index = idenreplacedies.IndexOf(sections[0].Trim().ToLower());
if (-1 < index)
values[index] = sections[1].Trim();
}
}
}
19
Source : momiji_preferences.cs
with BSD 2-Clause "Simplified" License
from chengse66
with BSD 2-Clause "Simplified" License
from chengse66
internal static int index_of(string ietf)
{
return languages.IndexOf(ietf);
}
19
Source : wzproperty.cs
with BSD 2-Clause "Simplified" License
from chengse66
with BSD 2-Clause "Simplified" License
from chengse66
internal static int index_of_type(string type)
{
return types.IndexOf(type);
}
19
Source : actions.cs
with BSD 2-Clause "Simplified" License
from chengse66
with BSD 2-Clause "Simplified" License
from chengse66
internal void update_actions()
{
if (Visible)
SendMessage(Handle, 0x000b, 0, 0);
timer.Enabled = false;
enable_action(false);
enable_emotion(false);
enable_others(false);
actions1.SelectedIndex = -1;
actions2.SelectedIndex = -1;
frames1.SelectedIndex = -1;
frames2.SelectedIndex = -1;
actions1.Items.Clear();
actions2.Items.Clear();
frames1.Items.Clear();
frames2.Items.Clear();
if (null != animation)
if (0 < animation.actions.Count)
{
actions1.Items.AddRange(animation.actions.ToArray());
if (animation.actions.Contains(animation.current1))
{
actions1.SelectedIndex = animation.actions.IndexOf(animation.current1);
}
else
{
int index;
for (index = 0; index < animation.actions.Count; ++index)
if (animation.actions[index].StartsWith("stand"))
{
actions1.SelectedIndex = index;
break;
}
if (animation.actions.Count == index)
actions1.SelectedIndex = 0;
}
enable_action(true);
if (null != animation.emotions)
{
actions2.Items.AddRange(animation.emotions.ToArray());
actions2.SelectedIndex = 0 > animation.emotions.IndexOf(animation.current2) ? 0 : animation.emotions.IndexOf(animation.current2);
enable_emotion(true);
}
if ("character" == current.type)
enable_others(true);
timer.Enabled = true;
}
if (Visible)
SendMessage(Handle, 0x000b, 1, 0);
Refresh();
}
19
Source : EditorCompilationAsmCacheModelSo.cs
with MIT License
from chenwansal
with MIT License
from chenwansal
public void SetDirty(string file) {
int index = dirtyFiles.IndexOf(file);
if (index == -1) {
dirtyFiles.Add(file);
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from cobbr
with GNU General Public License v3.0
from cobbr
private static BridgeProfile GetProfile(ref string[] args)
{
BridgeProfile profile = new BridgeProfile();
if (args.Contains("--profile"))
{
List<string> argList = args.ToList();
int profIndex = argList.IndexOf("--profile");
if (args.Length < profIndex)
{
return null;
}
try
{
profile = BridgeProfile.Create(args[profIndex + 1]);
}
catch
{
return null;
}
argList.Remove(args[profIndex]);
argList.Remove(args[profIndex + 1]);
args = argList.ToArray();
}
return profile;
}
19
Source : JSONObject.cs
with GNU General Public License v3.0
from Cocos-BCX
with GNU General Public License v3.0
from Cocos-BCX
public bool GetField(ref bool field, string name, FieldNotFound fail = null) {
if(type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = list[index].b;
return true;
}
}
if(fail != null) fail.Invoke(name);
return false;
}
19
Source : JSONObject.cs
with GNU General Public License v3.0
from Cocos-BCX
with GNU General Public License v3.0
from Cocos-BCX
public bool GetField(ref float field, string name, FieldNotFound fail = null) {
#else
public bool GetField(ref double field, string name, FieldNotFound fail = null) {
#endif
if(type == Type.OBJECT) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = list[index].n;
return true;
}
}
if(fail != null) fail.Invoke(name);
return false;
}
19
Source : JSONObject.cs
with GNU General Public License v3.0
from Cocos-BCX
with GNU General Public License v3.0
from Cocos-BCX
public bool GetField(ref uint field, string name, FieldNotFound fail = null) {
if(IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (uint)list[index].n;
return true;
}
}
if(fail != null) fail.Invoke(name);
return false;
}
19
Source : JSONObject.cs
with GNU General Public License v3.0
from Cocos-BCX
with GNU General Public License v3.0
from Cocos-BCX
public bool GetField(ref string field, string name, FieldNotFound fail = null) {
if(IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = list[index].str;
return true;
}
}
if(fail != null) fail.Invoke(name);
return false;
}
19
Source : JSONObject.cs
with GNU General Public License v3.0
from Cocos-BCX
with GNU General Public License v3.0
from Cocos-BCX
public void GetField(string name, GetFieldResponse response, FieldNotFound fail = null) {
if(response != null && IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
response.Invoke(list[index]);
return;
}
}
if(fail != null) fail.Invoke(name);
}
19
Source : JSONObject.cs
with GNU General Public License v3.0
from Cocos-BCX
with GNU General Public License v3.0
from Cocos-BCX
public bool GetField(ref int field, string name, FieldNotFound fail = null) {
if(IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (int)list[index].n;
return true;
}
}
if(fail != null) fail.Invoke(name);
return false;
}
19
Source : JSONObject.cs
with GNU General Public License v3.0
from Cocos-BCX
with GNU General Public License v3.0
from Cocos-BCX
public bool GetField(ref long field, string name, FieldNotFound fail = null) {
if(IsObject) {
int index = keys.IndexOf(name);
if(index >= 0) {
field = (long)list[index].n;
return true;
}
}
if(fail != null) fail.Invoke(name);
return false;
}
19
Source : TokenizerCodeGenerator.cs
with MIT License
from codewitch-honey-crisis
with MIT License
from codewitch-honey-crisis
static CodeTypeDeclaration _CreateTokenizerClreplaced(LexDoreplacedent lex, IList<string> symbolTable, string name,IProgress<FAProgress> progress)
{
var lexer = lex.ToLexer(progress);
var ii = 0;
var syms = new List<string>(symbolTable);
var bes = new string[syms.Count];
for (ii = 0; ii < bes.Length; ii++)
bes[ii] = lex.GetAttribute(syms[ii], "blockEnd", null) as string;
lexer = lexer.ToDfa(progress);
//lexer.TrimDuplicates(progress);
var dfaTable = lexer.ToArray(syms);
var result = new CodeTypeDeclaration();
var tt = new List<string>();
for (int ic = lex.Rules.Count, i = 0; i < ic; ++i)
{
var t = lex.Rules[i].Left;
if (!tt.Contains(t))
tt.Add(t);
}
tt.Add("#EOS");
tt.Add("#ERROR");
for (int ic = syms.Count, i = 0; i < ic; ++i)
{
if (!tt.Contains(syms[i]))
syms[i] = null;
}
result.Name = name;
result.BaseTypes.Add(typeof(TableTokenizer));
result.Attributes = MemberAttributes.FamilyOrreplacedembly;
CodeMemberField f;
foreach (var t in tt)
{
if (null != t)
{
f = new CodeMemberField();
f.Attributes = MemberAttributes.Const | MemberAttributes.Public;
f.Name = t.Replace("#", "_").Replace("'", "_").Replace("<", "_").Replace(">", "_");
f.Type = new CodeTypeReference(typeof(int));
f.InitExpression = CodeDomUtility.Serialize(syms.IndexOf(t));
result.Members.Add(f);
}
}
f = new CodeMemberField();
f.Name = "_Symbols";
f.Type = new CodeTypeReference(typeof(string[]));
f.Attributes = MemberAttributes.Static;
var arr = new string[syms.Count];
syms.CopyTo(arr, 0);
f.InitExpression = CodeDomUtility.Serialize(arr);
result.Members.Add(f);
f = new CodeMemberField();
f.Name = "_BlockEnds";
f.Type = new CodeTypeReference(typeof(string[]));
f.Attributes = MemberAttributes.Static;
f.InitExpression = CodeDomUtility.Serialize(bes);
result.Members.Add(f);
f = new CodeMemberField();
f.Name = "_DfaTable";
f.Type = new CodeTypeReference(typeof(CharDfaEntry[]));
f.Attributes = MemberAttributes.Static;
f.InitExpression = CodeDomUtility.Serialize(dfaTable);
result.Members.Add(f);
var ctor = new CodeConstructor();
ctor.Parameters.Add(new CodeParameterDeclarationExpression(typeof(IEnumerable<char>), "input"));
ctor.BaseConstructorArgs.AddRange(new CodeExpression[] {
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(result.Name), "_DfaTable"),
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(result.Name), "_Symbols"),
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(result.Name), "_BlockEnds"),
new CodeArgumentReferenceExpression("input")
});
ctor.Attributes = MemberAttributes.Public;
result.Members.Add(ctor);
return result;
}
19
Source : MachineConfig.cs
with MIT License
from colinator27
with MIT License
from colinator27
public void EditProject(string projectDir, ProjectConfig config)
{
if (!EnableProjectTracking)
return;
Projects[projectDir] = config;
// Update recent projects list
int ind = RecentProjects.IndexOf(projectDir);
if (ind != -1)
RecentProjects.RemoveAt(ind);
else if (RecentProjects.Count == MaxRecentProjects)
RecentProjects.RemoveAt(MaxRecentProjects - 1);
RecentProjects.Insert(0, projectDir);
}
19
Source : SceneSwitcherWindow.cs
with MIT License
from coryleach
with MIT License
from coryleach
private void MoveDown(string guid)
{
var index = _sceneSwitcherData.sceneGuids.IndexOf(guid);
_sceneSwitcherData.sceneGuids.RemoveAt(index);
if (index < _sceneSwitcherData.sceneGuids.Count)
{
index++;
}
_sceneSwitcherData.sceneGuids.Insert(index, guid);
}
19
Source : SceneSwitcherWindow.cs
with MIT License
from coryleach
with MIT License
from coryleach
private void MoveUp(string guid)
{
var index = _sceneSwitcherData.sceneGuids.IndexOf(guid);
_sceneSwitcherData.sceneGuids.RemoveAt(index);
if (index > 0)
{
index--;
}
_sceneSwitcherData.sceneGuids.Insert(index, guid);
}
19
Source : JSON.cs
with GNU General Public License v3.0
from CrackyStudio
with GNU General Public License v3.0
from CrackyStudio
public static int GetSelectedIndexProperty(string searchedKey, JObject refObject)
{
string keyValue = Read(serverJson)[searchedKey].ToString();
string key = "";
foreach (var item in refObject)
{
if (item.Value.ToString() == keyValue)
{
key = item.Key;
}
}
List<string> list = new List<string> { };
foreach (var item in refObject)
{
list.Add(item.Key.ToString());
}
return list.IndexOf(key);
}
19
Source : Controller.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
public void SetSelectedPage(string value)
{
int i = _pageNames.IndexOf(value);
if (i == -1)
i = 0;
this.SetSelectedIndex(i);
}
19
Source : Controller.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
public string GetPageIdByName(string aName)
{
int i = _pageNames.IndexOf(aName);
if (i != -1)
return _pageIds[i];
else
return null;
}
19
Source : Controller.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
public bool HasPage(string aName)
{
return _pageNames.IndexOf(aName) != -1;
}
19
Source : Controller.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
internal string GetPageNameById(string aId)
{
int i = _pageIds.IndexOf(aId);
if (i != -1)
return _pageNames[i];
else
return null;
}
19
Source : Controller.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
public void RemovePage(string name)
{
int i = _pageNames.IndexOf(name);
if (i != -1)
{
_pageIds.RemoveAt(i);
_pageNames.RemoveAt(i);
if (_selectedIndex >= _pageIds.Count)
this.selectedIndex = _selectedIndex - 1;
else
parent.ApplyController(this);
}
}
19
Source : Controller.cs
with MIT License
from CragonGame
with MIT License
from CragonGame
internal int GetPageIndexById(string aId)
{
return _pageIds.IndexOf(aId);
}
19
Source : MainCfg.cs
with GNU General Public License v2.0
from CrazyKTV
with GNU General Public License v2.0
from CrazyKTV
private void MainCfg_NonSingerDataLogTask()
{
Thread.CurrentThread.Priority = ThreadPriority.Lowest;
List<string> list = new List<string>();
List<string> Singerlist = new List<string>();
List<string> SpecialStrlist = new List<string>(Regex.Split(Global.SongAddSpecialStr, @"\|", RegexOptions.IgnoreCase));
DataTable dt = new DataTable();
string SingerQuerySqlStr = "SELECT First(Song_Singer) AS Song_Singer, First(Song_SingerType) AS Song_SingerType, Count(Song_Singer) AS Song_SingerCount FROM ktv_Song GROUP BY Song_Singer HAVING First(Song_SingerType)<=10 AND First(Song_SingerType)<>8 AND First(Song_SingerType)<>9 AND Count(Song_Singer)>0 ORDER BY First(Song_SingerType), First(Song_Singer)";
dt = CommonFunc.GetOleDbDataTable(Global.CrazyktvDatabaseFile, SingerQuerySqlStr, "");
if (dt.Rows.Count > 0)
{
string SingerName = "";
string SingerType = "";
foreach (DataRow row in dt.AsEnumerable())
{
SingerName = row["Song_Singer"].ToString();
SingerType = row["Song_SingerType"].ToString();
if (SingerType == "3")
{
List<string> slist = CommonFunc.GetChorusSingerList(SingerName);
foreach (string str in slist)
{
string ChorusSingerName = Regex.Replace(str, @"^\s*|\s*$", ""); //去除頭尾空白
if (Singerlist.IndexOf(ChorusSingerName) < 0)
{
// 查找資料庫預設歌手資料表
if (SingerMgr.AllSingerLowCaseList.IndexOf(ChorusSingerName.ToLower()) < 0)
{
if (list.IndexOf(ChorusSingerName) < 0)
{
list.Add(ChorusSingerName);
lock (LockThis) { Global.TotalList[1]++; }
}
}
Singerlist.Add(ChorusSingerName);
}
}
slist.Clear();
slist = null;
}
else
{
if (Singerlist.IndexOf(SingerName) < 0)
{
if (SingerMgr.AllSingerLowCaseList.IndexOf(SingerName.ToLower()) < 0)
{
if (list.IndexOf(SingerName) < 0)
{
list.Add(SingerName);
lock (LockThis) { Global.TotalList[1]++; }
}
}
Singerlist.Add(SingerName);
}
}
lock (LockThis) { Global.TotalList[0]++; }
this.BeginInvoke((Action)delegate()
{
MainCfg_Tooltip_Label.Text = "已解析到 " + Global.TotalList[0] + " 位歌手資料,請稍待...";
});
}
}
Singerlist.Clear();
dt.Dispose();
if (list.Count > 0)
{
foreach (string str in list)
{
Global.SongLogDT.Rows.Add(Global.SongLogDT.NewRow());
Global.SongLogDT.Rows[Global.SongLogDT.Rows.Count - 1][0] = "【記錄無資料歌手】未在預設歌手資料表的歌手: " + str;
Global.SongLogDT.Rows[Global.SongLogDT.Rows.Count - 1][1] = Global.SongLogDT.Rows.Count;
}
}
}
19
Source : MainCfg.cs
with GNU General Public License v2.0
from CrazyKTV
with GNU General Public License v2.0
from CrazyKTV
private void MainCfg_NonPhoneticsWordLogTask()
{
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
List<string> list = new List<string>();
string SongQuerySqlStr = "select Song_Id, Song_Lang, Song_SingerType, Song_Singer, Song_SongName, Song_Track, Song_SongType, Song_Volume, Song_PlayCount, Song_FileName, Song_Path from ktv_Song order by Song_Id";
using (DataTable SongDT = CommonFunc.GetOleDbDataTable(Global.CrazyktvDatabaseFile, SongQuerySqlStr, ""))
{
string MatchWord = "";
List<string> wordlist = new List<string>();
Parallel.ForEach(SongDT.AsEnumerable(), (row, loopState) =>
{
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
MatchWord = row["Song_Singer"].ToString() + row["Song_SongName"].ToString();
MatchWord = Regex.Replace(MatchWord, @"[\{\(\[{([【].+?[】])}\]\)\}]", "");
if (MatchWord != "")
{
MatchCollection CJKCharMatches = Regex.Matches(MatchWord, @"([\u2E80-\u33FF]|[\u4E00-\u9FCC\u3400-\u4DB5\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\ud840-\ud868][\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|[\ud86a-\ud86c][\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d]|[\uac00-\ud7ff])");
if (CJKCharMatches.Count > 0)
{
foreach (Match m in CJKCharMatches)
{
if (wordlist.IndexOf(m.Value) < 0)
{
// 查找資料庫拼音資料
if (Global.PhoneticsWordList.IndexOf(m.Value) < 0)
{
if (list.IndexOf(m.Value) < 0)
{
list.Add(m.Value);
lock (LockThis) { Global.TotalList[1]++; }
}
}
wordlist.Add(m.Value);
}
}
}
}
lock (LockThis) { Global.TotalList[0]++; }
this.BeginInvoke((Action)delegate()
{
MainCfg_Tooltip_Label.Text = "正在解析第 " + Global.TotalList[0] + " 首歌曲的拼音資料,請稍待...";
});
});
wordlist.Clear();
}
if (list.Count > 0)
{
foreach (string str in list)
{
Global.SongLogDT.Rows.Add(Global.SongLogDT.NewRow());
Global.SongLogDT.Rows[Global.SongLogDT.Rows.Count - 1][0] = "【記錄無拼音字】未在拼音資料表的文字: " + str;
Global.SongLogDT.Rows[Global.SongLogDT.Rows.Count - 1][1] = Global.SongLogDT.Rows.Count;
}
}
list.Clear();
}
19
Source : SingerMgrDataGridView.cs
with GNU General Public License v2.0
from CrazyKTV
with GNU General Public License v2.0
from CrazyKTV
private void SingerMgr_DataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (SingerMgr_EditMode_CheckBox.Checked == true)
{
if (SingerMgr_DataGridView.SelectedRows.Count > 0)
{
switch (e.KeyCode)
{
case Keys.Delete:
if (MessageBox.Show("你確定要移除歌手嗎?", "刪除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
List<string> RemoveSingerIdlist = new List<string>();
foreach (DataGridViewRow row in SingerMgr_DataGridView.SelectedRows)
{
RemoveSingerIdlist.Add(row.Cells["Singer_Id"].Value.ToString());
}
using (DataTable dt = (DataTable)SingerMgr_DataGridView.DataSource)
{
List<DataRow> RemoveRomList = new List<DataRow>();
foreach (DataRow row in dt.Rows)
{
if (RemoveSingerIdlist.IndexOf(row["Singer_Id"].ToString()) > -1)
{
RemoveRomList.Add(row);
}
}
foreach (DataRow row in RemoveRomList)
{
dt.Rows.Remove(row);
}
RemoveRomList.Clear();
}
Global.TotalList = new List<int>() { 0, 0, 0, 0 };
Common_SwitchSetUI(false);
var tasks = new List<Task>()
{
Task.Factory.StartNew(() => SingerMgr_SingerRemoveTask(RemoveSingerIdlist))
};
Task.Factory.ContinueWhenAll(tasks.ToArray(), EndTask =>
{
this.BeginInvoke((Action)delegate()
{
Common_SwitchSetUI(true);
Task.Factory.StartNew(() => Common_GetSingerStatisticsTask());
SingerMgr_Tooltip_Label.Text = "已成功移除 " + Global.TotalList[0] + " 位歌手資料。";
RemoveSingerIdlist.Clear();
});
});
}
break;
}
}
}
}
19
Source : SongAddSong.cs
with GNU General Public License v2.0
from CrazyKTV
with GNU General Public License v2.0
from CrazyKTV
public static void StartAddSong(int i)
{
// 判斷是否為重複歌曲
string DuplicateSongId = "";
float DuplicateSongMB = 0;
string SongData = SongAddDT.Rows[i].Field<string>("Song_Lang") + "|" + SongAddDT.Rows[i].Field<string>("Song_Singer").ToLower() + "|" + SongAddDT.Rows[i].Field<string>("Song_SongName").ToLower() + "|" + SongAddDT.Rows[i].Field<string>("Song_SongType").ToLower();
CommonFunc.DupSongStatus DupSongStatus = CommonFunc.IsDupSong(SongAddDT.Rows[i].Field<string>("Song_Lang"), SongAddDT.Rows[i].Field<string>("Song_Singer"), SongAddDT.Rows[i].Field<int>("Song_SingerType"), SongAddDT.Rows[i].Field<string>("Song_SongName"), SongAddDT.Rows[i].Field<string>("Song_SongType"), SongDataLowCaseList);
if (DupSongStatus.IsDupSong)
{
DuplicateSongId = SongDataIdList[DupSongStatus.DupSongIndex];
string file = SongDataFilePathList[DupSongStatus.DupSongIndex];
if (File.Exists(file))
{
FileInfo f = new FileInfo(file);
DuplicateSongMB = float.Parse(((f.Length / 1024f) / 1024f).ToString("F2"));
}
switch (Global.SongAddDupSongMode)
{
case "1":
lock (LockThis)
{
Global.TotalList[1]++;
Global.DuplicateSongDT.Rows.Add(Global.DuplicateSongDT.NewRow());
Global.DuplicateSongDT.Rows[Global.DuplicateSongDT.Rows.Count - 1][0] = SongAddDT.Rows[i].Field<string>("Song_SrcPath");
Global.DuplicateSongDT.Rows[Global.DuplicateSongDT.Rows.Count - 1][1] = Global.DuplicateSongDT.Rows.Count;
}
break;
case "2":
DataRow row2 = DupSongAddDT.NewRow();
row2["Song_AddStatus"] = "重複歌曲ID: " + DuplicateSongId;
row2["Song_Id"] = DuplicateSongId;
row2["Song_Lang"] = SongAddDT.Rows[i].Field<string>("Song_Lang");
row2["Song_SingerType"] = SongAddDT.Rows[i].Field<int>("Song_SingerType");
row2["Song_Singer"] = SongAddDT.Rows[i].Field<string>("Song_Singer");
row2["Song_SongName"] = SongAddDT.Rows[i].Field<string>("Song_SongName");
row2["Song_Track"] = SongAddDT.Rows[i].Field<int>("Song_Track");
row2["Song_SongType"] = SongAddDT.Rows[i].Field<string>("Song_SongType");
row2["Song_Volume"] = SongAddDT.Rows[i].Field<int>("Song_Volume");
row2["Song_WordCount"] = SongAddDT.Rows[i].Field<int>("Song_WordCount");
row2["Song_PlayCount"] = SongAddDT.Rows[i].Field<int>("Song_PlayCount");
row2["Song_MB"] = SongAddDT.Rows[i].Field<float>("Song_MB");
row2["Song_CreatDate"] = SongAddDT.Rows[i].Field<DateTime>("Song_CreatDate");
row2["Song_FileName"] = Path.GetFileName(SongDataFilePathList[DupSongStatus.DupSongIndex]);
row2["Song_Path"] = Path.GetDirectoryName(SongDataFilePathList[DupSongStatus.DupSongIndex]) + @"\";
row2["Song_Spell"] = SongAddDT.Rows[i].Field<string>("Song_Spell");
row2["Song_SpellNum"] = SongAddDT.Rows[i].Field<string>("Song_SpellNum");
row2["Song_SongStroke"] = SongAddDT.Rows[i].Field<int>("Song_SongStroke");
row2["Song_PenStyle"] = SongAddDT.Rows[i].Field<string>("Song_PenStyle");
row2["Song_PlayState"] = SongAddDT.Rows[i].Field<int>("Song_PlayState");
row2["Song_SrcPath"] = SongAddDT.Rows[i].Field<string>("Song_SrcPath");
row2["Song_SortIndex"] = "1";
row2["Song_ReplayGain"] = SongAddDT.Rows[i].Field<string>("Song_ReplayGain");
DupSongAddDT.Rows.Add(row2);
break;
case "3":
if (SongAddDT.Rows[i].Field<float>("Song_MB") > DuplicateSongMB)
{
DataRow row3 = DupSongAddDT.NewRow();
row3["Song_AddStatus"] = "重複歌曲";
row3["Song_Id"] = DuplicateSongId;
row3["Song_Lang"] = SongAddDT.Rows[i].Field<string>("Song_Lang");
row3["Song_SingerType"] = SongAddDT.Rows[i].Field<int>("Song_SingerType");
row3["Song_Singer"] = SongAddDT.Rows[i].Field<string>("Song_Singer");
row3["Song_SongName"] = SongAddDT.Rows[i].Field<string>("Song_SongName");
row3["Song_Track"] = SongAddDT.Rows[i].Field<int>("Song_Track");
row3["Song_SongType"] = SongAddDT.Rows[i].Field<string>("Song_SongType");
row3["Song_Volume"] = SongAddDT.Rows[i].Field<int>("Song_Volume");
row3["Song_WordCount"] = SongAddDT.Rows[i].Field<int>("Song_WordCount");
row3["Song_PlayCount"] = SongAddDT.Rows[i].Field<int>("Song_PlayCount");
row3["Song_MB"] = SongAddDT.Rows[i].Field<float>("Song_MB");
row3["Song_CreatDate"] = SongAddDT.Rows[i].Field<DateTime>("Song_CreatDate");
row3["Song_FileName"] = Path.GetFileName(SongDataFilePathList[DupSongStatus.DupSongIndex]);
row3["Song_Path"] = Path.GetDirectoryName(SongDataFilePathList[DupSongStatus.DupSongIndex]) + @"\";
row3["Song_Spell"] = SongAddDT.Rows[i].Field<string>("Song_Spell");
row3["Song_SpellNum"] = SongAddDT.Rows[i].Field<string>("Song_SpellNum");
row3["Song_SongStroke"] = SongAddDT.Rows[i].Field<int>("Song_SongStroke");
row3["Song_PenStyle"] = SongAddDT.Rows[i].Field<string>("Song_PenStyle");
row3["Song_PlayState"] = SongAddDT.Rows[i].Field<int>("Song_PlayState");
row3["Song_SrcPath"] = SongAddDT.Rows[i].Field<string>("Song_SrcPath");
row3["Song_SortIndex"] = "1";
row3["Song_ReplayGain"] = SongAddDT.Rows[i].Field<string>("Song_ReplayGain");
DupSongAddDT.Rows.Add(row3);
}
else
{
lock (LockThis)
{
Global.TotalList[1]++;
Global.DuplicateSongDT.Rows.Add(Global.DuplicateSongDT.NewRow());
Global.DuplicateSongDT.Rows[Global.DuplicateSongDT.Rows.Count - 1][0] = SongAddDT.Rows[i].Field<string>("Song_SrcPath");
Global.DuplicateSongDT.Rows[Global.DuplicateSongDT.Rows.Count - 1][1] = Global.DuplicateSongDT.Rows.Count;
}
}
break;
}
}
else
{
string SongId = SongAddDT.Rows[i].Field<string>("Song_Id"); ;
string SongLang = SongAddDT.Rows[i].Field<string>("Song_Lang");
int SongSingerType = SongAddDT.Rows[i].Field<int>("Song_SingerType");
string SongSinger = SongAddDT.Rows[i].Field<string>("Song_Singer");
string SongSongName = SongAddDT.Rows[i].Field<string>("Song_SongName");
int SongTrack = SongAddDT.Rows[i].Field<int>("Song_Track");
string SongSongType = SongAddDT.Rows[i].Field<string>("Song_SongType");
int SongVolume = SongAddDT.Rows[i].Field<int>("Song_Volume");
int SongWordCount = SongAddDT.Rows[i].Field<int>("Song_WordCount");
int SongPlayCount = SongAddDT.Rows[i].Field<int>("Song_PlayCount");
float SongMB = SongAddDT.Rows[i].Field<float>("Song_MB");
DateTime SongCreatDate = SongAddDT.Rows[i].Field<DateTime>("Song_CreatDate");
string SongFileName = "";
string SongPath = "";
string SongSpell = SongAddDT.Rows[i].Field<string>("Song_Spell");
string SongSpellNum = SongAddDT.Rows[i].Field<string>("Song_SpellNum");
int SongSongStroke = SongAddDT.Rows[i].Field<int>("Song_SongStroke");
string SongPenStyle = SongAddDT.Rows[i].Field<string>("Song_PenStyle");
int SongPlayState = SongAddDT.Rows[i].Field<int>("Song_PlayState");
string SongReplayGain = SongAddDT.Rows[i].Field<string>("Song_ReplayGain");
string SongAddSinger = "0";
string SongAddAllSinger = "0";
string SongSrcPath = SongAddDT.Rows[i].Field<string>("Song_SrcPath");
string SongExtension = Path.GetExtension(SongSrcPath);
string SingerName = SongSinger;
// SingerName bug
bool SingerNameisEmpty = false;
if (SongSinger == "")
{
SingerNameisEmpty = true;
Global.FailureSongDT.Rows.Add(Global.FailureSongDT.NewRow());
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][0] = "歌手名稱空白: 階段1 [" + SongData + "]";
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][1] = Global.FailureSongDT.Rows.Count;
}
// 判斷是否要加入歌手資料至歌手資料庫
if (SongSingerType != 3)
{
// 查找資料庫歌手表
if (SingerDataList.Count > 0)
{
if (SingerDataLowCaseList.IndexOf(SingerName.ToLower()) < 0)
{
SongAddSinger = "1";
}
}
else
{
SongAddSinger = "1";
}
}
else
{
List<string> list = CommonFunc.GetChorusSingerList(SingerName);
foreach (string str in list)
{
string SingerStr = Regex.Replace(str, @"^\s*|\s*$", ""); //去除頭尾空白
if (ChorusSingerList.ConvertAll(x => x.ToLower()).IndexOf(SingerStr.ToLower()) < 0)
{
ChorusSingerList.Add(SingerStr);
}
}
list.Clear();
list = null;
}
// 判斷是否要新增歌曲類別
if (SongSongType != "")
{
Regex r = new Regex("^" + SongSongType + ",|," + SongSongType + ",|," + SongSongType + "$");
if (!r.IsMatch(Global.SongMgrSongType))
{
Global.SongMgrSongType = Global.SongMgrSongType + "," + SongSongType;
}
}
bool UseCustomSongID = false;
if (Global.SongAddUseCustomSongID == "True")
{
if (SongId != "")
{
List<string> StartIdlist = new List<string>();
StartIdlist = new List<string>(Regex.Split(Global.SongMgrLangCode, ",", RegexOptions.None));
switch (Global.SongMgrMaxDigitCode)
{
case "1":
if (SongId.Length == 5 && SongDataIdList.IndexOf(SongId) < 0)
{
if (Global.CrazyktvSongLangList.IndexOf(SongLang) < 9)
{
if (Convert.ToInt32(SongId) >= Convert.ToInt32(StartIdlist[Global.CrazyktvSongLangList.IndexOf(SongLang)]) &&
Convert.ToInt32(SongId) < Convert.ToInt32(StartIdlist[Global.CrazyktvSongLangList.IndexOf(SongLang) + 1]))
{
UseCustomSongID = true;
}
}
else
{
if (Convert.ToInt32(SongId) >= Convert.ToInt32(StartIdlist[Global.CrazyktvSongLangList.IndexOf(SongLang)]) &&
Convert.ToInt32(SongId) < 100000)
{
UseCustomSongID = true;
}
}
}
break;
case "2":
if (SongId.Length == 6 && SongDataIdList.IndexOf(SongId) < 0)
{
if (Convert.ToInt32(SongId) >= 0 && Convert.ToInt32(SongId) <= 99999)
{
UseCustomSongID = true;
}
else
{
if (Global.CrazyktvSongLangList.IndexOf(SongLang) < 9)
{
if (Convert.ToInt32(SongId) >= Convert.ToInt32(StartIdlist[Global.CrazyktvSongLangList.IndexOf(SongLang)]) &&
Convert.ToInt32(SongId) < Convert.ToInt32(StartIdlist[Global.CrazyktvSongLangList.IndexOf(SongLang) + 1]))
{
UseCustomSongID = true;
}
}
else
{
if (Convert.ToInt32(SongId) >= Convert.ToInt32(StartIdlist[Global.CrazyktvSongLangList.IndexOf(SongLang)]) &&
Convert.ToInt32(SongId) < 1000000)
{
UseCustomSongID = true;
}
}
}
}
break;
}
}
}
// 自訂編號
if (UseCustomSongID)
{
if (SongId.Length == 6 && Convert.ToInt32(SongId) >= 0 && Convert.ToInt32(SongId) <= 99999)
{
List<string> StartIdlist = new List<string>();
StartIdlist = new List<string>(Regex.Split(Global.SongMgrLangCode, ",", RegexOptions.None));
bool RefreshID = false;
foreach (string startid in StartIdlist)
{
if (Convert.ToInt32(startid) <= 99999)
{
RefreshID = true;
}
}
if (RefreshID)
{
Parallel.ForEach(Global.CrazyktvSongLangList, (SongLangStr, loopState) =>
{
if (Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLangStr)].Count > 0)
{
if (Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLangStr)].IndexOf(SongId) >= 0)
{
lock (LockThis)
{
Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLangStr)].Remove(SongId);
if (Convert.ToInt32(SongId) > Global.MaxIDList[Global.CrazyktvSongLangList.IndexOf(SongLangStr)])
{
Global.MaxIDList[Global.CrazyktvSongLangList.IndexOf(SongLangStr)] = Convert.ToInt32(SongId);
GetUnUsedSongId(SongId, SongLangStr);
}
loopState.Break();
}
}
}
});
}
}
else
{
if (Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)].Count > 0)
{
if (Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)].IndexOf(SongId) >= 0)
{
lock (LockThis)
{
Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)].Remove(SongId);
}
}
}
if (Convert.ToInt32(SongId) > Global.MaxIDList[Global.CrazyktvSongLangList.IndexOf(SongLang)])
{
lock (LockThis)
{
Global.MaxIDList[Global.CrazyktvSongLangList.IndexOf(SongLang)] = Convert.ToInt32(SongId);
GetUnUsedSongId(SongId, SongLang);
}
}
}
}
else //自動分配編號
{
SongId = "";
// 查詢歌曲編號有無斷號
if (Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)].Count > 0)
{
SongId = Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)][0];
Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)].Remove(SongId);
}
// 若無斷號查詢各語系下個歌曲編號
if (SongId == "")
{
string MaxDigitCode = (Global.SongMgrMaxDigitCode == "1") ? "D5" : "D6";
Global.MaxIDList[Global.CrazyktvSongLangList.IndexOf(SongLang)]++;
SongId = Global.MaxIDList[Global.CrazyktvSongLangList.IndexOf(SongLang)].ToString(MaxDigitCode);
}
}
SongPath = Path.GetDirectoryName(SongSrcPath) + @"\";
SongFileName = Path.GetFileName(SongSrcPath);
if (Global.SongMgrSongAddMode != "3" && Global.SongMgrSongAddMode != "4")
{
string SongDestPath = CommonFunc.GetFileStructure(SongId, SongLang, SongSingerType, SongSinger, SongSongName, SongTrack, SongSongType, SongFileName, SongPath, false, "", false, false);
SongPath = Path.GetDirectoryName(SongDestPath) + @"\";
SongFileName = Path.GetFileName(SongDestPath);
}
if (SongSinger.Length > 60)
{
Global.TotalList[2]++;
Global.FailureSongDT.Rows.Add(Global.FailureSongDT.NewRow());
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][0] = "歌手名稱超過60字元: " + SongSrcPath;
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][1] = Global.FailureSongDT.Rows.Count;
}
else if (SongSongName.Length > 80)
{
Global.TotalList[2]++;
Global.FailureSongDT.Rows.Add(Global.FailureSongDT.NewRow());
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][0] = "歌曲名稱超過80字元: " + SongSrcPath;
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][1] = Global.FailureSongDT.Rows.Count;
}
// SingerName bug
else if (SongSinger == "")
{
SingerNameisEmpty = true;
Global.FailureSongDT.Rows.Add(Global.FailureSongDT.NewRow());
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][0] = "歌手名稱空白: 階段2 [" + SongData + "]";
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][1] = Global.FailureSongDT.Rows.Count;
}
else
{
bool FileIOError = false;
if (Global.SongMgrSongAddMode != "3" && Global.SongMgrSongAddMode != "4")
{
string SongDestPath = Path.Combine(SongPath, SongFileName);
if (!Directory.Exists(SongPath))
{
Directory.CreateDirectory(SongPath);
}
try
{
switch (Global.SongMgrSongAddMode)
{
case "1":
if (File.Exists(SongDestPath))
{
FileAttributes attributes = File.GetAttributes(SongDestPath);
if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
attributes = CommonFunc.RemoveAttribute(attributes, FileAttributes.ReadOnly);
File.SetAttributes(SongDestPath, attributes);
}
if (Global.SongMgrBackupRemoveSong == "True")
{
if (!Directory.Exists(Application.StartupPath + @"\SongMgr\RemoveSong")) Directory.CreateDirectory(Application.StartupPath + @"\SongMgr\RemoveSong");
if (File.Exists(Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName)) File.Delete(Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName);
File.Move(SongDestPath, Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName);
CommonFunc.SetFileTime(Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName, DateTime.Now);
}
else
{
File.Delete(SongDestPath);
}
}
File.Move(SongSrcPath, SongDestPath);
break;
case "2":
if (File.Exists(SongDestPath))
{
FileAttributes attributes = File.GetAttributes(SongDestPath);
if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
attributes = CommonFunc.RemoveAttribute(attributes, FileAttributes.ReadOnly);
File.SetAttributes(SongDestPath, attributes);
}
if (Global.SongMgrBackupRemoveSong == "True")
{
if (!Directory.Exists(Application.StartupPath + @"\SongMgr\RemoveSong")) Directory.CreateDirectory(Application.StartupPath + @"\SongMgr\RemoveSong");
if (File.Exists(Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName)) File.Delete(Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName);
File.Move(SongDestPath, Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName);
CommonFunc.SetFileTime(Application.StartupPath + @"\SongMgr\RemoveSong\" + SongFileName, DateTime.Now);
}
}
File.Copy(SongSrcPath, SongDestPath, true);
break;
}
}
catch
{
FileIOError = true;
lock (LockThis) { Global.TotalList[2]++; }
Global.FailureSongDT.Rows.Add(Global.FailureSongDT.NewRow());
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][0] = "檔案處理發生錯誤: " + SongDestPath + "(唯讀或使用中)";
Global.FailureSongDT.Rows[Global.FailureSongDT.Rows.Count - 1][1] = Global.FailureSongDT.Rows.Count;
}
}
// SingerName bug
if (SingerNameisEmpty)
{
lock (LockThis) { Global.TotalList[2]++; }
}
if (!FileIOError && !SingerNameisEmpty)
{
string SongAddValue = SongId + "|" + SongLang + "|" + SongSingerType + "|" + SongSinger + "|" + SongSongName + "|" + SongTrack + "|" + SongSongType + "|" + SongVolume + "|" + SongWordCount + "|" + SongPlayCount + "|" + SongMB + "|" + SongCreatDate.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture) + "|" + SongFileName + "|" + SongPath + "|" + SongSpell + "|" + SongSpellNum + "|" + SongSongStroke + "|" + SongPenStyle + "|" + SongPlayState + "|" + SongAddSinger + "|" + SongAddAllSinger + "|" + SongReplayGain;
SongAddSong.SongAddValueList.Add(SongAddValue);
lock (LockThis)
{
SongDataIdList.Add(SongId);
Global.TotalList[0]++;
}
}
}
}
}
19
Source : SongAddSong.cs
with GNU General Public License v2.0
from CrazyKTV
with GNU General Public License v2.0
from CrazyKTV
public static void GetUnUsedSongId(string MaxSongID, string SongLang)
{
string MaxDigitCode = (Global.SongMgrMaxDigitCode == "1") ? "D5" : "D6";
List<string> StartIdlist = new List<string>(Regex.Split(Global.SongMgrLangCode, ",", RegexOptions.None));
int iMin = Convert.ToInt32(StartIdlist[Global.CrazyktvSongLangList.IndexOf(SongLang)]);
int iMax = Convert.ToInt32(MaxSongID);
Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)].Clear();
for (int i = iMin; i < iMax; i++)
{
if (SongDataIdList.IndexOf(i.ToString(MaxDigitCode)) < 0)
{
Global.UnusedSongIdList[Global.CrazyktvSongLangList.IndexOf(SongLang)].Add(i.ToString(MaxDigitCode));
}
}
}
19
Source : SongDBConverter.cs
with GNU General Public License v2.0
from CrazyKTV
with GNU General Public License v2.0
from CrazyKTV
private void SongDBConverter_SrcDBFile_Button_Click(object sender, EventArgs e)
{
OpenFileDialog opd = new OpenFileDialog()
{
InitialDirectory = Application.StartupPath,
Filter = "資料庫檔案 (*.mdb)|*.mdb",
FilterIndex = 1
};
if (opd.ShowDialog() == DialogResult.OK && opd.FileName.Length > 0)
{
List<string> list;
string SongQuerySqlStr;
switch (SongDBConverter_SrcDBType_ComboBox.SelectedValue.ToString())
{
case "2":
SongDBConverter_SrcDBFile_TextBox.Text = "";
SongDBConverter_StartConv_Button.Enabled = false;
SongQuerySqlStr = "select Song_ID, Song_Type, Song_Singer, Song_SingerList, Song_replacedle from Tbl_Song";
list = CommonFunc.GetOleDbTableList(opd.FileName, "tmwcmgumbonqd");
if (list.IndexOf("Tbl_Song") >= 0)
{
if (SongDBConverter_Tooltip_Label.Text == "你選取的來源資料庫不是 JetKTV 資料庫!") SongDBConverter_Tooltip_Label.Text = "";
}
else
{
SongDBConverter_Tooltip_Label.Text = "你選取的來源資料庫不是 JetKTV 資料庫!";
}
if (SongDBConverter_Tooltip_Label.Text != "你選取的來源資料庫不是 JetKTV 資料庫!")
{
using (DataTable dt = CommonFunc.GetOleDbDataTable(opd.FileName, SongQuerySqlStr, "tmwcmgumbonqd"))
{
if (dt.Rows.Count > 0)
{
if (SongDBConverter_Tooltip_Label.Text == "你選取的來源資料庫沒有歌曲資料!") SongDBConverter_Tooltip_Label.Text = "";
SongDBConverter_SrcDBFile_TextBox.Text = opd.FileName;
SongDBConverter_SwitchButton(1);
}
else
{
SongDBConverter_Tooltip_Label.Text = "你選取的來源資料庫沒有歌曲資料!";
}
}
}
break;
case "3":
SongDBConverter_SrcDBFile_TextBox.Text = "";
SongDBConverter_StartConv_Button.Enabled = false;
SongQuerySqlStr = "select Song_ID, Song_replacedle, Song_Singer, Song_Channel, Song_Type, Song_FileName, Song_Count, Song_Path, Song_CreateDate, Song_Chorus, Song_Volume from Tbl_Song";
list = CommonFunc.GetOleDbTableList(opd.FileName, "");
bool DBError = false;
List<string> TBList = new List<string>() { "PhonAlpha", "PhonSpell", "Tbl_Extension", "Tbl_KeyName", "Tbl_Name", "Tbl_Remote2", "Tbl_Singer", "Tbl_Song", "Tbl_SongPath", "Tbl_Strokes" };
foreach (string TBName in TBList)
{
if (list.IndexOf(TBName) < 0)
{
DBError = true;
break;
}
}
if (DBError)
{
SongDBConverter_Tooltip_Label.Text = "你選取的來源資料庫不是 HomeKara2 資料庫!";
}
else
{
if (SongDBConverter_Tooltip_Label.Text == "你選取的來源資料庫不是 HomeKara2 資料庫!") SongDBConverter_Tooltip_Label.Text = "";
using (DataTable dt = CommonFunc.GetOleDbDataTable(opd.FileName, SongQuerySqlStr, ""))
{
if (dt.Rows.Count > 0)
{
if (SongDBConverter_Tooltip_Label.Text == "你選取的來源資料庫沒有歌曲資料!") SongDBConverter_Tooltip_Label.Text = "";
SongDBConverter_SrcDBFile_TextBox.Text = opd.FileName;
SongDBConverter_SwitchButton(1);
}
else
{
SongDBConverter_Tooltip_Label.Text = "你選取的來源資料庫沒有歌曲資料!";
}
}
}
break;
}
}
}
19
Source : SongDBConverterSongDB.cs
with GNU General Public License v2.0
from CrazyKTV
with GNU General Public License v2.0
from CrazyKTV
public static string GetSongInfo(string SongInfoType, string SongInfoValue)
{
string infovalue = "";
List<string> list = new List<string>();
List<string> CrazyktvSongLangKeyWordList = new List<string>() { "國語,國", "台語,台,閩南,閩,臺語,臺", "粵語,粵,廣東", "日語,日文,日", "英語,英文,英", "客語,客", "原住民語,民謠", "韓語,韓", "兒歌,兒,童謠", "其它" };
switch (SongInfoType)
{
case "SongLang":
foreach (string str in CrazyktvSongLangKeyWordList)
{
list = new List<string>(str.Split(','));
foreach (string liststr in list)
{
if (SongInfoValue == liststr)
{
infovalue = Global.CrazyktvSongLangList[CrazyktvSongLangKeyWordList.IndexOf(str)];
break;
}
}
if (infovalue != "") break;
}
break;
case "SongSingerType":
foreach (string str in Global.CrazyktvSingerTypeKeyWordList)
{
list = new List<string>(str.Split(','));
foreach (string liststr in list)
{
if (SongInfoValue == liststr)
{
infovalue = Global.CrazyktvSingerTypeKeyWordList.IndexOf(str).ToString();
break;
}
}
if (infovalue != "") break;
}
break;
case "SongTrack":
foreach (string str in Global.CrazyktvSongTrackKeyWordList)
{
list = new List<string>(str.Split(','));
foreach (string liststr in list)
{
if (SongInfoValue == liststr)
{
infovalue = Global.CrazyktvSongTrackKeyWordList.IndexOf(str).ToString();
break;
}
}
if (infovalue != "") break;
}
break;
}
list.Clear();
return infovalue;
}
See More Examples