Exemple #1
0
        private void _pftTreeView_NodeChecked
        (
            object sender,
            TreeViewEventArgs e
        )
        {
            TreeNode treeNode = e.Node;

            if (ReferenceEquals(treeNode, null))
            {
                return;
            }

            PftNodeInfo nodeInfo = treeNode.Tag as PftNodeInfo;

            if (ReferenceEquals(nodeInfo, null))
            {
                return;
            }

            PftNode node = nodeInfo.Node;

            if (ReferenceEquals(node, null))
            {
                return;
            }

            node.Breakpoint = treeNode.Checked;
        }
Exemple #2
0
        private void _pftTreeView_CurrentNodeChanged
        (
            object sender,
            TreeViewEventArgs e
        )
        {
            PftNodeInfo currentNode = _pftTreeView.CurrentNode;

            if (ReferenceEquals(currentNode, null))
            {
                return;
            }

            PftNode pftNode = currentNode.Node;

            if (ReferenceEquals(pftNode, null))
            {
                return;
            }

            string text   = pftNode.Text ?? string.Empty;
            int    line   = pftNode.LineNumber - 1;
            int    column = pftNode.Column - 1;

            if (line < 0 || column < 0)
            {
                return;
            }

            TextLocation    start  = new TextLocation(column, line);
            TextLocation    end    = new TextLocation(column + text.Length, line);
            TextAreaControl editor = _pftBox.ActiveTextAreaControl;

            editor.SelectionManager.SetSelection(start, end);
            editor.Caret.Position = start;
        }
Exemple #3
0
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                return;
            }

            string rootPath = args[0];
            string fileName = args[1];
            string format   = args[2];

            Log.ApplyDefaultsForConsoleApplication();

            try
            {
                using (LocalProvider provider = new LocalProvider(rootPath))
                {
                    FileSpecification specification = new FileSpecification
                                                      (
                        IrbisPath.MasterFile,
                        provider.Database,
                        format
                                                      );
                    string source = provider.ReadFile(specification);
                    if (string.IsNullOrEmpty(source))
                    {
                        Console.WriteLine("No file: {0}", format);
                    }
                    else
                    {
                        PftContext context = new PftContext(null);
                        context.SetProvider(provider);
                        PftFormatter formatter = new PftFormatter(context);
                        formatter.ParseProgram(source);

                        PftSerializer.Save(formatter.Program, fileName);

                        PftProgram program
                            = (PftProgram)PftSerializer.Read(fileName);

                        PftSerializationUtility.VerifyDeserializedProgram
                        (
                            formatter.Program,
                            program
                        );

                        PftNodeInfo nodeInfo = program.GetNodeInfo();

                        AbstractOutput console = new ConsoleOutput();
                        PftNodeInfo.Dump(console, nodeInfo, 0);

                        byte[] bytes
                            = PftSerializer.ToMemory(formatter.Program);

                        for (int i = 0; i < 10000; i++)
                        {
                            PftProgram restoredProgram
                                = (PftProgram)PftSerializer.FromMemory(bytes);
                            console.WriteLine("{0}", i + 1);
                            //console.WriteLine(restoredProgram.ToString());
                        }

                        PftPrettyPrinter printer = new PftPrettyPrinter();
                        program.PrettyPrint(printer);
                        console.WriteLine(printer.ToString());
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }