本文整理汇总了C#中Client.CalculateValue方法的典型用法代码示例。如果您正苦于以下问题:C# Client.CalculateValue方法的具体用法?C# Client.CalculateValue怎么用?C# Client.CalculateValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.CalculateValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoJumpLettersByValues
private char[] DoJumpLettersByValues(Client client, string verses_text, string extra)
{
int count = verses_text.Length;
char[] result = new char[count];
//text = verses_text.Replace("\r\n", "_"); // will miss 15 \n without \r before them
verses_text = verses_text.Replace("\r", "");
verses_text = verses_text.Replace("\n", "_");
int new_count = verses_text.Length;
int i = 0;
int r = 0;
while (i < new_count)
{
if (verses_text[i] == '_')
{
result[r++] = '\r';
result[r++] = '\n';
i++; // skip '_'
}
else
{
result[r++] = verses_text[i];
try
{
i += (int)client.CalculateValue(verses_text[i].ToString());
}
catch
{
// skip exceptions (in Abjad)
i += 1;
}
}
}
return result;
}
示例2: MyMethod
/// <summary>
/// Write your C# script inside this method.
/// Don't change its name or parameter list
/// This method is an example of finding all verses rhat have a prime value
/// and a P, AP, PP, C, AC, PC or a given digit_sum (e.g 19, or 0 -> any)
/// </summary>
/// <param name="client">Client object holding a reference to the currently selected Book object in TextMode (eg Simplified29)</param>
/// <param name="extra">any user parameter in the TextBox next to the EXE button (ex Frequency, LettersToJump, DigitSum target, etc)</param>
/// <returns>true to disply back in QuranCode matching verses. false to keep script window open</returns>
private bool MyMethod(Client client, string extra)
{
if (client == null) return false;
if (client.Selection == null) return false;
List<Verse> verses = client.Selection.Verses;
if (client.Book != null)
{
// OPTIONAL: query the whole book, not just the current verses
verses = client.Book.Verses;
client.FoundVerses = new List<Verse>();
foreach (Verse verse in verses)
{
long value = client.CalculateValue(verse);
if (Numbers.IsAdditivePrime(value))
{
bool digit_sum_ok = false;
int target;
if (extra == "")
{
target = 0; // any digit sum
digit_sum_ok = true;
}
else if (extra.ToUpper() == "P") // target == prime digit sum
{
digit_sum_ok = Numbers.IsPrime(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "AP") // target == additive prime digit sum
{
digit_sum_ok = Numbers.IsAdditivePrime(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "PP") // target == pure prime digit sum
{
digit_sum_ok = Numbers.IsPurePrime(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "C") // target == composite digit sum
{
digit_sum_ok = Numbers.IsComposite(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "AC") // target == additive composite digit sum
{
digit_sum_ok = Numbers.IsAdditiveComposite(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "PC") // target == pure composite digit sum
{
digit_sum_ok = Numbers.IsPureComposite(Numbers.DigitSum(value));
}
else
{
if (int.TryParse(extra, out target))
{
digit_sum_ok = (Numbers.DigitSum(value) == target);
}
else
{
return false; // to stay in the Script window
}
}
if (digit_sum_ok)
{
client.FoundVerses.Add(verse);
}
}
}
return true; // to close Script window and show result
}
return false; // to stay in the Script window
}
示例3: DoFindVersesWithXValueDigitSum
private static string DoFindVersesWithXValueDigitSum(Client client, string extra, NumberType number_type)
{
if (client == null) return null;
if (client.Book == null) return null;
if (client.Book.Verses == null) return null;
StringBuilder str = new StringBuilder();
str.Append("#" + "\t" + "Verse" + "\t" + "Address" + "\t" + "Words" + "\t" + "Letters" + "\t" + "Unique" + "\t" + "Value" + "\t" + "DigitSum" + "\t" + "Text");
str.Append("\r\n");
int count = 0;
foreach (Verse verse in client.Book.Verses)
{
long value = client.CalculateValue(verse);
bool extra_condition = false;
if (extra == "") // target == any digit sum
{
extra_condition = true;
}
else if (extra.ToUpper() == "P") // target == prime digit sum
{
extra_condition = Numbers.IsPrime(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "AP") // target == additive prime digit sum
{
extra_condition = Numbers.IsAdditivePrime(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "PP") // target == pure prime digit sum
{
extra_condition = Numbers.IsPurePrime(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "C") // target == composite digit sum
{
extra_condition = Numbers.IsComposite(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "AC") // target == additive composite digit sum
{
extra_condition = Numbers.IsAdditiveComposite(Numbers.DigitSum(value));
}
else if (extra.ToUpper() == "PC") // target == pure composite digit sum
{
extra_condition = Numbers.IsPureComposite(Numbers.DigitSum(value));
}
else
{
int target;
if (int.TryParse(extra, out target))
{
if (target == 0) // target == any digit sum
{
extra_condition = true;
}
else
{
extra_condition = (Numbers.DigitSum(value) == target);
}
}
else
{
return null; // invalid extra data
}
}
if (
(
(number_type == NumberType.Any)
||
(Numbers.IsNumberType(value, number_type))
)
&&
extra_condition
)
{
count++;
str.Append(count.ToString() + "\t");
str.Append(verse.Number.ToString() + "\t");
str.Append(verse.Address.ToString() + "\t");
str.Append(verse.Words.Count.ToString() + "\t");
str.Append(verse.LetterCount.ToString() + "\t");
str.Append(verse.UniqueLetters.Count.ToString() + "\t");
str.Append(value.ToString() + "\t");
str.Append(Numbers.DigitSum(value).ToString() + "\t");
str.Append(verse.Text + "\t");
str.Append("\r\n");
}
}
return str.ToString();
}
示例4: ChapterValuesSound
public static void ChapterValuesSound(Client client, string extra)
{
if (client == null) return;
if (client.Selection == null) return;
List<Verse> verses = client.Selection.Verses;
List<Chapter> chapters = client.Book.GetChapters(verses);
List<long> values = new List<long>();
foreach (Chapter chapter in chapters)
{
values.Add(client.CalculateValue(chapter));
}
string filename = client.NumerologySystem.Name + "_" + "ChapterValues" + Globals.OUTPUT_FILE_EXT;
string path = Globals.RESEARCH_FOLDER + "/" + filename;
DoSaveAndPlayWAVFile(path, values, extra);
}
示例5: DoChapterInformation
private static string DoChapterInformation(Client client, List<Chapter> chapters)
{
if (client == null) return null;
StringBuilder str = new StringBuilder();
str.Append("Name" + "\t" + "Transliteration" + "\t" + "English" + "\t" + "Place" + "\t" + "Order" + "\t" + "Page" + "\t" + "Chapter" + "\t" + "Verses" + "\t" + "Words" + "\t" + "Letters" + "\t" + "Unique" + "\t" + "Value" + "\t" + "Factors" + "\t" + "P" + "\t" + "AP" + "\t" + "PP" + "\t" + "C" + "\t" + "AC" + "\t" + "PC" + "\t");
NumerologySystem numerology_system = client.NumerologySystem;
if (numerology_system != null)
{
if (numerology_system.LetterValues.Keys.Count > 0)
{
foreach (char key in numerology_system.LetterValues.Keys)
{
str.Append(key.ToString() + "\t");
}
if (str.Length > 1)
{
str.Remove(str.Length - 1, 1); // \t
}
str.Append("\r\n");
}
foreach (Chapter chapter in chapters)
{
str.Append(chapter.Name + "\t");
str.Append(chapter.TransliteratedName + "\t");
str.Append(chapter.EnglishName + "\t");
str.Append(chapter.RevelationPlace.ToString() + "\t");
str.Append(chapter.RevelationOrder.ToString() + "\t");
str.Append(chapter.Verses[0].Page.Number.ToString() + "\t");
str.Append(chapter.Number.ToString() + "\t");
str.Append(chapter.Verses.Count.ToString() + "\t");
str.Append(chapter.WordCount.ToString() + "\t");
str.Append(chapter.LetterCount.ToString() + "\t");
str.Append(chapter.UniqueLetters.Count.ToString() + "\t");
long value = client.CalculateValue(chapter);
str.Append(value.ToString() + "\t");
str.Append(Numbers.FactorizeToString(value) + "\t");
int p = Numbers.IndexOfPrime(value);
int ap = Numbers.IndexOfAdditivePrime(value);
int pp = Numbers.IndexOfPurePrime(value);
int c = Numbers.IndexOfComposite(value);
int ac = Numbers.IndexOfAdditiveComposite(value);
int pc = Numbers.IndexOfPureComposite(value);
str.Append((p == -1 ? "-" : p.ToString()) + "\t"
+ (ap == -1 ? "-" : ap.ToString()) + "\t"
+ (pp == -1 ? "-" : pp.ToString()) + "\t"
+ (c == -1 ? "-" : c.ToString()) + "\t"
+ (ac == -1 ? "-" : ac.ToString()) + "\t"
+ (pc == -1 ? "-" : pc.ToString())
);
str.Append("\t");
if (numerology_system.LetterValues.Keys.Count > 0)
{
foreach (char key in numerology_system.LetterValues.Keys)
{
str.Append(chapter.GetLetterFrequency(key) + "\t");
}
if (str.Length > 1)
{
str.Remove(str.Length - 1, 1); // \t
}
str.Append("\r\n");
}
}
}
return str.ToString();
}
示例6: WordValuesSound
public static void WordValuesSound(Client client, string extra)
{
if (client == null) return;
if (client.Selection == null) return;
List<Verse> verses = client.Selection.Verses;
List<long> values = new List<long>();
foreach (Verse verse in verses)
{
foreach (Word word in verse.Words)
{
values.Add(client.CalculateValue(word));
}
}
string filename = client.NumerologySystem.Name + "_" + "WordValues" + Globals.OUTPUT_FILE_EXT;
string path = Globals.RESEARCH_FOLDER + "/" + filename;
DoSaveAndPlayWAVFile(path, values, extra);
}
示例7: WordValueDiffsSound
private static void WordValueDiffsSound(Client client, string extra)
{
if (client == null) return;
if (client.Selection == null) return;
List<Verse> verses = client.Selection.Verses;
List<long> values = new List<long>();
foreach (Verse verse in verses)
{
foreach (Word word in verse.Words)
{
values.Add(client.CalculateValue(word));
}
}
List<long> value_diffs = new List<long>();
for (int i = 0; i < values.Count - 1; i++)
{
long value_diff = values[i + 1] - values[i];
value_diffs.Add(value_diff);
}
string filename = client.NumerologySystem.Name + "_" + "WordValueDiffs" + Globals.OUTPUT_FILE_EXT;
string path = Globals.RESEARCH_FOLDER + "/" + filename;
DoSaveAndPlayWAVFile(path, values, extra);
}
示例8: FindBismAllahEqualsAlFatihaIndex
private static void FindBismAllahEqualsAlFatihaIndex(Client client, string extra)
{
if (client == null) return;
if (client.Book == null) return;
if (client.NumerologySystem == null) return;
NumerologySystem backup_numerology_system = new NumerologySystem(client.NumerologySystem);
long target_difference;
try
{
target_difference = long.Parse(extra);
}
catch
{
target_difference = 0L;
}
// zero difference between Value(BismAllah) and ValueIndex(Al-Fatiha)
List<ZeroDifferenceNumerologySystem> good_numerology_systems = new List<ZeroDifferenceNumerologySystem>();
NumberType[] number_types = (NumberType[])Enum.GetValues(typeof(NumberType));
foreach (NumberType number_type in number_types)
{
if (
(number_type == NumberType.Prime) ||
(number_type == NumberType.AdditivePrime) ||
(number_type == NumberType.PurePrime) ||
(number_type == NumberType.Composite) ||
(number_type == NumberType.AdditiveComposite) ||
(number_type == NumberType.PureComposite)
)
{
NumerologySystemScope[] numerology_system_scopes = (NumerologySystemScope[])Enum.GetValues(typeof(NumerologySystemScope));
foreach (NumerologySystemScope numerology_system_scope in numerology_system_scopes)
{
switch (numerology_system_scope)
{
case NumerologySystemScope.Book:
{
client.BuildNumerologySystem(client.Book.Text);
}
break;
case NumerologySystemScope.Selection:
{
client.BuildNumerologySystem(client.Book.Chapters[0].Text);
}
break;
case NumerologySystemScope.HighlightedText:
{
client.BuildNumerologySystem(client.Book.Verses[0].Text);
}
break;
default:
break;
}
// Quran 74:30 "Over It Nineteen."
int PERMUTATIONS = 524288; // 2^19
for (int i = 0; i < PERMUTATIONS; i++)
{
client.NumerologySystem.AddToLetterLNumber = ((i & 262144) != 0);
client.NumerologySystem.AddToLetterWNumber = ((i & 131072) != 0);
client.NumerologySystem.AddToLetterVNumber = ((i & 65536) != 0);
client.NumerologySystem.AddToLetterCNumber = ((i & 32768) != 0);
client.NumerologySystem.AddToLetterLDistance = ((i & 16384) != 0);
client.NumerologySystem.AddToLetterWDistance = ((i & 8192) != 0);
client.NumerologySystem.AddToLetterVDistance = ((i & 4096) != 0);
client.NumerologySystem.AddToLetterCDistance = ((i & 2048) != 0);
client.NumerologySystem.AddToWordWNumber = ((i & 1024) != 0);
client.NumerologySystem.AddToWordVNumber = ((i & 512) != 0);
client.NumerologySystem.AddToWordCNumber = ((i & 256) != 0);
client.NumerologySystem.AddToWordWDistance = ((i & 128) != 0);
client.NumerologySystem.AddToWordVDistance = ((i & 64) != 0);
client.NumerologySystem.AddToWordCDistance = ((i & 32) != 0);
client.NumerologySystem.AddToVerseVNumber = ((i & 16) != 0);
client.NumerologySystem.AddToVerseCNumber = ((i & 8) != 0);
client.NumerologySystem.AddToVerseVDistance = ((i & 4) != 0);
client.NumerologySystem.AddToVerseCDistance = ((i & 2) != 0);
client.NumerologySystem.AddToChapterCNumber = ((i & 1) != 0);
long alfatiha_value = client.CalculateValue(client.Book.Chapters[0]);
int alfatiha_value_index = -1;
switch (number_type)
{
case NumberType.Prime:
{
alfatiha_value_index = Numbers.IndexOfPrime(alfatiha_value);
}
break;
case NumberType.AdditivePrime:
{
alfatiha_value_index = Numbers.IndexOfAdditivePrime(alfatiha_value);
}
break;
case NumberType.PurePrime:
{
alfatiha_value_index = Numbers.IndexOfPurePrime(alfatiha_value);
}
break;
//.........这里部分代码省略.........
示例9: DoVerseInformation
private static string DoVerseInformation(Client client, List<Verse> verses)
{
if (client == null) return null;
StringBuilder str = new StringBuilder();
str.Append("#" + "\t" + "Page" + "\t" + "Chapter" + "\t" + "Verse" + "\t" + "Words" + "\t" + "Letters" + "\t" + "Unique" + "\t" + "Value" + "\t" + "Factors" + "\t" + "P" + "\t" + "AP" + "\t" + "PP" + "\t" + "C" + "\t" + "AC" + "\t" + "PC" + "\t");
NumerologySystem numerology_system = client.NumerologySystem;
if (numerology_system != null)
{
foreach (char key in numerology_system.LetterValues.Keys)
{
str.Append(key.ToString() + "\t");
}
str.Append("Text");
str.Append("\r\n");
int count = 0;
foreach (Verse verse in verses)
{
count++;
str.Append(verse.Number.ToString() + "\t");
str.Append(verse.Page.Number.ToString() + "\t");
str.Append(verse.Chapter.Number.ToString() + "\t");
str.Append(verse.NumberInChapter.ToString() + "\t");
str.Append(verse.Words.Count.ToString() + "\t");
str.Append(verse.LetterCount.ToString() + "\t");
str.Append(verse.UniqueLetters.Count.ToString() + "\t");
long value = client.CalculateValue(verse);
str.Append(value.ToString() + "\t");
str.Append(Numbers.FactorizeToString(value) + "\t");
int p = Numbers.IndexOfPrime(value);
int ap = Numbers.IndexOfAdditivePrime(value);
int pp = Numbers.IndexOfPurePrime(value);
int c = Numbers.IndexOfComposite(value);
int ac = Numbers.IndexOfAdditiveComposite(value);
int pc = Numbers.IndexOfPureComposite(value);
str.Append((p == -1 ? "-" : p.ToString()) + "\t"
+ (ap == -1 ? "-" : ap.ToString()) + "\t"
+ (pp == -1 ? "-" : pp.ToString()) + "\t"
+ (c == -1 ? "-" : c.ToString()) + "\t"
+ (ac == -1 ? "-" : ac.ToString()) + "\t"
+ (pc == -1 ? "-" : pc.ToString())
);
str.Append("\t");
foreach (char character in numerology_system.LetterValues.Keys)
{
if (Constants.INDIAN_DIGITS.Contains(character)) continue;
if (Constants.STOPMARKS.Contains(character)) continue;
if (Constants.QURANMARKS.Contains(character)) continue;
if (character == '{') continue;
if (character == '}') continue;
str.Append(verse.GetLetterFrequency(character).ToString() + "\t");
}
str.Append(verse.Text);
str.Append("\r\n");
}
}
return str.ToString();
}