示例#1
0
        private void newDMEToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result;

            result = folderBrowserDialog1.ShowDialog();
            if (result == DialogResult.Cancel)
            {
                return;
            }
            string_dialog S = new string_dialog("Enivorment name:");

            result = S.ShowDialog();
            if (result == DialogResult.Cancel)
            {
                return;
            }
            string name = S.getresult();
            string path = folderBrowserDialog1.SelectedPath;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            fileInfo     f    = addFile(path, name + ".dm");
            fileInfo     fdme = addFile(path, name + ".dme");
            StreamWriter P    = new StreamWriter(path + "\\" + name + "\\" + name + ".dme");

            P.Write(dme_string);
            P.Close();
            P = new StreamWriter(path + "\\" + name + "\\" + name + ".dm");
            P.Write(dm_string);
            P.Close();
            File.AppendAllText(path + "\\" + name + "\\" + name + ".dme", "\n #include \"" + name + ".dm\"\n // END_INCLUDE");
        }
示例#2
0
        private fileInfo addFile(string p, string name)
        {
            TreeNode tree = (TreeNode)file_list_menu.Tag;
            string   path = p;

            path = path.Replace('/', '\\');
            if (path.IndexOf('\\') != -1)
            {
                path = path.Substring(path.IndexOf('\\'));
                path = info.dir + path + "\\" + name;
            }
            else
            {
                path = info.dir + name;
            }
            if (File.Exists(path))
            {
                return(null);
            }
            StreamWriter B = File.CreateText(path);

            B.Close();
            fileInfo fInfo = new fileInfo(path, p);

            if (info.dme_Loaded)
            {
                info.files.Add(path, fInfo);
                info.save_dme();
            }
            return(fInfo);
        }
示例#3
0
        }           // ;

        private void open_tab(string name)
        {
            foreach (TabPage B in tabControl1.TabPages)
            {
                fileInfo fi = (fileInfo)B.Tag;
                if (fi.InternalPath == name)
                {
                    tabControl1.SelectTab(B);
                    return;
                }
            }
            fileInfo F = info.files[info.dirs + "\\" + name];

            if (F == null)
            {
                throw new NullReferenceException("Could not find file " + info.dirs + "\\" + name);
            }
            TabPage P = new TabPage(F.FileName + F.Extension);

            P.Controls.Add(new textEditor(this, console, P));
            P.Controls[0].Controls["editor"].Text = F.Text;
            P.Controls[0].Size = tabControl1.Size;
            //    P.Controls[0].Dock = DockStyle.Fill;
            ScintillaNET.Scintilla note = (ScintillaNET.Scintilla)P.Controls[0].Controls["editor"];
            note.UndoRedo.EmptyUndoBuffer();
            P.Controls["editor"].Tag = P;
            P.Tag = F;
            tabControl1.TabPages.Add(P);
            tabControl1.SelectTab(P);
        }
示例#4
0
        private void open_tab(fileInfo name)
        {
            if (name == null)
            {
                return;
            }
            foreach (TabPage B in tabControl1.TabPages)
            {
                fileInfo fi = (fileInfo)B.Tag;
                if (fi == name)
                {
                    tabControl1.SelectTab(B);
                    return;
                }
            }
            fileInfo F = name;

            if (F == null)
            {
                throw new NullReferenceException("Could not find file " + F.FullPath);
            }
            if (info.sound_Filetypes.Contains(F.Extension))
            {
                TabPage V = new TabPage(F.FileName + F.Extension);
                V.Text = F.FileName + F.Extension;
                V.Name = V.Text;
                V.Controls.Add(new Mediaplayer(info, F.FullPath));
                tabControl1.TabPages.Add(V);
                tabControl1.SelectTab(V);
                return;
            }
            if (F.Extension == ".dmi")
            {
                TabPage page = new TabPage(F.FileName + F.Extension);
                page.Text = F.FileName + F.Extension;
                page.Name = page.Text;
                page.Controls.Add(new DMI.dmiViewer(new DMI.DMimage(F.FullPath)));
                tabControl1.TabPages.Add(page);
                tabControl1.SelectTab(page);
                return;
            }
            if (F.Extension != ".dm")
            {
                return;
            }
            TabPage P = new TabPage(F.FileName + F.Extension);

            P.Controls.Add(new textEditor(this, console, P));
            P.Controls[0].Controls["editor"].Text = F.Text;
            P.Controls[0].Size = tabControl1.Size;
            // P.Controls[0].Dock = DockStyle.Fill;
            ScintillaNET.Scintilla note = (ScintillaNET.Scintilla)P.Controls[0].Controls["editor"];
            note.UndoRedo.EmptyUndoBuffer();
            P.Tag = F;
            tabControl1.TabPages.Add(P);
            tabControl1.SelectTab(P);
        }
