示例#1
0
        static void Main(string[] args)
        {
            using (var fr = new FlowRuntime())
            {
                var frc = new FlowRuntimeConfiguration();

                var pageBufferContainer = new DataContainer <PageBuffer>();

                var frontend = new Frontend();

                frc.AddFlow(new Main(new Formatter(),
                                     frontend));
                frc.AddFlow(new Features(new CommandlineParser(pageBufferContainer),
                                         new TextFileAdapter(),
                                         new LineBuffer(pageBufferContainer),
                                         new Pager(pageBufferContainer)));
                fr.Configure(frc);

                frontend.displayFirstPage += fr.CreateEventProcessor(".displayFirstPage");
                frontend.displayLastPage  += fr.CreateEventProcessor(".displayLastPage");
                frontend.displayNextPage  += fr.CreateEventProcessor(".displayNextPage");
                frontend.displayPrevPage  += fr.CreateEventProcessor(".displayPrevPage");

                //fr.Message += Console.WriteLine;

                fr.Process(new Message(".run", new[] { "test1.txt" }));

                fr.WaitForResult();
            }
        }
示例#2
0
        public void Run() {
            FlowRuntimeConfiguration.SynchronizationFactory = () => new SyncWithWPFDispatcher();
            var frc = new FlowRuntimeConfiguration();
            frc.AddStreamsFrom("appchatten.application.root.flow", Assembly.GetExecutingAssembly());

            var chat = new Chat(new QueueFinder<Message>());
            var mainWindow = new MainWindow();

            frc.AddAction<string>("anmelden", chat.Anmelden);
            frc.AddAction<string>("verbinden", chat.Verbinden);
            frc.AddFunc<string, Message>("absender_hinzufuegen", chat.Absender_hinzufuegen);
            frc.AddFunc<Message, Message>("versenden", chat.Versenden).MakeAsync();
            frc.AddFunc<Message, string>("formatieren", m => string.Format("{0}: {1}", m.Absender, m.Text));
            frc.AddAction<string>("anzeigen", mainWindow.MessageHinzufügen).MakeSync();
            frc.AddOperation(new Timer("timer", 500));
            frc.AddAction<Message>("empfangen", chat.Empfangen).MakeAsync();
            frc.AddAction<FlowRuntimeException>("fehler_anzeigen", ex => mainWindow.FehlerAnzeigen(ex.InnerException.Message)).MakeSync();

            using (var fr = new FlowRuntime(frc)) {
                fr.Message += Console.WriteLine;

                fr.UnhandledException += fr.CreateEventProcessor<FlowRuntimeException>(".exception");

                mainWindow.Anmelden += fr.CreateEventProcessor<string>(".anmelden");
                mainWindow.Verbinden += fr.CreateEventProcessor<string>(".verbinden");
                mainWindow.TextSenden += fr.CreateEventProcessor<string>(".senden");

                var app = new Application{MainWindow = mainWindow};
                app.Run(mainWindow);
            }
        }     
示例#3
0
        static void Main(string[] args)
        {
            using(var fr = new FlowRuntime())
            {
                var frc = new FlowRuntimeConfiguration();

                var pageBufferContainer = new DataContainer<PageBuffer>();

                var frontend = new Frontend();

                frc.AddFlow(new Main(new Formatter(),
                                    frontend));
                frc.AddFlow(new Features(new CommandlineParser(pageBufferContainer),
                                        new TextFileAdapter(),
                                        new LineBuffer(pageBufferContainer),
                                        new Pager(pageBufferContainer)));
                fr.Configure(frc);

                frontend.displayFirstPage += fr.CreateEventProcessor(".displayFirstPage");
                frontend.displayLastPage += fr.CreateEventProcessor(".displayLastPage");
                frontend.displayNextPage += fr.CreateEventProcessor(".displayNextPage");
                frontend.displayPrevPage += fr.CreateEventProcessor(".displayPrevPage");

                //fr.Message += Console.WriteLine;

                fr.Process(new Message(".run", new[]{"test1.txt"}));

                fr.WaitForResult();
            }
        }
示例#4
0
        public static void Main()
        {
            using (var flowRuntime = new FlowRuntime())
            {
                flowRuntime.AddStream(".in", "Dateien im Pfad ermitteln");
                flowRuntime.AddStream(".abort", "Ermittlung abbrechen");
                flowRuntime.AddStream("Dateien im Pfad ermitteln", "filtern");
                flowRuntime.AddStream("filtern", "map");

                var viewModel = new ViewModel();
                var mainWindow = new MainWindow(viewModel);
                var map = new Map(viewModel);

                var dateien_im_Pfad_ermitteln = new Dateien_im_Pfad_ermitteln();

                var flowOperationContainer = new FlowOperationContainer(() => new WpfSynchronize<IMessage>())
                    .AddFunc<string, IEnumerable<messages.Datei>>("Dateien im Pfad ermitteln", dateien_im_Pfad_ermitteln.Process)
                        .MakeAsync()
                    .AddAction("Ermittlung abbrechen", dateien_im_Pfad_ermitteln.Abbrechen)
                    .AddFunc<IEnumerable<messages.Datei>, IEnumerable<messages.Datei>>("filtern", Filtern_der_20_groessten_Dateien.Process)
                    .AddAction<IEnumerable<messages.Datei>>("map", map.Process)
                        .MakeSync();

                flowRuntime.AddOperations(flowOperationContainer.Operations);
                flowRuntime.UnhandledException += e => MessageBox.Show(e.InnerException.Message);

                mainWindow.Suchen += flowRuntime.CreateEventProcessor<string>(".in");
                mainWindow.Abbrechen += flowRuntime.CreateEventProcessor(".abort");

                var app = new Application {MainWindow = mainWindow};
                app.Run(app.MainWindow);
            }
        }
示例#5
0
        public static void Main(string[] args)
        {
            var twitterops = new TwitterOperations();
            var gui = new MainWindow();
            var ironmq = new IronMQOperations("AppZwitschern", TokenRepository.LoadFrom("ironmq.credentials.txt"));
            var serialisieren = new Serialization<Versandauftrag>();
            var urlShortener = new TinyUrlOperations();
            var compressor = new TextCompressor();

            FlowRuntimeConfiguration.SynchronizationFactory = () => new SyncWithWPFDispatcher();

            var config = new FlowRuntimeConfiguration()
                .AddStreamsFrom("az.application.flows.flow", Assembly.GetExecutingAssembly())
                .AddFunc<Versandauftrag, Versandauftrag>("versandauftrag_schnueren", twitterops.Versandauftrag_um_access_token_erweitern)
                .AddFunc<Versandauftrag, string>("serialisieren", serialisieren.Serialize)
                .AddAction<string>("enqueue", ironmq.Enqueue, true)
                .AddFunc<string, string[]>("extract_urls", compressor.Extract_Urls)
                .AddFunc<Tuple<string, Tuple<string,string>[]>,string>("replace_urls", compressor.Replace_Urls)
                .AddFunc<IEnumerable<string>, Tuple<String,string>[]>("shorten_urls", urlShortener.ShortenMany)
                .AddOperation(new AutoResetJoin<string, Tuple<string,string>[]>("join"))
                .AddOperation(new Throttle("throttle", 1000))
                .AddAction<string>("display_shortened_text", gui.ShortenedText).MakeSync()
                .AddAction("versandstatus_anzeigen", () => gui.Versandstatus("Versendet!")).MakeSync();

            using (var fr = new FlowRuntime(config)) {
                fr.UnhandledException += ex => MessageBox.Show(ex.InnerException.Message);
                fr.Message += Console.WriteLine;

                gui.Versenden += fr.CreateEventProcessor<Versandauftrag>(".versenden");
                gui.ShortenText += fr.CreateEventProcessor<string>(".shortenText");

                var app = new Application { MainWindow = gui };
                app.Run(gui);
            }
        }
