private void UpdateChilds()
        {
            var c = Program.AnimationXML.Childs;

            listView3.Items.Clear();
            if (c == null || c.Child == null)
            {
                return;
            }
            listView3.SmallImageList = XmlTools.AnimationIcons;
            childsList.Clear();
            foreach (var n in c.Child)
            {
                childsList.Add(n.Id);
                var lv = listView3.Items.Add(" Child #" + n.Id + " - " + XmlTools.GetXmlAnimationNode(n.Id).Name);
                lv.ImageIndex = XmlTools.GetXmlAnimationNode(n.Next).Sequence.Frame[0];
            }
        }
        private void removeNodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var cms = contextMenuStrip1;
            var lv  = cms.SourceControl as ListView;

            if (lv.SelectedIndices.Count == 0)
            {
                return;
            }
            if (lv == listView1) // spawn
            {
                if (lv.Items.Count <= 1)
                {
                    Program.AddLog("You need at least 1 spawn for your animation!", "Remove Spawn", Program.LOG_TYPE.ERROR, lv);
                }
                else
                {
                    treeView1.SelectedNode = treeView1.Nodes[0].Nodes[2];
                    var node = XmlTools.GetXmlSpawnNode(spawnsList[lv.SelectedIndices[0]]);
                    XmlTools.UpdateXmlSpawnNode(node, null);
                }
            }
            else if (lv == listView2) // animations
            {
                treeView1.SelectedNode = treeView1.Nodes[0].Nodes[3];
                var node = XmlTools.GetXmlAnimationNode(animationsList[lv.SelectedIndices[0]]);
                XmlTools.UpdateXmlAnimationNode(node, null);
            }
            else if (lv == listView3) // childs
            {
                treeView1.SelectedNode = treeView1.Nodes[0].Nodes[4];
                var node = XmlTools.GetXmlChildNode(childsList[lv.SelectedIndices[0]]);
                XmlTools.UpdateXmlChildNode(node, null);
            }
            else if (lv == listView4) // sounds
            {
                treeView1.SelectedNode = treeView1.Nodes[0].Nodes[5];
                var node = XmlTools.GetXmlSoundNode(soundsList[lv.SelectedIndices[0]]);
                XmlTools.UpdateXmlSoundNode(node, null);
            }
            UpdateData();
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter           = "Animations (animations.xml)|*.xml";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;

                string xmlString = XmlTools.GenerateXmlString();

                File.WriteAllText(FileName, xmlString);

                for (var k = 0; k < mustSave.Count; k++)
                {
                    mustSave[k] = false;
                }
            }
        }
Beispiel #4
0
        private void ShowNewForm(object sender, EventArgs e)
        {
            bool messageshow = false;

            foreach (var k in mustSave)
            {
                if (k)
                {
                    messageshow = true;
                    if (MessageBox.Show("There are still nodes not saved. Do you really want dismiss your changes?", "save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
                    {
                        return;
                    }
                    for (var j = 0; j < mustSave.Count; j++)
                    {
                        mustSave[j] = false;
                    }
                    break;
                }
            }
            if (!messageshow && xmlModified)
            {
                if (MessageBox.Show("Current project is not saved, do you want close without saving the changes?", "save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
            }

            toolStripButton1.Enabled = true;
            toolStripButton2.Enabled = true;

            if (formProject != null)
            {
                formProject.Hide();
                editWindows.Hide();
                log.Hide();
                formProject.Close();
                editWindows.Close();
                log.Close();
            }

            richTextBox1.Hide();
            formChat.Hide();

            editWindows           = new EditWindows();
            editWindows.MdiParent = this;
            editWindows.Parent    = splitContainer2.Panel1;
            editWindows.Dock      = DockStyle.Fill;
            editWindows.Show();

            log           = new Log();
            log.MdiParent = this;
            log.Parent    = splitContainer2.Panel2;
            log.Dock      = DockStyle.Fill;
            log.Show();

            formProject           = new ProjectStructure();
            formProject.MdiParent = this;
            formProject.Parent    = splitContainer1.Panel1;
            formProject.Dock      = DockStyle.Fill;
            formProject.Show();

            xmlViewer           = new Tools();
            xmlViewer.MdiParent = this;
            xmlViewer.Parent    = splitContainer2.Panel1;
            xmlViewer.Dock      = DockStyle.Fill;

            Program.LogForm = log;

            XmlTools.LoadXML("");

            XmlTools.FillMissingDataOnXML();

            UpdateData();

            if (e != null)
            {
                UpdateData();
            }

            for (var k = 0; k < 8; k++)
            {
                mustSave[k] = false;
            }
            XmlModified(true);
        }
        private void insertNodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var cms = contextMenuStrip1;
            var lv  = cms.SourceControl as ListView;

            if (lv == listView1) // spawn
            {
                treeView1.SelectedNode = treeView1.Nodes[0].Nodes[2];
                var node = new XmlData.SpawnNode();
                for (var j = 1; j <= listView1.Items.Count + 2; j++)
                {
                    if (XmlTools.GetXmlSpawnNode(j) == null)
                    {
                        node.Id          = j;
                        node.Next        = new XmlData.NextNode();
                        node.Probability = 10;
                        node.X           = "";
                        node.Y           = "";
                        XmlTools.UpdateXmlSpawnNode(null, node);
                        MainWindow.MainWin.UpdateData();
                        break;
                    }
                }
            }
            else if (lv == listView2) // animations
            {
                treeView1.SelectedNode = treeView1.Nodes[0].Nodes[3];
                var node = new XmlData.AnimationNode();
                for (var j = 1; j <= listView2.Items.Count + 2; j++)
                {
                    if (XmlTools.GetXmlAnimationNode(j) == null)
                    {
                        node.Id   = j;
                        node.Name = "New";
                        XmlTools.UpdateXmlAnimationNode(null, node);
                        MainWindow.MainWin.UpdateData();
                        break;
                    }
                }
            }
            else if (lv == listView3) // childs
            {
                treeView1.SelectedNode = treeView1.Nodes[0].Nodes[4];
                var node = new XmlData.ChildNode();
                for (var j = 1; j <= listView3.Items.Count + 2; j++)
                {
                    if (XmlTools.GetXmlChildNode(j) == null)
                    {
                        node.Id   = j;
                        node.Next = j;
                        XmlTools.UpdateXmlChildNode(null, node);
                        MainWindow.MainWin.UpdateData();
                        break;
                    }
                }
            }
            else if (lv == listView4) // sounds
            {
                treeView1.SelectedNode = treeView1.Nodes[0].Nodes[5];
                var node = new XmlData.SoundNode();
                for (var j = 1; j <= listView4.Items.Count + 2; j++)
                {
                    if (XmlTools.GetXmlSoundNode(j) == null)
                    {
                        node.Id = j;
                        XmlTools.UpdateXmlSoundNode(null, node);
                        MainWindow.MainWin.UpdateData();
                        break;
                    }
                }
            }
        }