private string OpenApp(string appKey) { ApplicationInfo app; if (this.AppMan.Apps.TryGetValue(appKey, out app)) { object instance; if (!this.AppInstances.TryGetValue(app, out instance)) { instance = app.Asm.CreateInstance(app.AppType.ToString()); ApplicationBase appbase = (ApplicationBase)instance; appbase.User = this.UserWrapper; appbase.AppLoad(); this.AppInstances.Add(app, instance); } this.CurrentApp = new KeyValuePair <ApplicationInfo, object>(app, instance); this.CurrentAppKey = appKey; return(string.Format("{0} has been loaded.", appKey)); } return(string.Format("Unable to find appliation \"{0}\"", appKey)); }
// creates the Microsoft engines on their own // thread bound to the current Wisej session. private static ScriptEngine CreateThreadBoundEngine(EngineType type, string name, WindowsScriptEngineFlags flags) { ScriptEngine engine = null; var checkPoint = new ManualResetEventSlim(); ApplicationBase.StartTask(() => { switch (type) { case EngineType.JScript: engine = new JScriptEngine(name, flags); break; case EngineType.VBScript: engine = new VBScriptEngine(name, flags); break; default: throw new InvalidOperationException(); } checkPoint.Set(); Dispatcher.Run(); }); checkPoint.Wait(); checkPoint.Reset(); return(engine); }
public MainWindow() { InitializeComponent(); this.Loaded += (s, e) => { MainWindow.WindowHandle = new WindowInteropHelper(Application.Current.MainWindow).Handle; HwndSource.FromHwnd(MainWindow.WindowHandle)?.AddHook(new HwndSourceHook(HandleMessages)); }; //Todo: this.Title = $"Parameter passing example - Process Id: {Process.GetCurrentProcess().Id}"; string b = (System.Environment.Is64BitProcess == true ? "64" : "32"); this.Title = "Generic Tracker (" + b + " bits)"; //Get assembly info ApplicationBase Assembly = new ApplicationBase(); string[] v = Assembly.Info.Version.ToString().Split('.'); sbVersion.Text = "Version: " + v[0] + "." + v[1] + "." + v[2]; sbUserName.Text = AppsCommon.Classes.Common.User(); cnnMain = MyDb.Common.cnnType2DbConnection(Class_Settings.getCnnType(My.Application.Csettings), My.Application.Csettings.cnnString); GetMenuItems(); }
public void UnregisterApplication(ApplicationBase app) { lock (apps) { apps.Remove(app); } }
/// <summary> /// Class Fotootof Application Constructor. /// </summary> public App() { // Must be placed at the top start of the application. InitializeLog4Net(); // Reset application // delete user my documents application folder. App_Reset(); // Starting the application // The application loads options & parameters from files. // Create default files if not exists ApplicationBase.Start(); // Initialize language. // Must be placed in the top start of the application. Trace.TraceInformation(Local.Properties.Logs.IntializingApplicationLanguage); CultureInfo ci = new CultureInfo(ApplicationBase.Language); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; Trace.WriteLine("-------------------------------------------------------------------------------------------------------"); /*ResourceDictionary rd = new ResourceDictionary * { * Source = new Uri("Fotootof.Template;component/Theme/Dark.xaml", UriKind.Relative) * }; * Current.Resources.MergedDictionaries.Add(rd);*/ }
/// <summary> /// Method called on add new client event. /// </summary> /// <param name="sender">The <see cref="object"/> sender of the event.</param> /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/>.</param> public void AddClient_Click(object sender, RoutedEventArgs e) { var tag = ((FrameworkElement)sender).Tag; Client client = new Client(); if (tag != null && tag.GetType() == typeof(Client)) { client = tag as Client; } using (WindowFormClientLayout dlg = new WindowFormClientLayout(client)) { bool?result = dlg.ShowDialog(); if (result == true) { MessageBoxs.IsBusy = true; ApplicationBase.Options.Remote.Clients.AddKeySingle(dlg.NewForm); ApplicationBase.SaveOptions(); RaiseClientAdded(this, e.RoutedEvent); MessageBoxs.IsBusy = false; } } }
public override bool Startup(ApplicationBase app, IConfiguration?config) { Logger?.Info("Starting HTTP Server"); server = new HTTPRPCServer("localhost", 5010); server.Run(); Logger?.Info("Starting Client Sendings by Timer"); var cli = HTTPRPCClient.Client <IHttpAPI>(new Uri("http://localhost:5010/api")); var inprogress = false; timer = new Timer((st) => { if (inprogress) { return; } inprogress = true; try { cnt++; var sw = Stopwatch.StartNew(); var r = cli.Test(cnt); Logger?.Info($"RPC Call Executed in {sw.ElapsedMilliseconds} ms. Result: {r.ToString("HH:mm:ss",CultureInfo.InvariantCulture)}"); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { Logger?.Error(ex.Message); } #pragma warning restore CA1031 // Do not catch general exception types inprogress = false; }, null, 5000, 5000); return(true); }
/// <summary> /// Method called on language changed click event. /// </summary> /// <param name="sender">The <see cref="object"/> sender of the event.</param> /// <param name="e">The routed event arguments <see cref="RoutedEventArgs"/>.</param> private void LanguageChanged_Click(object sender, RoutedEventArgs e) { // Ask for user confirmation. var result = MessageBoxs.YesNo(Layouts.Dialogs.Properties.Translations.ApplicationRestartRequired, Local.Properties.Translations.Language); if (result != MessageBoxResult.Yes) { return; } // Get culture parameters. MenuItem menu = (MenuItem)sender; string culture = (string)menu.Tag; CultureInfo before = Thread.CurrentThread.CurrentCulture; // Change application culture info. try { Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); } catch { Thread.CurrentThread.CurrentUICulture = before; } // Save language to the application preferences. ApplicationBase.Language = Thread.CurrentThread.CurrentCulture.ToString(); ApplicationBase.Save(); // Restart the application. System.Windows.Forms.Application.Restart(); Application.Current.Shutdown(); }
public static async Task Main(string[] args) { string appPath = ApplicationBase.GetEntryApplicationPath(); using (var context = new CommandContext(appPath)) using (var app = new HelperApplication(context)) { if (args.Length == 0) { await Gui.ShowWindow(() => new TesterWindow(), IntPtr.Zero); return; } app.RegisterCommand(new CredentialsCommandImpl(context)); app.RegisterCommand(new OAuthCommandImpl(context)); int exitCode = app.RunAsync(args) .ConfigureAwait(false) .GetAwaiter() .GetResult(); Environment.Exit(exitCode); } }
private string GetCurrentShortCulture() { var currentLanguage = ApplicationBase.GetCurrentLanguage(); switch (currentLanguage) { case Enums.Languages.ENG: return("en"); case Enums.Languages.ARA: return("en"); case Enums.Languages.JPN: return("ja-JP"); case Enums.Languages.CHS: return("zh-CHS"); case Enums.Languages.DEU: return("en"); case Enums.Languages.PLK: return("en"); default: throw new ArgumentOutOfRangeException(); } }
public void RegisterApplication(ApplicationBase app) { lock (apps) { apps.Add(app); } }
/// <summary> /// /// </summary> /// <param name="sender">The object sender of the event.</param> /// <param name="e"></param> private void App_Startup(object sender, StartupEventArgs e) { Trace.WriteLine("Starting Application Base. Please wait..."); // Start application base manager. ApplicationBase.Debug(); // Initialize application preferences. InitializePreferences(); // Application is running // Process command line args bool startMinimized = false; for (int i = 0; i != e.Args.Length; ++i) { if (e.Args[i] == "/StartMinimized") { startMinimized = true; } } // Create main application window, starting minimized if specified MainWindow mainWindow = new MainWindow(); if (startMinimized) { mainWindow.WindowState = WindowState.Minimized; } mainWindow.Show(); }
/// <summary> /// Method to save a string Control property value. /// </summary> /// <param name="ctrl">The Control.</param> /// <param name="propertyName">The property name to store in settings.</param> /// <param name="propertyValue">The property value to store in settings.</param> /// <returns>The property value stored in settings.</returns> public static string SaveString(Control ctrl, string propertyName, string propertyValue = default(string)) { string s = SetString(ctrl, propertyName, propertyValue); ApplicationBase.SaveUi(); return(s); }
/// <summary> /// Method to save the application settings. /// </summary> private void SaveSettings() { Trace.WriteLine("-------------------------------------------------------------------------------------------------------"); Trace.TraceInformation(Local.Properties.Logs.WaitingApplicationSave); Settings.Controls.Default.Save(); Settings.Sections.Default.Save(); ApplicationBase.Save(); }
/// <summary> /// Method called before the application closing. /// </summary> /// <param name="sender">The object sender of the event</param> /// <param name="e">Exit event arguments.</param> private void App_Exit(object sender, ExitEventArgs e) { Trace.WriteLine(string.Format("# {0}.{1} ------------------------------------------------", MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name)); Trace.WriteLine("Saving the application options & parameters before exit. Please wait..."); ApplicationBase.Save(); Trace.WriteLine("-------------------------------------------------------------------------------------------------------"); Trace.WriteLine(""); }
/// <summary> /// Method to save a long Control property value. /// </summary> /// <param name="ctrl">The Control.</param> /// <param name="propertyName">The property name to store in settings.</param> /// <param name="propertyValue">The property value to store in settings.</param> /// <returns>The property value stored in settings.</returns> public static long SaveLong(Control ctrl, string propertyName, long propertyValue = default(long)) { long l = SetLong(ctrl, propertyName, propertyValue); ApplicationBase.SaveUi(); return(l); }
/// <summary> /// Method to save an int Control property value. /// </summary> /// <param name="ctrl">The Control.</param> /// <param name="propertyName">The property name to store in settings.</param> /// <param name="propertyValue">The property value to store in settings.</param> /// <returns>The property value stored in settings.</returns> public static int SaveInt(Control ctrl, string propertyName, int propertyValue = default(int)) { int val = SetInt(ctrl, propertyName, propertyValue); ApplicationBase.SaveUi(); return(val); }
/// <summary> /// Method to save a boolean Control property value. /// </summary> /// <param name="ctrl">The Control.</param> /// <param name="propertyName">The property name to store in settings.</param> /// <param name="propertyValue">The property value to store in settings.</param> /// <returns>The property value stored in settings.</returns> public static bool?SaveBool(Control ctrl, string propertyName, bool?propertyValue = default(bool)) { bool?val = SetBool(ctrl, propertyName, propertyValue); ApplicationBase.SaveUi(); return(val); }
/// <summary> /// Method to save an object Control property value. /// </summary> /// <typeparam name="V">The object Type to store.</typeparam> /// <param name="ctrl">The Control.</param> /// <param name="propertyName">The property name to store in settings.</param> /// <param name="propertyValue">The property value to store in settings.</param> /// <returns>The property value stored in settings.</returns> public static V SaveValue <V>(Control ctrl, string propertyName, V propertyValue = default(V)) where V : class { V b = SetValue <V>(ctrl, propertyName, propertyValue); ApplicationBase.SaveUi(); return(b as V); }
public void GetEnvironmentVariable_ArgumentException() { var app = new ApplicationBase(); var key = GetEnvironmentVariables().LastOrDefault().Item1 ?? ""; var ex = Assert.Throws <ArgumentException>(() => app.GetEnvironmentVariable(key + "z")); _ = ex.ToString(); // ensure message can be formatted }
/// <summary> /// Initializes a new instance of the <see cref="T:Photon.SocketServer.ServerToServer.TemporaryServerPeer"/> class for TCP connections. /// </summary> /// <param name="application">The application that requested to establish the connection.</param> /// <param name="remoteEndPoint">The remote endpoint to connect to.</param> /// <param name="appName">The application name to connect to.</param> /// <param name="useMux">Share a single physical connection between multiple logical connections.</param> /// <param name="state">A state object that is passed to the callback </param> public TemporaryServerPeer(ApplicationBase application, IPEndPoint remoteEndPoint, string appName, bool useMux, object state) : this() { this.application = application; this.appName = appName; this.state = state; this.remoteEndPoint = remoteEndPoint; this.useMux = useMux; }
public void GetEnvironmentVariable() { var app = new ApplicationBase(); foreach (var(key, value) in GetEnvironmentVariables()) { Assert.Equal(value, app.GetEnvironmentVariable(key)); } }
public void Info() { var app = new ApplicationBase(); var assembly = System.Reflection.Assembly.GetEntryAssembly() ?? System.Reflection.Assembly.GetCallingAssembly(); var assemblyName = assembly.GetName(); Assert.Equal(assemblyName.Name, app.Info.AssemblyName); Assert.Equal(assemblyName.Version, app.Info.Version); }
/// <summary> /// Invokes the translation service provider asynchronously and returns the result of the request in an instance /// of the <see cref="T:Wisej.Ext.Translation.TranslationResult"/> class. /// </summary> /// <param name="text">The text to translate.</param> /// <param name="from">The source language ("en", "de", ...) or null/empty to ask the provider to auto detect the source language.</param> /// <param name="to">The target language ("en", "de", ...)</param> /// <param name="resultCallback">Callback method that will receive the TranslationResult when ready.</param> public override void TranslateAsync(string text, string from, string to, Action <TranslationResult> resultCallback) { var callback = resultCallback; ApplicationBase.StartTask(() => { TranslationResult result = this.Translate(text, from, to); callback(result); }); }
/// <summary> /// Setups the specified application. /// </summary> /// <param name="application">The application.</param> /// <param name="settings">The settings.</param> internal static void Setup(ApplicationBase application, AppSettings settings) { Application = application; Settings = settings; if (Settings.WindowOpacity < 0.5) { Settings.WindowOpacity = 0.5; } }
private static IContainer ConfigureContainer() { var container = ApplicationBase.Initialize(); container.ConfigureCassandra(); container.ConfigureRemoteTaskQueueForConsumer <RtqConsumerSettings, RtqTaskHandlerRegistry>(); container.Configurator.ForAbstraction <ITestTaskLogger>().UseType <TestTaskLogger>(); container.Configurator.ForAbstraction <ITestCounterRepository>().UseType <TestCounterRepository>(); return(container); }
/// <summary> /// Method called at the start up of the application. /// </summary> /// <param name="sender">The object sender of the event.</param> /// <param name="e">Strart up event arguments.</param> private void App_Startup(object sender, StartupEventArgs e) { Trace.TraceInformation(Local.Properties.Logs.WaitingApplicationStart); // Start application base manager. ApplicationBase.Debug(); // Initialize application preferences. InitializePreferences(); // Initialize application options. InitializeOptions(); // Add Theme to Application UI Parmeters. //ApplicationBase.UI.AddParameter("ApplicationTheme", "Dark"); // Application is running // Process command line args bool startMinimized = false; for (int i = 0; i != e.Args.Length; ++i) { if (e.Args[i] == "/StartMinimized") { startMinimized = true; } } // Create main application window, starting minimized if specified MainWindow mainWindow = new MainWindow(); if (startMinimized) { mainWindow.WindowState = WindowState.Minimized; } string ws = ApplicationBase.UI.AddParameter("WindowState", "Maximized"); switch (ws) { case "Maximized": mainWindow.WindowState = WindowState.Maximized; break; case "Minimized": mainWindow.WindowState = WindowState.Minimized; break; case "Normal": mainWindow.WindowState = WindowState.Normal; break; } mainWindow.Show(); }
/// <summary> /// Initializes a new instance of the <see cref="T:Photon.SocketServer.ServerToServer.TemporaryServerPeer"/> class for reliable UDP connections. /// </summary> /// <param name="application">The application that requested to establish the connection.</param> /// <param name="remoteEndPoint">The remote endpoint to connect to.</param> /// <param name="appName">The application name to connect to.</param> /// <param name="state">A state object that is passed to the callback </param> /// <param name="numChannels">The number of channels that are used by the UDP connection.</param> /// <param name="mtu">The maximum size for each package.</param> public TemporaryServerPeer(ApplicationBase application, IPEndPoint remoteEndPoint, string appName, object state, byte numChannels, short?mtu) : this() { this.application = application; this.appName = appName; this.state = state; this.remoteEndPoint = remoteEndPoint; this.isENet = true; this.numChannels = numChannels; this.mtu = mtu; }
public void GetEnvironmentVariable() { var app = new ApplicationBase(); var variables = System.Environment.GetEnvironmentVariables().Keys; foreach (string variable in variables) { Assert.Equal(System.Environment.GetEnvironmentVariable(variable), app.GetEnvironmentVariable(variable)); break; } }
/// <summary> /// Initializes a new instance of the <see cref="T:Photon.SocketServer.ServerToServer.TemporaryServerPeer"/> class for Hixie76 WebSocket connections. /// </summary> /// <param name="application">The application that requested to establish the connection.</param> /// <param name="remoteEndPoint">The remote endpoint to connect to.</param> /// <param name="appName"> The application name to connect to.</param> /// <param name="state"> A state object that is passed to the callback </param> /// <param name="origin">The origin of the connection</param> public TemporaryServerPeer(ApplicationBase application, IPEndPoint remoteEndPoint, string appName, object state, string origin) : this() { this.application = application; this.appName = appName; this.state = state; this.remoteEndPoint = remoteEndPoint; this.isWebSocket = true; this.isHixie76 = true; this.origin = origin; this.protocol = Protocol.Json; }
private static void Main(string[] args) { var bootstrapper = new Bootstrapper(); var programBase = new ApplicationBase(args, bootstrapper); }
public WpfScreen(ApplicationBase<WinWindow> application, WinWindow window) { Application = application; Window = window; }