Here are the examples of the csharp api System.Convert.ToInt32(decimal) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
90 Examples
19
Source : SQLite.cs
with GNU General Public License v3.0
from 0xfd3
with GNU General Public License v3.0
from 0xfd3
private void ReadMasterTable(ulong Offset)
{
if (this.db_bytes[(int)Offset] == 13)
{
ushort num2 = Convert.ToUInt16(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
int length = 0;
if (this.master_table_entries != null)
{
length = this.master_table_entries.Length;
this.master_table_entries = (sqlite_master_entry[])Utils.CopyArray((Array)this.master_table_entries, new sqlite_master_entry[(this.master_table_entries.Length + num2) + 1]);
}
else
{
this.master_table_entries = new sqlite_master_entry[num2 + 1];
}
int num13 = num2;
for (int i = 0; i <= num13; i++)
{
ulong num = this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 8M), new decimal(i * 2))), 2);
if (decimal.Compare(new decimal(Offset), 100M) != 0)
{
num += Offset;
}
int endIndex = this.GVL((int)num);
long num7 = this.CVL((int)num, endIndex);
int num6 = this.GVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)));
this.master_table_entries[length + i].row_id = this.CVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)), num6);
num = Convert.ToUInt64(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(num6), new decimal(num))), decimal.One));
endIndex = this.GVL((int)num);
num6 = endIndex;
long num5 = this.CVL((int)num, endIndex);
long[] numArray = new long[5];
int index = 0;
do
{
endIndex = num6 + 1;
num6 = this.GVL(endIndex);
numArray[index] = this.CVL(endIndex, num6);
if (numArray[index] > 9L)
{
if (this.IsOdd(numArray[index]))
{
numArray[index] = (long)Math.Round((double)(((double)(numArray[index] - 13L)) / 2.0));
}
else
{
numArray[index] = (long)Math.Round((double)(((double)(numArray[index] - 12L)) / 2.0));
}
}
else
{
numArray[index] = this.SQLDataTypeSize[(int)numArray[index]];
}
index++;
}
while (index <= 4);
if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
{
this.master_table_entries[length + i].item_type = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
}
else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
{
this.master_table_entries[length + i].item_type = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
}
else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
{
this.master_table_entries[length + i].item_type = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
}
if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
{
this.master_table_entries[length + i].item_name = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0]))), (int)numArray[1]);
}
else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
{
this.master_table_entries[length + i].item_name = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0]))), (int)numArray[1]);
}
else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
{
this.master_table_entries[length + i].item_name = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0]))), (int)numArray[1]);
}
this.master_table_entries[length + i].root_num = (long)this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2]))), (int)numArray[3]);
if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
{
this.master_table_entries[length + i].sql_statement = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
}
else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
{
this.master_table_entries[length + i].sql_statement = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
}
else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
{
this.master_table_entries[length + i].sql_statement = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
}
}
}
else if (this.db_bytes[(int)Offset] == 5)
{
ushort num11 = Convert.ToUInt16(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
int num14 = num11;
for (int j = 0; j <= num14; j++)
{
ushort startIndex = (ushort)this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 12M), new decimal(j * 2))), 2);
if (decimal.Compare(new decimal(Offset), 100M) == 0)
{
this.ReadMasterTable(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger(startIndex, 4)), decimal.One), new decimal(this.page_size))));
}
else
{
this.ReadMasterTable(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger((int)(Offset + startIndex), 4)), decimal.One), new decimal(this.page_size))));
}
}
this.ReadMasterTable(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 8M)), 4)), decimal.One), new decimal(this.page_size))));
}
}
19
Source : SQLite.cs
with GNU General Public License v3.0
from 0xfd3
with GNU General Public License v3.0
from 0xfd3
private bool ReadTableFromOffset(ulong Offset)
{
if (this.db_bytes[(int)Offset] == 13)
{
int num2 = Convert.ToInt32(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
int length = 0;
if (this.table_entries != null)
{
length = this.table_entries.Length;
this.table_entries = (table_entry[])Utils.CopyArray((Array)this.table_entries, new table_entry[(this.table_entries.Length + num2) + 1]);
}
else
{
this.table_entries = new table_entry[num2 + 1];
}
int num16 = num2;
for (int i = 0; i <= num16; i++)
{
record_header_field[] _fieldArray = null;
ulong num = this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 8M), new decimal(i * 2))), 2);
if (decimal.Compare(new decimal(Offset), 100M) != 0)
{
num += Offset;
}
int endIndex = this.GVL((int)num);
long num9 = this.CVL((int)num, endIndex);
int num8 = this.GVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)));
this.table_entries[length + i].row_id = this.CVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)), num8);
num = Convert.ToUInt64(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(num8), new decimal(num))), decimal.One));
endIndex = this.GVL((int)num);
num8 = endIndex;
long num7 = this.CVL((int)num, endIndex);
long num10 = Convert.ToInt64(decimal.Add(decimal.Subtract(new decimal(num), new decimal(endIndex)), decimal.One));
for (int j = 0; num10 < num7; j++)
{
_fieldArray = (record_header_field[])Utils.CopyArray((Array)_fieldArray, new record_header_field[j + 1]);
endIndex = num8 + 1;
num8 = this.GVL(endIndex);
_fieldArray[j].type = this.CVL(endIndex, num8);
if (_fieldArray[j].type > 9L)
{
if (this.IsOdd(_fieldArray[j].type))
{
_fieldArray[j].size = (long)Math.Round((double)(((double)(_fieldArray[j].type - 13L)) / 2.0));
}
else
{
_fieldArray[j].size = (long)Math.Round((double)(((double)(_fieldArray[j].type - 12L)) / 2.0));
}
}
else
{
_fieldArray[j].size = this.SQLDataTypeSize[(int)_fieldArray[j].type];
}
num10 = (num10 + (num8 - endIndex)) + 1L;
}
this.table_entries[length + i].content = new string[(_fieldArray.Length - 1) + 1];
int num4 = 0;
int num17 = _fieldArray.Length - 1;
for (int k = 0; k <= num17; k++)
{
if (_fieldArray[k].type > 9L)
{
if (!this.IsOdd(_fieldArray[k].type))
{
if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
{
this.table_entries[length + i].content[k] = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
}
else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
{
this.table_entries[length + i].content[k] = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
}
else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
{
this.table_entries[length + i].content[k] = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
}
}
else
{
this.table_entries[length + i].content[k] = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
}
}
else
{
this.table_entries[length + i].content[k] = Conversions.ToString(this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size));
}
num4 += (int)_fieldArray[k].size;
}
}
}
else if (this.db_bytes[(int)Offset] == 5)
{
ushort num14 = Convert.ToUInt16(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
int num18 = num14;
for (int m = 0; m <= num18; m++)
{
ushort num13 = (ushort)this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 12M), new decimal(m * 2))), 2);
this.ReadTableFromOffset(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger((int)(Offset + num13), 4)), decimal.One), new decimal(this.page_size))));
}
this.ReadTableFromOffset(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 8M)), 4)), decimal.One), new decimal(this.page_size))));
}
return true;
}
19
Source : MathFilters.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
public static int Ceil(object value)
{
return value == null
? 0
: Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(value)));
}
19
Source : MathFilters.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
public static int Floor(object value)
{
return value == null
? 0
: Convert.ToInt32(Math.Floor(Convert.ToDecimal(value)));
}
19
Source : MathFilters.cs
with MIT License
from Adoxio
with MIT License
from Adoxio
public static object Round(object value, int decimals = 0)
{
if (value == null)
{
return 0;
}
return decimals == 0
? Convert.ToInt32(Math.Round(Convert.ToDecimal(value), decimals))
: Math.Round(Convert.ToDecimal(value), decimals);
}
19
Source : Render.cs
with MIT License
from AiursoftWeb
with MIT License
from AiursoftWeb
public static async Task StartGameWithObserver(Game game, Game observer)
{
// Add Remote Repository
await game.AddRemote(Constants.EndPointUrl);
await observer.AddRemote(Constants.EndPointUrl);
observer.GenerateRecurrent();
Console.Clear();
// Draw Items
game.Draw();
observer.Draw();
// Wait the input to start the game.
game.ListenInput(true);
while (!game.IsGameEnd)
{
// Player's panel
game.UpdateDirection();
game.UpdateFrame();
if (game.NeedSpeedUp())
{
_gameSpeed *= 0.95m;
}
// Observer's panel
observer.RecurrentFromRepo();
observer.UpdateFrame();
// Listening input command
game.ListenInput();
await Task.Delay(Convert.ToInt32(_gameSpeed));
}
while (!observer.IsGameEnd)
{
observer.RecurrentFromRepo();
observer.UpdateFrame();
}
}
19
Source : MarketDepthPainter.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void PaintMarketDepth(MarketDepth depth)
{
try
{
_lastMarketDepth = depth;
if (_hostGlreplaced == null || depth == null)
{
return;
}
if (_glreplacedBox.InvokeRequired)
{
_glreplacedBox.Invoke(new Action<MarketDepth>(PaintMarketDepth), depth);
return;
}
if (depth.Bids[0].Bid == 0 ||
depth.Asks[0].Ask == 0)
{
return;
}
decimal maxVol = 0;
decimal allBid = 0;
decimal allAsk = 0;
for (int i = 0; depth.Bids != null && i < 25; i++)
{
if (i < depth.Bids.Count)
{
_glreplacedBox.Rows[25 + i].Cells[2].Value = depth.Bids[i].Price.ToStringWithNoEndZero();
_glreplacedBox.Rows[25 + i].Cells[3].Value = depth.Bids[i].Bid.ToStringWithNoEndZero();
if (depth.Bids[i].Bid > maxVol)
{
maxVol = depth.Bids[i].Bid;
}
allAsk += depth.Bids[i].Bid;
}
else if (_glreplacedBox.Rows[25 + i].Cells[2].Value != null)
{
_glreplacedBox.Rows[25 + i].Cells[0].Value = null;
_glreplacedBox.Rows[25 + i].Cells[1].Value = null;
_glreplacedBox.Rows[25 + i].Cells[2].Value = null;
_glreplacedBox.Rows[25 + i].Cells[3].Value = null;
}
}
for (int i = 0; depth.Asks != null && i < 25; i++)
{
if (i < depth.Asks.Count)
{
_glreplacedBox.Rows[24 - i].Cells[2].Value = depth.Asks[i].Price.ToStringWithNoEndZero();
_glreplacedBox.Rows[24 - i].Cells[3].Value = depth.Asks[i].Ask.ToStringWithNoEndZero();
if (depth.Asks[i].Ask > maxVol)
{
maxVol = depth.Asks[i].Ask;
}
allBid += depth.Asks[i].Ask;
}
else if (_glreplacedBox.Rows[24 - i].Cells[2].Value != null)
{
_glreplacedBox.Rows[24 - i].Cells[2].Value = null;
_glreplacedBox.Rows[24 - i].Cells[3].Value = null;
_glreplacedBox.Rows[24 - i].Cells[0].Value = null;
_glreplacedBox.Rows[24 - i].Cells[1].Value = null;
}
}
// volume in sticks for ask
// объём в палках для аска
for (int i = 0; depth.Bids != null && i < 25 && i < depth.Bids.Count; i++)
{
int percentFromMax = Convert.ToInt32(depth.Bids[i].Bid / maxVol * 50);
if (percentFromMax == 0)
{
percentFromMax = 1;
}
StringBuilder builder = new StringBuilder(percentFromMax);
for (int i2 = 0; i2 < percentFromMax; i2++)
{
builder.Append('|');
}
_glreplacedBox.Rows[25 + i].Cells[1].Value = builder;
}
// volume in bid sticks
// объём в палках для бида
for (int i = 0; depth.Asks != null && i < 25 && i < depth.Asks.Count; i++)
{
int percentFromMax = Convert.ToInt32(depth.Asks[i].Ask / maxVol * 50);
if (percentFromMax == 0)
{
percentFromMax = 1;
}
StringBuilder builder = new StringBuilder(percentFromMax);
for (int i2 = 0; i2 < percentFromMax ; i2++)
{
builder.Append('|');
}
_glreplacedBox.Rows[24 - i].Cells[1].Value = builder;
}
decimal maxSeries;
if (allAsk > allBid)
{
maxSeries = allAsk;
}
else
{
maxSeries = allBid;
}
// volume replacedulative for ask
// объём комулятивный для аска
decimal summ = 0;
for (int i = 0; depth.Bids != null && i < 25 && i < depth.Bids.Count; i++)
{
summ += depth.Bids[i].Bid;
int percentFromMax = Convert.ToInt32(summ / maxSeries * 50);
if (percentFromMax == 0)
{
percentFromMax = 1;
}
StringBuilder builder = new StringBuilder(percentFromMax);
for (int i2 = 0; i2 < percentFromMax; i2++)
{
builder.Append('|');
}
_glreplacedBox.Rows[25 + i].Cells[0].Value = builder;
}
// volume is replacedulative for bids
// объём комулятивный для бида
summ = 0;
for (int i = 0; depth.Asks != null && i < 25 && i < depth.Asks.Count; i++)
{
summ += depth.Asks[i].Ask;
int percentFromMax = Convert.ToInt32(summ / maxSeries * 50);
if (percentFromMax == 0)
{
percentFromMax = 1;
}
StringBuilder builder = new StringBuilder(percentFromMax);
for (int i2 = 0; i2 < percentFromMax; i2++)
{
builder.Append('|');
}
_glreplacedBox.Rows[24 - i].Cells[0].Value = builder;
}
// _glreplacedBox.Refresh();
}
catch (Exception error)
{
//SendNewLogMessage(error.ToString(), LogMessageType.Error);
}
}
19
Source : DealStaticticGenerator.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
public static decimal GetMidleProfitInPunkt(Position[] deals)
{
if(deals.Length == 0)
{
return 0;
}
decimal profit = 0;
decimal someProfit = 0;
for (int i = 0; i < deals.Length; i++)
{
profit += deals[i].ProfitOperationPunkt;
if (deals[i].ProfitOperationPunkt != 0)
{
someProfit = deals[i].ProfitOperationPunkt;
}
}
if (Convert.ToInt32(someProfit) == someProfit)
{
return Math.Round(profit / deals.Length, 2);
}
try
{
return Math.Round(profit / deals.Length, 6);
}
catch (Exception)
{
return Math.Round(profit, 6);
}
}
19
Source : AcebergMaker.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void CreateOpenOrders()
{
Side side = _position.Direction;
int realCountOrders = _ordersCount;
if (realCountOrders > _volume)
{
realCountOrders = Convert.ToInt32(_volume);
}
Order[] orders = new Order[realCountOrders];
for (int i = 0; i < orders.Length; i++)
{
orders[i] = new Order();
orders[i].Side = side;
orders[i].LifeTime = _lifiTime;
orders[i].Volume = Convert.ToInt32(Math.Round(Convert.ToDecimal(_volume) / Convert.ToDecimal(realCountOrders)));
orders[i].Price = _price;
orders[i].PortfolioNumber = _bot.Portfolio.Number;
orders[i].SecurityNameCode = _bot.Securiti.Name;
orders[i].NumberUser = NumberGen.GetNumberOrder(_bot.StartProgram);
if (i + 1 == orders.Length)
{
decimal realVolume = 0;
for (int i2 = 0; i2 < orders.Length - 1; i2++)
{
realVolume += orders[i2].Volume;
}
orders[i].Volume = _volume - realVolume;
}
}
_ordersNeadToCreate = orders.ToList();
}
19
Source : AcebergMaker.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void CreateModificateOrdersBuy()
{
Side side = Side.Buy;
int realCountOrders = _ordersCount;
if (realCountOrders > _volume)
{
realCountOrders = Convert.ToInt32(_volume);
}
Order[] orders = new Order[realCountOrders];
for (int i = 0; i < orders.Length; i++)
{
orders[i] = new Order();
orders[i].Side = side;
orders[i].LifeTime = _lifiTime;
orders[i].Volume = Convert.ToInt32(Math.Round(Convert.ToDecimal(_volume) / Convert.ToDecimal(realCountOrders)));
orders[i].Price = _price;
orders[i].PortfolioNumber = _bot.Portfolio.Number;
orders[i].SecurityNameCode = _bot.Securiti.Name;
orders[i].NumberUser = NumberGen.GetNumberOrder(_bot.StartProgram);
if (i + 1 == orders.Length)
{
decimal realVolume = 0;
for (int i2 = 0; i2 < orders.Length - 1; i2++)
{
realVolume += orders[i2].Volume;
}
orders[i].Volume = _volume - realVolume;
}
}
_ordersNeadToCreate = orders.ToList();
}
19
Source : AcebergMaker.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void CreateModificateOrdersSell()
{
Side side = Side.Sell;
int realCountOrders = _ordersCount;
if (realCountOrders > _volume)
{
realCountOrders = Convert.ToInt32(_volume);
}
Order[] orders = new Order[realCountOrders];
for (int i = 0; i < orders.Length; i++)
{
orders[i] = new Order();
orders[i].Side = side;
orders[i].LifeTime = _lifiTime;
orders[i].Volume = Convert.ToInt32(Math.Round(Convert.ToDecimal(_volume) / Convert.ToDecimal(realCountOrders)));
orders[i].Price = _price;
orders[i].PortfolioNumber = _bot.Portfolio.Number;
orders[i].SecurityNameCode = _bot.Securiti.Name;
orders[i].NumberUser = NumberGen.GetNumberOrder(_bot.StartProgram);
if (i + 1 == orders.Length)
{
decimal realVolume = 0;
for (int i2 = 0; i2 < orders.Length - 1; i2++)
{
realVolume += orders[i2].Volume;
}
orders[i].Volume = _volume - realVolume;
}
}
_ordersNeadToCreate = orders.ToList();
}
19
Source : OptimizerMaster.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private decimal GetInSampleRecurs(decimal curLenghtInSample,int fazeCount, bool lastInSample, int allDays)
{
// х = Y + Y/P * С;
// x - общая длинна в днях. Уже известна
// Y - длинна InSample
// P - процент OutOfSample от InSample
// C - количество отрезков
decimal outOfSampleLength = curLenghtInSample * (_percentOnFilration / 100);
int count = fazeCount;
if(lastInSample)
{
count--;
}
int allLenght = Convert.ToInt32(curLenghtInSample + outOfSampleLength * count);
if(allLenght > allDays)
{
curLenghtInSample--;
return GetInSampleRecurs(curLenghtInSample, fazeCount, lastInSample, allDays);
}
else
{
return curLenghtInSample;
}
}
19
Source : OptimizerMaster.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
public void ReloadFazes()
{
int fazeCount = IterationCount;
if (fazeCount < 1)
{
fazeCount = 1;
}
if (TimeEnd == DateTime.MinValue ||
TimeStart == DateTime.MinValue)
{
SendLogMessage(OsLocalization.Optimizer.Message12, LogMessageType.System);
return;
}
int dayAll = Convert.ToInt32((TimeEnd - TimeStart).TotalDays);
if (dayAll < 2)
{
SendLogMessage(OsLocalization.Optimizer.Message12, LogMessageType.System);
return;
}
int daysOnInSample = (int)GetInSampleRecurs(dayAll, fazeCount, _lastInSample, dayAll);
int daysOnForward = Convert.ToInt32(daysOnInSample * (_percentOnFilration / 100));
Fazes = new List<OptimizerFaze>();
DateTime time = _timeStart;
for (int i = 0; i < fazeCount; i++)
{
OptimizerFaze newFaze = new OptimizerFaze();
newFaze.TypeFaze = OptimizerFazeType.InSample;
newFaze.TimeStart = time;
newFaze.TimeEnd = time.AddDays(daysOnInSample);
time = time.AddDays(daysOnForward);
newFaze.Days = daysOnInSample;
Fazes.Add(newFaze);
if(_lastInSample
&& i +1 == fazeCount)
{
newFaze.Days = daysOnInSample + daysOnForward;
break;
}
OptimizerFaze newFazeOut = new OptimizerFaze();
newFazeOut.TypeFaze = OptimizerFazeType.OutOfSample;
newFazeOut.TimeStart = newFaze.TimeStart.AddDays(daysOnInSample);
newFazeOut.TimeEnd = newFazeOut.TimeStart.AddDays(daysOnForward);
newFazeOut.TimeStart = newFazeOut.TimeStart.AddDays(1);
newFazeOut.Days = daysOnForward;
Fazes.Add(newFazeOut);
}
/*while (DaysInFazes(Fazes) != dayAll)
{
int daysGone = DaysInFazes(Fazes) - dayAll;
for (int i = 0; i < Fazes.Count && daysGone != 0; i++)
{
if (daysGone > 0)
{
Fazes[i].Days--;
if (Fazes[i].TypeFaze == OptimizerFazeType.InSample &&
i + 1 != Fazes.Count)
{
Fazes[i + 1].TimeStart = Fazes[i + 1].TimeStart.AddDays(-1);
}
else
{
Fazes[i].TimeStart = Fazes[i].TimeStart.AddDays(-1);
}
daysGone--;
}
else if (daysGone < 0)
{
Fazes[i].Days++;
if (Fazes[i].TypeFaze == OptimizerFazeType.InSample &&
i + 1 != Fazes.Count)
{
Fazes[i + 1].TimeStart = Fazes[i + 1].TimeStart.AddDays(+1);
}
else
{
Fazes[i].TimeStart = Fazes[i].TimeStart.AddDays(+1);
}
daysGone++;
}
}
}*/
}
19
Source : AcebergMaker.cs
with Apache License 2.0
from AlexWan
with Apache License 2.0
from AlexWan
private void CreateCloseOrders()
{
Side side;
if (_position.Direction == Side.Buy)
{
side = Side.Sell;
}
else
{
side = Side.Buy;
}
int realCountOrders = _ordersCount;
if (realCountOrders > _volume)
{
realCountOrders = Convert.ToInt32(_volume);
}
Order[] orders = new Order[realCountOrders];
for (int i = 0; i < orders.Length; i++)
{
orders[i] = new Order();
orders[i].Side = side;
orders[i].LifeTime = _lifiTime;
orders[i].Volume = Convert.ToInt32(Math.Round(Convert.ToDecimal(_volume) / Convert.ToDecimal(realCountOrders)));
orders[i].Price = _price;
orders[i].PortfolioNumber = _bot.Portfolio.Number;
orders[i].SecurityNameCode = _bot.Securiti.Name;
orders[i].NumberUser = NumberGen.GetNumberOrder(_bot.StartProgram);
if (i + 1 == orders.Length)
{
decimal realVolume = 0;
for (int i2 = 0; i2 < orders.Length - 1; i2++)
{
realVolume += orders[i2].Volume;
}
orders[i].Volume = _volume - realVolume;
}
}
_ordersNeadToCreate = orders.ToList();
}
19
Source : TimeHelper.cs
with MIT License
from aprilyush
with MIT License
from aprilyush
public static int SecondToMinute(int Second)
{
decimal mm = (decimal)((decimal)Second / (decimal)60);
return Convert.ToInt32(Math.Ceiling(mm));
}
19
Source : ComponentWizardPage.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
try
{
UpdateProgress(1);
int total = 10;
int index = 0;
AsposeComponentsManager comManager = new AsposeComponentsManager(this);
foreach (AsposeComponent component in AsposeComponents.list.Values)
{
if (component.is_selected())
{
GlobalData.SelectedComponent = component.get_name();
if (AsposeComponentsManager.libraryAlreadyExists(component.get_downloadFileName()))
{
component.set_downloaded(true);
}
else
{
AsposeComponentsManager.addToDownloadList(component, component.get_downloadUrl(), component.get_downloadFileName());
}
}
decimal percentage = ((decimal)(index + 1) / (decimal)total) * 100;
UpdateProgress(Convert.ToInt32(percentage));
index++;
}
UpdateProgress(100);
UpdateText("All operations completed");
}
catch (Exception) { }
}
19
Source : Tests.cs
with Apache License 2.0
from aws-samples
with Apache License 2.0
from aws-samples
[TestMethod]
public async Task MakeSyntheticData()
{
var startDate = new DateTime(2013, 1, 1);
var endDate = new DateTime(2017, 12, 31);
var numberOfStores = 10;
var numberOfItems = 50;
var yearlyDemandIncrease = 0.015;
var highestDemanddItem = 125;
var lowestDemanddItem = 5;
var totalDays = endDate.Subtract(startDate).TotalDays;
var itemDemands = new Dictionary<int, int>();
var storeModifiers = new Dictionary<int, decimal>();
var weekModifiers = new Dictionary<DayOfWeek, decimal>
{
{DayOfWeek.Sunday, 0.16m},
{DayOfWeek.Monday, 0.14m},
{DayOfWeek.Tuesday, 0.12m},
{DayOfWeek.Wednesday, 0.10m},
{DayOfWeek.Thursday, 0.15m},
{DayOfWeek.Friday, 0.17m},
{DayOfWeek.Saturday, 0.18m}
};
for (var item = 1; item <= numberOfItems; item++)
{
var demand = new Random().Next(lowestDemanddItem, highestDemanddItem);
itemDemands.Add(item, demand);
}
for (var store = 1; store <= numberOfStores; store++)
{
var modifier = new Random().Next(-20, 20);
storeModifiers.Add(store, modifier);
}
using (var file = File.CreateText("train.csv"))
{
file.WriteLine("date,store,item,demand");
for (var day = 0; day <= totalDays; day++)
{
var date = startDate.AddDays(day);
var year = 1 + (date.Year - startDate.Year);
for (var store = 1; store <= numberOfStores; store++)
for (var item = 1; item <= numberOfItems; item++)
{
var startingDemand = itemDemands[item];
var demandIncrease = startingDemand * (year * yearlyDemandIncrease);
var demand = Convert.ToInt32(startingDemand + demandIncrease);
var modifier = storeModifiers[store] * 0.01m;
var storeModification = demand * modifier;
demand = Convert.ToInt32(demand + storeModification);
var dayOfWeekModifier = weekModifiers[date.DayOfWeek];
var dayOfWeekModification = demand * dayOfWeekModifier;
demand = Convert.ToInt32(demand + dayOfWeekModification);
await file.WriteLineAsync($"{date.Year}-{date.Month:D2}-{date.Day:D2},{store},{item},{demand}");
}
}
}
}
19
Source : CreditCard.cs
with MIT License
from ay2015
with MIT License
from ay2015
private static string FakeCreditCardNumber(string prefix, int length)
{
string creditCardNumber = prefix;
int sum = 0, pos = 0;
while (creditCardNumber.Length < (length - 1))
{
double randomNumber = (new Random().NextDouble() * 1.0f - 0f);
creditCardNumber += Math.Floor(randomNumber * 10);
}
var creditCardNumberReversed = creditCardNumber.ToCharArray().Reverse();
var creditCardNumbers = creditCardNumberReversed.Select(c => Convert.ToInt32(c.ToString()));
int[] number = creditCardNumbers.ToArray();
while (pos < length - 1)
{
int odd = number[pos] * 2;
if (odd > 9) { odd -= 9; }
sum += odd;
if (pos != (length - 2)) { sum += number[pos + 1]; }
pos += 2;
}
int validDigit = Convert.ToInt32((Math.Floor((decimal) sum/10) + 1)*10 - sum)%10;
creditCardNumber += validDigit;
return creditCardNumber;
}
19
Source : SqlServerAdapter.cs
with MIT License
from borisdj
with MIT License
from borisdj
private static DataTable InnerGetDataTable<T>(DbContext context, ref Type type, IList<T> enreplacedies, TableInfo tableInfo)
{
var dataTable = new DataTable();
var columnsDict = new Dictionary<string, object>();
var ownedEnreplacediesMappedProperties = new HashSet<string>();
var isSqlServer = context.Database.ProviderName.EndsWith(DbServer.SqlServer.ToString());
var sqlServerBytesWriter = new SqlServerBytesWriter();
var objectIdentifier = tableInfo.ObjectIdentifier;
type = tableInfo.HasAbstractList ? enreplacedies[0].GetType() : type;
var enreplacedyType = context.Model.FindEnreplacedyType(type);
var enreplacedyTypeProperties = enreplacedyType.GetProperties();
var enreplacedyPropertiesDict = enreplacedyTypeProperties.Where(a => tableInfo.PropertyColumnNamesDict.ContainsKey(a.Name) ||
(tableInfo.BulkConfig.OperationType != OperationType.Read && a.Name == tableInfo.TimeStampPropertyName))
.ToDictionary(a => a.Name, a => a);
var enreplacedyNavigationOwnedDict = enreplacedyType.GetNavigations().Where(a => a.TargetEnreplacedyType.IsOwned()).ToDictionary(a => a.Name, a => a);
var enreplacedyShadowFkPropertiesDict = enreplacedyTypeProperties.Where(a => a.IsShadowProperty() &&
a.IsForeignKey() &&
a.GetContainingForeignKeys().FirstOrDefault()?.DependentToPrincipal?.Name != null)
.ToDictionary(x => x.GetContainingForeignKeys().First().DependentToPrincipal.Name, a => a);
var enreplacedyShadowFkPropertyColumnNamesDict = enreplacedyShadowFkPropertiesDict.ToDictionary(a => a.Key, a => a.Value.GetColumnName(objectIdentifier));
var shadowPropertyColumnNamesDict = enreplacedyPropertiesDict.Where(a => a.Value.IsShadowProperty()).ToDictionary(a => a.Key, a => a.Value.GetColumnName(objectIdentifier));
var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
var discriminatorColumn = GetDiscriminatorColumn(tableInfo);
foreach (var property in properties)
{
var hasDefaultVauleOnInsert = tableInfo.BulkConfig.OperationType == OperationType.Insert && !tableInfo.BulkConfig.SetOutputIdenreplacedy && tableInfo.DefaultValueProperties.Contains(property.Name);
if (enreplacedyPropertiesDict.ContainsKey(property.Name))
{
var propertyEnreplacedyType = enreplacedyPropertiesDict[property.Name];
string columnName = propertyEnreplacedyType.GetColumnName(objectIdentifier);
var isConvertible = tableInfo.ConvertibleColumnConverterDict.ContainsKey(columnName);
var propertyType = isConvertible ? tableInfo.ConvertibleColumnConverterDict[columnName].ProviderClrType : property.PropertyType;
var underlyingType = Nullable.GetUnderlyingType(propertyType);
if (underlyingType != null)
{
propertyType = underlyingType;
}
if (isSqlServer && (propertyType == typeof(Geometry) || propertyType.IsSubclreplacedOf(typeof(Geometry))))
{
propertyType = typeof(byte[]);
tableInfo.HreplacedpatialType = true;
if (tableInfo.BulkConfig.PropertiesToIncludeOnCompare != null || tableInfo.BulkConfig.PropertiesToIncludeOnCompare != null)
{
throw new InvalidOperationException("OnCompare properties Config can not be set for Enreplacedy with Spatial types like 'Geometry'");
}
}
if (!columnsDict.ContainsKey(property.Name) && !hasDefaultVauleOnInsert)
{
dataTable.Columns.Add(columnName, propertyType);
columnsDict.Add(property.Name, null);
}
}
else if (enreplacedyShadowFkPropertiesDict.ContainsKey(property.Name))
{
var fk = enreplacedyShadowFkPropertiesDict[property.Name];
enreplacedyPropertiesDict.TryGetValue(fk.GetColumnName(objectIdentifier), out var enreplacedyProperty);
if (enreplacedyProperty == null) // BulkRead
continue;
var columnName = enreplacedyProperty.GetColumnName(objectIdentifier);
var propertyType = enreplacedyProperty.ClrType;
var underlyingType = Nullable.GetUnderlyingType(propertyType);
if (underlyingType != null)
{
propertyType = underlyingType;
}
if (propertyType == typeof(Geometry) && isSqlServer)
{
propertyType = typeof(byte[]);
}
if (!columnsDict.ContainsKey(columnName) && !hasDefaultVauleOnInsert)
{
dataTable.Columns.Add(columnName, propertyType);
columnsDict.Add(columnName, null);
}
}
else if (enreplacedyNavigationOwnedDict.ContainsKey(property.Name)) // isOWned
{
Type navOwnedType = type.replacedembly.GetType(property.PropertyType.FullName);
var ownedEnreplacedyType = context.Model.FindEnreplacedyType(property.PropertyType);
if (ownedEnreplacedyType == null)
{
ownedEnreplacedyType = context.Model.GetEnreplacedyTypes().SingleOrDefault(a => a.DefiningNavigationName == property.Name && a.DefiningEnreplacedyType.Name == enreplacedyType.Name);
}
var ownedEnreplacedyProperties = ownedEnreplacedyType.GetProperties().ToList();
var ownedEnreplacedyPropertyNameColumnNameDict = new Dictionary<string, string>();
foreach (var ownedEnreplacedyProperty in ownedEnreplacedyProperties)
{
if (!ownedEnreplacedyProperty.IsPrimaryKey())
{
string columnName = ownedEnreplacedyProperty.GetColumnName(objectIdentifier);
if (tableInfo.PropertyColumnNamesDict.ContainsValue(columnName))
{
ownedEnreplacedyPropertyNameColumnNameDict.Add(ownedEnreplacedyProperty.Name, columnName);
ownedEnreplacediesMappedProperties.Add(property.Name + "_" + ownedEnreplacedyProperty.Name);
}
}
}
var innerProperties = property.PropertyType.GetProperties();
if (!tableInfo.LoadOnlyPKColumn)
{
foreach (var innerProperty in innerProperties)
{
if (ownedEnreplacedyPropertyNameColumnNameDict.ContainsKey(innerProperty.Name))
{
var columnName = ownedEnreplacedyPropertyNameColumnNameDict[innerProperty.Name];
var propertyName = $"{property.Name}_{innerProperty.Name}";
if (tableInfo.ConvertibleColumnConverterDict.ContainsKey(propertyName))
{
var convertor = tableInfo.ConvertibleColumnConverterDict[propertyName];
var underlyingType = Nullable.GetUnderlyingType(convertor.ProviderClrType) ?? convertor.ProviderClrType;
dataTable.Columns.Add(columnName, underlyingType);
}
else
{
var ownedPropertyType = Nullable.GetUnderlyingType(innerProperty.PropertyType) ?? innerProperty.PropertyType;
dataTable.Columns.Add(columnName, ownedPropertyType);
}
columnsDict.Add(property.Name + "_" + innerProperty.Name, null);
}
}
}
}
}
if (tableInfo.BulkConfig.EnableShadowProperties)
{
foreach (var shadowProperty in enreplacedyPropertiesDict.Values.Where(a => a.IsShadowProperty()))
{
var columnName = shadowProperty.GetColumnName(objectIdentifier);
// If a model has an enreplacedy which has a relationship without an explicity defined FK, the data table will already contain the foreign key shadow property
if (dataTable.Columns.Contains(columnName))
continue;
var isConvertible = tableInfo.ConvertibleColumnConverterDict.ContainsKey(columnName);
var propertyType = isConvertible ? tableInfo.ConvertibleColumnConverterDict[columnName].ProviderClrType : shadowProperty.ClrType;
var underlyingType = Nullable.GetUnderlyingType(propertyType);
if (underlyingType != null)
{
propertyType = underlyingType;
}
if (isSqlServer && (propertyType == typeof(Geometry) || propertyType.IsSubclreplacedOf(typeof(Geometry))))
{
propertyType = typeof(byte[]);
}
dataTable.Columns.Add(columnName, propertyType);
columnsDict.Add(shadowProperty.Name, null);
}
}
if (discriminatorColumn != null)
{
var discriminatorProperty = enreplacedyPropertiesDict[discriminatorColumn];
dataTable.Columns.Add(discriminatorColumn, discriminatorProperty.ClrType);
columnsDict.Add(discriminatorColumn, enreplacedyType.GetDiscriminatorValue());
}
bool hasConverterProperties = tableInfo.ConvertiblePropertyColumnDict.Count > 0;
foreach (var enreplacedy in enreplacedies)
{
var propertiesToLoad = properties.Where(a => !tableInfo.AllNavigationsDictionary.ContainsKey(a.Name) || enreplacedyShadowFkPropertiesDict.ContainsKey(a.Name) || tableInfo.OwnedTypesDict.ContainsKey(a.Name)); // omit virtual Navigation (except Owned and ShadowNavig.) since it's Getter can cause unwanted Select-s from Db
foreach (var property in propertiesToLoad)
{
var propertyValue = tableInfo.FastPropertyDict.ContainsKey(property.Name) ? tableInfo.FastPropertyDict[property.Name].Get(enreplacedy) : null;
var hasDefaultVauleOnInsert = tableInfo.BulkConfig.OperationType == OperationType.Insert && !tableInfo.BulkConfig.SetOutputIdenreplacedy && tableInfo.DefaultValueProperties.Contains(property.Name);
if (tableInfo.BulkConfig.DateTime2PrecisionForceRound && isSqlServer && tableInfo.DateTime2PropertiesPrecisionLessThen7Dict.ContainsKey(property.Name))
{
DateTime dateTimePropertyValue = (DateTime)propertyValue;
int precision = tableInfo.DateTime2PropertiesPrecisionLessThen7Dict[property.Name];
int digitsToRemove = 7 - precision;
int powerOf10 = (int)Math.Pow(10, digitsToRemove);
long subsecondTicks = dateTimePropertyValue.Ticks % 10000000;
long ticksToRound = subsecondTicks + (subsecondTicks % 10 == 0 ? 1 : 0); // if ends with 0 add 1 tick to make sure rounding of value .5_zeros is rounded to Upper like SqlServer is doing, not to Even as Math.Round works
int roundedTicks = Convert.ToInt32(Math.Round((decimal)ticksToRound / powerOf10, 0)) * powerOf10;
dateTimePropertyValue = dateTimePropertyValue.AddTicks(-subsecondTicks).AddTicks(roundedTicks);
propertyValue = dateTimePropertyValue;
}
if (hasConverterProperties && tableInfo.ConvertiblePropertyColumnDict.ContainsKey(property.Name))
{
string columnName = tableInfo.ConvertiblePropertyColumnDict[property.Name];
propertyValue = tableInfo.ConvertibleColumnConverterDict[columnName].ConvertToProvider.Invoke(propertyValue);
}
if (tableInfo.HreplacedpatialType && propertyValue is Geometry geometryValue)
{
geometryValue.SRID = tableInfo.BulkConfig.SRID;
if (tableInfo.PropertyColumnNamesDict.ContainsKey(property.Name))
{
sqlServerBytesWriter.IsGeography = tableInfo.ColumnNamesTypesDict[tableInfo.PropertyColumnNamesDict[property.Name]] == "geography"; // "geography" type is default, otherwise it's "geometry" type
}
propertyValue = sqlServerBytesWriter.Write(geometryValue);
}
if (enreplacedyPropertiesDict.ContainsKey(property.Name) && !hasDefaultVauleOnInsert)
{
columnsDict[property.Name] = propertyValue;
}
else if (enreplacedyShadowFkPropertiesDict.ContainsKey(property.Name))
{
var foreignKeyShadowProperty = enreplacedyShadowFkPropertiesDict[property.Name];
var columnName = enreplacedyShadowFkPropertyColumnNamesDict[property.Name];
enreplacedyPropertiesDict.TryGetValue(columnName, out var enreplacedyProperty);
if (enreplacedyProperty == null) // BulkRead
continue;
columnsDict[columnName] = propertyValue == null ? null : foreignKeyShadowProperty.FindFirstPrincipal().PropertyInfo.GetValue(propertyValue); // TODO Check if can be optimized
}
else if (enreplacedyNavigationOwnedDict.ContainsKey(property.Name) && !tableInfo.LoadOnlyPKColumn)
{
var ownedProperties = property.PropertyType.GetProperties().Where(a => ownedEnreplacediesMappedProperties.Contains(property.Name + "_" + a.Name));
foreach (var ownedProperty in ownedProperties)
{
var columnName = $"{property.Name}_{ownedProperty.Name}";
var ownedPropertyValue = propertyValue == null ? null : tableInfo.FastPropertyDict[columnName].Get(propertyValue);
if (tableInfo.ConvertibleColumnConverterDict.ContainsKey(columnName))
{
var converter = tableInfo.ConvertibleColumnConverterDict[columnName];
columnsDict[columnName] = ownedPropertyValue == null ? null : converter.ConvertToProvider.Invoke(ownedPropertyValue);
}
else
{
columnsDict[columnName] = ownedPropertyValue;
}
}
}
}
if (tableInfo.BulkConfig.EnableShadowProperties)
{
foreach (var shadowPropertyName in shadowPropertyColumnNamesDict.Keys)
{
var shadowProperty = enreplacedyPropertiesDict[shadowPropertyName];
var columnName = shadowPropertyColumnNamesDict[shadowPropertyName];
var propertyValue = context.Entry(enreplacedy).Property(shadowPropertyName).CurrentValue;
if (tableInfo.ConvertibleColumnConverterDict.ContainsKey(columnName))
{
propertyValue = tableInfo.ConvertibleColumnConverterDict[columnName].ConvertToProvider.Invoke(propertyValue);
}
columnsDict[shadowPropertyName] = propertyValue;
}
}
var record = columnsDict.Values.ToArray();
dataTable.Rows.Add(record);
}
return dataTable;
}
19
Source : WeChatPaymentUnifyOrderInput.cs
with MIT License
from bxjg1987
with MIT License
from bxjg1987
public string ToXml()
{
var x = this;
//也许某些参数没有值的时候可以不传,没有测试过,如果可行 可以减少传输的数据量
return $@"; <xml>
<appid>{x.appid}</appid>
<mch_id>{x.mch_id}</mch_id>
<device_info>{x.device_info}</device_info>
<nonce_str>{x.nonce_str}</nonce_str>
<sign>{x.sign}</sign>
<sign_type>{x.sign_type}</sign>
<body>{x.body}</body>
<detail><![CDATA[{x.detail}]]></detail>
<attach>{x.attach}</attach>
<out_trade_no>{x.out_trade_no}</out_trade_no>
<fee_type>{x.fee_type}</fee_type>
<total_fee>{ Convert.ToInt32(x.total_fee * 100)}</total_fee>
<spbill_create_ip>{x.spbill_create_ip}</spbill_create_ip>
<time_start>{x.time_start?.ToString("yyyyMMddHHmmss")}</time_start>
<time_expire>{x.time_expire?.ToString("yyyyMMddHHmmss")}</time_expire>
<goods_tag>{x.goods_tag}</goods_tag>
<notify_url>{x.notify_url}</notify_url>
<trade_type>{x.trade_type}</trade_type>
<product_id>{x.product_id}</product_id>
<limit_pay>{x.limit_pay}</limit_pay>
<openid>{x.openid}</openid>
<receipt>{x.receipt}</receipt>
<scene_info>{x.scene_info}</scene_info>
</xml>";
}
19
Source : MuestraImpresa.cs
with GNU General Public License v3.0
from chilesystems
with GNU General Public License v3.0
from chilesystems
private void Number_ValueChanged(object sender, EventArgs e)
{
var txt = sender as NumericUpDown;
if (txt == null)
return;
switch (txt.Name)
{
case "txtFolio":
doreplacedent.Folio = Convert.ToInt32(txt.Value);
break;
case "txtIva":
doreplacedent.IVA = Convert.ToInt32(txt.Value);
break;
case "txtNeto":
doreplacedent.Neto = Convert.ToInt32(txt.Value);
break;
case "txtTotal":
doreplacedent.Total = Convert.ToInt32(txt.Value);
break;
case "txtExento":
doreplacedent.TotalExento = Convert.ToInt32(txt.Value);
break;
case "txtNumeroResolucion":
doreplacedent.NumeroResolucion = Convert.ToInt32(txt.Value);
break;
default:
break;
}
}
19
Source : BtcMarkets.cs
with GNU Affero General Public License v3.0
from coj337
with GNU Affero General Public License v3.0
from coj337
public async Task<ExchangeOrderResult> CreateOrder(string pair, OrderSide side, OrderType type, decimal price, decimal amount)
{
string[] currencies = pair.Split('/');
string orderSide = side == OrderSide.Buy ? "Ask" : "Bid";
string orderType = type == OrderType.Market ? "Market" : "Limit";
string orderId = _client.CreateNewOrder(currencies[0], currencies[1], Convert.ToInt64(price * 100000000), Convert.ToInt32(amount * 100000000), orderSide, orderType);
return new ExchangeOrderResult()
{
OrderId = orderId
};
}
19
Source : FileHelper.cs
with GNU General Public License v3.0
from CyanLabs
with GNU General Public License v3.0
from CyanLabs
public async Task<bool> CopyFileAsync(string source, string destination, CancellationToken ct)
{
try
{
FileOptions fileOptions = FileOptions.Asynchronous | FileOptions.SequentialScan;
int bufferSize = 1024 * 512;
using FileStream inStream = new(source, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, bufferSize, fileOptions);
using FileStream fileStream = new(destination, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, bufferSize, fileOptions);
int bytesRead;
int totalReads = 0;
long totalBytes = inStream.Length;
byte[] bytes = new byte[bufferSize];
int prevPercent = 0;
while ((bytesRead = await inStream.ReadAsync(bytes, 0, bufferSize, ct)) > 0)
{
if (ct.IsCancellationRequested)
{
fileStream.Close();
fileStream.Dispose();
try
{
File.Delete(destination);
}
catch (IOException)
{
}
return false;
}
await fileStream.WriteAsync(bytes, 0, bytesRead, ct);
totalReads += bytesRead;
int percent = Convert.ToInt32(totalReads / (decimal) totalBytes * 100);
if (percent == prevPercent) continue;
_percentageChanged.Raise(this, percent, 0);
prevPercent = percent;
}
}
catch (IOException ioException)
{
await Application.Current.Dispatcher.BeginInvoke(() => UIHelper.ShowErrorDialog(ioException.GetFullMessage()));
AppMan.Logger.Info("ERROR: " + ioException.GetFullMessage());
return false;
}
catch (UnauthorizedAccessException exception)
{
await Application.Current.Dispatcher.BeginInvoke(() => UIHelper.ShowErrorDialog(exception.GetFullMessage()));
AppMan.Logger.Info("ERROR: " + exception.GetFullMessage());
return false;
}
return true;
}
19
Source : DecimalRoughAdvancedConverter.cs
with MIT License
from DataObjects-NET
with MIT License
from DataObjects-NET
int IAdvancedConverter<decimal, int>.Convert(decimal value)
{
return Convert.ToInt32(value);
}
19
Source : OracleValueConverterTests.cs
with MIT License
from DIPSAS
with MIT License
from DIPSAS
[Fact]
public void GetOracleDecimalReturnsInt32()
{
decimal input = 100;
var expected = Convert.ToInt32(input);
var result = OracleValueConverter.Convert<int>(new OracleDecimal(input));
result.Should().Be(expected);
}
19
Source : OracleValueConverterTests.cs
with MIT License
from DIPSAS
with MIT License
from DIPSAS
[Fact]
public void GetOracleDecimalReturnsNullableInt32()
{
decimal input = 100;
var expected = Convert.ToInt32(input);
var result = OracleValueConverter.Convert<int?>(new OracleDecimal(input));
result.Should().Be(expected);
}
19
Source : Urls.cs
with MIT License
from DmitriyBobrovskiy
with MIT License
from DmitriyBobrovskiy
private static string GetSum(decimal sum)
=> $"{Convert.ToInt32(Math.Round(sum, 2, MidpointRounding.AwayFromZero) * 100)}";
19
Source : BasicConvert.Overload.cs
with MIT License
from Dogwei
with MIT License
from Dogwei
int IXConverter<decimal, int>.Convert(decimal value)
=> Convert.ToInt32(value);
19
Source : WeChatPayFeeConverter.cs
with MIT License
from EasyAbp
with MIT License
from EasyAbp
public virtual int ConvertToWeChatPayFee(decimal fee)
{
return Convert.ToInt32(decimal.Round(fee, 2, MidpointRounding.AwayFromZero) * 100);
}
19
Source : Price.cs
with Apache License 2.0
from elucidsoft
with Apache License 2.0
from elucidsoft
public static Price FromString(string price)
{
if (string.IsNullOrEmpty(price))
throw new ArgumentNullException(nameof(price), "price cannot be null");
var maxInt = new decimal(int.MaxValue);
var number = Convert.ToDecimal(price, CultureInfo.InvariantCulture);
decimal a;
decimal f;
var fractions = new List<decimal[]>();
fractions.Add(new[] { new decimal(0), new decimal(1) });
fractions.Add(new[] { new decimal(1), new decimal(0) });
var i = 2;
while (true)
{
if (number.CompareTo(maxInt) > 0)
break;
a = decimal.Floor(number);
f = decimal.Subtract(number, a);
var h = decimal.Add(decimal.Multiply(a, fractions[i - 1][0]), fractions[i - 2][0]);
var k = decimal.Add(decimal.Multiply(a, fractions[i - 1][1]), fractions[i - 2][1]);
if (h.CompareTo(maxInt) > 0 || k.CompareTo(maxInt) > 0)
break;
fractions.Add(new[] { h, k });
if (f.CompareTo(0m) == 0)
break;
number = decimal.Divide(1m, f);
i += 1;
}
var n = fractions[fractions.Count - 1][0];
var d = fractions[fractions.Count - 1][1];
return new Price(Convert.ToInt32(n), Convert.ToInt32(d));
}
19
Source : LoanField.cs
with MIT License
from EncompassRest
with MIT License
from EncompassRest
public int? ToInt32()
{
var value = Value;
switch (value)
{
case string str:
return int.TryParse(str, out var n) ? n : (int?)null;
case decimal d:
return d <= int.MaxValue && d >= int.MinValue ? Convert.ToInt32(d) : (int?)null;
case int i:
return i;
}
return null;
}
19
Source : GeneralRecordWrapper.cs
with GNU Lesser General Public License v3.0
from faib920
with GNU Lesser General Public License v3.0
from faib920
public virtual int GetInt32(IDataRecord reader, int i)
{
if (reader.IsDBNull(i))
{
return 0;
}
var type = reader.GetFieldType(i);
if (type == typeof(int))
{
return reader.GetInt32(i);
}
else if (type == typeof(char))
{
return reader.GetChar(i);
}
else if (type == typeof(byte))
{
return reader.GetByte(i);
}
else if (type == typeof(short))
{
return reader.GetInt16(i);
}
else if (type == typeof(long))
{
return Convert.ToInt32(reader.GetInt64(i));
}
else if (type == typeof(decimal))
{
return Convert.ToInt32(reader.GetDecimal(i));
}
else if (type == typeof(float))
{
return Convert.ToInt32(reader.GetFloat(i));
}
else if (type == typeof(double))
{
return Convert.ToInt32(reader.GetDouble(i));
}
return Convert.ToInt32(GetValue(reader, i));
}
19
Source : LinkedTweaks.cs
with MIT License
from FelisDiligens
with MIT License
from FelisDiligens
public static void LinkSize(NumericUpDown width, NumericUpDown height, ITweak<Size> tweak)
{
SetValueActions.Add(() =>
{
Size size = tweak.GetValue();
width.Value = size.Width;
height.Value = size.Height;
});
EventHandler sizeChanged = (object sender, EventArgs e) =>
{
Size newSize = new Size(
Convert.ToInt32(width.Value),
Convert.ToInt32(height.Value)
);
tweak.SetValue(newSize);
};
width.ValueChanged += sizeChanged;
height.ValueChanged += sizeChanged;
}
19
Source : LinkedTweaks.cs
with MIT License
from FelisDiligens
with MIT License
from FelisDiligens
public static void LinkTweak(NumericUpDown num, ITweak<int> tweak)
{
SetValueActions.Add(() => num.Value = Utils.Clamp(tweak.GetValue(), Convert.ToInt32(num.Minimum), Convert.ToInt32(num.Maximum)));
num.ValueChanged += (object sender, EventArgs e) => tweak.SetValue(Convert.ToInt32(num.Value));
}
19
Source : Utils.cs
with MIT License
from FelisDiligens
with MIT License
from FelisDiligens
public static int ToInt(string num)
{
//return Convert.ToInt32(num, enUS); // "0.0" => String.FormatException
return Convert.ToInt32(Convert.ToDecimal(num, enUS)); // "0.0" => (int)0
}
19
Source : MainWindow.xaml.cs
with MIT License
from Flumpster
with MIT License
from Flumpster
private bool LoadItemData()
{
try
{
itemTotal = gecko.GetInt(VersionedItemOffsets.Count);
var currenreplacedemAddress = VersionedItemOffsets.End;
for (var x = 1; x <= itemTotal; x++)
{
var itemData = gecko.ReadBytes(currenreplacedemAddress, 0x70);
var page = BitConverter.ToInt32(itemData.Take(4).Skip(0).Reverse().ToArray(), 0);
if (page < 0 || page > 9)
{
currenreplacedemAddress -= 0x220;
x = x - 1;
continue;
}
var builder = new StringBuilder();
for (var i = 0; i < 36; i++)
{
var data = itemData.Skip(i + 28).Take(1).ToArray()[0];
if (data == 0)
{
break;
}
builder.Append((char)data);
}
var id = builder.ToString();
if (string.IsNullOrWhiteSpace(id))
{
currenreplacedemAddress -= 0x220;
x = x - 1;
continue;
}
var unknown = BitConverter.ToInt32(itemData.Skip(4).Take(4).Reverse().ToArray(), 0);
var value = BitConverter.ToUInt32(itemData.Skip(8).Take(4).Reverse().ToArray(), 0);
var equipped = BitConverter.ToBoolean(itemData.Skip(12).Take(1).Reverse().ToArray(), 0);
var current = BitConverter.ToBoolean(itemData.Skip(13).Take(1).Reverse().ToArray(), 0);
var nameStart = currenreplacedemAddress + 0x1C;
var item = new Item
{
BaseAddress = currenreplacedemAddress,
Page = page,
Unknown = unknown,
Value = value,
Equipped = equipped,
Current = current,
NameStart = nameStart,
Id = id,
Modifier1Value = gecko.ByteToHexBitFiddle(itemData.Skip(92).Take(4).ToArray()),
Modifier2Value = gecko.ByteToHexBitFiddle(itemData.Skip(96).Take(4).ToArray()),
Modifier3Value = gecko.ByteToHexBitFiddle(itemData.Skip(100).Take(4).ToArray()),
Modifier4Value = gecko.ByteToHexBitFiddle(itemData.Skip(104).Take(4).ToArray()),
Modifier5Value = gecko.ByteToHexBitFiddle(itemData.Skip(108).Take(4).ToArray())
};
// look for name in item details list
var name = GetNameFromId(item.Id, item.PageName);
item.Name = name;
items.Add(item);
var currentPercent = (100m / itemTotal) * x;
Dispatcher.Invoke(
() =>
{
ProgressText.Text = string.Format("{0}/{1}", x, itemTotal);
UpdateProgress(Convert.ToInt32(currentPercent));
});
currenreplacedemAddress -= 0x220;
}
return true;
}
catch (Exception ex)
{
Dispatcher.Invoke(() => LogError(ex));
return false;
}
}
19
Source : CacheProgressUI.cs
with GNU General Public License v3.0
from HicServices
with GNU General Public License v3.0
from HicServices
private CacheLagPeriod CreateNewCacheLagPeriod(decimal value, object selectedItem)
{
var duration = Convert.ToInt32(value);
CacheLagPeriod cacheLagPeriod = null;
if (selectedItem != null)
cacheLagPeriod = new CacheLagPeriod(duration, (CacheLagPeriod.PeriodType)selectedItem);
return cacheLagPeriod;
}
19
Source : Main.cs
with MIT License
from hotshotz79
with MIT License
from hotshotz79
public void DisplayIcons(decimal zoom)
{
//Set the Icon Size
int iconSize = 0;
if (cmbSubfolders.SelectedItem.ToString() == "Vertical")
iconSize = Convert.ToInt32(155 * zoom);
else if (cmbSubfolders.SelectedItem.ToString() == "Horizontal")
iconSize = Convert.ToInt32(397 * zoom);
else
iconSize = Convert.ToInt32(256 * zoom);
iconFolder = subPath + "\\" + dgvFolders.SelectedCells[0].Value;
flowIcons.Controls.Clear();
string[] fileEntries = Directory.GetFiles(iconFolder);
for (int x = 0; x < fileEntries.Length; x++)
{
DirectoryInfo dir_info = new DirectoryInfo(fileEntries[x]);
string fileName = dir_info.Name;
if (fileName.Contains(".jpg"))
{
//Break filename into name and replacedle id
string[] splitFileName = fileName.Split('[', ']');
if (splitFileName.Length == 1)
{
Array.Resize(ref splitFileName, 2);
splitFileName[2 - 1] = "0"; //Missing replacedle ID
}
if (showIconsForInstalledGamesOnlyToolStripMenuItem.Checked)
{
foreach (DataRow csvRow in dtCSV.Rows)
{
Console.WriteLine(csvRow.ItemArray[0]);
if (splitFileName[1].ToString() == csvRow.ItemArray[0].ToString())
{
PictureBox pbIcon = new PictureBox();
pbIcon.ImageLocation = dir_info.ToString();
pbIcon.Name = splitFileName[0].Replace('-', ' ').Trim();
pbIcon.Tag = splitFileName[1];
pbIcon.Size = new Size(iconSize, Convert.ToInt32(256 * zoom));
pbIcon.SizeMode = PictureBoxSizeMode.StretchImage;
pbIcon.DoubleClick += new EventHandler(this.iconClicked);
flowIcons.Controls.Add(pbIcon);
break;
}
}
}
else
{
//Populate the Flow Panel
PictureBox pbIcon = new PictureBox();
pbIcon.ImageLocation = dir_info.ToString();
pbIcon.Name = splitFileName[0].Replace('-', ' ').Trim();
pbIcon.Tag = splitFileName[1];
pbIcon.Size = new Size(iconSize, Convert.ToInt32(256 * zoom));
pbIcon.SizeMode = PictureBoxSizeMode.StretchImage;
pbIcon.DoubleClick += new EventHandler(this.iconClicked);
flowIcons.Controls.Add(pbIcon);
}
}
}
}
19
Source : SettingForm.cs
with GNU General Public License v3.0
from hyjiacan
with GNU General Public License v3.0
from hyjiacan
private Control RenderNumber(SettingModule module, PropertyInfo item, char type)
{
var attr = item.GetCustomAttribute<SettingItemAttribute>();
var name = attr.Name;
var itemContainer = new Panel
{
AutoSize = true,
Margin = new Padding(0, 10, 0, 10)
};
var label = new Label
{
Text = name,
Left = 0,
Top = 0,
AutoSize = true
};
if (attr.RestartRequired)
{
label.ForeColor = Color.Red;
}
itemContainer.Controls.Add(label);
var textbox = new NumericUpDown
{
Left = 0,
Top = 16,
Width = 400,
Minimum = 0,
Maximum = type == 'i' ? int.MaxValue : long.MaxValue
};
textbox.Value = long.Parse(item.GetValue(module).ToString());
itemContainer.Controls.Add(textbox);
textbox.ValueChanged += (sender, e) =>
{
if(type == 'i')
{
item.SetValue(module, Convert.ToInt32(textbox.Value));
}
else
{
item.SetValue(module, Convert.ToInt64(textbox.Value));
}
};
return itemContainer;
}
19
Source : frmImport_SetAssignments.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
[DebuggerStepThrough]
bool ParseClreplacedes(string iFileName)
{
int num1 = 0;
Enums.eSetType eSetType = Enums.eSetType.Untyped;
StreamReader iStream;
try
{
iStream = new StreamReader(iFileName);
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
int num2 = (int)Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, "IO CSV Not Opened");
bool flag = false;
ProjectData.ClearProjectError();
return flag;
}
int num3 = 0;
int num4 = 0;
int num5 = 0;
bool[] flagArray = new bool[Enum.GetValues(eSetType.GetType()).Length - 1 + 1];
int index1 = -1;
int num6 = DatabaseAPI.Database.Power.Length - 1;
for (int index2 = 0; index2 <= num6; ++index2)
DatabaseAPI.Database.Power[index2].SetTypes = new Enums.eSetType[0];
try
{
string iLine;
do
{
iLine = FileIO.ReadLineUnlimited(iStream, char.MinValue);
if (iLine != null && !iLine.StartsWith("#"))
{
++num5;
if (num5 >= 9)
{
this.BusyMsg(Strings.Format(num3, "###,##0") + " records parsed.");
num5 = 0;
}
string[] array = CSV.ToArray(iLine);
if (array.Length > 1)
{
int num2 = DatabaseAPI.NidFromUidioSet(array[0]);
if (num2 != index1 & index1 > -1)
flagArray[(int)DatabaseAPI.Database.EnhancementSets[index1].SetType] = true;
index1 = num2;
if (index1 > -1 && !flagArray[(int)DatabaseAPI.Database.EnhancementSets[index1].SetType])
{
int nIDPower = DatabaseAPI.NidFromUidPower(array[1]);
if (nIDPower > -1)
this.AddSetType(nIDPower, DatabaseAPI.Database.EnhancementSets[index1].SetType);
}
++num1;
}
else
++num4;
++num3;
}
}
while (iLine != null);
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
Exception exception = ex;
iStream.Close();
int num2 = (int)Interaction.MsgBox(exception.Message, MsgBoxStyle.Critical, "IO CSV Parse Error");
bool flag = false;
ProjectData.ClearProjectError();
return flag;
}
iStream.Close();
DatabaseAPI.Database.IOreplacedignmentVersion.SourceFile = this.dlgBrowse.FileName;
DatabaseAPI.Database.IOreplacedignmentVersion.RevisionDate = DateTime.Now;
DatabaseAPI.Database.IOreplacedignmentVersion.Revision = Convert.ToInt32(this.udRevision.Value);
var serializer = My.MyApplication.GetSerializer();
DatabaseAPI.SaveMainDatabase(serializer);
this.DisplayInfo();
int num7 = (int)Interaction.MsgBox(("Parse Completed!\r\nTotal Records: " + Conversions.ToString(num3) + "\r\nGood: " + Conversions.ToString(num1) + "\r\nRejected: " + Conversions.ToString(num4)), MsgBoxStyle.Information, "File Parsed");
return true;
}
19
Source : frmEditArchetype.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void btnOK_Click(object sender, EventArgs e)
{
if (!this.CheckClreplacedName())
return;
if (this.clbOrigin.CheckedItems.Count < 1)
{
int num1 = (int)Interaction.MsgBox("An archetype clreplaced must have at least one valid origin!", MsgBoxStyle.Information, "Oops.");
}
else if (this.cbPriGroup.Text == "" | this.cbSecGroup.Text == "")
{
int num2 = (int)Interaction.MsgBox("You must set a Primary and Secondary Powerset Group!", MsgBoxStyle.Information, "Oops.");
}
else
{
float num3 = (float)Conversion.Val(this.txtHP.Text);
if ((double)num3 < 1.0)
{
num3 = 1f;
int num4 = (int)Interaction.MsgBox("Hit Point value of < 1 is invalid. Hit Points set to 1", MsgBoxStyle.Information, null);
}
this.MyAT.Hitpoints = (int)Math.Round((double)num3);
float num5 = (float)Conversion.Val(this.txtHPCap.Text);
if ((double)num5 < 1.0)
num5 = 1f;
if ((double)num5 < (double)this.MyAT.Hitpoints)
num5 = (float)this.MyAT.Hitpoints;
this.MyAT.HPCap = num5;
float num6 = (float)Conversion.Val(this.txtResCap.Text);
if ((double)num6 < 1.0)
num6 = 1f;
this.MyAT.ResCap = num6 / 100f;
float num7 = (float)Conversion.Val(this.txtDamCap.Text);
if ((double)num7 < 1.0)
num7 = 1f;
this.MyAT.DamageCap = num7 / 100f;
float num8 = (float)Conversion.Val(this.txtRechargeCap.Text);
if ((double)num8 < 1.0)
num8 = 1f;
this.MyAT.RechargeCap = num8 / 100f;
float num9 = (float)Conversion.Val(this.txtRecCap.Text);
if ((double)num9 < 1.0)
num9 = 1f;
this.MyAT.RecoveryCap = num9 / 100f;
float num10 = (float)Conversion.Val(this.txtRegCap.Text);
if ((double)num10 < 1.0)
num10 = 1f;
this.MyAT.RegenCap = num10 / 100f;
float num11 = (float)Conversion.Val(this.txtBaseRec.Text);
if ((double)num11 < 0.0)
num11 = 0.0f;
if ((double)num11 > 100.0)
num11 = 1.67f;
this.MyAT.BaseRecovery = num11;
float num12 = (float)Conversion.Val(this.txtBaseRegen.Text);
if ((double)num12 < 0.0)
num12 = 0.0f;
if ((double)num12 > 100.0)
num12 = 100f;
this.MyAT.BaseRegen = num12;
float num13 = (float)Conversion.Val(this.txtPerceptionCap.Text);
if ((double)num13 < 0.0)
num13 = 0.0f;
if ((double)num13 > 10000.0)
num13 = 1153f;
this.MyAT.PerceptionCap = num13;
this.MyAT.PrimaryGroup = this.cbPriGroup.Text;
this.MyAT.SecondaryGroup = this.cbSecGroup.Text;
this.MyAT.Origin = new string[this.clbOrigin.CheckedItems.Count - 1 + 1];
int num14 = this.clbOrigin.CheckedItems.Count - 1;
for (int index = 0; index <= num14; ++index)
this.MyAT.Origin[index] = Conversions.ToString(this.clbOrigin.CheckedItems[index]);
this.MyAT.Column = Decimal.Compare(this.udColumn.Value, new Decimal(0)) >= 0 ? Convert.ToInt32(this.udColumn.Value) : 0;
this.MyAT.BaseThreat = Decimal.Compare(this.udThreat.Value, new Decimal(0)) >= 0 ? Convert.ToSingle(this.udThreat.Value) : 0.0f;
this.DialogResult = DialogResult.OK;
this.Hide();
}
}
19
Source : frmSetEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void udMaxLevel_ValueChanged(object sender, EventArgs e)
{
if (this.Loading)
return;
this.mySet.LevelMax = Convert.ToInt32(Decimal.Subtract(this.udMaxLevel.Value, new Decimal(1)));
this.udMinLevel.Maximum = this.udMaxLevel.Value;
}
19
Source : frmDBEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void udIssue_KeyPress(object sender, KeyPressEventArgs e)
{
if (!MainModule.MidsController.IsAppInitialized)
return;
DatabaseAPI.Database.Issue = Convert.ToInt32(this.UdIssue.Value);
}
19
Source : frmDBEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void udIssue_ValueChanged(object sender, EventArgs e)
{
if (!MainModule.MidsController.IsAppInitialized | !this.Initialized)
return;
DatabaseAPI.Database.Issue = Convert.ToInt32(this.UdIssue.Value);
}
19
Source : frmSetEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void udMinLevel_ValueChanged(object sender, EventArgs e)
{
if (this.Loading)
return;
this.mySet.LevelMin = Convert.ToInt32(Decimal.Subtract(this.udMinLevel.Value, new Decimal(1)));
this.udMaxLevel.Minimum = this.udMinLevel.Value;
}
19
Source : frmCalcOpt.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void StoreControls()
{
ConfigData config = MidsContext.Config;
if (this.optSO.Checked)
config.CalcEnhOrigin = Enums.eEnhGrade.SingleO;
else if (this.optDO.Checked)
config.CalcEnhOrigin = Enums.eEnhGrade.DualO;
else if (this.optTO.Checked)
config.CalcEnhOrigin = Enums.eEnhGrade.TrainingO;
config.CalcEnhLevel = (Enums.eEnhRelative)this.cbEnhLevel.SelectedIndex;
config.ExempHigh = Convert.ToInt32(this.udExHigh.Value);
config.ExempLow = Convert.ToInt32(this.udExLow.Value);
if (config.ExempHigh < config.ExempLow)
config.ExempHigh = config.ExempLow;
config.ForceLevel = Convert.ToInt32(this.udForceLevel.Value);
if (this.rbGraphTwoLine.Checked)
config.DataGraphType = Enums.eDDGraph.Both;
else if (this.rbGraphStacked.Checked)
config.DataGraphType = Enums.eDDGraph.Stacked;
else if (this.rbGraphSimple.Checked)
config.DataGraphType = Enums.eDDGraph.Simple;
config.Inc.DisablePvE = !this.rbPvE.Checked;
if (this.rbChanceAverage.Checked)
config.DamageMath.Calculate = ConfigData.EDamageMath.Average;
else if (this.rbChanceMax.Checked)
config.DamageMath.Calculate = ConfigData.EDamageMath.Max;
else if (this.rbChanceIgnore.Checked)
config.DamageMath.Calculate = ConfigData.EDamageMath.Minimum;
config.BaseAcc = Convert.ToSingle(decimal.Divide(this.udBaseToHit.Value, new decimal(100)));
config.DisableVillainColours = !this.chkVillainColour.Checked;
config.CheckForUpdates = this.chkUpdates.Checked;
config.I9.DefaultIOLevel = Convert.ToInt32(this.udIOLevel.Value) - 1;
config.I9.HideIOLevels = !this.chkIOLevel.Checked;
config.I9.IgnoreEnhFX = !this.chkIOEffects.Checked;
config.I9.IgnoreSetBonusFX = !this.chkSetBonus.Checked;
config.ShowRelSymbols = this.chkRelSignOnly.Checked;
config.I9.DisablePrintIOLevels = !this.chkIOPrintLevels.Checked;
config.PrintInColour = this.chkColourPrint.Checked;
config.RtFont.RTFBase = Convert.ToInt32(decimal.Multiply(this.udRTFSize.Value, new decimal(2)));
config.RtFont.PairedBase = Convert.ToSingle(this.udStatSize.Value);
config.RtFont.RTFBold = this.chkTextBold.Checked;
config.RtFont.PairedBold = this.chkStatBold.Checked;
config.DisableLoadLastFileOnStart = !this.chkLoadLastFile.Checked;
if (config.DefaultSaveFolderOverride != this.lblSaveFolder.Text)
{
config.DefaultSaveFolderOverride = this.lblSaveFolder.Text;
this.myParent.DlgOpen.InitialDirectory = config.DefaultSaveFolderOverride;
this.myParent.DlgSave.InitialDirectory = config.DefaultSaveFolderOverride;
}
config.EnhanceVisibility = this.chkHighVis.Checked;
//config.UpdatePath = this.txtUpdatePath.Text;
config.DisableDesaturateInherent = !this.chkColorInherent.Checked;
config.DisableRepeatOnMiddleClick = !this.chkMiddle.Checked;
config.NoToolTips = this.chkNoTips.Checked;
config.DisableAlphaPopup = !this.chkShowAlphaPopup.Checked;
config.UseArcanaTime = this.chkUseArcanaTime.Checked;
config.TeamSize = Convert.ToInt32(this.TeamSize.Value);
int index = 0;
do
{
config.DragDropScenarioAction[index] = this.defActs[index];
++index;
}
while (index <= 19);
}
19
Source : frmRecipeEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
int MinMax(int iValue, NumericUpDown iControl)
{
if (decimal.Compare(new decimal(iValue), iControl.Minimum) < 0)
iValue = Convert.ToInt32(iControl.Minimum);
if (decimal.Compare(new decimal(iValue), iControl.Maximum) > 0)
iValue = Convert.ToInt32(iControl.Maximum);
return iValue;
}
19
Source : frmRecipeEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void udCostX_ValueChanged(object sender, EventArgs e) => this.EventHandlerWithCatch(() =>
{
if (this.NoUpdate || this.RecipeID() < 0 || this.EntryID() < 0)
return;
var recipeItem = DatabaseAPI.Database.Recipes[this.RecipeID()].Item[this.EntryID()];
recipeItem.Level = Convert.ToInt32(decimal.Subtract(this.udLevel.Value, new decimal(1)));
recipeItem.BuyCost = Convert.ToInt32(this.udBuy.Value);
recipeItem.BuyCostM = Convert.ToInt32(this.udBuyM.Value);
recipeItem.CraftCost = Convert.ToInt32(this.udCraft.Value);
recipeItem.CraftCostM = Convert.ToInt32(this.udCraftM.Value);
});
19
Source : frmSetEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
void btnOK_Click(object sender, EventArgs e)
{
this.mySet.LevelMin = Convert.ToInt32(Decimal.Subtract(this.udMinLevel.Value, new Decimal(1)));
this.mySet.LevelMax = Convert.ToInt32(Decimal.Subtract(this.udMaxLevel.Value, new Decimal(1)));
this.DialogResult = DialogResult.OK;
this.Hide();
}
19
Source : frmSetEdit.cs
with GNU General Public License v3.0
from ImaginaryDevelopment
with GNU General Public License v3.0
from ImaginaryDevelopment
public void SetMaxLevel(int iValue)
{
if (Decimal.Compare(new Decimal(iValue), this.udMaxLevel.Minimum) < 0)
iValue = Convert.ToInt32(this.udMaxLevel.Minimum);
if (Decimal.Compare(new Decimal(iValue), this.udMaxLevel.Maximum) > 0)
iValue = Convert.ToInt32(this.udMaxLevel.Maximum);
this.udMaxLevel.Value = new Decimal(iValue);
}
See More Examples