Exemplo n.º 1
0
        public ServerModuleFolder(string name, string path, string icon)
            : base(name, path, icon)
        {
            Groups.Add(new FileGroup("Guis", Path.Combine(path, "Gui"), @"/InteractServer;component/Resources/Icons/screen.png", ".json", typeof(Gui), ContentType.ServerGui));
            GuiGroup = Groups.Last();

            Groups.Add(new FileGroup("Patchers", Path.Combine(path, "Patcher"), @"/InteractServer;component/Resources/Icons/Patcher_16x.png", ".yap", typeof(Patcher), ContentType.ServerPatcher));
            PatcherGroup = Groups.Last();

            Groups.Add(new FileGroup("Sounds", Path.Combine(path, "Sound"), @"/InteractServer;component/Resources/Icons/SoundFile_16x.png", ".json", typeof(SoundPage), ContentType.ServerSounds));
            SoundGroup = Groups.Last();

            Groups.Add(new FileGroup("Scripts", Path.Combine(path, "Script"), @"/InteractServer;component/Resources/Icons/Script_16x.png", ".cs", typeof(Script), ContentType.ServerScript));
            ScriptGroup = Groups.Last();

            Groups.Add(new FileGroup("Outputs", Path.Combine(path, "Output"), @"/InteractServer;component/Resources/Icons/route-16.png", ".out", typeof(OutputPage), ContentType.ServerOutput));
            OutputGroup = Groups.Last();

            if (!File.Exists(Path.Combine(path, "Script", "Main.cs")))
            {
                var resource = ScriptGroup.CreateResource("Main", true);
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("InteractServer.Resources.Definitions.ServerScriptTemplate1.cs"))
                {
                    if (stream != null)
                    {
                        StreamReader reader = new StreamReader(stream);
                        (resource as Script).View.Text = reader.ReadToEnd();
                        (resource as Script).SaveContent();
                    }
                }
                needsSaving = true;
            }
        }
Exemplo n.º 2
0
        public ClientModuleFolder(string name, string path, string icon)
            : base(name, path, icon)
        {
            Groups.Add(new FileGroup("Guis", Path.Combine(path, "Gui"), @"/InteractServer;component/Resources/Icons/screen.png", ".json", typeof(Gui), ContentType.ClientGui));
            GuiGroup = Groups.Last();

            Groups.Add(new FileGroup("Patchers", Path.Combine(path, "Patcher"), @"/InteractServer;component/Resources/Icons/Patcher_16x.png", ".yap", typeof(Patcher), ContentType.ClientPatcher));
            PatcherGroup = Groups.Last();

            Groups.Add(new FileGroup("Scripts", Path.Combine(path, "Script"), @"/InteractServer;component/Resources/Icons/Script_16x.png", ".cs", typeof(Script), ContentType.ClientScript));
            ScriptGroup = Groups.Last();

            Groups.Add(new FileGroup("Sensors", Path.Combine(path, "Sensor"), @"/InteractServer;component/Resources/Icons/sensors_16.png", ".json", typeof(SensorConfig), ContentType.ClientSensors));
            SensorGroup = Groups.Last();

            Groups.Add(new FileGroup("Arduino", Path.Combine(path, "Arduino"), @"/InteractServer;component/Resources/Icons/arduino_16.png", ".json", typeof(ArduinoConfig), ContentType.ClientArduino));
            ArduinoGroup = Groups.Last();

            if (!File.Exists(Path.Combine(path, "Script", "Main.cs")))
            {
                var resource = ScriptGroup.CreateResource("Main", false);
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("InteractServer.Resources.Definitions.ClientScriptTemplate1.cs"))
                {
                    if (stream != null)
                    {
                        StreamReader reader = new StreamReader(stream);
                        (resource as Script).View.Text = reader.ReadToEnd();
                        (resource as Script).SaveContent();
                    }
                }
                needsSaving = true;
            }
        }
Exemplo n.º 3
0
        public override bool CreateResource(string name, ContentType type)
        {
            switch (type)
            {
            case ContentType.ServerGui:
                GuiGroup.CreateResource(name, true);
                break;

            case ContentType.ServerPatcher:
                PatcherGroup.CreateResource(name, true);
                break;

            case ContentType.ServerSounds:
                SoundGroup.CreateResource(name, true);
                break;

            case ContentType.ServerOutput:
                OutputGroup.CreateResource(name, true);
                break;

            case ContentType.ServerScript:
                var resource = ScriptGroup.CreateResource(name, true);
#if (WithSyntaxEditor)
                ((resource as Script).View as CodeEditor.CodeEditor).SetLanguage(Project.Current.Intellisense.ServerLanguage);
#endif
                string path = "InteractServer.Resources.Definitions.ServerScriptTemplate2.cs";

                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path))
                {
                    if (stream != null)
                    {
                        StreamReader reader = new StreamReader(stream);
                        (resource as Script).View.Text = reader.ReadToEnd();
                        (resource as Script).SaveContent();
                    }
                }
                break;
            }
            needsSaving = true;
            return(true);
        }