Esempio n. 1
0
 /// <summary>
 /// Configures the automatic run at startup.
 /// </summary>
 /// <param name="autorun">if set to <c>true</c> [autorun].</param>
 protected override void ConfigureAutoRunAtStartup(bool autorun)
 {
     if (SupportsAutoRunAtStartup)
     {
         NativeApp.ConfigureAutoRun(autorun);
     }
 }
Esempio n. 2
0
        public static int Main(string[] args)
        {
            BrowserWindow nw = new BrowserWindow();

            NativeApp.Run(nw);
            return(0);
        }
        private void OnAccessorKeyPressed(object sender, AcceleratorKeyPressedEventArgs e)
        {
            uint currentStyle   = this.GetWindowStyle();
            uint currentExStyle = this.GetWindowExStyle();

            if (e.KeyVentType == KeyEventType.KeyDown && e.VirtualKey == Diga.Core.Api.Win32.VirtualKeys.VK_F11)
            {
                if (currentStyle == NoneStyle && currentExStyle == NoneExStyle)
                {
                    this.SetWindowState(WindowState.Normal);
                    this.UpdateStyle(this.OldStyle);
                    this.UpdateExStyle(this.OldExStyle);
                    this.UpdateWidow();
                }
                else
                {
                    this.OldStyle   = currentStyle;
                    this.OldExStyle = currentExStyle;
                    this.SetWindowState(WindowState.Maximized);
                    this.UpdateStyle(NoneStyle);
                    this.UpdateExStyle(NoneExStyle);
                    this.UpdateWidow();
                }
                NativeApp.DoEvents();
            }
        }
Esempio n. 4
0
        public void Init()
        {
            if (NativeApp != null)
            {
                throw new InvalidOperationException("Application was already initialized.");
            }

            if (X11Application.IsAvailable())
            {
                NativeApp = new X11Application();
            }
            else if (Win32Application.IsAvailable())
            {
                NativeApp = new Win32Application();
            }
            else
            {
                throw new InvalidOperationException("Cannot determine a suitable API.");
            }

            NativeApp.Init();

            Graphics   = new NGraphics(NativeApp.Graphics);
            ImageCodec = new NImageCodec(NativeApp.ImageCodec);
            Clipboard  = new NClipboard(NativeApp.Clipboard);
        }
Esempio n. 5
0
 private void FormKeyDown(object sender, NativeKeyEventArgs e)
 {
     if (e.VirtalKey == Diga.Core.Api.Win32.VirtualKeys.VK_F11)
     {
         this.SetWindowState(WindowState.Maximized);
         NativeApp.DoEvents();
     }
 }
Esempio n. 6
0
        public void Run(NWindow window)
        {
            if (NativeApp == null)
            {
                throw new InvalidOperationException("Application is not initialized yet.");
            }

            window.Application = this;
            NativeApp.Run(window.StartupInfo);
        }