示例#6
0
        public static void Main() {
            using (var fr = new FlowRuntime()) {
                fr.Message += Console.WriteLine;
                fr.UnhandledException += ex => MessageBox.Show(ex.ToString());

                var mainWindow = new MainWindow();
                var viewModel = new MainWindowVM();
                mainWindow.DataContext = viewModel;
                var mapper = new Mapper(viewModel);
                var metronom = new Metronom(new Play());
                var stopuhr = new Stopuhr();
                var pausenuhr = new Pausenuhr();
                var aufgabentimer = new Timer("aufgaben_timer");
                var pausentimer = new Timer("pausen_timer");
                var uebungsdauertimer = new Timer("uebungsdauer_timer");
                var repository = new Repository();

                var frc = new FlowRuntimeConfiguration();

                frc.AddStreamsFrom("metronom.logik.flows.root.flow", typeof(Metronom).Assembly);

                frc.AddAction<string>("aufgabe_laden", repository.Naechste_Aufgabe)
                    .AddAction<Metrum>("metrum_laden", repository.Naechstes_Metrum)
                    .AddAction("ende_der_aufgaben", repository.Ende_der_Aufgaben)
                    .AddAction<string>("aufgabe_anzeigen", mapper.Aufgabe_anzeigen)
                    .AddOperation(aufgabentimer)
                    .AddFunc<Metrum, int>("timer_konfigurieren", metronom.Timer_konfigurieren)
                    .AddAction("metronom_click", metronom.Click)
                    .AddFunc("uebungsdauer_timer_konfigurieren", stopuhr.Timer_konfigurieren)
                    .AddFunc("uebungsdauer_ermitteln", stopuhr.Uebungsdauer_ermitteln)
                    .AddOperation(uebungsdauertimer)
                    .AddAction<string>("uebungsdauer_anzeigen", mapper.Uebungsdauer_anzeigen)
                    .AddAction<string>("restdauer_anzeigen", mapper.Restdauer_anzeigen)
                    .AddAction("aufgabentimer_ausschalten", aufgabentimer.Stop)
                    .AddFunc("pausentimer_konfigurieren", pausenuhr.Pausentimer_konfigurieren)
                    .AddAction("pausentimer_ausschalten", pausentimer.Stop)
                    .AddFunc("restdauer_ermitteln", pausenuhr.Restdauer_ermitteln)
                    .AddOperation(pausentimer)
                    .AddAction<int>("restdauer_pruefen", pausenuhr.Restdauer_pruefen)
                    .AddAction("uebungsdauer_timer_ausschalten", uebungsdauertimer.Stop)
                    ;
                fr.Configure(frc);

                mainWindow.Start += fr.CreateEventProcessor(".start");
                mainWindow.Pause += fr.CreateEventProcessor(".pause");

                var app = new Application { MainWindow = mainWindow };
                app.Run(mainWindow);
            }
        }
示例#7
0
        public void Run() {
            var mainWindowViewModel = new MainWindowViewModel();
            var mainWindow = new MainWindow();
            mainWindow.DataContext = mainWindowViewModel;
            var app = new Application {
                MainWindow = mainWindow
            };

            var mapper = new Mapper(mainWindowViewModel);

            FlowRuntimeConfiguration.DispatcherFactory = () => new DispatchForWPF();

            var flowRuntimeConfguration = new FlowRuntimeConfiguration()
                .AddStreamsFrom("fotobrowser.root.flow", Assembly.GetExecutingAssembly())
                .AddFunc("arbeitsverzeichnis_ermitteln", () => Environment.GetCommandLineArgs()[1])
                .AddFunc<string, IEnumerable<contracts.Directory>>("unterverzeichnisse_ermitteln", Drives.Verzeichnisse_ermitteln)
                .AddAction<IEnumerable<contracts.Directory>>("verzeichnisse_mappen", mapper.MapDirectories).MakeDispatched()
                .AddFunc<string, IEnumerable<string>>("bilddateien_ermitteln", Drives.Bilddateien_ermitteln)
                .AddAction<IEnumerable<string>>("bilddateien_mappen", mapper.MapFilenames).MakeDispatched();

            using (var flowRuntime = new FlowRuntime(flowRuntimeConfguration)) {
                flowRuntime.Message += Console.WriteLine;
                flowRuntime.UnhandledException += Console.WriteLine;

                mainWindow.Refresh += flowRuntime.CreateEventProcessor<string>(".refresh");

                flowRuntime.Process(".start");
                app.Run(mainWindow);
            }
        }