示例#5
0
        private void file_list_AfterCheck(object sender, TreeViewEventArgs e)
        {
            fileInfo F = (fileInfo)e.Node.Tag;

            if (F == null)
            {
                throw new NullReferenceException("Node tag is null.");
            }
            F.Checked = !F.Checked;
            info.save_dme();
        }
示例#6
0
        private void file_list_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            fileInfo F = (fileInfo)e.Node.Tag;

            if (e.Node.Level == 0)
            {
                HideCheckBox(e.Node);
            }
            else if (F == null || F.Extension != ".dm" && F.Extension != ".dmf")
            {
                HideCheckBox(e.Node);
            }
            e.DrawDefault = true;
        }
示例#7
0
        public void open_tab(string name, int line)
        {
            ScintillaNET.Scintilla chat;
            if (name.Contains(info.dir))
            {
                name = name.Remove(0, info.dir.Length + 1);
            }
            foreach (TabPage B in tabControl1.TabPages)
            {
                fileInfo fi = (fileInfo)B.Tag;
                if (fi.InternalPath == name)
                {
                    tabControl1.SelectTab(B);
                    chat = (ScintillaNET.Scintilla)tabControl1.SelectedTab.Controls[0].Controls["editor"];
                    chat.GoTo.Line(line);
                    return;
                }
            }

            if (!info.files.ContainsKey(info.dir + "\\" + name))
            {
                throw new NullReferenceException("Could not find file " + info.dir + "\\" + name);
            }
            fileInfo F = info.files[info.dir + "\\" + name];

            if (F.Extension != ".dm")
            {
                return;
            }
            if (F == null)
            {
                throw new NullReferenceException("Could not find file " + info.dir + "\\" + name);
            }
            TabPage P = new TabPage(F.FileName + F.Extension);

            P.Controls.Add(new textEditor(this, console, P));
            P.Controls[0].Controls["editor"].Text = F.Text;
            P.Controls[0].Size = tabControl1.Size;
            // P.Controls[0].Dock = DockStyle.Fill;
            ScintillaNET.Scintilla note = (ScintillaNET.Scintilla)P.Controls[0].Controls["editor"];
            note.UndoRedo.EmptyUndoBuffer();
            P.Controls["editor"].Tag = P;
            P.Tag = F;
            tabControl1.TabPages.Add(P);
            tabControl1.SelectTab(P);
            chat = (ScintillaNET.Scintilla)tabControl1.SelectedTab.Controls[0].Controls["editor"];
            chat.GoTo.Line(Convert.ToInt32(line));
        }
示例#8
0
        private void save_tab(TabPage P)
        {
            fileInfo F = (fileInfo)P.Tag;

            if (F == null || info.sound_Filetypes.Contains(F.Extension))
            {
                return;
            }
            System.IO.StreamWriter file = new System.IO.StreamWriter(F.FullPath);
            file.Write(P.Controls[0].Controls["editor"].Text);
            F.Text = P.Controls[0].Controls["editor"].Text;
            textEditor UC = (textEditor)P.Controls[0];

            UC.isModified = false;
            tabControl1.Invalidate();
            file.Close();
        }           // ;
示例#9
0
 private void file_list_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         fileInfo f = (fileInfo)e.Node.Tag;
         if (f == null) // directory
         {
             Point F = file_list.PointToScreen(e.Location);
             file_list_menu.Tag = e.Node;
             file_list_menu.Show(F);
         }
         else
         {
             return;
         }
     }
     else
     {
         return;
     }
 }
