private void OnMenuSendMenuCommand(object sender, EventArgs e)
        {
            MenuCommand command = sender as MenuCommand;
            Store       store   = this.CurrentDocData.Store;

            using (Transaction transaction =
                       store.TransactionManager.BeginTransaction("Send command"))
            {
                this.CurrentRobotsLanguageDocData.ValidationController.Validate(this.CurrentDocData.RootElement, ValidationCategories.Menu);
                if (CurrentRobotsLanguageDocData.ValidationController.ErrorMessages.Count == 0)
                {
                    RuntimeTextTemplate1 run = new RuntimeTextTemplate1((RobotModel)this.CurrentDocData.RootElement);
                    String pageContent       = run.TransformText();
                    //System.IO.File.WriteAllText(this.CurrentRobotsLanguageDocView.CurrentDiagram.Name + ".js", pageContent);
                    string hostname = ((RobotModel)CurrentDocData.RootElement).Hostname;

                    using (TcpClient client = new TcpClient(hostname, 8888))
                        using (BinaryWriter writer = new BinaryWriter(client.GetStream()))
                        {
                            writer.Write("directScript: " + pageContent);
                        }
                }
                transaction.Commit();
            }
        }
        private void OnMenuMyContextMenuCommand(object sender, EventArgs e)
        {
            MenuCommand command = sender as MenuCommand;
            Store       store   = this.CurrentDocData.Store;

            using (Transaction transaction =
                       store.TransactionManager.BeginTransaction("My command"))
            {
                this.CurrentRobotsLanguageDocData.ValidationController.Validate(this.CurrentDocData.RootElement, ValidationCategories.Menu);
                if (CurrentRobotsLanguageDocData.ValidationController.ErrorMessages.Count == 0)
                {
                    RuntimeTextTemplate1 run = new RuntimeTextTemplate1((RobotModel)this.CurrentDocData.RootElement);
                    String pageContent       = run.TransformText();
                    System.IO.File.WriteAllText(this.CurrentRobotsLanguageDocView.CurrentDiagram.Name + ".js", pageContent);
                    //SDTE dte = (SDTE) this.CurrentRobotsLanguageDocView.CurrentDiagram.GetService(typeof(SDTE));
                    EnvDTE.DTE dte = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SD‌​TE)) as EnvDTE.DTE;
                    dte.ItemOperations.OpenFile(this.CurrentRobotsLanguageDocView.CurrentDiagram.Name + ".js");
                    //this.CurrentRobotsLanguageDocData.Load(this.CurrentRobotsLanguageDocView.CurrentDiagram.Name + ".js", 3, 1);
                }
                transaction.Commit();
            }
        }
Beispiel #3
0
 public Generator(RobotModel r, RuntimeTextTemplate1 w)
 {
     RobotModel = r;
     writer     = w;
     //controller = (RobotsLanguageDocData) this.CurrentDocData.ValidationController;
 }