示例#8
0
文件: Program.cs 项目: ralfw/dnp2012
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var operation = new Operationsschlange();
            var akku = new Zwischenergebnis();
            var ui = new WinMain();

            var config = new FlowRuntimeConfiguration()
                .AddStreamsFrom("Taschenrechner.root.flow", Assembly.GetExecutingAssembly())

                .AddFunc<int, int>("ergebnis_zwischenspeichern", akku.Merken)
                .AddFunc<Tuple<int, int, Operatoren>, int>("operanden_verknuepfen", Rechenwerk.Operanden_verknüpfen)
                .AddFunc<Rechenauftrag, int>("operation_speichern", operation.Einstellen)
                .AddPushCausality("pushc")
                .AddPopCausality("popc")
                .AddFunc<Tuple<int, int>, Tuple<int, int, Operatoren>>("vormalige_operation_laden", operation.Herausholen)
                .AddEventBasedComponent("akku", akku)
                .AddEventBasedComponent("ui", ui);

            using (var fr = new FlowRuntime(config))
            {
                fr.Message += Console.WriteLine;

                fr.UnhandledException += fr.CreateEventProcessor<FlowRuntimeException>(".error");

                Application.Run(ui);
            }
        }
示例#9
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            /*
             * The dialog/clock are outside the flow; they are viewed as part of the environment.
             * They are bound to the flow as event source using CreateEventProcessor().
             */
            using (var fr = new FlowRuntime())
            {
                var frc = new FlowRuntimeConfiguration();

                // Register streams
                frc.AddStreamsFrom("Alarm_clock.Flow2.flow", typeof(Program2).Assembly);

                // Register operations
                var dlg    = new Dialog2();
                var clock  = new Clock2();
                var player = new Soundplayer();

                frc.AddAction("Alarm switched off", dlg.Alarm_switched_off).MakeSync()
                .AddAction("Alarm switched on", dlg.Alarm_switched_on).MakeSync()
                .AddAction <TimeSpan>("Alarm time reached", Alarm_time_reached)
                .AddFunc <Tuple <DateTime, DateTime>, TimeSpan>("Calc time diff", Calc_time_diff)
                .AddAction <TimeSpan>("Display time diff", dlg.Display_time_diff).MakeSync()
                .AddManualResetJoin <DateTime, DateTime>("Join")
                .AddAction("Sound alarm", player.Start_playing)
                .AddAction("Stop alarm", player.Stop_playing);
                fr.Configure(frc);

                // Wire-up event sources
                dlg.SetAlarm      += fr.CreateEventProcessor <DateTime>(".setAlarm");
                dlg.ResetAlarm    += fr.CreateEventProcessor(".resetAlarm");
                clock.CurrentTime += fr.CreateEventProcessor <DateTime>(".now");

                fr.Message            += Console.WriteLine;
                fr.UnhandledException += Console.WriteLine;

                // Execute flow
                // Feature: start application
                Application.Run(dlg); // needs to run on this thread; cannot be done on flow runtime thread.
            }
        }
示例#10
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            /*
             * The dialog/clock are outside the flow; they are viewed as part of the environment.
             * They are bound to the flow as event source using CreateEventProcessor().
             */
            using(var fr = new FlowRuntime())
            {
                var frc = new FlowRuntimeConfiguration();

                // Register streams
                frc.AddStreamsFrom("Alarm_clock.Flow2.flow", typeof(Program2).Assembly);

                // Register operations
                var dlg = new Dialog2();
                var clock = new Clock2();
                var player = new Soundplayer();

                frc.AddAction("Alarm switched off", dlg.Alarm_switched_off).MakeSync()
                   .AddAction("Alarm switched on", dlg.Alarm_switched_on).MakeSync()
                   .AddAction<TimeSpan>("Alarm time reached", Alarm_time_reached)
                   .AddFunc<Tuple<DateTime, DateTime>, TimeSpan>("Calc time diff", Calc_time_diff)
                   .AddAction<TimeSpan>("Display time diff", dlg.Display_time_diff).MakeSync()
                   .AddManualResetJoin<DateTime, DateTime>("Join")
                   .AddAction("Sound alarm", player.Start_playing)
                   .AddAction("Stop alarm", player.Stop_playing);
                fr.Configure(frc);

                // Wire-up event sources
                dlg.SetAlarm += fr.CreateEventProcessor<DateTime>(".setAlarm");
                dlg.ResetAlarm += fr.CreateEventProcessor(".resetAlarm");
                clock.CurrentTime += fr.CreateEventProcessor<DateTime>(".now");

                fr.Message += Console.WriteLine;
                fr.UnhandledException += Console.WriteLine;

                // Execute flow
                // Feature: start application
                Application.Run(dlg); // needs to run on this thread; cannot be done on flow runtime thread.
            }
        }