Esempio n. 7
0
 private void KeepAlive()
 {
     try
     {
         NativeApp.PreventSystemStandby();
     }
     catch (Exception ex)
     {
         _logger.ErrorException("Error resetting system standby timer", ex);
     }
 }
        /// <summary>
        /// Shuts down.
        /// </summary>
        public override async Task Shutdown()
        {
            try
            {
                await SessionManager.SendServerShutdownNotification(CancellationToken.None).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Error sending server shutdown notification", ex);
            }

            NativeApp.Shutdown();
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the composable part assemblies.
        /// </summary>
        /// <returns>IEnumerable{Assembly}.</returns>
        protected override IEnumerable <Assembly> GetComposablePartAssemblies()
        {
            var list = GetPluginAssemblies()
                       .ToList();

            // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
            // This will prevent the .dll file from getting locked, and allow us to replace it when needed

            // Include composable parts in the Api assembly
            list.Add(typeof(ApiEntryPoint).Assembly);

            // Include composable parts in the Dashboard assembly
            list.Add(typeof(DashboardService).Assembly);

            // Include composable parts in the Model assembly
            list.Add(typeof(SystemInfo).Assembly);

            // Include composable parts in the Common assembly
            list.Add(typeof(IApplicationHost).Assembly);

            // Include composable parts in the Controller assembly
            list.Add(typeof(IServerApplicationHost).Assembly);

            // Include composable parts in the Providers assembly
            list.Add(typeof(ProviderUtils).Assembly);

            // Common implementations
            list.Add(typeof(TaskManager).Assembly);

            // Server implementations
            list.Add(typeof(ServerApplicationPaths).Assembly);

            // MediaEncoding
            list.Add(typeof(MediaEncoder).Assembly);

            // Dlna
            list.Add(typeof(DlnaEntryPoint).Assembly);

            // Local metadata
            list.Add(typeof(AlbumXmlProvider).Assembly);

            // Xbmc
            list.Add(typeof(ArtistNfoProvider).Assembly);

            list.AddRange(NativeApp.GetAssembliesWithParts());

            // Include composable parts in the running assembly
            list.Add(GetType().Assembly);

            return(list);
        }
Esempio n. 10
0
        /// <summary>
        /// Checks for update.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="progress">The progress.</param>
        /// <returns>Task{CheckForUpdateResult}.</returns>
        public override async Task <CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress <double> progress)
        {
            var result = await NativeApp.CheckForApplicationUpdate(ApplicationVersion,
                                                                   ConfigurationManager.CommonConfiguration.SystemUpdateLevel, InstallationManager,
                                                                   cancellationToken, progress).ConfigureAwait(false);

            HasUpdateAvailable = result.IsUpdateAvailable;

            if (result.IsUpdateAvailable)
            {
                Logger.Info("New application version is available: {0}", result.AvailableVersion);
            }

            return(result);
        }
Esempio n. 11
0
        /// <summary>
        /// Registers the server with administrator access.
        /// </summary>
        private void RegisterServerWithAdministratorAccess()
        {
            Logger.Info("Requesting administrative access to authorize http server");

            try
            {
                NativeApp.AuthorizeServer(
                    ServerConfigurationManager.Configuration.HttpServerPortNumber,
                    HttpServerUrlPrefixes.First(),
                    UdpServerEntryPoint.PortNumber,
                    ConfigurationManager.CommonApplicationPaths.TempDirectory);
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Error authorizing server", ex);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Restarts this instance.
        /// </summary>
        public override async Task Restart()
        {
            if (!CanSelfRestart)
            {
                throw new InvalidOperationException("The server is unable to self-restart. Please restart manually.");
            }

            try
            {
                await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Error sending server restart notification", ex);
            }

            NativeApp.Restart();
        }
Esempio n. 13
0
File: Program.cs Progetto: w3fs/Emby
        private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)
        {
            SystemEvents.SessionEnding += SystemEvents_SessionEnding;

            // Allow all https requests
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); });

            var fileSystem = new ManagedFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")), false, false);

            fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));

            var nativeApp = new NativeApp(options);

            _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "emby.mono.zip", nativeApp);

            if (options.ContainsOption("-v"))
            {
                Console.WriteLine(_appHost.ApplicationVersion.ToString());
                return;
            }

            Console.WriteLine("appHost.Init");

            var initProgress = new Progress <double>();

            var task = _appHost.Init(initProgress);

            Task.WaitAll(task);

            Console.WriteLine("Running startup tasks");

            task = _appHost.RunStartupTasks();
            Task.WaitAll(task);

            task = ApplicationTaskCompletionSource.Task;

            Task.WaitAll(task);
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            NativeApp app = new NativeApp();

            bool         running = true;
            NativeWindow window  = new NativeWindow(app, size: new Int2(1280, 720), minSize: new Int2(150, 150), title: "MacWindow");

            window.CloseRequested += () => running = false;
            window.Resized        += size => Console.WriteLine("Resized: " + size);
            window.Moved          += pos => Console.WriteLine("Moved: " + pos);

            int counter = 0;

            while (running)
            {
                window.Title = (counter++).ToString();

                app.ProcessEvents();
                Thread.Sleep(30); //Lets not use all the cpu :)
            }
            window.Dispose();

            app.Dispose();
        }
