Esempio n. 1
0
        /// <summary>
        /// Creates a new empty Lua script in the specified project, in the specified folder.
        /// </summary>
        /// <param name="data">The solution creation data, usually derived from the user's input in a NewSolutionForm.</param>
        /// <returns>A new solution that can be loaded.</returns>
        public override Moai.Platform.Management.File Create(string name, Project project, Folder folder)
        {
            File f = null;

            // Determine where to place the file.
            if (folder == null)
            {
                // Place the file in the root of the project
                f = new File(project, project.ProjectInfo.DirectoryName, name);
                project.AddFile(f);
            }
            else
            {
                // Place the file in the specified folder
                f = new File(project, project.ProjectInfo.DirectoryName, System.IO.Path.Combine(folder.FolderInfo.Name, name));
                folder.Add(f);
            }

            // Write the contents of the data into the file.
            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(f.FileInfo.FullName))
            {
                writer.WriteLine("-- An empty script file.");
                writer.WriteLine();
            }

            return f;
        }
Esempio n. 2
0
 public FileTreeNode(File file)
 {
     this.File = file;
     this.File.SyncDataChanged += (sender, e) =>
         {
             this.Resync();
         };
     this.Resync();
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a new solution using the data requested.
        /// </summary>
        /// <param name="data">The solution creation data, usually derived from the user's input in a NewSolutionForm.</param>
        /// <returns>A new solution that can be loaded.</returns>
        public override Solution Create(SolutionCreationData data)
        {
            // Create the new, empty solution on disk.
            Solution s = null;

            if (data.SolutionDirUsed)
            {
                s = Solution.Create(data.SolutionDirName, Path.Combine(data.Path, data.SolutionDirName));
            }
            else
            {
                s = Solution.Create(data.Name, Path.Combine(data.Path, data.Name));
            }

            // Create the new, empty project on disk.
            Project p = null;

            if (data.SolutionDirUsed)
            {
                p = Project.Create(data.Name, Path.Combine(Path.Combine(data.Path, data.SolutionDirName), data.Name));
            }
            else
            {
                p = Project.Create(data.Name, Path.Combine(data.Path, data.Name));
            }

            // Create a new file associated with the project.
            Moai.Platform.Management.File f = new Moai.Platform.Management.File(p, p.ProjectInfo.Directory.FullName, "Main.lua");
            StreamWriter w = new StreamWriter(f.FileInfo.FullName);

            w.WriteLine("-- Main game entry point.");
            w.WriteLine();
            w.Close();

            // Add the file to the project.
            p.AddFile(f);

            // Save the project back to disk.
            p.Save();

            // Add the project to the solution.
            s.Projects.Add(p);

            // Save the solution back to disk.
            s.Save();

            // Return the new solution.
            return(s);
        }
Esempio n. 4
0
        /// <summary>
        /// Opens a new designer for the specified file, or returns an existing
        /// editor for this file.
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public IDesigner OpenDesigner(File file)
        {
            // Search through our existing designers to see if there's
            // already a designer open for this file.
            foreach (IDesigner d in this.m_Designers)
            {
                if (d.File.FileInfo.FullName == file.FileInfo.FullName)
                {
                    if (this.DesignerRefocused != null)
                        this.DesignerRefocused(this, new DesignerEventArgs(d));
                    return d;
                }
            }

            // Ensure that FileInfo property is valid (if it is not, then we
            // are dealing with a non-file).
            if (file.FileInfo == null)
                return null;

            // Detect the type of designer to create by the file's extension.
            Type t = Central.Platform.GetDesignerTypeImplementing(Associations.GetDesignerType(file.FileInfo.Extension.Substring(1)));
            if (t == null)
            {
                Central.Platform.UI.ShowMessage("There is no designer associated with this file type.", "No Designer", MessageBoxButtons.OK);
                return null;
            }

            // Invoke the constructor.
            IDesigner ds = t.GetConstructor(new Type[] { typeof(File) }).Invoke(new object[] { file as object }) as IDesigner;
            ds.Closed += (sender, e) =>
                {
                    if (this.DesignerClosed != null)
                        this.DesignerClosed(this, new DesignerEventArgs(ds));
                    this.m_Designers.Remove(ds);
                };
            ds.Opened += (sender, e) =>
                {
                    if (this.DesignerOpened != null)
                        this.DesignerOpened(this, new DesignerEventArgs(ds));
                };
            this.m_Designers.Add(ds);
            if (this.DesignerCreated != null)
                this.DesignerCreated(this, new DesignerEventArgs(ds));

            return ds;
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new start page.
        /// </summary>
        /// <param name="manager">The main Moai manager.</param>
        /// <param name="file">The associated file.</param>
        public Designer(File file)
            : base(file)
        {
            InitializeComponent();

            // Listen for events.
            Central.Manager.IDE.ActiveTabChanged += (sender, e) =>
            {
                this.OnTabChanged();
            };
            Central.Manager.IDE.ResizeEnd += (sender, e) =>
            {
                this.OnResize();
            };

            this.TabText = "Cloud Dashboard";
            this.c_WebBrowser.ScriptErrorsSuppressed = true;
            this.c_WebBrowser.Url = new System.Uri("https://dashboard.moaicloud.com/login.php", System.UriKind.Absolute);
        }
Esempio n. 6
0
        /// <summary>
        /// Creates a new solution using the data requested.
        /// </summary>
        /// <param name="data">The solution creation data, usually derived from the user's input in a NewSolutionForm.</param>
        /// <returns>A new solution that can be loaded.</returns>
        public override Solution Create(SolutionCreationData data)
        {
            // Create the new, empty solution on disk.
            Solution s = null;
            if (data.SolutionDirUsed)
                s = Solution.Create(data.SolutionDirName, Path.Combine(data.Path, data.SolutionDirName));
            else
                s = Solution.Create(data.Name, Path.Combine(data.Path, data.Name));

            // Create the new, empty project on disk.
            Project p = null;
            if (data.SolutionDirUsed)
                p = Project.Create(data.Name, Path.Combine(Path.Combine(data.Path, data.SolutionDirName), data.Name));
            else
                p = Project.Create(data.Name, Path.Combine(data.Path, data.Name));

            // Create a new file associated with the project.
            Moai.Platform.Management.File f = new Moai.Platform.Management.File(p, p.ProjectInfo.Directory.FullName, "Main.lua");
            StreamWriter w = new StreamWriter(f.FileInfo.FullName);
            w.WriteLine("-- Main game entry point.");
            w.WriteLine();
            w.Close();

            // Add the file to the project.
            p.AddFile(f);

            // Save the project back to disk.
            p.Save();

            // Add the project to the solution.
            s.Projects.Add(p);

            // Save the solution back to disk.
            s.Save();

            // Return the new solution.
            return s;
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a new code editor.
        /// </summary>
        /// <param name="file">The associated file.</param>
        public Designer(File file)
            : base(file)
        {
            InitializeComponent();

            // Listen for events.
            file.Project.FileRenamed += new EventHandler<FileEventArgs>((sender, e) =>
            {
                if (e.File == this.File)
                {
                    if (this.c_CodeEditor.Text != this.m_SavedText)
                        this.TabText = this.File.FileInfo.Name + " *";
                    else
                        this.TabText = this.File.FileInfo.Name;
                }
            });

            // Initialize the code editor.
            this.c_CodeEditor = new CodeEditor(
                Central.Manager.CacheManager,
                (this.File.FileInfo.Extension.Substring(1) == "lua" ||
                 this.File.FileInfo.Extension.Substring(1) == "rks" ||
                 this.File.FileInfo.Extension.Substring(1) == "rs")
                );
            this.c_CodeEditor.DwellStart += new EventHandler<ScintillaNet.ScintillaMouseEventArgs>(c_CodeEditor_DwellStart);
            this.c_CodeEditor.DwellEnd += new EventHandler<ScintillaNet.ScintillaMouseEventArgs>(c_CodeEditor_DwellEnd);
            this.c_CodeEditor.KeyUp += new KeyEventHandler(c_CodeEditor_KeyUp);
            this.c_CodeEditor.SyntaxCheckRequested += new EventHandler(c_CodeEditor_SyntaxCheckRequested);
            this.c_CodeEditor.SelectionChanged += new EventHandler(c_CodeEditor_SelectionChanged);
            this.c_CodeEditor.GotFocus += new EventHandler(c_CodeEditor_GotFocus);
            this.c_CodeEditor.LostFocus += new EventHandler(c_CodeEditor_LostFocus);
            this.c_CodeEditor.MarginClick += new EventHandler<ScintillaNet.MarginClickEventArgs>(c_CodeEditor_MarginClick);

            // Initalize the context menu for the code editor.
            this.c_CodeEditor.ContextMenuStrip = ActionWrapper.GetContextMenu(new Platform.Menus.Action[]
            {
                    new Platform.Menus.Definitions.Actions.Undo(this.c_CodeEditor),
                    new Platform.Menus.Definitions.Actions.Redo(this.c_CodeEditor),
                    new SeperatorAction(),
                    new Platform.Menus.Definitions.Actions.Cut(this.c_CodeEditor),
                    new Platform.Menus.Definitions.Actions.Copy(this.c_CodeEditor),
                    new Platform.Menus.Definitions.Actions.Paste(this.c_CodeEditor),
                    new Platform.Menus.Definitions.Actions.Delete(this.c_CodeEditor)
            });

            // Now load the file data.
            using (System.IO.StreamReader reader = new System.IO.StreamReader(this.File.FileInfo.FullName))
            {
                this.c_CodeEditor.Text = reader.ReadToEnd();
            }
            this.m_SavedText = this.c_CodeEditor.Text;

            // Load the breakpoints.
            string relname = PathHelpers.GetRelativePath(this.File.Project.ProjectInfo.DirectoryName, this.File.FileInfo.FullName);
            List<IBreakpoint> breakpoints = Central.Manager.DebugManager.Breakpoints.Where(result => result.SourceFile == relname).ToList();
            foreach (IBreakpoint b in breakpoints)
            {
                this.c_CodeEditor.Lines[(int)b.SourceLine - 1].AddMarker(0);
            }

            // Detect if this file is read-only.
            this.p_CanSave = !this.File.FileInfo.IsReadOnly;
            if (this.p_CanSave)
                this.TabText = this.File.FileInfo.Name;
            else
            {
                this.TabText = this.File.FileInfo.Name + " (Read Only)";
                this.c_CodeEditor.NativeInterface.SetReadOnly(true);
            }

            // Add the code editor to the tab.
            this.Controls.Add(this.c_CodeEditor);
        }
Esempio n. 8
0
 /// <summary>
 /// Called when a breakpoint has been hit and we should highlight it.
 /// </summary>
 /// <param name="file">The file that the breakpoint occurred in (should be the same as the file owned by the debugger).</param>
 /// <param name="line">The line number the breakpoint occurred on.</param>
 public void Debug(File file, uint line)
 {
     this.c_CodeEditor.Lines[(int)line - 1].AddMarker(1);
     this.c_CodeEditor.Lines[(int)line - 1].AddMarker(2);
     this.c_CodeEditor.GetRange(this.c_CodeEditor.Lines[(int)line - 1].StartPosition, this.c_CodeEditor.Lines[(int)line - 1].StartPosition).Select();
     this.m_ActiveLine = (int)line - 1;
 }
Esempio n. 9
0
 public FileEventArgs(File file)
 {
     this.File = file;
 }
Esempio n. 10
0
 /// <summary>
 /// Creates a new Designer base object.
 /// </summary>
 /// <param name="file">The associated file.</param>
 public Designer(File file)
 {
     this.File = file;
     if (this.File != null)
         this.TabText = this.File.FileInfo.Name;
 }
Esempio n. 11
0
                private Folder FindImmediateParentFolder(Folder root, File file)
                {
                    foreach (File f in root.Files)
                    {
                        if (f == file)
                            return root;
                        else if (f is Folder)
                        {
                            Folder parent = this.FindImmediateParentFolder(f as Folder, file);
                            if (parent != null)
                                return parent;
                        }
                    }

                    return null;
                }
Esempio n. 12
0
 /// <summary>
 /// Creates a new item object representing the file or folder information.
 /// </summary>
 /// <param name='project'>The file or folder to represent.</param>
 public SolutionItem(File file)
 {
     if (file == null)
         throw new ArgumentNullException("file");
     try
     {
         m_Log.Debug("Creating new solution item to represent file '" + file.FileInfo.Name + "'.");
     }
     catch
     {
         m_Log.Debug("Creating new solution item to represent file '<unknown>'.");
     }
     this.m_File = file;
 }