示例#11
0
        public static void Main(string[] args)
        {
            var twitterops    = new TwitterOperations();
            var gui           = new MainWindow();
            var ironmq        = new IronMQOperations("AppZwitschern", TokenRepository.LoadFrom("ironmq.credentials.txt"));
            var serialisieren = new Serialization <Versandauftrag>();
            var urlShortener  = new TinyUrlOperations();
            var compressor    = new TextCompressor();

            FlowRuntimeConfiguration.SynchronizationFactory = () => new SyncWithWPFDispatcher();

            var config = new FlowRuntimeConfiguration()
                         .AddStreamsFrom("az.application.flows.flow", Assembly.GetExecutingAssembly())
                         .AddFunc <Versandauftrag, Versandauftrag>("versandauftrag_schnueren", twitterops.Versandauftrag_um_access_token_erweitern)
                         .AddFunc <Versandauftrag, string>("serialisieren", serialisieren.Serialize)
                         .AddAction <string>("enqueue", ironmq.Enqueue, true)
                         .AddFunc <string, string[]>("extract_urls", compressor.Extract_Urls)
                         .AddFunc <Tuple <string, Tuple <string, string>[]>, string>("replace_urls", compressor.Replace_Urls)
                         .AddFunc <IEnumerable <string>, Tuple <String, string>[]>("shorten_urls", urlShortener.ShortenMany)
                         .AddOperation(new AutoResetJoin <string, Tuple <string, string>[]>("join"))
                         .AddOperation(new Throttle("throttle", 1000))
                         .AddAction <string>("display_shortened_text", gui.ShortenedText).MakeSync()
                         .AddAction("versandstatus_anzeigen", () => gui.Versandstatus("Versendet!")).MakeSync();

            using (var fr = new FlowRuntime(config)) {
                fr.UnhandledException += ex => MessageBox.Show(ex.InnerException.Message);
                fr.Message            += Console.WriteLine;

                gui.Versenden   += fr.CreateEventProcessor <Versandauftrag>(".versenden");
                gui.ShortenText += fr.CreateEventProcessor <string>(".shortenText");


                var app = new Application {
                    MainWindow = gui
                };
                app.Run(gui);
            }
        }
