private void btOK_Click(object sender, EventArgs e)
        {
            if (null == _mgr)
            {
                MessageBox.Show("无效操作,RecipeManager未设置");
                return;
            }

            if (!_mgr.IsInitOK)
            {
                MessageBox.Show("无效操作,RecipeManager未初始化,ErrorInfo:" + _mgr.GetInitErrorInfo());
                return;
            }

            if (string.IsNullOrWhiteSpace(cbGenCate.Text))
            {
                MessageBox.Show("参数项 Categoty 不能为空值!");
                return;
            }

            if (string.IsNullOrWhiteSpace(tbGenID.Text))
            {
                MessageBox.Show("参数项 RecipeID 不能为空值!");
                return;
            }

            string[] existIDs = _mgr.AllRecipeIDsInCategoty(cbGenCate.Text);
            if (null != existIDs && existIDs.Contains(tbGenID.Text))
            {
                MessageBox.Show("添加Recipe失败,Categoty = " + cbGenCate.Text + "已包含当前RecipeID = " + tbGenID.Text);
                return;
            }

            JFCommonRecipe newRecipe = new JFCommonRecipe();

            newRecipe.Categoty = cbGenCate.Text;
            newRecipe.ID       = tbGenID.Text;
            if (chkCopy.Checked) //以拷贝的方式创建新的Recipe
            {
                if (string.IsNullOrEmpty(cbCopyCate.Text))
                {
                    MessageBox.Show("请选择待拷贝的Categoty!");
                    return;
                }

                if (string.IsNullOrEmpty(cbCopyID.Text))
                {
                    MessageBox.Show("请选择待拷贝的RecipeID!");
                    return;
                }

                JFCommonRecipe recipe = _mgr.GetRecipe(cbCopyCate.Text, cbCopyID.Text) as JFCommonRecipe;
                string         xmlTxt;
                string         typeTxt;
                JFFunctions.ToXTString(recipe.Dict, out xmlTxt, out typeTxt);
                newRecipe.Dict = JFFunctions.FromXTString(xmlTxt, typeTxt) as JFXmlDictionary <string, object>;
            }


            _mgr.AddRecipe(cbGenCate.Text, tbGenID.Text, newRecipe);
            _mgr.Save();
            DialogResult = DialogResult.OK;
        }
Exemple #2
0
        void AdjustStationView()
        {
            IJFRecipeManager mgr = JFHubCenter.Instance.RecipeManager;

            if (null == mgr)
            {
                Enabled         = false;
                cbRecipeID.Text = "RecipeManager = null!";
                return;
            }

            if (!mgr.IsInitOK)
            {
                Enabled         = false;
                cbRecipeID.Text = "RecipeManager not init!";
                return;
            }

            if (_station == null)
            {
                Enabled = false;
                return;
            }

            string _modelPicPath = _station.GetCfgParamValue(DLAFVisionTeachStation.SCItemName_ModelPicPath) as string;

            if (null == _modelPicPath)
            {
                tbModelPicPath.Text = "";
            }
            tbModelPicPath.Text = _modelPicPath;

            Enabled = true;
            string currRecipeID = cbRecipeID.Text; //当前已选的RecipeID

            cbRecipeID.Items.Clear();
            string[] allRecipeIDs = mgr.AllRecipeIDsInCategoty(CategoteProduct);
            if (null != allRecipeIDs && allRecipeIDs.Length > 0)
            {
                foreach (string s in allRecipeIDs)
                {
                    cbRecipeID.Items.Add(s);
                }
                if (!string.IsNullOrEmpty(currRecipeID))
                {
                    if (allRecipeIDs.Contains(currRecipeID))
                    {
                        cbRecipeID.Text = currRecipeID;
                    }
                    else
                    {
                        cbRecipeID.SelectedIndex = -1;
                    }
                }
            }
            else
            {
                cbRecipeID.SelectedIndex = -1;
            }

            string currVAName = cbVAName.Text;

            cbVAName.Items.Clear();
            JFVisionManager vm = JFHubCenter.Instance.VisionMgr;

            string[] allVANames = vm.AllSVAssistNames();
            if (null != allVANames && allVANames.Length > 0)
            {
                foreach (string s in allVANames)
                {
                    cbVAName.Items.Add(s);
                }
                if (!allVANames.Contains(currVAName))
                {
                    cbVAName.SelectedIndex = -1;
                }
                else
                {
                    cbVAName.Text = currVAName;
                }
            }
            else
            {
                cbVAName.SelectedIndex = -1;
            }

            AdjustVisionCfg();
        }