Beispiel #1
0
 public void registerMacro(String name, ObjectBuilder macro)
 {
     IScriptExporter exporter = App.CurrentProject.Exporter;
     String macroScript = macro.exportScript(exporter);
     macro.RegisteredName = name;
     send("PUT /Macros/" + name + " " + macroScript, (byte)Connection.CommandType.C_PUT, registerMacroCallbackRest, macro);
 }
Beispiel #2
0
 public void registerScript(String name, ObjectBuilder script)
 {
     throw new NotImplementedException("Implement registerScript and ScriptExporter");
     IScriptExporter exporter = null;// App.CurrentProject.Exporter;
     String scriptExported = script.exportScript(exporter);
     send("PUT /Scripts/" + name + " " + scriptExported + " HTTP/1.1", (byte)Connection.CommandType.C_PUT, registerScriptCallbackRest);
 }
Beispiel #3
0
 public void registerMacro(String name, ObjectBuilder macro)
 {
     throw new NotImplementedException("Implement registerMacro and ScriptExporter");
     IScriptExporter exporter = null;// App.CurrentProject.Exporter;
     String macroScript = macro.exportScript(exporter);
     macro.RegisteredName = name;
     send("PUT /Macros/" + name + " " + macroScript, (byte)Connection.CommandType.C_PUT, registerMacroCallbackRest, macro);
 }
Beispiel #4
0
 public void runScriptOnce(String name, ObjectBuilder script)
 {
     IScriptExporter exporter = App.CurrentProject.Exporter;
     if (exporter == null)
     {
         MessageBox.Show("No Exporter set", "Error");
         return;
     }
     String scriptExported = script.exportScript(exporter);
     send("PUT /Scripts/" + name + "/ " + scriptExported + " HTTP/1.1", (byte)Connection.CommandType.C_PUT, runScriptOnceCallbackRest, name);
 }
Beispiel #5
0
 public void registerMacroInScript(ObjectBuilder macro)
 {
     if (macro.IsRegistered)
     {
         System.Windows.MessageBox.Show("Macro is already registered!", "Error");
     }
     else if (macro == ObjectBuilder)
     {
         System.Windows.MessageBox.Show("Cannot register macro within itself!", "Error");
     }
     else
     {
         MacroRegistration macroReg = new MacroRegistration();
         StringQueryItem qry = new StringQueryItem("Enter new macro name", "New Macro", "Macro");
         StringQuery q = new StringQuery();
         q.DataContext = qry;
         bool? result = q.ShowDialog();
         if (result.Value)
         {
             macro.IsRegistered = true;
             macro.RegisteredName = qry.Text;
             macroReg.Name = qry.Text;
             macroReg.Script = macro;
             ObjectBuilder.ScriptObjects.Add(macroReg);
         }
     }
 }
Beispiel #6
0
 public ObjectBuilder openTemplate(String filename)
 {
     Recent.newRecentFile(filename, filename);
     ObjectBuilder newOb = null;
     using (System.IO.Stream file = File.Open(filename, FileMode.Open))
     {
         using (System.IO.BinaryReader br = new System.IO.BinaryReader(file))
         {
             Version v = new Version();
             v.deserialize(br);
             newOb = new ObjectBuilder(Data);
             newOb.deserialize(br);
         }
     }
     return newOb;
 }
Beispiel #7
0
 public bool isLoaded(ProjectTemplateFile projectTemplate, out ObjectBuilder selected)
 {
     String name = "";
     int index = projectTemplate.Name.LastIndexOf('.');
     if (index > 0)
         name = projectTemplate.Name.Substring(0, index);
     foreach (ObjectBuilder template in Templates.Templates)
     {
         if (template.Name == name)
         {
             selected = template;
             return true;
         }
     }
     selected = null;
     return false;
 }
Beispiel #8
0
        public void exportTemplate(ObjectBuilder template, String filename)
        {
            if (CurrentProject.Exporter != null)
            {
                String script = template.exportScript(CurrentProject.Exporter);

                using (FileStream fs = System.IO.File.Open(filename + CurrentProject.Exporter.Extension, FileMode.OpenOrCreate))
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.Write(script);
                        sw.Flush();
                    }
                    fs.Close();
                }
            }
        }
Beispiel #9
0
 public void selectTemplateEditor()
 {
     m_activeObjectBuilder = Templates.Template;
 }
Beispiel #10
0
 public void selectLiveEditor()
 {
     m_activeObjectBuilder = Data.LiveGameObjects as ObjectBuilder;
 }
Beispiel #11
0
 public void remove(ObjectBuilder ob)
 {
     int index = m_templates.IndexOf(ob);
     if (index > 0)
     {
         Selected = index - 1;
     }
     m_templates.Remove(ob);
 }
Beispiel #12
0
 public ObjectBuilder newTemplate(String name)
 {
     ObjectBuilder newObjBuild = new ObjectBuilder(name, m_data);
     m_templates.Add(newObjBuild);
     return newObjBuild;
 }