示例#12
0
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var win = new WinDesigner();
            var nav = new Navigator();

            var frc = new FlowRuntimeConfiguration()
                      .AddStreamsFrom("npantarhei.interviz.root.flow", Assembly.GetExecutingAssembly())
                      .AddFunc <Tuple <string, string>[], Tuple <string, string> >("combine_sources", AssemblyResourceAdapter.Combine_sources)
                      .AddFunc <string, Tuple <Image, NodeMap> >("compile_dot_source", GraphVizAdapter.Compile_graph)
                      .AddFunc <string[], string>("compile_flow_to_dot_source", FlowCompiler.Compile_to_dot_source)
                      .AddAction <Tuple <string, string> >("display_flow", win.Display_flow).MakeSync()
                      .AddAction <Tuple <string[], int> >("display_flownames", win.Display_flownames).MakeSync()
                      .AddAction <Tuple <Image, NodeMap> >("display_graph", win.Display_graph).MakeSync()
                      .AddFunc <string[], string>("extract_filename_from_commandline", _ => _[0])
                      .AddFunc <Tuple <string[], int>, Tuple <string[], Tuple <string[], int> > >("extract_flownames", FlowCompiler.Extract_flownames)
                      .AddAction <Tuple <string[], string> >("extend_history", nav.Extend_history)
                      .AddFunc <Tuple <string[], string>, int>("find_flow_headline", FlowCompiler.Find_flow_headline)
                      .AddFunc <string, Tuple <Assembly, string[]> >("find_flow_resources", AssemblyResourceAdapter.Find_flow_resources)
                      .AddFunc <string, Tuple <string, string> >("load_flow_from_file", filename => new Tuple <string, string>(filename, File.ReadAllText(filename)))
                      .AddFunc <Tuple <Assembly, string[]>, Tuple <string, string>[]>("load_sources_from_resources", AssemblyResourceAdapter.Load_soures_from_resources)
                      .AddAction <int>("move_cursor_to_flow_header", win.Move_cursor_to_flow_header).MakeSync()
                      .AddAction <string[], Tuple <string[], string> >("navigate_backward_in_flow", nav.Navigate_backward)
                      .AddAction <string[], Tuple <string[], string> >("navigate_forward_in_flow", nav.Navigate_forward)
                      .AddAction <Tuple <string, string> >("save_flow", _ => File.WriteAllText(_.Item1, _.Item2))
                      .AddFunc <Tuple <string[], int>, string[]>("select_current_flow", FlowCompiler.Select_flow_by_line)
                      .AddFunc <Tuple <string[], Tuple <string[], int> >, Tuple <string[], int> >("select_flowname", FlowCompiler.Select_flowname)
                      .AddOperation(new Throttle("throttle_redrawings"));

            using (var fr = new FlowRuntime(frc)) {
                fr.Message            += Console.WriteLine;
                fr.UnhandledException += ex => MessageBox.Show(ex.ToString());

                win.Redraw += fr.CreateEventProcessor <Tuple <string[], int> >(".redraw");
                win.Load_flow_from_textfile += fr.CreateEventProcessor <string>(".loadFromTextfile");
                win.Load_flow_from_assembly += fr.CreateEventProcessor <string>(".loadFromAssembly");
                win.Save_flow         += fr.CreateEventProcessor <Tuple <string, string> >(".save");
                win.Jump_to_flow      += fr.CreateEventProcessor <Tuple <string[], string> >(".jump_to_flow");
                win.Navigate_backward += fr.CreateEventProcessor <string[]>(".navigate_backward");
                win.Navigate_forward  += fr.CreateEventProcessor <string[]>(".navigate_forward");

                fr.Process(".run", args);

                Application.Run(win);
            }
        }