Esempio n. 15
0
 protected override INetworkManager CreateNetworkManager(ILogger logger)
 {
     return(NativeApp.CreateNetworkManager(logger));
 }
Esempio n. 16
0
        static void Main()
        {
            BrowserWindow bw = new BrowserWindow();

            NativeApp.Run(bw);
        }
Esempio n. 17
0
 public void Dispose()
 {
     NativeApp?.Dispose();
 }
Esempio n. 18
0
        static void Main(string[] args)
        {
            string configFile = "WebAssemblyViewer.cfg";


            ArgOptions argOptions = GetOptions(args);

            if (argOptions.ContainsHelp)
            {
                MessageBox.Show(IntPtr.Zero,
                                "Parameter:\n\n/f:<Path>\tset the path to config-file\n/e \t\topens the Config Editor!\n/?\t\tHelp\n\nExample:\n\nWebAssemblyViewer.exe /f:c:\\tmp\\config.cfg\n\n",
                                "Parameters", MessageBoxOptions.OkOnly | MessageBoxOptions.IconInformation);
                return;
            }

            if (argOptions.ContainsConfigFilePath)
            {
                configFile = argOptions.ConfigFilePath;
                FileInfo fi = new FileInfo(configFile);
                if (fi.Directory == null || !fi.Directory.Exists)
                {
                    MessageBox.Show("The directory of config-File cannot be found!");
                    return;
                }
            }

            BrowserOptions opetions;

            if (!LoadOptions(configFile, out opetions))
            {
                opetions = GetDefaultOptions();
                if (WriteOptions(configFile, opetions))
                {
                    if (!argOptions.ContainsEdit)
                    {
                        MessageBoxResult result = MessageBox.Show(IntPtr.Zero,
                                                                  "The Application created a configuration - file = (WebAssemblyViewer.cfg)\nDo you want to continue with emtyp configuration file?",
                                                                  "Config file created!",
                                                                  MessageBoxOptions.YesNo | MessageBoxOptions.IconQuestion | MessageBoxOptions.DefButton2);
                        if (result == MessageBoxResult.No)
                        {
                            result = MessageBox.Show(IntPtr.Zero, "Do you want to Edit the Cofig-File?",
                                                     "Want to edit Config-File?", MessageBoxOptions.OkOnly | MessageBoxOptions.YesNo);
                            if (result == MessageBoxResult.Yes)
                            {
                                argOptions.ContainsEdit = true;
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
            }

            if (argOptions.ContainsEdit)
            {
                EditWindow ew = new EditWindow(opetions);
                NativeApp.Run(ew);


                if (ew.Result)
                {
                    if (WriteOptions(configFile, opetions))
                    {
                        AppMessageBox mg = new AppMessageBox();
                        mg.Caption = "Continue?";
                        mg.Message =
                            "The configuration has been saved.\nDo you want to start the App?\nClick Ok to start the Applicaiton.";
                        NativeApp.Run(mg);
                        var result = mg.Result;
                        if (result == MessageBoxResult.Cancel)
                        {
                            return;
                        }
                    }
                }
            }

            BrowserWindow bw = new BrowserWindow(opetions);

            NativeApp.Run(bw);
        }
Esempio n. 19
0
        static void Main()
        {
            MainWindow mw = new MainWindow();

            NativeApp.Run(mw);
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            BrowserWindow browserWindow = new BrowserWindow();

            NativeApp.Run(browserWindow);
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            MainForm nw = new MainForm();

            NativeApp.Run(nw);
        }