Example #1
0
 public override void Execute(Engine engine)
 {
     ProcessStartInfo info = new ProcessStartInfo(engine.Expand(FileName));
     //info.UseShellExecute = false;
     if (Arguments != null)
         info.Arguments = engine.Expand(Arguments);
     if (Directory != null)
         info.WorkingDirectory = engine.Expand(Directory);
     Process.Start(info);
 }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();

            engine = Engine.Load("config.xml");

            session = new Session(engine);
            session.WidgetChanged += (sender, widget) => UpdateWidget(widget);
            session.CommandExecuted += (sender, lvl) => ClearInput();
            session.ExceptionThrown += (sender, e) => DisplayException(e);
            session.ScopeChanged += (sender, cmd) => ClearInput();

            noMatch.Content = "No completion";
        }
Example #3
0
        public void ExecuteCommand(Engine eng, Level lvl)
        {
            // Execute or change scope
            if (!lvl.Command.Executable)
            {
                Scope = lvl.Command;
            }
            else if (lvl.Execute(this))
            {
                // Only raise event and exit if command is actually executed
                CommandExecuted?.Invoke(this, lvl);

                // TODO: separate config & event
                if (eng.AutoExit)
                    Application.Current.Shutdown();
            }
        }
Example #4
0
 public static Engine Load(string file)
 {
     try
     {
         using (FileStream fs = File.OpenRead(file))
             return (Engine)serializer.Deserialize(fs);
     }
     catch (FileNotFoundException)
     {
         Engine engine = new Engine();
         engine.Save(file);
         return engine;
     }
 }
Example #5
0
 public override void Execute(Engine engine)
 {
     Application.Current.Shutdown(Code);
 }
Example #6
0
 public override void Execute(Engine engine)
 {
     engine.Variables[engine.Expand(Name)] = engine.Expand(Value);
 }
Example #7
0
 public abstract void Execute(Engine engine);
Example #8
0
 public Session(Engine eng)
 {
     Engine = eng;
     Scope = eng.Main;
 }