private void _cropsView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (_isLoaded && e.RowIndex >= 0) { CropFormat format = _cropsView.Rows[e.RowIndex].Tag as CropFormat; string newName = _cropsView["NameColumn", e.RowIndex].Value != null ? _cropsView["NameColumn", e.RowIndex].Value.ToString() : string.Empty; float newWidth = 0.0f; if (_cropsView["WidthColumn", e.RowIndex].Value != null) { float.TryParse(_cropsView["WidthColumn", e.RowIndex].Value.ToString(), out newWidth); } float newHeight = 0.0f; if (_cropsView["HeightColumn", e.RowIndex].Value != null) { float.TryParse(_cropsView["HeightColumn", e.RowIndex].Value.ToString(), out newHeight); } if (format != null) { format.Name = newName; format.Width = newWidth; format.Height = newHeight; } else { format = CropManager.AddCropFormat(newName, newWidth, newHeight, false); _cropsView.Rows[e.RowIndex].Tag = format; } ValidateCells(null); } }
public CarrotStage2(string name) : base(name) { Classes.ItemHelper.OnRemove[] onRemoveNode = { new Classes.ItemHelper.OnRemove("carrotstage1", 1, 0.8f) }; this.OnRemove = onRemoveNode; this.IsSolid = false; this.NeedsBase = true; this.OnRemoveAudio = "grassDelete"; this.OnPlaceAudio = "grassDelete"; this.MaxStackSize = 1200; this.NPCLimit = 0; this.SideAll = "wheatwheat"; this.Mesh = "carrotstage2"; this.AllowCreative = false; this.maxGrowth = 1f; TypeManager.registerCrop(this); CropManager.addCropStage(name, "carrotstage3"); CropManager.CropTypes.Add("carrotstage2", this); this.Register(); }
// Run on add to world (also runs when added by game - ie: when a crop grows to the next stage) public void OnAddAction(Vector3Int position, ushort newType, Players.Player causedBy) { ushort num; // check if the block below is fertile if (World.TryGetTypeAt(position.Add(0, -1, 0), out num) && ItemTypes.IsFertile(num)) { CropManager.trackCrop(position, this); } else { // Tell the user you can't do this Pipliz.Chatting.Chat.Send(causedBy, string.Format("{0} can't grow here! It's not fertile!", ItemTypes.IndexLookup.GetName(newType))); // Get the air block, and replace the new crop with it ushort airBlockID = ItemTypes.IndexLookup.GetIndex("air"); ServerManager.TryChangeBlock(position, airBlockID); // Give the user the block Stockpile s = Stockpile.GetStockPile(causedBy); // Give them an item back? s.Add(newType, 1); // Update it? s.SendUpdate(); } }
public LettuceStage1(string name) : base(name, true) { Classes.ItemHelper.OnRemove[] onRemoveNode = { new Classes.ItemHelper.OnRemove("lettucestage1", 1, 0.6f) }; this.OnRemove = onRemoveNode; this.IsSolid = false; this.NeedsBase = true; this.IsPlaceable = true; this.AllowCreative = true; this.OnRemoveAudio = "grassDelete"; this.OnPlaceAudio = "grassDelete"; this.MaxStackSize = 1200; this.Icon = "lettuce"; this.NPCLimit = 0; this.SideAll = "wheatwheat"; this.Mesh = "wheatstage1"; this.maxGrowth = 12f; this.NutritionalValue = 0.3F; TypeManager.registerCrop(this); CropManager.addCropStage(name, "lettucestage2"); CropManager.CropTypes.Add("lettucestage1", this); this.Register(); }
private void _cropsView_UserDeletedRow(object sender, DataGridViewRowEventArgs e) { CropFormat format = e.Row.Tag as CropFormat; CropManager.RemoveCropFormat(format); ValidateCells(null); _cropsView.AllowUserToAddRows = _cropsView.Rows.Count <= Constants.MaxCropsCount; }
private void Awake() { if (Instance != null) { throw new System.Exception("There should only ever be one CropManager"); } Instance = this; audioSource = GetComponent <AudioSource>(); }
private void _contextMenuItem_Click(object sender, EventArgs args) { int rowIndex = _mouseLocation.RowIndex; if (rowIndex >= 0 && rowIndex < _formatsView.Rows.Count) { PaperFormat format = _formatsView.Rows[rowIndex].Tag as PaperFormat; if (format != null) { CropManager.AddCropFormat(format.Name, format.Width, format.Height, true); } } }
private void _cropsView_DragDrop(object sender, DragEventArgs e) { var newFormats = new CropFormat[CropManager.CropFormats.Count]; for (int i = 0; i < _cropsView.Rows.Count; i++) { CropFormat type = _cropsView.Rows[i].Tag as CropFormat; if (type != null) { newFormats[i] = type; } } CropManager.UpdateCropFormats(newFormats); ValidateCells(null); }
private void _contextMenu_DropDownOpened(object sender, CancelEventArgs args) { int rowIndex = _mouseLocation.RowIndex; if (rowIndex >= 0 && rowIndex < _formatsView.Rows.Count) { PaperFormat format = _formatsView.Rows[rowIndex].Tag as PaperFormat; if (format != null) { _contextMenuItem.Enabled = !CropManager.ContainsCrop(format.Name, format.Width, format.Height) && CropManager.CropFormats.Count < Constants.MaxCropsCount; } else { args.Cancel = true; } } else { args.Cancel = true; } }
public void OnRemoveAction(Vector3Int position, ushort wasType, Players.Player causedBy) { CropManager.untrackCrop(position, this); }
public ExecutionEngine(Frame frame, MainWindow mainWindow) { _lastInstance = this; _mainWindow = mainWindow; _isBluetooth = false; _showingFrame = frame; _resource = mainWindow.Resources; _orderManager = new OrderManagerAddon(); LoadDefaultResources(); try { if (Mutex.OpenExisting(MutexName) != null) { ShowMessageAndQuit(StringResources.GetString("MessageOnlyOneInstanceCanBeRun")); return; } } catch (WaitHandleCannotBeOpenedException) { } // no need to handle _namedMutex = new Mutex(false, MutexName); _errorLogger = new WindowsAppLog(true); _errorLogger.Enabled = true; try { _config = new Config(true); } catch (Exception e) { _errorLogger.WriteExceptionInfo(e); ShowMessageAndQuit(StringResources.GetString("MessageConfigReadingError")); return; } try { _priceManager = new PriceManager(true, _config.PriceFile.Value); } catch (Exception e) { _errorLogger.WriteExceptionInfo(e); ShowMessageAndQuit(StringResources.GetString("MessagePriceReadingError")); return; } try { _crops = new CropManager(true, _config.CropFile.Value); } catch (Exception e) { _errorLogger.WriteExceptionInfo(e); ShowMessageAndQuit(StringResources.GetString("MessageCropsReadingError")); return; } _eventLogger = new FileLog(Config.EventLogFile, false); _eventLogger.Enabled = _config.EnableEventLogging.Value; _dataContext = new DataContext(); _dataContext[Constants.OrderContextName] = new Order(); _lastUserActionTime = System.DateTime.Now; _eventLogger.Write(string.Format(CultureInfo.InvariantCulture, "ExecutionEngine:Load headers and backgrounds")); _headerDictionary = new Dictionary <string, BitmapImage>(); _backgroundDictionary = new Dictionary <string, ImageBrush>(); // Add main banner to resources try { _resource.Add(Constants.ImageBannerKey, BitmapFrame.Create(new Uri(_config.MainBanner.Value))); } catch (Exception e) { _eventLogger.Write(string.Format(StringResources.GetString("MessageImageLoadError"), _config.MainBanner.Value, e.Message)); _resource.Add(Constants.ImageBannerKey, null); } LoadScreenSettings(_config.Screens); LoadCustomResources(); _stages = new List <StageBase>(); _stages.Add(new WelcomeStage()); _stages.Add(new SelectStage()); _stages.Add(new ImageEditorStage()); _stages.Add(new ProcessOrderStage()); _stages.Add(new FindingPhotosStage()); // Clear bluetooth folder FileOrderStorage.ClearBluetoothDirectory(); NativeMethods.SetErrorMode(NativeMethods.SEM_FAILCRITICALERRORS); }
public MainForm() { InitializeComponent(); _panelCollection.Add("BehaviourNode", _behaviourPanel); _panelCollection.Add("BehaviourGeneralNode", _behaviourPanel); _panelCollection.Add("BehaviourContactInfoNode", _contactInfoPanel); _panelCollection.Add("BehaviourCallbackNode", _callbackPanel); _panelCollection.Add("BluetoothNode", _bluetoothPanel); _panelCollection.Add("ImageEditorNode", _imageEditorPanel); _panelCollection.Add("ImageEditorGeneralNode", _imageEditorPanel); _panelCollection.Add("CropsNode", _cropsPanel); _panelCollection.Add("AppearanceNode", _appearancePanel); _panelCollection.Add("AppearanceGeneralNode", _appearancePanel); _panelCollection.Add("PaperFormatsNode", _paperFormatsPanel); _panelCollection.Add("PaperTypesNode", _paperTypesPanel); _panelCollection.Add("PricesNode", _pricePanel); _panelCollection.Add("PricesGeneralNode", _pricePanel); _panelCollection.Add("ServicesNode", _servicesPanel); _panelCollection.Add("OrderManagerNode", _orderManagerPanel); _panelCollection.Add("OrderManagerGeneralNode", _orderManagerPanel); _panelCollection.Add("ArbitraryFormatNode", _arbitraryFormatPanel); _panelCollection.Add("DpofNode", _dpofPanel); _panelCollection.Add("PhotoPrinterNode", _photoPrinterPanel); _panelCollection.Add("CdBurnerNode", _cdBurnerPanel); _panelCollection.Add("ReceiptPrinterNode", _receiptPrinterPanel); _pricesGeneralNode = _optionsTree.Nodes["PricesNode"].Nodes["PricesGeneralNode"]; try { _config = new Config(false); } catch (Exception e) { ShowErrorMessage(string.Format(RM.GetString("PhotoKioskConfigError"), e.Message)); return; } try { _priceManager = new PriceManager(false, _config.PriceFile.Value, new PriceManager.ModifiedHandler(_settings_Modified)); } catch (Exception e) { ShowErrorMessage(string.Format(RM.GetString("PriceReadingError"), e.Message)); return; } try { _orderManager = new OrderManager(); } catch (Exception e) { ShowErrorMessage(string.Format(RM.GetString("OrderManagerConfigError"), e.Message)); return; } try { _cropManager = new CropManager(false, _config.CropFile.Value, new CropManager.ModifiedHandler(_settings_Modified)); } catch (Exception e) { ShowErrorMessage((string.Format(RM.GetString("CropReadingError"), e.Message))); return; } _config.Modified += new Config.ModifiedHandler(_settings_Modified); _orderManager.Modified += new OrderManager.ModifiedHandler(_settings_Modified); foreach (BasePanel panel in _panelCollection.Values) { panel.Config = _config; panel.PriceManager = _priceManager; panel.OrderManager = _orderManager; panel.CropManager = _cropManager; } _screenPanel.Config = _config; }
public NewDayObserverCropManager(CropManager cm) { CM = cm; }