示例#10
0
 private void open_tab(fileInfo name)
 {
     if (name == null)
         return;
     foreach (TabPage B in tabControl1.TabPages)
     {
         fileInfo fi = (fileInfo)B.Tag;
         if (fi == name)
         {
             tabControl1.SelectTab(B);
             return;
         }
     }
     fileInfo F = name;
     if (F == null)
         throw new NullReferenceException("Could not find file " + F.FullPath);
     if (info.sound_Filetypes.Contains(F.Extension))
     {
         TabPage V = new TabPage(F.FileName + F.Extension);
         V.Text = F.FileName + F.Extension;
         V.Name = V.Text;
         V.Controls.Add(new Mediaplayer(info, F.FullPath));
         tabControl1.TabPages.Add(V);
         tabControl1.SelectTab(V);
         return;
     }
     if (F.Extension == ".dmi")
     {
         TabPage page = new TabPage(F.FileName + F.Extension);
         page.Text = F.FileName + F.Extension;
         page.Name = page.Text;
         page.Controls.Add(new DMI.dmiViewer(new DMI.DMimage(F.FullPath)));
         tabControl1.TabPages.Add(page);
         tabControl1.SelectTab(page);
         return;
     }
     if (F.Extension != ".dm")
         return;
     TabPage P = new TabPage(F.FileName + F.Extension);
     P.Controls.Add(new textEditor(this, console,P));
     P.Controls[0].Controls["editor"].Text = F.Text;
     P.Controls[0].Size = tabControl1.Size;
        // P.Controls[0].Dock = DockStyle.Fill;
     ScintillaNET.Scintilla note = (ScintillaNET.Scintilla)P.Controls[0].Controls["editor"];
     note.UndoRedo.EmptyUndoBuffer();
     P.Tag = F;
     tabControl1.TabPages.Add(P);
     tabControl1.SelectTab(P);
 }
示例#11
0
 private fileInfo addFile(string p, string name)
 {
     TreeNode tree = (TreeNode)file_list_menu.Tag;
     string path = p;
     path = path.Replace('/', '\\');
     if (path.IndexOf('\\') != -1)
     {
         path = path.Substring(path.IndexOf('\\'));
         path = info.dir + path + "\\" + name;
     }
     else
         path = info.dir + name;
     if (File.Exists(path))
         return null;
     StreamWriter B = File.CreateText(path);
     B.Close();
     fileInfo fInfo = new fileInfo(path,p);
     if (info.dme_Loaded)
     {
         info.files.Add(path, fInfo);
         info.save_dme();
     }
     return fInfo;
 }
示例#12
0
        private void file_list_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            fileInfo F = (fileInfo)e.Node.Tag;

            open_tab(F);
        }
示例#13
0
        public void load_dme()
        {
            if (dme_Loaded)
            {
                dirs       = new List <string>();
                dirsfull   = new Dictionary <string, string>();
                files      = new Dictionary <string, fileInfo>();
                root       = new TreeNode();
                dme_Loaded = false;
            }
            dir  = Path.GetDirectoryName(dme_path);
            root = new TreeNode(Path.GetFileNameWithoutExtension(dme_path));
            string[]    test    = File.ReadAllLines(dme_path);
            int         t_lines = test.Length;
            int         d_lines = 0;
            ProgressBar bar     = (ProgressBar)mainWindow.Controls["work_bar"];

            test = null;
            StreamReader tr = new StreamReader(dme_path);

            bar.Visible = true;
            while (tr.EndOfStream == false)
            {
                string   temp  = tr.ReadLine();
                string[] lines = temp.Split(' ');
                d_lines++;
                bar.Value = (d_lines / t_lines);
                if (lines[0] == "#include")
                {
                    string line = lines[1];
                    if (lines.Length > 2)
                    {
                        for (int i = 2; i < lines.Length; i++)
                        {
                            line += " " + lines[i];
                        }
                    }
                    line = line.Substring(1, line.Length - 2);
                    files[dir + "\\" + line] = new fileInfo(dir + '\\' + line, line);
                    System.Console.WriteLine(dir + '\\' + line);
                }
                else if (lines.Length - 1 >= 1 && lines[1] == "FILE_DIR")
                {
                    string line = lines[2];
                    if (line == ".")
                    {
                        continue;
                    }
                    if (lines.Length > 3)
                    {
                        for (int i = 3; i < lines.Length; i++)
                        {
                            line += " " + lines[i];
                        }
                    }
                    line = line.Substring(1, line.Length - 2);
                    if (line.IndexOf('/') == -1)
                    {
                        dirs.Add(line);
                        dirsfull[line] = line;
                    }
                    else
                    {
                        lines = line.Split('/');
                        dirs.Add(lines[lines.Length - 1]);
                        dirsfull[line] = lines[lines.Length - 1];
                    }
                }
            }
            popTree(dir, root);
            TreeView T = mainWindow.get_tree();

            T.Nodes.Add(root);
            dme_Loaded = true;
            tr.Close();
            save_dme();
            bar.Visible = false;
        }
