コード例 #1
0
ファイル: PlotControl.cs プロジェクト: dwhobrey/BabelTools
 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(); })
                ));
 }
コード例 #2
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); })
                ));
 }
コード例 #3
0
 public static Shell OpenShell(XmlNode node)
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         if (node == null)
         {
             return(null);
         }
         string id          = Project.GetNodeAttributeValue(node, "name", "");
         string title       = Project.GetNodeAttributeValue(node, "title", "");
         int    width       = Convert.ToInt32(Project.GetNodeAttributeValue(node, "width", "300"));
         int    height      = Convert.ToInt32(Project.GetNodeAttributeValue(node, "height", "200"));
         int    x           = Convert.ToInt32(Project.GetNodeAttributeValue(node, "x", "-1"));
         int    y           = Convert.ToInt32(Project.GetNodeAttributeValue(node, "y", "-1"));
         int    windowState = Convert.ToInt32(Project.GetNodeAttributeValue(node, "windowstate", "0"));
         string workingDir  = Project.GetNodeAttributeValue(node, "workingdir", Project.GetProjectDir());
         return(Shell.OpenShell(title, width, height, x, y, windowState, id, workingDir));
     }
     return((Shell)Application.Current.Dispatcher.Invoke(
                new Func <Shell>(() => { return OpenShell(node); })
                ));
 }
コード例 #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); })
                ));
 }