Ejemplo n.º 1
0
        void BehaviorKeyPanel_MouseEnter(object sender, EventArgs e)
        {
            ParticalsWin pw = ownerPanel as ParticalsWin;
            BehaviorWin  bw = ownerPanel as BehaviorWin;

            if (ModifierKeys == Keys.Control)
            {//((ParticalsWin)this.Parent.Parent.Parent)
                if (pw != null)
                {
                    pw.fToolTip.Active = true;
                }
                else if (bw != null)
                {
                    bw.fToolTip.Active = true;
                }
            }
            else
            {
                if (pw != null)
                {
                    pw.fToolTip.Active = false;
                }
                else if (bw != null)
                {
                    bw.fToolTip.Active = false;
                }
            }
        }
        private void load_btn_Click(object sender, System.EventArgs e)
        {
            if ((openFileDialog1.InitialDirectory == null ||
                 !openFileDialog1.InitialDirectory.ToLower().Contains(@"data\fx")) &&
                openFileDialog1.FileName != null &&
                openFileDialog1.FileName.ToLower().Contains(@"data\fx"))
            {
                openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName);
            }

            else if (!openFileDialog1.InitialDirectory.ToLower().Contains(@"data\fx") && fxFile != null)
            {
                openFileDialog1.InitialDirectory = Path.GetDirectoryName(fxFile);
            }

            if (eventsBhvrFilesMComboBx.Text != null)
            {
                string currentFileName = eventsBhvrFilesMComboBx.Text;

                openFileDialog1.FileName = currentFileName;
            }

            DialogResult dr = openFileDialog1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                if (ownerName.Equals("Behavior"))
                {
                    BehaviorWin bWin = (BehaviorWin)this.ownerDockablePanel;
                    bWin.loadStandAloneBhvrFile(openFileDialog1.FileName);
                    this.eventsComboBx.Enabled           = true;
                    this.eventsBhvrFilesMComboBx.Enabled = true;
                    this.saveAs_btn.Enabled = true;
                }
                else
                {
                    ParticalsWin pWin = (ParticalsWin)this.ownerDockablePanel;
                    pWin.loadStandAlonePartFile(openFileDialog1.FileName);
                }

                openFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName);

                eventsComboBx_SelectedIndexChanged(eventsComboBx, new System.EventArgs());

                if (eventsBhvrFilesMComboBx.Items.Count > 0)
                {
                    eventsBhvrFilesMComboBx.SelectedIndex = eventsBhvrFilesMComboBx.Items.Count - 1;
                }
            }
        }
        private void new_btn_Click(object sender, System.EventArgs e)
        {
            if (saveFileDialog1.InitialDirectory == null &&
                saveFileDialog1.FileName != null &&
                saveFileDialog1.FileName.ToLower().Contains(@"data\fx"))
            {
                saveFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName);
            }
            else if (saveFileDialog1.InitialDirectory == null &&
                     openFileDialog1.FileName != null &&
                     openFileDialog1.FileName.ToLower().Contains(@"data\fx"))
            {
                saveFileDialog1.InitialDirectory = Path.GetDirectoryName(openFileDialog1.FileName);
            }
            if (!saveFileDialog1.InitialDirectory.ToLower().Contains(@"data\fx") && fxFile != null)
            {
                saveFileDialog1.InitialDirectory = Path.GetDirectoryName(fxFile);
            }

            if (eventsBhvrFilesMComboBx.Text != null)
            {
                string currentFileName = eventsBhvrFilesMComboBx.Text;

                saveFileDialog1.FileName = currentFileName;
            }

            DialogResult dr = saveFileDialog1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                if (dr == DialogResult.OK)
                {
                    if (ownerName.Equals("Behavior"))
                    {
                        BehaviorWin bWin = (BehaviorWin)this.ownerDockablePanel;
                        bWin.setBhvrPanels(new Behavior("null.bhvr"));
                        common.COH_IO.writeDistFile(bWin.getData(), saveFileDialog1.FileName);
                        bWin.loadStandAloneBhvrFile(saveFileDialog1.FileName);
                    }
                    else
                    {
                        ParticalsWin pWin = (ParticalsWin)this.ownerDockablePanel;
                        pWin.setPartPanels(new Partical("null.part", false));
                        common.COH_IO.writeDistFile(pWin.getData(), saveFileDialog1.FileName);
                        pWin.loadStandAlonePartFile(saveFileDialog1.FileName);
                    }
                    enableElements(true);
                }
            }
        }
        private void setStatus()
        {
            if (ownerName.Equals("Behavior"))
            {
                BehaviorWin bWin = (BehaviorWin)ownerDockablePanel;

                Behavior bhvr = (Behavior)(bWin).BhvrTag;

                bhvr.refreshP4ROAttributes();

                save_btn.Enabled = !bhvr.isReadOnly;

                bool lockCtl = bhvr.isReadOnly;

                if (Path.GetFileName(bhvr.fileName).ToLower().Equals("null.bhvr"))
                {
                    lockCtl = false;
                }


                bWin.enable(!lockCtl);

                bWin.isLocked = lockCtl;
            }
            else
            {
                ParticalsWin pWin = (ParticalsWin)ownerDockablePanel;

                Partical part = (Partical)(pWin).Tag;

                part.refreshP4ROAttributes();

                save_btn.Enabled = !part.isReadOnly;

                pWin.enable(!part.isReadOnly);

                pWin.isLocked = part.isReadOnly;
            }

            eventsBhvrFilesMComboBx_SelectedIndexChanged(eventsBhvrFilesMComboBx, new EventArgs());
        }
        private void updateBhvr(string fileName, ArrayList data)
        {
            Behavior bhvr = BehaviorParser.parse(fileName, ref data);

            BehaviorWin bWin = (BehaviorWin)ownerDockablePanel;

            foreach (KeyValuePair <string, object> kvp in bhvr.bParameters)
            {
                bWin.BhvrTag.bParameters[kvp.Key] = kvp.Value;
            }

            bWin.BhvrTag.fileName = bhvr.fileName;

            bWin.BhvrTag.isCommented = bhvr.isCommented;

            bWin.BhvrTag.isDirty = bhvr.isDirty;

            bWin.BhvrTag.isP4 = bhvr.isP4;

            bWin.BhvrTag.isReadOnly = bhvr.isReadOnly;

            ((BehaviorWin)ownerDockablePanel).setIsDirty(false);
        }
        private void saveFile(string file_name)
        {
            if (ownerName.Equals("Behavior"))
            {
                BehaviorWin bWin = (BehaviorWin)this.ownerDockablePanel;

                ArrayList data = bWin.getData();

                common.COH_IO.writeDistFile(data, file_name);

                //updateBhvr(file_name, data);
            }
            else
            {
                ParticalsWin pWin = (ParticalsWin)this.ownerDockablePanel;

                ArrayList data = pWin.getData();

                common.COH_IO.writeDistFile(data, file_name);

                //updatePart(file_name, data);
            }
        }