示例#14
0
        private void popTree(string dir, TreeNode node)
        {
            DirectoryInfo directory = new DirectoryInfo(dir);

            foreach (DirectoryInfo d in directory.GetDirectories())
            {
                if (!dirs.Contains(d.Name))
                {
                    continue; // it's not in the DME ignore it.
                }
                TreeNode t = new TreeNode(d.Name);
                t.ImageIndex = 0;
                popTree(d.FullName, t);
                node.Nodes.Add(t);
            }
            foreach (FileInfo f in directory.GetFiles())
            {
                // create a new node
                if (!isdm(f.Extension) && !issound(f.Extension))
                {
                    continue;
                }
                TreeNode t  = new TreeNode(f.Name);
                fileInfo FI = null;
                if (!files.ContainsKey(f.FullName))
                {
                    string paths = Path.GetDirectoryName(f.FullName);
                    paths             = paths.Substring(paths.IndexOf(this.dir + "\\") + this.dir.Length + 1);
                    files[f.FullName] = new fileInfo(f.FullName, paths + "\\" + f.Name, false);
                    FI = files[f.FullName];
                }
                else
                {
                    t.Checked = true;
                    FI        = files[f.FullName];
                }
                if (FI == null)
                {
                    throw new ArgumentNullException();
                }
                t.Tag = FI;
                if (isdm(f.Extension))
                {
                    if (f.Extension == ".dmf")
                    {
                        t.ImageIndex         = 2;
                        t.SelectedImageIndex = 2;
                    }
                    else if (f.Extension == ".dmi")
                    {
                        t.ImageIndex         = 4;
                        t.SelectedImageIndex = 4;
                    }
                    else
                    {
                        t.ImageIndex         = 1;
                        t.SelectedImageIndex = 1;
                    }
                }
                else if (issound(f.Extension))
                {
                    t.ImageIndex         = 3;
                    t.SelectedImageIndex = 3;
                }
                // add it to the "master"
                node.Nodes.Add(t);
            }
        }
示例#15
0
 private fileInfo addFile(TreeNode p, string name)
 {
     TreeNode tree = (TreeNode)file_list_menu.Tag;
     string path = tree.FullPath;
     path = path.Replace("/", Config.path_seperator);
     if (path.IndexOf(Config.path_seperator) != -1)
     {
         path = path.Substring(path.IndexOf(Config.path_seperator));
         path = info.dir + path + Config.path_seperator + name;
     }
     else
         path = info.dir + name;
     if (File.Exists(path))
         return null;
     StreamWriter B = File.CreateText(path);
     B.Close();
     fileInfo fInfo = new fileInfo(path, tree.FullPath.Replace("/", Config.path_seperator).Substring(tree.FullPath.IndexOf('/')));
     if (info.dme_Loaded)
     {
         info.files.Add(path, fInfo);
         info.save_dme();
     }
     return fInfo;
 }
示例#16
0
        public void load_dme()
        {
            if (dme_Loaded)
            {
                dirs = new List<string>();
                dirsfull = new Dictionary<string, string>();
                files = new Dictionary<string, fileInfo>();
                root = new TreeNode();
                dme_Loaded = false;
            }
            dir = Path.GetDirectoryName(dme_path);
            root = new TreeNode(Path.GetFileNameWithoutExtension(dme_path));
            StreamReader tr = new StreamReader(dme_path);
            while (tr.EndOfStream == false)
            {
                string temp = tr.ReadLine();
                string[] lines = temp.Split(' ');
                if (lines[0] == "#include")
                {
                    string line = lines[1];
                    if (lines.Length > 2)
                    {
                        for (int i = 2; i < lines.Length; i++)
                        {
                            line += " " + lines[i];

                        }
                    }
                    line = line.Substring(1,line.Length-2);
                    files[dir + "\\" + line] = new fileInfo(dir + '\\' + line,line);
                    System.Console.WriteLine(dir+'\\'+line);
                }
                else if (lines.Length - 1 >= 1 && lines[1] == "FILE_DIR")
                {
                    string line = lines[2];
                    if (line == ".")
                        continue;
                    if (lines.Length > 3)
                    {
                        for (int i = 3; i < lines.Length; i++)
                        {
                            line += " " + lines[i];

                        }
                    }
                    line = line.Substring(1, line.Length - 2);
                    if (line.IndexOf('/') == -1)
                    {
                        dirs.Add(line);
                        dirsfull[line] = line;
                    }
                    else
                    {
                        lines = line.Split('/');
                        dirs.Add(lines[lines.Length - 1]);
                        dirsfull[line] = lines[lines.Length - 1];
                    }

                }

            }
            popTree(dir, root);
            TreeView T = mainWindow.get_tree();
            T.Nodes.Add(root);
            dme_Loaded = true;
            tr.Close();
            save_dme();
        }