示例#13
0
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var win = new WinDesigner();
            var nav = new Navigator();

            var frc = new FlowRuntimeConfiguration()
                            .AddStreamsFrom("npantarhei.interviz.root.flow", Assembly.GetExecutingAssembly())
                            .AddFunc<Tuple<string, string>[], Tuple<string, string>>("combine_sources", AssemblyResourceAdapter.Combine_sources)
                            .AddFunc<string, Tuple<Image, NodeMap>>("compile_dot_source", GraphVizAdapter.Compile_graph)
                            .AddFunc<string[], string>("compile_flow_to_dot_source", FlowCompiler.Compile_to_dot_source)
                            .AddAction<Tuple<string, string>>("display_flow", win.Display_flow).MakeSync()
                            .AddAction<Tuple<string[], int>>("display_flownames", win.Display_flownames).MakeSync()
                            .AddAction<Tuple<Image, NodeMap>>("display_graph", win.Display_graph).MakeSync()
                            .AddFunc<string[], string>("extract_filename_from_commandline", _ => _[0])
                            .AddFunc<Tuple<string[], int>, Tuple<string[], Tuple<string[], int>>>("extract_flownames", FlowCompiler.Extract_flownames)
                            .AddAction<Tuple<string[], string>>("extend_history", nav.Extend_history)
                            .AddFunc<Tuple<string[], string>, int>("find_flow_headline", FlowCompiler.Find_flow_headline)
                            .AddFunc<string, Tuple<Assembly, string[]>>("find_flow_resources", AssemblyResourceAdapter.Find_flow_resources)
                            .AddFunc<string, Tuple<string, string>>("load_flow_from_file", filename => new Tuple<string, string>(filename, File.ReadAllText(filename)))
                            .AddFunc<Tuple<Assembly, string[]>, Tuple<string, string>[]>("load_sources_from_resources", AssemblyResourceAdapter.Load_soures_from_resources)
                            .AddAction<int>("move_cursor_to_flow_header", win.Move_cursor_to_flow_header).MakeSync()
                            .AddAction<string[], Tuple<string[], string>>("navigate_backward_in_flow", nav.Navigate_backward)
                            .AddAction<string[], Tuple<string[], string>>("navigate_forward_in_flow", nav.Navigate_forward)
                            .AddAction<Tuple<string, string>>("save_flow", _ => File.WriteAllText(_.Item1, _.Item2))
                            .AddFunc<Tuple<string[], int>, string[]>("select_current_flow", FlowCompiler.Select_flow_by_line)
                            .AddFunc<Tuple<string[], Tuple<string[], int>>, Tuple<string[], int>>("select_flowname", FlowCompiler.Select_flowname)
                            .AddOperation(new Throttle("throttle_redrawings"));

            using (var fr = new FlowRuntime(frc)) {
                fr.Message += Console.WriteLine;
                fr.UnhandledException += ex => MessageBox.Show(ex.ToString());

                win.Redraw += fr.CreateEventProcessor<Tuple<string[], int>>(".redraw");
                win.Load_flow_from_textfile += fr.CreateEventProcessor<string>(".loadFromTextfile");
                win.Load_flow_from_assembly += fr.CreateEventProcessor<string>(".loadFromAssembly");
                win.Save_flow += fr.CreateEventProcessor<Tuple<string, string>>(".save");
                win.Jump_to_flow += fr.CreateEventProcessor<Tuple<string[], string>>(".jump_to_flow");
                win.Navigate_backward += fr.CreateEventProcessor<string[]>(".navigate_backward");
                win.Navigate_forward += fr.CreateEventProcessor<string[]>(".navigate_forward");

                fr.Process(".run", args);

                Application.Run(win);
            }
        }
示例#14
0
        public void Run() {
            FlowRuntimeConfiguration.SynchronizationFactory = () => new SyncWithWPFDispatcher();

            var frc = new FlowRuntimeConfiguration();
            frc.AddStreamsFrom("mp3viewer.application.root.flow", Assembly.GetExecutingAssembly());

            frc.AddAction<string, string>("mp3_dateien_ermitteln", filenameReader.Read);
            frc.AddFunc<string, Title>("titel_bilden", mp3TagsReader.Read).MakeAsync();
            frc.AddAction("clear", mapper.Clear).MakeSync();
            frc.AddFunc<Title, IRowVM>("titel_in_row_umwandeln", mapper.CreateRow);
            frc.AddAction<IRowVM>("map", mapper.Map).MakeSync();

            using (var fr = new FlowRuntime(frc)) {
                fr.Message += Console.WriteLine;

                mainWindow.Scan += fr.CreateEventProcessor<string>(".scan");

                var app = new Application {
                    MainWindow = (Window)mainWindow
                };
                app.Run((Window)mainWindow);
            }
        }
示例#15
0
文件: Program.cs 项目: ralfw/dnp2012
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var config = new FlowRuntimeConfiguration();

            config.AddStreamsFrom("WinScratchpad.flows.flow", Assembly.GetExecutingAssembly());

            config.AddFunc<string, string>("toUpper", Program.ToUpper).MakeParallel();
            config.AddFunc<string, string>("reverse", Program.Reverse);

            var dlg = new Dialog();
            config.AddAction<Correlation>("display", dlg.Display).MakeSync();
            config.AddOperation(new Correlator());

            using (var fr = new FlowRuntime(config))
            {
                dlg.Transform_text += fr.CreateEventProcessor<Correlation>(".transform_text");

                Application.Run(dlg);
            }
        }