Ejemplo n.º 1
1
        public PlatformWpf()
            : base(null, true)
        {
            var app = new Application ();
            var slCanvas = new Canvas ();
            var win = new Window
            {
                Title = Title,
                Width = Width,
                Height = Height,
                Content = slCanvas
            };

            var cirrusCanvas = new CirrusCanvas(slCanvas, Width, Height);
            MainCanvas = cirrusCanvas;

            win.Show ();

            EntryPoint.Invoke (null, null);

            var timer = new DispatcherTimer ();
            timer.Tick += runDelegate;
            timer.Interval = TimeSpan.FromMilliseconds (1);

            timer.Start ();
            app.Run ();
        }
Ejemplo n.º 2
1
		public static void Main()
		{
			// original (doesn't work with snoop, well, can't find a window to own the snoop ui)
			Window window = new Window();
			window.Title = "Say Hello";
			window.Show();

			Application application = new Application();
			application.Run();


			// setting the MainWindow directly (works with snoop)
//			Window window = new Window();
//			window.Title = "Say Hello";
//			window.Show();
//
//			Application application = new Application();
//			application.MainWindow = window;
//			application.Run();


			// creating the application first, then the window (works with snoop)
//			Application application = new Application();
//			Window window = new Window();
//			window.Title = "Say Hello";
//			window.Show();
//			application.Run();


			// creating the application first, then the window (works with snoop)
//			Application application = new Application();
//			Window window = new Window();
//			window.Title = "Say Hello";
//			application.Run(window);
		}	}
