Exemplo n.º 1
0
        private void buttonModify_Click(object sender, EventArgs e)
        {
            System.IO.Stream    dFile      = null;
            Info.ProcessProgram dRecipe    = null;
            Info.ProcessProgram dRecipeOld = null;
            switch (this.tabControl1.SelectedIndex)
            {
            case 0:
                return;

                break;

            case 1:
                if (this.listBoxType1.SelectedIndex == -1)
                {
                    return;
                }
                dRecipeOld = this.mPpidType1[this.listBoxType1.SelectedIndex];

                Forms.PpidType1 type1Ppid = new PpidType1(Info.Action.MODIFY);
                type1Ppid.pRecipe = dRecipeOld;
                DialogResult res = type1Ppid.ShowDialog();

                if (res != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                dRecipe = type1Ppid.pRecipe;

                dFile = System.IO.File.Create(this.mType1Folder + "\\" + type1Ppid.pRecipe.ID + this.mSuffix);

                break;

            case 2:
                List <string> recipes = new List <string>();
                foreach (Info.ProcessProgram item in mPpidType1)
                {
                    recipes.Add(item.ID);
                }

                Forms.PpidType2 type2Ppid = new PpidType2(recipes, Info.Action.MODIFY);
                DialogResult    res2      = type2Ppid.ShowDialog();
                if (res2 != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                dRecipe = type2Ppid.pRecipe;
                dFile   = System.IO.File.Create(this.mType2Folder + "\\" + type2Ppid.pRecipe.ID + this.mSuffix);
                break;
            }
            if (dFile == null || dRecipe == null)
            {
                if (dFile != null)
                {
                    dFile.Close();
                }
                return;
            }
            this.mBinaryFormatter.Serialize(dFile, dRecipe);
            dFile.Close();
            if (dRecipe.TYPE == Info.PPIDType.TYPE_1)
            {
                foreach (Info.ProcessProgram item in dRecipeOld.funMappingList())
                {
                    dRecipe.subMapping(item);
                }
                this.mPpidType1.Remove(dRecipeOld);
                this.listBoxType1.Items.Remove(dRecipeOld.ID);
                this.mPpidType1.Add(dRecipe);
                this.listBoxType1.Items.Add(dRecipe.ID);
            }
            else if (dRecipe.TYPE == Info.PPIDType.TYPE_2)
            {
                this.mPpidType2.Add(dRecipe);
                foreach (Info.ProcessProgram item in this.mPpidType1)
                {
                    if (item.ID == dRecipe.processCommands[0].CCODE[0].P_PARM)
                    {
                        item.subMapping(dRecipe);
                    }
                }
            }

            //this.subCreatePPID(dRecipe);
            this.subModifyPPID(dRecipe);
            if (dRecipe.TYPE == Info.PPIDType.TYPE_1)
            {
                foreach (Info.ProcessProgram item in dRecipe.funMappingList())
                {
                    this.subModifyPPID(item);
                }
            }
        }
Exemplo n.º 2
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            System.IO.Stream    dFile   = null;
            Info.ProcessProgram dRecipe = null;
            switch (this.tabControl1.SelectedIndex)
            {
            case 0:
                return;

                break;

            case 1:
                Forms.PpidType1 type1Ppid = new PpidType1(Info.Action.CREATE);
                DialogResult    res       = type1Ppid.ShowDialog();

                if (res != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                foreach (Info.ProcessProgram item in this.mPpidType1)
                {
                    if (item.ID == type1Ppid.pRecipe.ID)
                    {
                        System.Windows.Forms.MessageBox.Show("아이디는 유일해야 합니다");
                        return;
                    }
                }
                dRecipe = type1Ppid.pRecipe;
                dFile   = System.IO.File.Create(this.mType1Folder + "\\" + type1Ppid.pRecipe.ID + this.mSuffix);

                break;

            case 2:
                List <string> recipes = new List <string>();
                foreach (Info.ProcessProgram item in mPpidType1)
                {
                    recipes.Add(item.ID);
                }

                Forms.PpidType2 type2Ppid = new PpidType2(recipes, Info.Action.CREATE);
                DialogResult    res2      = type2Ppid.ShowDialog();
                if (res2 != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                foreach (Info.ProcessProgram item in this.mPpidType2)
                {
                    if (item.ID == type2Ppid.pRecipe.ID)
                    {
                        System.Windows.Forms.MessageBox.Show("아이디는 유일해야 합니다");
                        return;
                    }
                }
                dRecipe = type2Ppid.pRecipe;
                dFile   = System.IO.File.Create(this.mType2Folder + "\\" + type2Ppid.pRecipe.ID + this.mSuffix);
                break;
            }
            if (dFile == null || dRecipe == null)
            {
                if (dFile != null)
                {
                    dFile.Close();
                }
                return;
            }
            this.mBinaryFormatter.Serialize(dFile, dRecipe);
            dFile.Close();
            if (dRecipe.TYPE == Info.PPIDType.TYPE_1)
            {
                this.mPpidType1.Add(dRecipe);
                this.listBoxType1.Items.Add(dRecipe.ID);
                this.listBoxType1.SelectedIndex = this.listBoxType1.Items.Count - 1;
            }
            else if (dRecipe.TYPE == Info.PPIDType.TYPE_2)
            {
                this.mPpidType2.Add(dRecipe);
                this.listBoxType2.Items.Add(dRecipe.ID);
                this.listBoxType2.SelectedIndex = this.listBoxType2.Items.Count - 1;
                foreach (Info.ProcessProgram item in this.mPpidType1)
                {
                    if (item.ID == dRecipe.processCommands[0].CCODE[0].P_PARM)
                    {
                        item.subMapping(dRecipe);
                    }
                }
            }

            this.subCreatePPID(dRecipe);
        }