Пример #1
0
        public static void StartProject()
        {
            XmlNodeList nodeList = Project.GetNodes(Project.ProjectRootNodeName + "/shells/*");

            foreach (XmlNode p in nodeList)
            {
                Shell shell = OpenShell(p);
                if (shell.MainControl == null)
                {
                    string controlKind          = Project.GetNodeAttributeValue(p, "controlkind", null);
                    ShellDeserializerDelegate d = GetShellDeserializer(controlKind);
                    if (d != null)
                    {
                        if (!shell.SetControl(d(shell.ShellId, p)))
                        {
                            // return "Error: unable to create shell control.";
                        }
                    }
                }
            }
            Shell s = GetShell(ConsoleShellId);

            if (s != null)
            {
                s.SetActive();
            }
        }
Пример #2
0
 public static string OpenPlotShell()
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         Shell  shell   = Shell.OpenShell("Plot", 300, 500);
         string shellId = shell.ShellId;
         if (shell.MainControl == null)
         {
             if (!shell.SetControl(new PlotControl(shellId)))
             {
                 return("Error: unable to create shell plot control.");
             }
         }
         return(shellId);
     }
     return((string)Application.Current.Dispatcher.Invoke(
                new Func <string>(() => { return OpenPlotShell(); })
                ));
 }
Пример #3
0
 public static string OpenEditorShell(string scriptName = "")
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         if (String.IsNullOrWhiteSpace(scriptName))
         {
             scriptName = Scripts.GenerateNewFileName("Script", Project.ScriptExt, Project.GetProjectScriptDir());
         }
         string fileName = Scripts.GetScriptFilePath(scriptName);
         if (fileName == null)
         {
             if (scriptName.IndexOfAny(PathChars) < 0)
             {
                 fileName = Path.Combine(Project.GetProjectScriptDir(), scriptName + Project.ScriptExt);
             }
             else
             {
                 fileName = scriptName;
                 if (Directory.Exists(fileName))
                 {
                     scriptName = Scripts.GenerateNewFileName("Script", Project.ScriptExt, fileName);
                     fileName   = Path.Combine(fileName, scriptName + Project.ScriptExt);
                 }
             }
         }
         Shell  shell   = Shell.OpenShell(scriptName, 400, 400);
         string shellId = shell.ShellId;
         if (shell.MainControl == null)
         {
             // TODO: update script cache - rehash when editor closed.
             if (!shell.SetControl(new EditorControl(shellId, fileName)))
             {
                 return("Error: unable to create shell editor control.");
             }
         }
         return(shellId);
     }
     return((string)Application.Current.Dispatcher.Invoke(
                new Func <string>(() => { return OpenEditorShell(scriptName); })
                ));
 }
Пример #4
0
 public static string OpenTextShell(string title,
                                    int width          = 300, int height       = 200, int x = -1, int y = -1, int windowState = 0,
                                    string shellId     = "", string workingDir = "",
                                    string scriptStart = "shellstart", string scriptEnd = "shellend",
                                    bool isInteractive = false, bool useTimePrompt      = false)
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         Shell shell = Shell.OpenShell(title, width, height, x, y, windowState, shellId, workingDir);
         shellId = shell.ShellId;
         if (shell.MainControl == null)
         {
             if (!shell.SetControl(new ShellTextControl(shellId, scriptStart, scriptEnd, isInteractive, useTimePrompt)))
             {
                 return("Error: unable to create shell script control.");
             }
         }
         return(shellId);
     }
     return((string)Application.Current.Dispatcher.Invoke(
                new Func <string>(() => { return OpenTextShell(title, width, height, x, y, windowState, shellId, workingDir, scriptStart, scriptEnd, isInteractive, useTimePrompt); })
                ));
 }
Пример #5
0
 public static string OpenExplorerShell(string filePath = "")
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         Shell  shell   = Shell.OpenShell("Explorer", 300, 500);
         string shellId = shell.ShellId;
         if (shell.MainControl == null)
         {
             if (String.IsNullOrWhiteSpace(filePath))
             {
                 filePath = Project.GetProjectDir();
             }
             if (!shell.SetControl(new ExplorerControl(shellId, filePath)))
             {
                 return("Error: unable to create shell explorer control.");
             }
         }
         return(shellId);
     }
     return((string)Application.Current.Dispatcher.Invoke(
                new Func <string>(() => { return OpenExplorerShell(filePath); })
                ));
 }