/// <summary> /// ќбновить таймер в списке таймеров /// </summary> /// <param name="row"></param> private void UpdateTimerListItem(DataGridViewRow row) { TimerListItem timerListItem = row.Tag as TimerListItem; if (timerListItem != null) { if (timerListItem.TimeToAsterEnd == 0) { row.DefaultCellStyle.BackColor = Color.FromArgb(255, 200, 200); timerListItem.StopTurrets(); } else if (timerListItem.LasersCount > 0 && timerListItem.IsSatrted) { row.DefaultCellStyle.BackColor = timerListItem.IsEmptyClose ? Color.FromArgb(255, 255, 200) : Color.FromArgb(200, 255, 200); } row.Cells[ColumnTimeToEnd.Index].Value = string.Format("{0:00}:{1:00}", Math.Floor(timerListItem.TimeToAsterEnd / 60), timerListItem.TimeToAsterEnd % 60); row.Cells[ColumnCycle.Index].Value = string.Format("{0:00}:{1:00}", Math.Floor(timerListItem.TimeToCycleEnd / 60), timerListItem.TimeToCycleEnd % 60); row.Cells[ColumnCurrentQty.Index].Value = string.Format("{0}", timerListItem.CurrentVolume.ToString("F0")); if (timerListItem.TimeToAsterEnd == 0) { row.Tag = null; } } }
/// <summary> /// /// </summary> void RemoveRows() { foreach (DataGridViewRow row in dataGridViewTimers.Rows) { TimerListItem titem = row.Tag as TimerListItem; if (titem != null) { titem.StopTurrets(); } } dataGridViewTimers.Rows.Clear(); }
/// <summary> /// Removes the row. /// </summary> /// <param name="index">The index.</param> void RemoveRow(int index) { if (index >= 0) { DataGridViewRow row = dataGridViewTimers.Rows[index]; TimerListItem titem = row.Tag as TimerListItem; if (titem != null) { titem.StopTurrets(); } dataGridViewTimers.Rows.Remove(dataGridViewTimers.Rows[index]); } }
/// <summary> /// “ик таймера /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimerTick(object sender, EventArgs e) { for (int n = 0; n < dataGridViewTimers.Rows.Count; n++) { TimerListItem titem = dataGridViewTimers.Rows[n].Tag as TimerListItem; if (titem != null && titem.IsSatrted) { UpdateTimerListItem(dataGridViewTimers.Rows[n]); _currentCargo += Config <Settings> .Instance.MiningAmount / Config <Settings> .Instance.Cycle * titem.LasersCount; SetProgressCargo(); //SetProgressCycles(); } } }
/// <summary> /// Handles the Click event of the buttonUpdate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void ButtonUpdateClick(object sender, EventArgs e) { double miningYield = Config <Settings> .Instance.MiningAmount; for (int n = 0; n < dataGridViewTimers.Rows.Count; n++) { TimerListItem titem = dataGridViewTimers.Rows[n].Tag as TimerListItem; if (titem != null) { titem.SetMiningYield(miningYield); UpdateTimerListItem(dataGridViewTimers.Rows[n]); } } }
/// <summary> /// /// </summary> /// <param name="row"></param> /// <param name="indexColumn"></param> private void ChangeTurretState(DataGridViewRow row, int indexColumn) { TimerListItem tItem = row.Tag as TimerListItem; if (tItem == null) { return; } bool bState = !tItem.IsEnableTurret(); int count = Convert.ToInt32(row.Cells[ColumnLasers.Index].Value); tItem.EnableTurret(bState, count); if (bState) { row.Cells[indexColumn].Value = Resources.stop_24; } else { row.Cells[indexColumn].Value = Resources.play_24; } UpdateTimerListItem(row); }
/// <summary> /// Handles the Click event of the buttonAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void ButtonAddClick(object sender, EventArgs e) { Ore ore = OreList.Get(comboBoxOre.SelectedItem.ToString()); try { double startVolume = Convert.ToDouble(textBoxStartValue.Text); if (startVolume == 0) { return; } double cycle = Config <Settings> .Instance.Cycle; double miningYield = Config <Settings> .Instance.MiningAmount; TimerListItem timerListItem = new TimerListItem(ore, startVolume, cycle, miningYield); DataGridViewRow row = new DataGridViewRow { Tag = timerListItem }; DataGridViewCell[] cells = new DataGridViewCell[dataGridViewTimers.ColumnCount]; cells[ColumnOre.Index] = new DataGridViewTextBoxCell { Value = timerListItem.ore.Name }; cells[ColumnStartQty.Index] = new DataGridViewTextBoxCell { Value = startVolume }; cells[ColumnCurrentQty.Index] = new DataGridViewTextBoxCell { Value = startVolume }; cells[ColumnTimeToEnd.Index] = new DataGridViewTextBoxCell { Value = string.Format("{0:00}:{1:00}", Math.Floor(timerListItem.TimeToAsterEnd / 60), timerListItem.TimeToAsterEnd % 60) }; cells[ColumnLaser1Start.Index] = new DataGridViewImageCell { Value = Resources.play_24 }; cells[ColumnCycle.Index] = new DataGridViewTextBoxCell { Value = string.Format("{0:00}:{1:00}", Math.Floor(timerListItem.TimeToCycleEnd / 60), timerListItem.TimeToCycleEnd % 60) }; DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); cell.Items.AddRange("1", "2", "3", "4", "5", "6", "7", "8"); cell.Value = "1"; cells[ColumnLasers.Index] = cell; //cells[ColumnButtonDelete.Index] = new DataGridViewButtonCell {Value = "x"}; cells[ColumnButtonDelete.Index] = new DataGridViewImageCell { Value = Resources.close_24 }; row.Cells.AddRange(cells); dataGridViewTimers.Rows.Add(row); UpdateTimerListItem(row); textBoxStartValue.SelectionStart = 0; textBoxStartValue.SelectionLength = textBoxStartValue.TextLength; } catch (FormatException) { textBoxStartValue.Text = Resources.TimersForm_ButtonAddClick__0; } }
/// <summary> /// Handles the Click event of the buttonAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void ButtonAddClick(object sender, EventArgs e) { Ore ore = OreList.Get(comboBoxOre.SelectedItem.ToString()); try { double startVolume = Convert.ToDouble(textBoxStartValue.Text); if (startVolume == 0) return; double cycle = Config<Settings>.Instance.Cycle; double miningYield = Config<Settings>.Instance.MiningAmount; TimerListItem timerListItem = new TimerListItem(ore, startVolume, cycle, miningYield); DataGridViewRow row = new DataGridViewRow {Tag = timerListItem}; DataGridViewCell[] cells = new DataGridViewCell[dataGridViewTimers.ColumnCount]; cells[ColumnOre.Index] = new DataGridViewTextBoxCell {Value = timerListItem.ore.Name}; cells[ColumnStartQty.Index] = new DataGridViewTextBoxCell {Value = startVolume}; cells[ColumnCurrentQty.Index] = new DataGridViewTextBoxCell {Value = startVolume}; cells[ColumnTimeToEnd.Index] = new DataGridViewTextBoxCell { Value = string.Format("{0:00}:{1:00}", Math.Floor(timerListItem.TimeToAsterEnd/60), timerListItem.TimeToAsterEnd%60) }; cells[ColumnLaser1Start.Index] = new DataGridViewImageCell {Value = Resources.play_24}; cells[ColumnCycle.Index] = new DataGridViewTextBoxCell { Value = string.Format("{0:00}:{1:00}", Math.Floor(timerListItem.TimeToCycleEnd / 60), timerListItem.TimeToCycleEnd % 60) }; DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell(); cell.Items.AddRange("1", "2", "3", "4", "5", "6", "7", "8"); cell.Value = "1"; cells[ColumnLasers.Index] = cell; //cells[ColumnButtonDelete.Index] = new DataGridViewButtonCell {Value = "x"}; cells[ColumnButtonDelete.Index] = new DataGridViewImageCell {Value = Resources.close_24}; row.Cells.AddRange(cells); dataGridViewTimers.Rows.Add(row); UpdateTimerListItem(row); textBoxStartValue.SelectionStart = 0; textBoxStartValue.SelectionLength = textBoxStartValue.TextLength; } catch (FormatException) { textBoxStartValue.Text = Resources.TimersForm_ButtonAddClick__0; } }