Example #1
0
        private void EditHandler(object sender, EventArgs e)
        {
            if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _devices.Rows.Count - 1)
            {
                return;
            }
            string oldName = _devices.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString();
            string newName = InvokeDeviceEditor(oldName);

            if (string.IsNullOrEmpty(newName))
            {
                return;
            }
            _devices.Rows[_mouseLocation.RowIndex].Cells[0].Value =
                newName;
            for (int i = 0; i < _recipeDevicesValues.Count; i++)
            {
                if (_recipeDevicesValues[i].Item1 != oldName)
                {
                    continue;
                }
                _recipeDevicesValues[i] =
                    Tuple.Create(newName, _recipeDevicesValues[i].Item2);
                break;
            }
            OnDataChange?.Invoke(new[] { _deviceNames, _recipeDevicesValues });
            OnLock?.Invoke();
        }
Example #2
0
        private void DeleteHandler(object sender, EventArgs e)
        {
            if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _devices.Rows.Count - 1)
            {
                return;
            }
            string name = _devices.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString();

            if (ConfirmationForm.Invoke(name) != DialogResult.OK)
            {
                return;
            }

            _devices.Rows.RemoveAt(_mouseLocation.RowIndex);
            for (int i = 0; i < _recipeDevicesValues.Count; i++)
            {
                if (_recipeDevicesValues[i].Item1 != name)
                {
                    continue;
                }
                _recipeDevicesValues[i] =
                    Tuple.Create("", _recipeDevicesValues[i].Item2);
                break;
            }
            OnDataChange?.Invoke(new[] { _deviceNames, _recipeDevicesValues });
            OnLock?.Invoke();
        }
        public override bool TryLockOne()
        {
            var retVal = _wrapped.TryLockOne();

            OnLock?.Invoke(this, retVal);
            return(retVal);
        }
Example #4
0
 public void Lock()
 {
     locked++;
     if (locked == 1)
     {
         OnLock?.Invoke();
     }
 }
 public void Lock()
 {
     if (isLocked)
     {
         return;
     }
     isLocked = true;
     OnLock?.Invoke();
 }
Example #6
0
        private void AddHandler(object sender, EventArgs e)
        {
            string newName = InvokeDeviceEditor("Отсутствует");

            _devices.Rows.Add(newName);
            _recipeDevicesValues.Add(Tuple.Create(newName, ""));
            OnDataChange?.Invoke(new[] { _deviceNames, _recipeDevicesValues });
            OnLock?.Invoke();
        }
Example #7
0
        private void AddHandler(object sender, EventArgs e)
        {
            var lst = InvokeIngredEditor(new List <string>
            {
                "Ничто", "Нисколько", "Никакие"
            });

            _dgv.Rows.Add(lst[0], lst[1], lst[2]);
            _data.Add(Tuple.Create(
                          Tuple.Create(lst[0], ""),
                          Tuple.Create(lst[1], ""),
                          Tuple.Create(lst[2], "")));
            OnDataChange?.Invoke(_data);
            OnLock?.Invoke();
        }
Example #8
0
        private void EditHandler(object sender, EventArgs e)
        {
            if (_mouseLocation.RowIndex < 0 || _mouseLocation.RowIndex > _dgv.Rows.Count - 1)
            {
                return;
            }
            string oldName = _dgv.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString();
            var    lst     = InvokeIngredEditor(new List <string>
            {
                _dgv.Rows[_mouseLocation.RowIndex].Cells[0].Value.ToString(),
                _dgv.Rows[_mouseLocation.RowIndex].Cells[1].Value.ToString(),
                _dgv.Rows[_mouseLocation.RowIndex].Cells[2].Value.ToString()
            });

            if (string.IsNullOrEmpty(lst[0]) ||
                string.IsNullOrEmpty(lst[1]) ||
                string.IsNullOrEmpty(lst[2]))
            {
                return;
            }

            for (int i = 0; i < 3; i++)
            {
                _dgv.Rows[_mouseLocation.RowIndex].Cells[i].Value = lst[i];
            }

            for (int i = 0; i < _data.Count; i++)
            {
                if (_data[i].Item1.Item1 != oldName)
                {
                    continue;
                }

                _data[i] = Tuple.Create(
                    Tuple.Create(lst[0], _data[i].Item1.Item2),
                    Tuple.Create(lst[1], _data[i].Item2.Item2),
                    Tuple.Create(lst[2], _data[i].Item3.Item2));
                break;
            }
            OnDataChange?.Invoke(_data);
            OnLock?.Invoke();
        }