Beispiel #13
0
        /// <summary>
        /// Initialization for the object 
        /// </summary>
        /// <param name="nFormatIndex">Zero based index into the list of formats that indicates the current format 
        /// of the file</param>
        /// <returns>S_OK if the method succeeds</returns>
        int IPersistFileFormat.InitNew(uint nFormatIndex)
        {
            if (nFormatIndex != MyFormat)
            {
                return VSConstants.E_INVALIDARG;
            }
            // until someone change the file, we can consider it not dirty as
            // the user would be annoyed if we prompt him to save an empty file

            ObjectBuilder obj = new ObjectBuilder(CogaenEditExtensionPackage.Data);
            obj.Dirty = false;
            editorControl.ObjectBuilderControl.DataContext = obj;
            //objectBuilder.DataContext = obj;

            return VSConstants.S_OK;
        }
Beispiel #14
0
 public void registerScript(String name, ObjectBuilder script)
 {
     IScriptExporter exporter = App.CurrentProject.Exporter;
     String scriptExported = script.exportScript(exporter);
     send("PUT /Scripts/" + name + " " + scriptExported + " HTTP/1.1", (byte)Connection.CommandType.C_PUT, registerScriptCallbackRest);
 }
Beispiel #15
0
 public void renameTemplate(ObjectBuilder template)
 {
     StringQueryItem qry = new StringQueryItem("Enter new name", "New Name", "NewName");
     StringQuery q = new StringQuery();
     q.DataContext = qry;
     bool? res = q.ShowDialog();
     if (res.Value)
     {
         template.Name = qry.Text;
     }
 }
Beispiel #16
0
 public void saveTemplate(ObjectBuilder objectBuilder, bool force)
 {
     DialogResult result;
     String filename = "";
     if (!force)
     {
         SaveFileDialog saveDialog;
         saveDialog = new SaveFileDialog();
         saveDialog.Title = "Save Template";
         saveDialog.Filter = "Template files (*.ctl)|*.ctl";
         FolderOption path = Config.getOption("Save Path") as FolderOption;
         saveDialog.InitialDirectory = path.Value;
         result = saveDialog.ShowDialog();
         if (result == DialogResult.OK)
         {
             filename = saveDialog.FileName;
         }
     }
     else
     {
         String path = "";
         if (CurrentProject != null)
         {
             path = CurrentProject.ProjectDirectory.TrimEnd('\\');
             path += "\\";
             filename = path + objectBuilder.Name + ".ctl";
         }
     }
     if (filename != "")
     {
         using (System.IO.Stream file = new FileStream(filename, FileMode.OpenOrCreate))
         {
             using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(file))
             {
                 Version v = new Version();
                 v.serialize(bw);
                 objectBuilder.serialize(bw);
                 objectBuilder.Dirty = false;
             }
         }
     }
 }
Beispiel #17
0
 public void deserialize(System.IO.BinaryReader br)
 {
     int compCount = br.ReadInt32();
     for (int i = 0; i < compCount; ++i)
     {
         ObjectBuilder newOb = new ObjectBuilder(m_data);
         newOb.deserialize(br);
         m_templates.Add(newOb);
     }
 }
Beispiel #18
0
 public void selectObjectBuilder(int index)
 {
     if (index >= 0)
     {
         m_activeObjectBuilder = m_templates.Templates[index];
         m_templates.Selected = index;
     }
 }
Beispiel #19
0
 public ObjectBuilder newMacro(String name)
 {
     ObjectBuilder newObjBuild = new ObjectBuilder(name, m_data);
     newObjBuild.IsMacro = true;
     m_templates.Add(newObjBuild);
     return newObjBuild;
 }
Beispiel #20
0
 public virtual int Load(string fileName, uint mode, int readOnly)
 {
     //this.load(fileName, false, null);
     if (ObjectBuilder == null)
         ObjectBuilder = new ObjectBuilder(CogaenEditExtensionPackage.Data);
     try
     {
         ObjectBuilder.load(fileName);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error while loading");
         return VSConstants.E_FAIL;
     }
     return VSConstants.S_OK;
 }
Beispiel #21
0
        private bool exportFile(string filename)
        {
            // load file into an ObjectBuilder
            ObjectBuilder objectBuilder = new ObjectBuilder(null);
            objectBuilder.deserializeFromXml(filename);
            string script;
            if (m_exporter.ExportScript(objectBuilder, out script))
            {
                // construct output filename
                StringBuilder expoFileBuilder = new StringBuilder();
                expoFileBuilder.Append(OutputDirectory);
                if (!OutputDirectory.EndsWith("\\"))
                    expoFileBuilder.Append("\\");

                // cerate directory if it doesn't exist yet
                if (!Directory.Exists(expoFileBuilder.ToString()))
                {
                    Directory.CreateDirectory(expoFileBuilder.ToString());
                }

                expoFileBuilder.Append(Path.GetFileNameWithoutExtension(filename));
                if (!m_exporter.ExportExtension.StartsWith("."))
                {
                    expoFileBuilder.Append(".");
                }
                expoFileBuilder.Append(m_exporter.ExportExtension);

                // write file to disk
                using (FileStream fs = File.Create(expoFileBuilder.ToString()))
                {
                    using (StreamWriter sw = new StreamWriter(fs))
                    {
                        sw.Write(script);
                    }
                }
                return true;
            }
            return false;
        }