Ejemplo n.º 3
0
        public static void Main()
        {
            App = new Application();
            App.Startup += (o, e) =>
            {
                //EU AWS
                DAOFactory.ConnectionString =
                    "SERVER=ec2-79-125-81-60.eu-west-1.compute.amazonaws.com;" +
                    "DATABASE=px3;" +
                    "UID=px3;" +
                    "PASSWORD=abcd1234;";

                //LOCAL
                /*DAOFactory.ConnectionString =
                "SERVER=localhost;" +
                "DATABASE=px3;" +
                "UID=root;" +
                "PASSWORD=abcd1234;";*/

                RunApp(CurrentUser);
            };
            try
            {
                App.Run();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " Unfortunately the application couldn't be recovered, and is therefore restarting.");
                System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown();
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            i = new Image();
            RenderOptions.SetBitmapScalingMode(i, BitmapScalingMode.NearestNeighbor);
            RenderOptions.SetEdgeMode(i, EdgeMode.Aliased);

            w = new Window();
            w.Content = i;
            w.Show();

            writeableBitmap = new WriteableBitmap(
                (int)w.ActualWidth,
                (int)w.ActualHeight,
                96,
                96,
                PixelFormats.Bgr32,
                null);

            i.Source = writeableBitmap;

            i.Stretch = Stretch.None;
            i.HorizontalAlignment = HorizontalAlignment.Left;
            i.VerticalAlignment = VerticalAlignment.Top;

            i.MouseMove += new MouseEventHandler(i_MouseMove);
            i.MouseLeftButtonDown +=
                new MouseButtonEventHandler(i_MouseLeftButtonDown);
            i.MouseRightButtonDown +=
                new MouseButtonEventHandler(i_MouseRightButtonDown);

            w.MouseWheel += new MouseWheelEventHandler(w_MouseWheel);

            Application app = new Application();
            app.Run();
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
    override protected void OnStart()
    {
      appViewModel = new PeerCastAppViewModel(Application);
      versionChecker = new PeerCastStation.UI.Updater();
      notifyIconThread = new Thread(() => {
        notifyIconManager = new NotifyIconManager(appViewModel, this);
        versionChecker.NewVersionFound += (sender, e) => {
          notifyIconManager.NotifyNewVersions(e.VersionDescriptions);
        };
        notifyIconManager.Run();
      });
      notifyIconThread.SetApartmentState(ApartmentState.STA);
      notifyIconThread.Start();
      versionCheckTimer = new Timer(OnVersionCheckTimer, null, 1000, 1000*7200);

      mainThread = new Thread(() => {
        var app = new Application();
        var settings = Application.Settings.Get<WPFSettings>();
        mainWindow = new MainWindow(appViewModel);
        if (settings.ShowWindowOnStartup) mainWindow.Show();
        app.Run();
      });
      mainThread.Name = "WPF UI Thread";
      mainThread.SetApartmentState(ApartmentState.STA);
      mainThread.Start();
    }
        public ConvertToWriteableBitmap()
        {
            WriteableBitmap wb = null;

            // OpenCVによる画像処理 (Threshold)
            using (IplImage src = new IplImage(Const.ImageLenna, LoadMode.GrayScale))
            using (IplImage dst = new IplImage(src.Size, BitDepth.U8, 1))
            {
                src.Smooth(src, SmoothType.Gaussian, 5);
                src.Threshold(dst, 0, 255, ThresholdType.Otsu);
                // IplImage -> WriteableBitmap
                wb = dst.ToWriteableBitmap(PixelFormats.BlackWhite);
                //wb = WriteableBitmapConverter.ToWriteableBitmap(dst, PixelFormats.BlackWhite);
            }

            // WPFのWindowに表示してみる
            Image image = new Image { Source = wb };
            Window window = new Window
            {
                Title = "from IplImage to WriteableBitmap",
                Width = wb.PixelWidth,
                Height = wb.PixelHeight,
                Content = image
            };

            Application app = new Application();
            app.Run(window);
        }
Ejemplo n.º 9
0
        protected override void Run()
        {
            RxApp.LoggerFactory = _ => new FileLogger("Squirrel") { Level = ReactiveUIMicro.LogLevel.Info };
            ReactiveUIMicro.RxApp.ConfigureFileLogging(); // HACK: we can do better than this later

            theApp = new Application();

            // NB: These are mirrored instead of just exposing Command because
            // Command is impossible to mock, since there is no way to set any
            // of its properties
            DisplayMode = Command.Display;
            Action = Command.Action;

            this.Log().Info("WiX events: DisplayMode: {0}, Action: {1}", Command.Display, Command.Action);

            setupWiXEventHooks();

            var bootstrapper = new WixUiBootstrapper(this);

            theApp.MainWindow = new RootWindow
            {
                viewHost = { Router = bootstrapper.Router }
            };

            MainWindowHwnd = IntPtr.Zero;
            if (Command.Display == Display.Full)
            {
                MainWindowHwnd = new WindowInteropHelper(theApp.MainWindow).Handle;
                uiDispatcher = theApp.MainWindow.Dispatcher;
                theApp.Run(theApp.MainWindow);
            }

            Engine.Quit(0);
        }
Ejemplo n.º 10
0
        private static void EnsureApplication()
        {
            lock(m_appInitializingSync)
            {
                if(Application.Current != null)
                {
                    return;
                }

                var waitForApplication = new TaskCompletionSource<bool>();
                Thread thread = new Thread(new ThreadStart(() =>
                    {
                        var app = new Application();
                        app.Startup += (s, e) => { waitForApplication.SetResult(true); };
                        app.Run();
                    }));

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();

                //Task task = new Task(new Action(() =>
                //{
                //    var app = new Application();
                //    app.Startup += (s, e) => { waitForApplication.SetResult(true); };
                //    app.Run();
                //}));

                //task.Start();

                waitForApplication.Task.Wait();
            }
        }
Ejemplo n.º 11
0
        private static void Main()
        {
            CosturaUtility.Initialize();

            // enabled TLS1.2
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            var app = new System.Windows.Application()
            {
                ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose
            };

            app.DispatcherUnhandledException           += App_DispatcherUnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

            app.Run(new MainView());

#if false
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
#endif
        }
Ejemplo n.º 12
0
        public void RunApplication(Application app)
        {
            try
            {
                DynamoModel.RequestMigrationStatusDialog += MigrationStatusDialogRequested;

                var model = Dynamo.Applications.StartupUtils.MakeModel(false);

                viewModel = DynamoViewModel.Start(
                    new DynamoViewModel.StartConfiguration()
                    {
                        CommandFilePath = commandFilePath,
                        DynamoModel = model,
                        Watch3DViewModel = HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(new Watch3DViewModelStartupParams(model), model.Logger),
                        ShowLogin = true
                    });

                var view = new DynamoView(viewModel);
                view.Loaded += (sender, args) => CloseMigrationWindow();

                app.Run(view);

                DynamoModel.RequestMigrationStatusDialog -= MigrationStatusDialogRequested;

            }

            catch (Exception e)
            {
                try
                {
#if DEBUG
                    // Display the recorded command XML when the crash happens, 
                    // so that it maybe saved and re-run later
                    if (viewModel != null)
                        viewModel.SaveRecordedCommand.Execute(null);
#endif

                    DynamoModel.IsCrashing = true;
                    InstrumentationLogger.LogException(e);
                    StabilityTracking.GetInstance().NotifyCrash();

                    if (viewModel != null)
                    {
                        // Show the unhandled exception dialog so user can copy the 
                        // crash details and report the crash if she chooses to.
                        viewModel.Model.OnRequestsCrashPrompt(null,
                            new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace));

                        // Give user a chance to save (but does not allow cancellation)
                        viewModel.Exit(allowCancel: false);
                    }
                }
                catch
                {
                }

                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
Ejemplo n.º 13
0
        static void Main()
        {
            //the WPF application object will be the main UI loop
            System.Windows.Application wpfApplication = new System.Windows.Application
            {
                //otherwise the application will close when all WPF windows are closed
                ShutdownMode = ShutdownMode.OnExplicitShutdown
            };
            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

            //set the WinForms properties
            //notice how you don't need to do anything else with the Windows Forms Application (except handle exceptions)
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            WpfProgramAddWinForms p = new WpfProgramAddWinForms();

            p.ExitRequested += (sender, e) =>
            {
                wpfApplication.Shutdown();
            };

            Task programStart = p.StartAsync();

            HandleExceptions(programStart, wpfApplication);

            wpfApplication.Run();
        }
Ejemplo n.º 14
0
 static void Main()
 {
     var app = new Application();
     var window = new RegexEditor();
     app.MainWindow = window;
     app.Run(window);
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            var cards       = new Game().GetData();
            var application = new System.Windows.Application();

            application.Run(new StartWindow(cards));
        }
Ejemplo n.º 16
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);
            }
        }
        private void EnsureFileUpdateWindow()
        {
            lock (_Lock)
            {
                if (_FileUpdateWindow == null)
                {
                    AutoResetEvent wait = new AutoResetEvent(false);

                    ThreadStart threadStart =
                        delegate
                        {
                            _FileUpdateWindow = new FileUpdateWindow();
                            _FileUpdateWindow.DeploymentManifest = DeploymentManifest;
                            _FileUpdateWindow.TotalUpdateSize = TotalUpdateSize;
                            wait.Set();

                            _FileUpdateWindow.Show();
                            _FileUpdateWindow.SlideUp();

                            Application app = new Application();
                            app.Run(_FileUpdateWindow);
                        };
                    Thread thread = new Thread(threadStart);
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();

                    wait.WaitOne();
                }
            }
        }
Ejemplo n.º 18
0
        public ConvertToWriteableBitmap()
        {
            WriteableBitmap wb = null;

            // OpenCV processing
            using (var src = new IplImage(FilePath.Image.Lenna, LoadMode.GrayScale))
            using (var dst = new IplImage(src.Size, BitDepth.U8, 1))
            {
                src.Smooth(src, SmoothType.Gaussian, 5);
                src.Threshold(dst, 0, 255, ThresholdType.Otsu);
                // IplImage -> WriteableBitmap
                wb = dst.ToWriteableBitmap(PixelFormats.BlackWhite);
                //wb = WriteableBitmapConverter.ToWriteableBitmap(dst, PixelFormats.BlackWhite);
            }

            // Shows WriteableBitmap to WPF window
            var image = new Image { Source = wb };
            var window = new Window
            {
                Title = "from IplImage to WriteableBitmap",
                Width = wb.PixelWidth,
                Height = wb.PixelHeight,
                Content = image
            };

            var app = new Application();
            app.Run(window);
        }
Ejemplo n.º 19
0
 // This method is the main entry point to start the application. Call after all wiring and initilization is completed.
 public void Run()
 {
     window.Content = iuiStructure.GetWPFElement();
     System.Windows.Application app = new System.Windows.Application();
     Console.WriteLine("MainWindow Running");
     app.Run(window);
 }
Ejemplo n.º 20
0
        public static void Main() {
            var boardUi = new BoardUI();
            var interactors = new Interactors();
            var sync = new Synchronizer<IEnumerable<Task>>();

            // Start
            var columns_and_tasks = interactors.Start();
            boardUi.Setup_Board(columns_and_tasks);

            // Refresh
            sync.Result += tasks => boardUi.Set_Tasks(tasks);
            interactors.Refresh(tasks => sync.Process(tasks));

            // Create Task
            boardUi.Create_Task += text => {
                var task = interactors.Create_Task(text);
                boardUi.Add_Task(task);
            };

            // Show Task
            boardUi.Show_Task += (column, position) => {
                var text = interactors.Show_Task(column, position);
                boardUi.Display_Text(text);
            };

            // Move Task
            boardUi.Move_Task += (column, position, direction) => {
                var tasks_and_selectedTask = interactors.Move_Task(column, position, direction);
                boardUi.Set_Tasks(tasks_and_selectedTask.Item1, tasks_and_selectedTask.Item2);
            };

            var app = new Application { MainWindow = boardUi };
            app.Run(boardUi);
        }
Ejemplo n.º 21
0
 static void Main()
 {
     HostView hostView = new HostView();
     WorkflowApplicationManager manager = new WorkflowApplicationManager(hostView);
     Application application = new Application();
     application.Run(hostView);
 }
Ejemplo n.º 22
0
		public static void Main()
		{
			Application app = new Application();
			Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
			app.Startup += new StartupEventHandler(app_Startup);
			app.Run();
		}
Ejemplo n.º 23
0
        private static void MakeStandaloneAndRun(string commandFilePath, ref DynamoViewModel viewModel)
        {
            DynamoPathManager.Instance.InitializeCore(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            DynamoPathManager.PreloadAsmLibraries(DynamoPathManager.Instance);
            
            var model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
                {
                    Preferences = PreferenceSettings.Load()
                });

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
                {
                    CommandFilePath = commandFilePath,
                    DynamoModel = model
                });

            var view = new DynamoView(viewModel);

            var app = new Application();
            app.Run(view);
        }
Ejemplo n.º 24
0
        public ConvertToBitmapSource()
        {
            BitmapSource bs = null;

            // OpenCVによる画像処理 (Threshold)
            using (IplImage src = new IplImage(Const.ImageLenna, LoadMode.GrayScale))
            using (IplImage dst = new IplImage(src.Size, BitDepth.U8, 1))
            {
                src.Smooth(src, SmoothType.Gaussian, 5);
                src.Threshold(dst, 0, 255, ThresholdType.Otsu);
                // IplImage -> BitmapSource
                bs = dst.ToBitmapSource();
                //bs = BitmapSourceConverter.ToBitmapSource(dst);
            }

            // WPFのWindowに表示してみる
            Image image = new Image { Source = bs };
            Window window = new Window
            {
                Title = "from IplImage to BitmapSource",
                Width = bs.PixelWidth,
                Height = bs.PixelHeight,
                Content = image
            };

            Application app = new Application();
            app.Run(window);
        }
Ejemplo n.º 25
0
		static void Main()
		{
			//the WPF application object will be the main UI loop
			System.Windows.Application wpfApplication = new System.Windows.Application
			{
				//otherwise the application will close when all WPF windows are closed
				ShutdownMode = ShutdownMode.OnExplicitShutdown 
			};
			SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

			//set the WinForms properties
			//notice how you don't need to do anything else with the Windows Forms Application (except handle exceptions)
			System.Windows.Forms.Application.EnableVisualStyles();
			System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
			
			WpfProgramAddWinForms p = new WpfProgramAddWinForms();
			p.ExitRequested += (sender, e) =>
			{
				wpfApplication.Shutdown();
			};

			Task programStart = p.StartAsync();
			HandleExceptions(programStart, wpfApplication);

			wpfApplication.Run();
		}
Ejemplo n.º 26
0
        public MainClass()
        {
            window = new MainWindow();
            window.OnClickEvent += OnPinCode_ButtonClickEvent;
            window.Closing += new CancelEventHandler(MainWindow_Closing);
            window.Show();

            Task.Run(() => {
                trialThread = new Thread(TrialTimer);
                trialThread.Start();

                server = new QuitServer();
                serverThread = new Thread(server.Run);
                serverThread.Start();

                twitter = new Twitter();
                twitter.OnRequestEvent += OnRequest_TwitterEvent;
                twitter.OnIndexTextEvent += OnIndexText_TwitterEvent;
                twitter.OnAuthCompleteEvent += OnAuthComplete_TwitterEvent;
                twitter.OnAuthErrorEvent += OnAuthError_TwitterEvent;
                twitter.Init();
            });

            app = new Application();
            app.Run(window);
        }
Ejemplo n.º 27
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);
            }
        }     
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            Standard s1 = new Standard("ГОСТ Р 21.1101-2009");
            Standard s2 = new Standard("ГОСТ", "2.101");
            HashSet<Standard> sl1 = new HashSet<Standard>();
            HashSet<Standard> sl2 = new HashSet<Standard>();

            sl1.Add(s1);
            sl1.Add(s2);

            string[] test = { "tesT", "best", "rest" };
            IEnumerable<string> tt = test.Take(test.Length - 1).ToList();

            ConfigManager.ConfigManager cm = ConfigManager.ConfigManager.Instance;
            HashSet<Document> s1d = s1.Check();
            Console.WriteLine(s1d.First());

            string str = "333-ГОСТ--444";
            Console.WriteLine(str.cleanAllWithWhiteList());
            NormaCS ncs = new NormaCS(sl1);
            ncs.checkStandards();

            ReportWindow.Main mn = new ReportWindow.Main(ncs.Documents);

            Application app = new Application();
            app.Run(mn);
        }
Ejemplo n.º 29
0
 static void Main(string[] args)
 {
     Application app = new Application();
     MainWindow win = new MainWindow();
     //TestWnd win = new TestWnd();
     app.Run(win);
 }
Ejemplo n.º 30
0
        public static void Main(string[] args)
        {
            var app = new Application();
            Window wind = new PackageBuilderMainWindow();

            app.Run(wind);
        }
Ejemplo n.º 31
0
 public static void UiThread(object arg)
 {
     var app = new Application();
     var window = new MainWindow();
     window.onClosed += window_onClosed;
     app.Run(window);
 }
Ejemplo n.º 32
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += (args, e) => Log.Debug(e.ExceptionObject.ToString());

            Settings.KeyBindings.Initialize();

            var window = new EditorWindow();
            var context = new GxContext(window.DrawTarget);
            context.InitContext();

            InterfaceManager.Instance.Initialize(window.DrawTarget, context);
            WorldFrame.Instance.Initialize(window.DrawTarget, context);
            WorldFrame.Instance.OnResize((int) window.RenderSize.Width, (int) window.RenderSize.Height);

            InterfaceManager.Instance.RenderWindow.OnLoadFinished();

            var app = new Application();
            var timer = new DispatcherTimer(TimeSpan.FromMilliseconds(10), DispatcherPriority.ApplicationIdle,
                (sender, args) =>
                {
                    context.BeginFrame();
                    WorldFrame.Instance.OnFrame();
                    InterfaceManager.Instance.OnFrame();
                    context.EndFrame();
                }, app.Dispatcher);

            app.Run(window);

            WorldFrame.Instance.Shutdown();
        }
Ejemplo n.º 33
0
        public static void Main(string[] args)
        {
#if DEBUG
            if (string.IsNullOrEmpty(AppDomain.CurrentDomain.GetData("FX_PRODUCT_VERSION") as string))
            {
                System.Diagnostics.Debug.Fail(".deps.json not deployed");
            }
#endif

            using (var xamlApp = new XamlApp())
            {
                var wpfApp = new SW.Application();


                var rootPage = new ControlPlaygroundUwpLib.RootPage();
                rootPage.Dummy = new DummyFromNetCore();

                var window = new MainWindow()
                {
                    SnapsToDevicePixels = true,
                    Background          = new SW.Media.SolidColorBrush(Colors.OrangeRed),

                    Content = new WindowsXamlHost()
                    {
                        SnapsToDevicePixels = true,
                        Child = rootPage,
                    }
                };


                wpfApp.Run(window);
            }
        }
Ejemplo n.º 34
0
        public static void Main(string[] args) {
            var mainWindow = new MainWindow();
            var interactors = new Interactors();

            mainWindow.Resize += size => {
                var text = interactors.Resize(size);
                mainWindow.Seite_anzeigen(text);
            };

            mainWindow.Vorwärts += () => {
                var text = interactors.Vorwärts_blättern();
                mainWindow.Seite_anzeigen(text);
            };

            mainWindow.Rückwärts += () => {
                var text = interactors.Rückwärts_blättern();
                mainWindow.Seite_anzeigen(text);
            };

            var seite = interactors.Start();
            mainWindow.Seite_anzeigen(seite);

            var app = new Application { MainWindow = mainWindow };
            app.Run(mainWindow);
        }
Ejemplo n.º 35
0
        private void STAThreadWorker()
        {
            MessageBox.Show("STAThreadWorker" + Thread.CurrentThread.ManagedThreadId.ToString());
            Debug.WriteLine(string.Format("STAThreadWorker, TheadId:{0}", Thread.CurrentThread.ManagedThreadId));

            if (System.Windows.Application.Current == null)
            {
                lock (_locker)
                {
                    _app = new System.Windows.Application();
                    _app.DispatcherUnhandledException += app_DispatcherUnhandledException;
                    _app.SessionEnding += _app_SessionEnding;

                    //This is very important
                    _app.ShutdownMode = ShutdownMode.OnExplicitShutdown;

                    _app.Startup += _app_Startup;
                }
                _app.Run();
            }
            else
            {
                lock (_locker)
                {
                    _app = System.Windows.Application.Current;

                    _appStarted.Set();
                }
            }
        }
Ejemplo n.º 36
0
 public override void RunApplication()
 {
     dispatcherTimer          = new DispatcherTimer();
     dispatcherTimer.Tick    += TimerTick;
     dispatcherTimer.Interval = TimeSpan.FromMilliseconds(10);
     dispatcherTimer.Start();
     application.Run();
 }
        protected override void Run()
        {
            Application app = new Application();
            CaliburnMicroBootstrapper bootstrapper = new CaliburnMicroBootstrapper(this);
            app.Run();

            this.Engine.Quit(0);
        }
Ejemplo n.º 38
0
        private static void InitializeComponent()
        {
            var handle = GetConsoleWindow();

            ShowWindow(handle, SW_HIDE);
            var app = new System.Windows.Application();

            win = new Window();
            var grid = new Grid();

            win.Title   = "TaskSchedulerFromCurrentSynchronizationContext";
            win.Height  = 350;
            win.Width   = 525;
            win.Content = grid;
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            var Button1 = new Button()
            {
                Name = "Button1", Content = "実行(例外発生しない)", Height = 30, Width = 150
            };

            grid.Children.Add(Button1);
            var Button2 = new Button()
            {
                Name = "Button2", Content = "実行(例外発生)", Height = 30, Width = 150, HorizontalAlignment = HorizontalAlignment.Left
            };

            grid.Children.Add(Button2);
            Grid.SetColumn(Button2, 1);

            TextBox1 = new TextBox()
            {
                Name = "TextBox1", AcceptsReturn = true, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Auto
            };
            grid.Children.Add(TextBox1);
            Grid.SetRow(TextBox1, 1);
            Grid.SetColumnSpan(TextBox1, 2);

            Button1.Click += Button1_Click;
            Button2.Click += Button2_Click;

            app.Run(win);
        }
Ejemplo n.º 39
0
 public static void Main()
 {
     System.Windows.Application app = new System.Windows.Application();
     app.Run(new Hyperplan.Selenium.Window()
     {
         Title   = "Temperature Converter",
         Content = new ConverterView().UIElement
     });
 }
        static void Main(String[] args)
        {
            F.Application.EnableVisualStyles();
            F.Application.SetCompatibleTextRenderingDefault(false);
            var w1 = new Window1();

            System.Windows.Application app = new System.Windows.Application();
            app.Run(w1);
        }
Ejemplo n.º 41
0
        public void Run(System.Windows.Application app = null)
        {
            if (app == null)
            {
                app = CreateApp();
            }

            app.Run(window);
        }
Ejemplo n.º 42
0
        private static void OpenWindow(List <double> trainErrors, List <double> cvErrors)
        {
            //Exception(Cannot create more than one System.Windows.Application instance in the same AppDomain.)
            //is thrown at the second iteration.
            var app    = new System.Windows.Application();
            var window = new MainWindow(trainErrors, cvErrors);

            app.Run(window);
            //User  closes the opened window manually.
        }
Ejemplo n.º 43
0
        static void Main(string[] args)
        {
            var application = new Application();

            Forms.Init();
            var formsApplicationPage = new FormsApplicationPage();

            formsApplicationPage.LoadApplication(new App());
            application.Run(formsApplicationPage);
        }
Ejemplo n.º 44
0
 /// <summary>
 /// Creates the setup wizard and runs the application thread.
 /// </summary>
 private void Run()
 {
     app         = new Application();
     setupWizard = new SetupWizard(installStartEvent)
     {
         Session = session
     };
     setupWizard.InitializeComponent();
     setupWizard.Title = $"winprint {session["ProductVersion"]} installer";
     app.Run(setupWizard);
     installExitEvent.Set();
 }
Ejemplo n.º 45
0
        static void Main(string[] args)
        {
            var app    = new System.Windows.Application();
            var window = new Window();

            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.Width   = 300;
            window.Height  = 300;
            window.Title   = "Mouse Mover";
            window.Loaded += Window_Loaded;
            app.Run(window);
        }
Ejemplo n.º 46
0
        public static void Main()
        {
            //Set our thread name for tracing.
            Thread.CurrentThread.Name = Properties.Resources.Global_ApplicationName;

            //Generate application.
            System.Windows.Application thisApp = new System.Windows.Application();
            thisApp.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);

            //Get our settings so we can see if debug is on or off.
            App.IsDebug = Properties.Settings.Default.DebugEnabled;

            thisApp.Run(new UI.wpfMasterForm());
        }
Ejemplo n.º 47
0
 public static void Main()
 {
     System.Windows.Application app = new System.Windows.Application();
     app.Run(new Window().Let(w =>
     {
         w.Title   = "Window Size App";
         w.Content = new TextBlock()
         {
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment   = VerticalAlignment.Center,
             FontSize            = 50.0,
             _Text_ = new Driver <string>(() => $"[{w.Width}x{w.Height}]")
         };
     }));
 }
Ejemplo n.º 48
0
            /// <summary>
            /// Runs the application
            /// </summary>
            public int Run(IAsynchronousHostableProgram programToHost)
            {
                try
                {
                    programToHost.ExitRequested += programToHost_ExitRequested;

                    Task programStart = programToHost.StartAsync();
                    HandleExceptions(programStart);

                    return(m_wpfApplication.Run());
                }
                finally
                {
                    //it is good practice to unsubscribe from events on objects that have longer lifetimes than the event handler
                    programToHost.ExitRequested -= programToHost_ExitRequested;
                }
            }
        static void Main(string[] args) {

            //Initialize CoreHost (we can do it in Window Initialize but this way
            //we don't even pop the form if Initialize fails

            ArcGIS.Core.Hosting.Host.Initialize();//this will throw!

            Application app = new Application();
            w = new Window();
            w.Height = 500;
            w.Width = 700;
            Grid g = new Grid();
            g.Children.Add(new GDBGrid());
            w.Content = g;
            w.Title = "ArcGIS Pro CoreHost GDB Sample: File GDB Reader";
            app.Run(w);
            
        }
Ejemplo n.º 50
0
        static void Main(string[] args)
        {
            var application = new Application();

            Forms.Init();
            var formsApplicationPage = new FormsApplicationPage();

            formsApplicationPage.LoadApplication(new XamarinNeller.App());

            Task.Run(() =>
            {
                Task.Delay(1000).Wait();

                application.Dispatcher.InvokeAsync(() =>
                {
                    var window = new Window()
                    {
                        Height = 600,
                        Width  = 600
                    };

                    var viewPage = new ViewPage()
                    {
                        HeightRequest = 500,
                        WidthRequest  = 500
                    };

                    var pageRenderer = new PageRenderer();

                    var mainPage = new MainPage();
                    pageRenderer.SetElement(viewPage);

                    //var formsContentLoader = new FormsContentLoader();
                    //var content = formsContentLoader.LoadContentAsync(window,null, mainPage,new CancellationToken()).Result;

                    var frameworkElement = pageRenderer.GetNativeElement();
                    window.Content       = frameworkElement;
                    window.Show();
                });
            });

            application.Run();
        }
Ejemplo n.º 51
0
        static void RunUnderApplication(Activity activity)
        {
            Application application = new System.Windows.Application()
            {
                ShutdownMode = ShutdownMode.OnExplicitShutdown
            };

            application.Startup += delegate
            {
                WorkflowApplication wfApp = new WorkflowApplication(activity);
                wfApp.SynchronizationContext = SynchronizationContext.Current;
                wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
                {
                    application.Shutdown();
                };
                wfApp.Run();
            };
            application.Run();
        }
Ejemplo n.º 52
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                FreeConsole();
                var app         = new MainWindow();
                var application = new System.Windows.Application();
                application.Run(app);
                return;
            }

            else
            {
                if (args[0].Equals("dldata"))
                {
                    Getstockdata();
                }

                //Getstockind();
                //complete message
            }
        }
Ejemplo n.º 53
0
        private static void WpfMainMethod()
        {
            // Create a new WPF application.
            Application = new Application {
                ShutdownMode = ShutdownMode.OnExplicitShutdown
            };

            // Filter WPF message loop to forward keyboard messages to the Windows Forms
            // message loop. If this is uncommented, the XNA Keyboard will not receive all
            // inputs if the WPF window is active.
            ComponentDispatcher.ThreadFilterMessage += OnThreadFilterMessage;

            // The debugger will not break when an exception occurs inside the WPF thread
            // (unless catching first chance exceptions is enabled). If we break in the
            // UnhandledExceptionFilter event then the user sees the call stack of the event.
            // The call stack is unwound after this event.
            Dispatcher.UnhandledExceptionFilter += (s, e) => Debugger.Break();

            // Forward exceptions in the WPF thread to the WinForms thread.
            Application.DispatcherUnhandledException += (s, e) =>
            {
                // Set flag to avoid blocking of the forms thread.
                _applicationStarted = true;

                // Forward the exception to the main thread.
                if (Form != null)
                {
                    Form.BeginInvoke(new Action(delegate
                    {
                        throw new GraphicsException("Exception occurred in WPF environment.", e.Exception);
                    }));
                }
            };

            Application.Startup += (s, e) => _applicationStarted = true;

            Application.Run(); // This call blocks until Shutdown() is called.
        }
Ejemplo n.º 54
0
        /// <summary>
        /// Your own user code starts here.
        /// If this is your first time, do consider reading the notice above.
        /// It contains some very useful information.
        /// </summary>
        public static void Init()
        {
            /*
             *  Reloaded Mod Loader Sample: Windows Presentation Foundation
             *  Architectures supported: X86, X64
             *
             *  Creates an interactive Windows Presentation Foundation semi-transparent window inside
             *  the running process, demonstrating or giving an idea on how perhaps utility tools
             *  could be developed with libReloaded or how WPF may be used as an alternative to Direct2D
             *  HUDs/Overlays.
             *
             *  Note: In order to allow the use of WPF over the Reloaded Template, you need to add
             *  <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
             *  to the first PropertyGroup in the Project's .csproj and reference PresentationFramework + System.Xaml.
             */

            /*
             *  We create our own thread and run it in the background because Reloaded-Loader explicitly waits
             *  for the mod's thread to return before continuing to load other mods and ultimately the game.
             *
             *  Inside the thread, we initiate a regular WPF window to use for drawing.
             */

            /*
             * Generates a random sleep value ontop of the existing sleep value.
             * We want to reduce the amount of possible collisions of WPF overlays launching
             * at the same identical time, as Application.Current is not updated in real-time (seemingly).
             */
            Random randomNumberGenerator = new Random();
            int    randomSleepValue      = randomNumberGenerator.Next(0, 3000);

            Thread.Sleep(32); // Ensures different tick value for seeding, offsets overlay launch time to prevent collisions.

            Thread launchWpfThread = new Thread
                                     (
                () =>
            {
                // Loop infinitely until a window handle is found.
                while (GameProcess.Process.MainWindowHandle == IntPtr.Zero)
                {
                    // Sleep the thread for a sensible amount of time.
                    Thread.Sleep(1000);
                }

                // Wait a fixed amount of time + random extra (to not try to launch different copies at once, minimize collisions).
                Thread.Sleep(randomSleepValue);

                // Run the WPF window.

                // Note that our OverlayWindow comes from WPF-Demo-Overlay project (it's added in as a reference).
                // To use WPF windows, you want to create another project which is a WPF UserControl library, remove the
                // usercontrol and create a window, use that library as a reference in your Reloaded WPF overlays.

                // While this isn't strictly necessary to use another library/project, it will save you a lot of hassle when it
                // comes to interoperating with different overlays, this will also make your life easier in other ways, believe me.

                // Another overlay already active.
                if (Application.Current != null)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        WPFWindow = new OverlayWindow();
                        WPFWindow.Show();
                    });
                }
                // This is the first overlay.
                else
                {
                    try
                    {
                        // Create new Application Context.
                        Application WPFApp = new System.Windows.Application();

                        // Create our window
                        WPFWindow = new OverlayWindow();

                        // Instance the overlay.
                        WPFApp.Run(WPFWindow);
                    }
                    catch
                    {
                        // If it fails, fall back to second overlay anyway.
                        Application.Current?.Dispatcher.Invoke(() =>
                        {
                            WPFWindow = new OverlayWindow();
                            WPFWindow.Show();
                        });
                    }
                }
            }
                                     );

            launchWpfThread.SetApartmentState(ApartmentState.STA);
            launchWpfThread.Start();
        }
Ejemplo n.º 55
0
 public void Run()
 {
     window.Content = iuiStructure?.GetWPFElement();
     System.Windows.Application app = new System.Windows.Application();
     app.Run(window);
 }
Ejemplo n.º 56
0
 public void Run()
 {
     _documentApp.Do(d => d.RunHost());
     _app.Run();
 }
        private static void InitializeComponent()
        {
            var app = new System.Windows.Application();

            win = new Window();
            var grid = new Grid();

            win.Title   = "GUIアプリデッドロック発生サンプル";
            win.Height  = 350;
            win.Width   = 525;
            win.Content = grid;
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            var Button1 = new Button()
            {
                Name = "Button1", Content = "実行(デッドロック発生)", Height = 30, Width = 150
            };

            grid.Children.Add(Button1);
            var Button2 = new Button()
            {
                Name = "Button2", Content = "実行", Height = 30, Width = 150, HorizontalAlignment = HorizontalAlignment.Left
            };

            grid.Children.Add(Button2);
            Grid.SetColumn(Button2, 1);
            var Button3 = new Button()
            {
                Name = "Button3", Content = "実行(ブロックされるがデッドロック回避)", Height = 30, HorizontalAlignment = HorizontalAlignment.Left
            };

            grid.Children.Add(Button3);
            Grid.SetColumn(Button3, 2);


            TextBox1 = new TextBox()
            {
                Name = "TextBox1", AcceptsReturn = true, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto, VerticalScrollBarVisibility = ScrollBarVisibility.Auto
            };
            grid.Children.Add(TextBox1);
            Grid.SetRow(TextBox1, 1);
            Grid.SetColumnSpan(TextBox1, 4);

            Button1.Click += Button1_Click;
            Button2.Click += Button2_Click;
            Button3.Click += Button3_Click;
            app.Run(win);
        }
Ejemplo n.º 58
0
        /// <summary>
        /// Your own user code starts here.
        /// If this is your first time, do consider reading the notice above.
        /// It contains some very useful information.
        /// </summary>
        public static async void Init()
        {
            /*
             *  Reloaded Mod Loader Sample: Direct2D-WPF Hybrid External Overlay Example
             *  Architectures supported: X86, X64
             *
             *  An example of a simple Direct2D based External Overlay that draws
             *  ontop of the game's window.
             *
             *  Now improved to be hosted in a WPF window, granting you the full power of
             *  WPF combined with Direct2D, and also fixing a long standing Microsoft Windows 10 bug
             *  that was hard to pin and affected arbitrary configurations.
             *
             *  WPFOverlayWindow was copied from libReloaded's source, the main development library for
             *  Reloaded Mod Loader.
             */

            /*
             * Generates a random sleep value ontop of the existing sleep value.
             * We want to reduce the amount of possible collisions of WPF overlays launching
             * at the same identical time, as Application.Current is not updated in real-time (seemingly).
             */
            Random randomNumberGenerator = new Random();
            int    randomSleepValue      = randomNumberGenerator.Next(0, 3000);

            Thread.Sleep(32); // Ensures different tick value for seeding, offsets overlay launch time to prevent collisions.

            Thread D2DWindowThread = new Thread(() =>
            {
                // Wait for game window.
                while (GameProcess.Process.MainWindowHandle == IntPtr.Zero)
                {
                    Thread.Sleep(1000);
                }

                // Sleep to not access the main window.
                // Fixes odd badly programmed games like Sonic Adventure 2
                Thread.Sleep(randomSleepValue);

                /* Adjusted and tested for interop between different windows. */

                // Another overlay already active.
                if (Application.Current != null)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        _externalOverlayWindow = new WPFOverlayWindow(GameProcess.Process.MainWindowHandle, RenderDelegate);
                        _externalOverlayWindow.GameWindowResizeDelegate += GameWindowResizeDelegate;
                        _externalOverlayWindow.Show();
                    });
                }
                // This is the first overlay.
                else
                {
                    try
                    {
                        // Create new Application Context.
                        Application WPFApp = new System.Windows.Application();

                        // Create our window
                        _externalOverlayWindow = new WPFOverlayWindow(GameProcess.Process.MainWindowHandle, RenderDelegate);
                        _externalOverlayWindow.GameWindowResizeDelegate += GameWindowResizeDelegate;

                        // Instance the overlay.
                        WPFApp.Run(_externalOverlayWindow);
                    }
                    catch
                    {
                        Application.Current?.Dispatcher.Invoke(() =>
                        {
                            _externalOverlayWindow = new WPFOverlayWindow(GameProcess.Process.MainWindowHandle, RenderDelegate);
                            _externalOverlayWindow.GameWindowResizeDelegate += GameWindowResizeDelegate;
                            _externalOverlayWindow.Show();
                        });
                    }
                }
            });

            D2DWindowThread.SetApartmentState(ApartmentState.STA);
            D2DWindowThread.Start();
        }
        public void BitmapSourceSample()
        {
            const int size = 250;

            BitmapSource bs8, bs16;

            Scalar blueColor8  = new Scalar(128, 0, 0);
            Scalar greenColor8 = new Scalar(0, 128, 0);
            Scalar redColor8   = new Scalar(0, 0, 128);
            Scalar whiteColor8 = new Scalar(255, 255, 255);

            using (var mat = new Mat(size, size, MatType.CV_8UC3, new Scalar(128, 128, 128)))
            {
                mat.Rectangle(new Rect(15, 10, 100, 100), blueColor8, -1);
                mat.PutText("B", new Point(50, 70), HersheyFonts.HersheyComplex, 1, whiteColor8);

                mat.Rectangle(new Rect(130, 10, 100, 100), greenColor8, -1);
                mat.PutText("G", new Point(165, 70), HersheyFonts.HersheyComplex, 1, whiteColor8);

                mat.Rectangle(new Rect(75, 130, 100, 100), redColor8, -1);
                mat.PutText("R", new Point(110, 190), HersheyFonts.HersheyComplex, 1, whiteColor8);

                bs8 = OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(mat);
            }

            Scalar blueColor16  = new Scalar(32767, 0, 0);
            Scalar greenColor16 = new Scalar(0, 32767, 0);
            Scalar redColor16   = new Scalar(0, 0, 32767);
            Scalar whiteColor16 = new Scalar(65535, 65535, 65535);

            using (var mat = new Mat(size, size, MatType.CV_16UC3, new Scalar(32767, 32767, 32767)))
            {
                mat.Rectangle(new Rect(15, 10, 100, 100), blueColor16, -1);
                mat.PutText("B", new Point(50, 70), HersheyFonts.HersheyComplex, 1, whiteColor16);

                mat.Rectangle(new Rect(130, 10, 100, 100), greenColor16, -1);
                mat.PutText("G", new Point(165, 70), HersheyFonts.HersheyComplex, 1, whiteColor16);

                mat.Rectangle(new Rect(75, 130, 100, 100), redColor16, -1);
                mat.PutText("R", new Point(110, 190), HersheyFonts.HersheyComplex, 1, whiteColor16);

                bs16 = OpenCvSharp.Extensions.BitmapSourceConverter.ToBitmapSource(mat);
            }

            var image8 = new System.Windows.Controls.Image {
                Source = bs8
            };
            var image16 = new System.Windows.Controls.Image {
                Source = bs16
            };
            var grid = new System.Windows.Controls.Grid();

            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            Grid.SetRow(image8, 0);
            Grid.SetColumn(image8, 0);
            grid.Children.Add(image8);
            Grid.SetRow(image16, 0);
            Grid.SetColumn(image16, 1);
            grid.Children.Add(image16);
            var window = new System.Windows.Window
            {
                Title   = "Left:8bit Right:16bit",
                Width   = size * 2,
                Height  = size,
                Content = grid
            };

            var app = new System.Windows.Application();

            app.Run(window);
        }
Ejemplo n.º 60
0
 public override void RunApplication()
 {
     application.Run();
 }