예제 #1
0
        private void pbButton_Click(object sender, EventArgs e)
        {
            RunApp r = new RunApp();
            contentPath = @"D:\workspace\of_v0.8.4_vs_release\apps\PegasusHighwaysHotelKidsZone\bin\PegasusHighwaysHotelLauncher\PegasusHighwaysHotelLauncher.exe";
            ProcessStartInfo contentInfo = new ProcessStartInfo();

            contentInfo.FileName = contentPath;
            contentInfo.WorkingDirectory = Path.GetDirectoryName(contentPath);

            contentInfo.UseShellExecute = true;
            contentInfo.CreateNoWindow = true;
            contentInfo.WindowStyle = ProcessWindowStyle.Maximized;
            contentInfo.RedirectStandardInput = false;
            contentInfo.RedirectStandardOutput = false;
            contentInfo.RedirectStandardError = false;

            content = Process.Start(contentInfo);
            content.WaitForInputIdle();
            SetParent(content.MainWindowHandle, this.Handle);
            content.EnableRaisingEvents = true;
            content.Exited += Content_Exited;
            while (!content.Responding)
            {
                Game_Loaded();
            }
        }
예제 #2
0
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Log.Trace("OnLaunched");
            DispatcherHelper.Initialize();
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                Log.Trace("rootFrame != null");
                rootFrame = new Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;
                if (e != null)
                {
                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                    {
                        //TODO: Загрузить состояние из ранее приостановленного приложения
                    }
                }
                AppCenter.Start("96c77488-34ce-43d0-b0d3-c4b1ce326c7f", typeof(Analytics), typeof(Push), typeof(Crashes));
                AppCenter.LogLevel = LogLevel.Verbose;
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                //try
                //{
                //    StaticContent.IsPro = await StoreService.IsBuyPro();
                //    //StaticContent.IsPro = true;
                //}catch(Exception eee)
                //{
                //    //await ContentDialogService.Show(new ExceptionDialog("Ошибка при получении лицензии", "АУЕ БЛЯ", eee));
                //    StaticContent.IsPro = false;
                //}

                var appView = ApplicationView.GetForCurrentView();
                appView.TitleBar.ButtonBackgroundColor         = Colors.Transparent;
                appView.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                StaticContent.LocalFolder = ApplicationData.Current.LocalFolder;
                if (await StaticContent.LocalFolder.TryGetItemAsync("Playlists") != null)
                {
                    Log.Trace("Set playlistFolder");
                    StaticContent.PlaylistsFolder = await StaticContent.LocalFolder.GetFolderAsync("Playlists");
                }

                if (await StaticContent.LocalFolder.TryGetItemAsync("Covers") != null)
                {
                    Log.Trace("Set CoversFolder");

                    StaticContent.CoversFolder = await StaticContent.LocalFolder.GetFolderAsync("Covers");
                }

                if (await StaticContent.LocalFolder.TryGetItemAsync("ConfigApp.json") != null)
                {
                    var file = await StaticContent.LocalFolder.GetFileAsync("ConfigApp.json");

                    var fileString = await FileIO.ReadTextAsync(file);

                    var config = JsonConvert.DeserializeObject <ConfigApp>(fileString);
                    StaticContent.Config = config;
                }

                var settings = ApplicationData.Current.LocalSettings;



                try
                {
                    Windows.Storage.ApplicationDataCompositeValue composite =
                        (Windows.Storage.ApplicationDataCompositeValue)settings.Values["themeApp"];

                    if (composite == null)
                    {
                        appView.TitleBar.ButtonForegroundColor = Colors.Black;
                    }
                    else
                    {
                        var theme = (int)settings.Values["themeApp"];
                        if (theme == 0)
                        {
                            appView.TitleBar.ButtonForegroundColor = Colors.Black;
                        }
                        else
                        {
                            appView.TitleBar.ButtonForegroundColor = Colors.White;
                        }
                    }
                }catch
                {
                    var theme = (int)settings.Values["themeApp"];
                    if (theme == 0)
                    {
                        appView.TitleBar.ButtonForegroundColor = Colors.Black;
                    }
                    else
                    {
                        appView.TitleBar.ButtonForegroundColor = Colors.White;
                    }
                }


                try
                {
                    if (InternetService.Connected)
                    {
                        StaticContent.IsAuth = await AuthService.IsAuth();

                        if (StaticContent.IsAuth)
                        {
                            await AuthService.AutoAuth();
                        }
                    }
                    else
                    {
                        StaticContent.IsAuth = false;
                    }
                }catch (Exception ee)
                {
                    StaticContent.IsAuth = false;
                }


                Log.Trace("Размещение фрейма в текущем окне.");
                Window.Current.Content = rootFrame;
            }

            if (e != null)
            {
                if (e.PrelaunchActivated == false)
                {
                    if (rootFrame.Content == null)
                    {
                        if (await StaticContent.LocalFolder.TryGetItemAsync("RunApp.json") == null)
                        {
                            var runFile = await StaticContent.LocalFolder.CreateFileAsync("RunApp.json");

                            var model = new RunApp()
                            {
                                CodeName   = "Test",
                                FirstStart = true,
                                RunUpdate  = true
                            };

                            var json = JsonConvert.SerializeObject(model);
                            await FileIO.WriteTextAsync(runFile, json);

                            rootFrame.Navigate(typeof(Views.WelcomeView), null);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(Views.MainFrameView), null);
                        }
                    }
                }
            }
            else
            {
                if (rootFrame.Content == null)
                {
                    if (await StaticContent.LocalFolder.TryGetItemAsync("RunApp.json") == null)
                    {
                        var runFile = await StaticContent.LocalFolder.CreateFileAsync("RunApp.json");

                        var model = new RunApp()
                        {
                            CodeName   = "Test",
                            FirstStart = true,
                            RunUpdate  = true
                        };

                        var json = JsonConvert.SerializeObject(model);
                        await FileIO.WriteTextAsync(runFile, json);

                        rootFrame.Navigate(typeof(Views.WelcomeView), null);
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(Views.MainFrameView), null);
                    }
                }
            }


            Window.Current.Activate();
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
            Push.CheckLaunchedFromNotification(e);
        }
예제 #3
0
파일: liqud.cs 프로젝트: dested/Spoke
        public void run(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            var rv = new Dictionary
                     <string, Func <SpokeObject[], SpokeObject> >()
            {
                {
                    "write", (a) =>
                    {
                        for (int index = 1; index < a.Length; index++)
                        {
                            var spokeObject = a[index];
                            Console.Write(spokeObject.ToString() + " ");
                        }
                        return(null);
                    }
                },
                {
                    "readLine", (a) =>
                    {
                        return(new SpokeObject()
                        {
                            Type = ObjectType.String,
                            StringVal = Console.ReadLine()
                        });
                    }
                },
                {
                    "read", (a) =>
                    {
                        return(new SpokeObject()
                        {
                            Type = ObjectType.String,
                            StringVal = Console.Read().ToString()
                        });
                    }
                },
                {
                    "stringToInt", (a) =>
                    {
                        return(new SpokeObject()
                        {
                            Type = ObjectType.Int,
                            IntVal = int.Parse(a[1].StringVal)
                        });
                    }
                }, {
                    "floatToInt", (a) =>
                    {
                        return(new SpokeObject()
                        {
                            Type = ObjectType.Int,
                            IntVal = (int)a[1].FloatVal
                        });
                    }
                },
                {
                    "debug", (a) =>
                    {
                        return(null);
                    }
                },
                {
                    "writeLine", (a) =>
                    {
                        for (int index = 1; index < a.Length; index++)
                        {
                            var spokeObject = a[index];
                            Console.Write(spokeObject.ToString() + " ");
                        }
                        Console.Write("\r\n");
                        return(null);
                    }
                },
                {
                    "clearConsole", (a) =>
                    {
                        Console.Clear();
                        return(null);
                    }
                },
                {
                    "stringLength", (a) =>
                    {
                        return(new SpokeObject()
                        {
                            Type = ObjectType.Int,
                            IntVal = a[1].StringVal.Length
                        });
                    }
                },
                {
                    "setConsolePosition", (a) =>
                    {
                        Console.SetCursorPosition(a[1].IntVal, a[2].IntVal);
                        return(null);
                    }
                },

                {
                    "abs", (a) =>
                    {
                        switch (a[1].Type)
                        {
                        case ObjectType.Int: var c = a[1].IntVal;
                            return(new SpokeObject()
                            {
                                IntVal = Math.Abs(c), Type = ObjectType.Int
                            });

                            break;

                        case ObjectType.Float: var cd = a[1].FloatVal;
                            return(new SpokeObject()
                            {
                                FloatVal = Math.Abs(cd), Type = ObjectType.Float
                            });

                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                },
                {
                    "nextRandom", (a) =>
                    {
                        return(new SpokeObject()
                        {
                            Type = ObjectType.Int,
                            IntVal = rad.Next(a[1].IntVal, a[2].IntVal)
                        });

                        return(null);
                    }
                },
                {
                    "rand", (a) =>
                    {
                        var vfd = new SpokeObject()
                        {
                            Type = ObjectType.Float, FloatVal = (float)rad.NextDouble()
                        };
                        return(vfd);
                    }
                }, {
                    "getMouseX", (a) =>
                    {
                        var vfd = new SpokeObject()
                        {
                            Type = ObjectType.Int, IntVal = _mouseStatus().Item1.X
                        };
                        return(vfd);
                    }
                }, {
                    "getMouseY", (a) =>
                    {
                        var vfd = new SpokeObject()
                        {
                            Type = ObjectType.Int, IntVal = _mouseStatus().Item1.Y
                        };
                        return(vfd);
                    }
                }, {
                    "getMouseClicked", (a) =>
                    {
                        var vfd = new SpokeObject()
                        {
                            Type = ObjectType.Bool, BoolVal = _mouseStatus().Item2
                        };
                        return(vfd);
                    }
                }


                , {
                    "line", (a) =>
                    {
                        lines.Add(new Tuple <PointF, PointF>(new PointF(a[1].FloatVal + 10, a[2].FloatVal + 10), new PointF(a[3].FloatVal + 10, a[4].FloatVal + 10)));
                        return(null);
                    }
                }, {
                    "wait", (a) =>
                    {
                        ((BackgroundWorker)sender).ReportProgress(0, lines);
                        lines = new List <Tuple <PointF, PointF> >();
                        return(null);
                    }
                },
            };



            lines = new List <Tuple <PointF, PointF> >();

            try
            {
                var ra = new RunApp(@"liquid.spoke");
                ((BackgroundWorker)sender).ReportProgress(0, lines);
                //  ra.run(rv);

                Console.Write("DonSe");
            }
            catch (Exception er)
            {
                Console.WriteLine(er);

                Application.Exit();
            }
        }