private void RecipeEditorControl_Load(object sender, EventArgs e) { if (ProcessInfo.IsDesignMode()) { return; } _recipeInfoCollection = new RecipeInfoCollection(); this.SelectedRecipeInfo = new RecipeInfo(); RecipeInfoManager.GetInstance().RecipeInfoSelectedIndexChanged += new RecipeInfoManager.RecipeInfoSelectedIndexChangedEventHandler(RecipeEditorControl_RecipeInfoSelectedIndexChangedEvent); RecipeInfoManager.GetInstance().RecipeInfoCollectionChanged += new RecipeInfoManager.RecipeInfoCollectionChangedEventHandler(RecipeEditorControl_RecipeInfoCollectionChangedEvent); RecipeInfoManager.GetInstance().RecipeInfoCopyChanged += new RecipeInfoManager.RecipeInfoCopyChangedEventHandler(RecipeEditorControl_RecipeInfoCopyChangedEvent); RefreshRecipeInfoCollection(); RecipeInfo actRecipeInfo = RecipeInfoManager.GetInstance().ActiveRecipe; if (actRecipeInfo != null) { RefreshRecipeStatus(actRecipeInfo.RecipeNo.ToString("D3"), actRecipeInfo.RecipeID); } LanguageManager.Apply(this); }
private void RecipeEditorControl_RecipeInfoCollectionChangedEvent(RecipeInfoCollection recipeInfoCollection) { RefreshRecipeInfoCollection(); }
private void RefreshRecipeInfoCollection() { if (this.InvokeRequired) { this.Invoke(new Action(RefreshRecipeInfoCollection)); return; } try { _recipeInfoCollection = RecipeInfoManager.GetInstance().GetRecipeInfoCollection(); this.dgvRecipeList.Rows.Clear(); this.dgvRecipeList.Columns.Clear(); this.dgvRecipeList.Columns.AddRange(new DataGridViewColumn[] { new DataGridViewTextBoxColumn() { HeaderText = "RecipeNo", Name = "RecipeNo", ReadOnly = true, Width = 55 }, new DataGridViewTextBoxColumn() { HeaderText = "RecipeID", Name = "RecipeID", ReadOnly = true, Width = 120 }, new DataGridViewTextBoxColumn() { HeaderText = "Description", Name = "Description", ReadOnly = true, Width = 160 }, new DataGridViewTextBoxColumn() { HeaderText = "ModifyTime", Name = "ModifyTime", ReadOnly = true, Width = 120 } }); foreach (RecipeInfo recipeInfo in _recipeInfoCollection) { this.dgvRecipeList.Rows.Add( string.Format("{0:D3}", recipeInfo.RecipeNo), recipeInfo.RecipeID, recipeInfo.Description, recipeInfo.ModifyTime.ToString("yyyy.MM.dd HH:mm:ss")); } this.cboCurrentRecipeChange.DataSource = null; this.cboCurrentRecipeChange.DataSource = _recipeInfoCollection; if (this.cboCurrentRecipeChange.SelectedIndex == -1) { this.SelectedRecipeInfo = null; this.lblRecipeNo.Text = ""; this.lblRecipeID.Text = ""; RefreshRecipeStatus("", ""); } else { this.SelectedRecipeInfo = (RecipeInfo)this.cboCurrentRecipeChange.SelectedItem; this.lblRecipeNo.Text = string.Format("Recipe No:{0:D3}", this.SelectedRecipeInfo.RecipeNo); this.lblRecipeID.Text = string.Format("Recipe ID:{0}", this.SelectedRecipeInfo.RecipeID); RefreshRecipeStatus(this.SelectedRecipeInfo.RecipeNo.ToString("D3"), this.SelectedRecipeInfo.RecipeID); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }