public MainWindow() { InitializeComponent(); // Initialize the portfolios var portfolios = new string[] { "High-risk", "Moderate", "Low-risk" }; lbPortfolios.ItemsSource = portfolios; this.glue = new Glue42(); this.glue.Initialize("DotNetApp", useContexts: true); // Initialize Window Stickiness and read from config: var swOptions = this.glue.GlueWindows?.GetStartupOptions() ?? new GlueWindowOptions(); swOptions.WithChannelSupport(true); this.glue.GlueWindows?.RegisterWindow(this, swOptions) .ContinueWith(r => { glueWindow = r.Result; glueWindow.Title = "Glue42 Bloomberg Net App"; glueWindow.ChannelContext.Subscribe(new LambdaGlueChannelEventHandler <string>( (context, channel, instrument) => Dispatcher.BeginInvoke((Action)(() => tbBBG.Text = instrument)), (context, channel, arg3) => Dispatcher.BeginInvoke((Action)(() => tbBBG.Text = context.GetValue <string>( instrumentFieldPath_, ChannelLevel.Root)))), instrumentFieldPath_, ChannelLevel.Root); }); }
internal void RegisterGlue(Glue42 glue) { _glue = glue; UpdateUI(true); _glue.Interop.ConnectionStatusChanged += InteropConnectionStatusChanged; // register a streaming endpoint (Glue stream) called GlueDemoTickStream stream_ = _glue.Interop.RegisterStreamingEndpoint(smb => smb.SetMethodName("GlueDemoTickStream") .SetParameterSignature("bool reject, string symbol"), new ServerEventStreamHandler(false) { // in each of the stream handler events we have the optional cookie parameter // that is optionally supplied while registering the stream // this lambda is invoked when a new subscription request is received SubscriptionRequestHandler = SubscriptionRequestHandler, // this lambda is invoked when new subscriber has been connected to a branch SubscriberHandler = SubscriberHandler, //this lambda is invoked when a subscriber cancels its subscription or has been kicked (banned) by the publisher UnsubscribeHandler = UnsubscribeHandler }); }
static void Main(string[] args) { var initializeOptions = new InitializeOptions() { ApplicationName = "Shared Context Publisher", IncludedFeatures = GDFeatures.UseContexts, InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Console.WriteLine("Unable to initialize Glue42!"); return; } var glueInstance = glue.Result; StartUpdatingContext(glueInstance); Console.WriteLine("Context publisher is started..."); }); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Glue = new Glue42(); Glue.Initialize("Portfolio"); }
internal void RegisterGlue(Glue42 glue) { _glue = glue; UpdateUI(true); //bounds are optional. With them we will just set initial placement of the application var defaultBounds = new GlueWindowBounds() { X = (int)((SystemParameters.PrimaryScreenWidth / 2) - (Width / 2)), Y = (int)((SystemParameters.PrimaryScreenHeight / 2) - (Height / 2)), Width = (int)Width, Height = (int)Height }; var gwOptions = glue.GetStartupWindowOptions("AppManager Demo", defaultBounds); gwOptions.WithType(GlueWindowType.Flat); glue.GlueWindows?.RegisterWindow(this, gwOptions); var appManager = glue.AppManager; if (appManager != null) { appManager.ApplicationAdded += OnApplicationAdded; appManager.ApplicationUpdated += OnApplicationUpdated; appManager.ApplicationRemoved += OnApplicationRemoved; appManager.ApplicationInstanceStarted += OnApplicationInstanceStarted; appManager.ApplicationInstanceStopped += OnApplicationInstanceStopped; ExecuteAction(() => appManager.Applications.Each(OnApplicationAdded)); } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Glue = new Glue42(); Glue.Initialize("Contacts"); }
private void InitializeGlue() { var initializeOptions = new InitializeOptions() { ApplicationName = "AppManager Demo", IncludedFeatures = GDFeatures.UseAppManager | GDFeatures.UseGlueWindows, LogLibrary = LogLibrary.StaticLog4Net, InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { ShowMainWindow(); return; } var glueInstance = glue.Result; //window management in not initialized correctly if (glueInstance.GlueWindows == null) { ShowMainWindow(); } //register glue GetMainWindow()?.RegisterGlue(glueInstance); }, TaskScheduler.FromCurrentSynchronizationContext()); }
public static void Init() { var applicationName = "Clients"; Glue42 = new Glue42(); Glue42.Initialize(applicationName); }
public static void Init() { var applicationName = "NotificationDetails"; Glue42 = new Glue42(); Glue42.Initialize(applicationName); }
private static async void ListenForContextUpdates(Glue42 glue) { // Listen for updates in TestContext var context = await glue.Contexts.GetContext("TestContext"); context.ContextUpdated += OnContextUpdated; }
public MainWindow() { InitializeComponent(); var initializeOptions = new InitializeOptions(); initializeOptions.SetSaveRestoreStateEndpoint(_ => // Returning the state that has to be saved when the applicaiton is saved in a layout // In this case the app saves the selected color from the dropdown new AppState { SelectedIndex = ColorSelector.SelectedIndex }.AsCompletedTask(), null, Dispatcher); Task <Glue42> g = Glue42.InitializeGlue(initializeOptions); // Registering the main window and then continuing with the registration of the additional applications RegisterMainWindow(g).ContinueWith(r => { // glue will be initialized with the registration of the main window glue42_ = g.Result; // Getting the restored state if one is provided (the restored state will be populated when the app is restored from GlueDesktop) var appState = glue42_.GetRestoreState <AppState>(); ColorSelector.SelectedIndex = appState?.SelectedIndex ?? -1; RegisterColorApp(); RegisterChartApp(); }, TaskScheduler.FromCurrentSynchronizationContext()); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Glue = new Glue42(); Glue.Initialize("Notifications"); }
public void Initialize(MainWindow context, SymbolState state, Glue42 glue, GDStartingContext startingContext, IGlueWindow glueWindow) { // Invoked when the window is restored Dispatcher.Invoke(() => { Symbol.Text = state?.ActiveSymbol ?? SymbolOneName; }); }
internal void RegisterGlue(Glue42 glue) { _glue = glue; UpdateUI(true); _glue.Interop.ConnectionStatusChanged += InteropConnectionStatusChanged; _glue.Interop.EndpointStatusChanged += InteropEndpointStatusChanged; }
public MainWindow() { InitializeComponent(); //Initialize Glue42 and register the current app: this.glue = new Glue42(); this.glue.Initialize(appName); this.glue.AppManager.ApplicationAdded += AppManager_ApplicationAdded; }
private void InitializeGlue() { // initialize Tick42 Interop Log("Initializing Glue42"); var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Imperative Duplex Chat", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } _glue42 = glue.Result; // subscribe to interop connection status event _glue42.Interop.ConnectionStatusChanged += (sender, args) => { Log($"Glue connection is now {args.Status}"); }; _glue42.Interop.EndpointStatusChanged += InteropEndpointStatusChanged; _glue42.Interop.RegisterEndpoint(mdb => mdb.SetMethodName(_chatEndpointName), (method, context, caller, resultBuilder, asyncResponseCallback, cookie) => ThreadPool.QueueUserWorkItem(_ => { // simulate asynchronous work // grab the invocation context (e.g. take "id" from the input arguments) // we don't care about the id type, so get it as Value Value id = context.Arguments.GetValueByName("id", v => v); // we care about the message type - we take it as a string var message = context.Arguments.GetValueByName("message", v => v.AsString); Log($"Call from {caller} with id {id}: {message}"); // do slow job here with context and caller Thread.Sleep(500); // respond when ready asyncResponseCallback(resultBuilder.SetMessage(id + " processed") .SetContext(cb => cb.AddValue("id", id)).Build()); })); //Enable textbox for send of messages BeginInvoke((Action)(() => txtMsg_.Enabled = true)); Log("Initialized Glue."); }); }
public MainWindow() { InitializeComponent(); this.glue = new Glue42(); this.glue.Initialize("DotNetWindowLoadCaller", useContexts: true); // Initialize Window Stickiness and read from config: var swOptions = this.glue.GlueWindows?.GetStartupOptions() ?? new GlueWindowOptions(); this.glue.GlueWindows?.RegisterWindow(this, swOptions); }
private static async void StartUpdatingContext(Glue42 glue) { int data = 0; // update TestContext every second incrementing the value of data var context = await glue.Contexts.GetContext("TestContext"); ThreadPool.QueueUserWorkItem((c) => { while (true) { Thread.Sleep(1000); context["data"] = data++; } }); }
static void Main(string[] args) { Glue42 glue42 = null; var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Interop", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } glue42 = glue.Result; // subscribe to interop connection status event glue42.Interop.ConnectionStatusChanged += InteropOnConnectionStatusChanged; // Register synchronous calling endpoint, called HelloGlue. // we could use the serverEndpoint returned by this method to later unregister it by calling glue.Interop.UnregisterEndpoint IServerMethod serverEndpoint = glue42.Interop.RegisterSynchronousEndpoint(mdb => mdb.SetMethodName("HelloGlue"), OnHelloWorldInvoked); Log($"Registered endpoint called {serverEndpoint.Definition.Name}"); Log("Initialized Glue."); }); string input; // start the main loop, take console inputs until '!q' is passed. // send each line as an invocation argument, if not empty while (!string.Equals(input = Console.ReadLine(), "!q", StringComparison.CurrentCultureIgnoreCase)) { if (glue42 == null) { return; } InteropSendOperation(glue42, input); } }
private void InitializeGlue() { // initialize Tick42 Interop Log("Initializing Glue42"); var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Advance Declarative Interop", AdvancedOptions = new Glue42.AdvancedOptions() { SynchronizationContext = SynchronizationContext.Current }, InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } _glue42 = glue.Result; // subscribe to interop connection status event _glue42.Interop.ConnectionStatusChanged += (sender, args) => { Log($"Glue connection is now {args.Status}"); }; _glue42.Interop.TargetStatusChanged += (sender, args) => Log($"{args.Status.State} target {args.Target}"); // force single target _service = _glue42.Interop.CreateServiceProxy <IServiceContract>(targetType: MethodTargetType.Any); // let's track the status of the service target - if anybody has implemented it. _glue42.Interop.CreateServiceSubscription( _service, (_, status) => Log($"{nameof(IServiceContract)} is now {(status ? string.Empty : "in")}active")); //Enable registration of ServiceContract BeginInvoke((Action)(() => btnRegister.Enabled = true)); Log("Initialized Glue Interop"); }); }
private static void InteropSendOperation(Glue42 glue, string data) { // search and invoke 'HelloGlue' endpoint Task <IClientMethodResult> invoke; if (string.IsNullOrEmpty(data)) { // simply execute, passing no arguments invoke = glue.Interop.Invoke("HelloGlue"); } else { // we have some argument, let's pass it invoke = glue.Interop.Invoke("HelloGlue", mib => mib.SetContext(cb => cb.AddValue("input", data))); } invoke.ContinueWith(InvocationResultHandler); }
public MainWindow() { InitializeComponent(); this.allData = DataLoader.Load(); lbCustomers.ItemsSource = allData.Clients; //Initialize Glue42 and register the current app: var applicationName = "ClientPortfolio"; this.glue = new Glue42(); this.glue.Initialize(applicationName); this.companyService = this.glue.Interop.CreateServiceProxy <ICompanyService>(); // Initialize Window Stickiness and read from config: var swOptions = glue.StickyWindows?.GetStartupOptions() ?? new SwOptions(); glue.StickyWindows?.RegisterWindow(this, swOptions); }
private void InitializeGlue(SynchronizationContext synchronizationContext) { // initialize Tick42 Interop (AGM) and Metrics components Console.WriteLine("Initializing Glue42"); string glueUser = Environment.UserName; Console.WriteLine($"User is {glueUser}"); // these envvars are expanded in some configuration files Environment.SetEnvironmentVariable("PROCESSID", Process.GetCurrentProcess().Id + ""); Environment.SetEnvironmentVariable("GW_USERNAME", glueUser); //Environment.SetEnvironmentVariable("DEMO_MODE", Mode + ""); // The Glue42 facade provides a simplified programming // interface over the core Glue42 components. Glue = new Glue42(); Glue.Interop.ConnectionStatusChanged += (sender, args) => { Console.WriteLine($"Glue connection is now {args.Status}"); }; Glue.Interop.TargetStatusChanged += (sender, args) => Console.WriteLine($"{args.Status.State} target {args.Target}"); var advancedOptions = new Glue42.AdvancedOptions { SynchronizationContext = synchronizationContext }; Glue.Initialize( Assembly.GetEntryAssembly().GetName().Name, // application name - required useAgm: true, useAppManager: true, useMetrics: true, useContexts: false, useGlueWindows: true, credentials: Tuple.Create(glueUser, ""), advancedOptions: advancedOptions); Service = Glue.Interop.CreateServiceProxy <ISignalExecute>(); // let's track the status of the service target - if anybody has implemented it. Glue.Interop.CreateServiceSubscription(Service, (_, status) => Console.WriteLine($"{nameof(ISignalExecute)} is now {(status ? string.Empty : "in")}active")); Console.WriteLine("Initialized Glue Interop"); }
private void InitializeGlue() { var initializeOptions = new InitializeOptions() { ApplicationName = "My Glue Streams Publisher Demo", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //register glue successfuly if (glue.Status == TaskStatus.RanToCompletion) { var glueInstance = glue.Result; GetMainWindow()?.RegisterGlue(glueInstance); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
protected override void OnShown(EventArgs e) { Log("Initializing Glue42"); var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Interop", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } _glue42 = glue.Result; // subscribe to interop connection status event _glue42.Interop.ConnectionStatusChanged += (sender, args) => { Log($"Glue connection is now {args.Status}"); }; _glue42.Interop.TargetStatusChanged += (sender, args) => Log($"{args.Status.State} target {args.Target}"); _service = _glue42.Interop.CreateServiceProxy <IServiceContract>(); // let's track the status of the service target - if anybody has implemented it. _glue42.Interop.CreateServiceSubscription( _service, (_, status) => Log($"{nameof(IServiceContract)} is now {(status ? string.Empty : "in")}active")); BeginInvoke((Action)(() => btnRegister.Enabled = true)); Log("Initialized Glue Interop"); }); }
internal void RegisterGlue(Glue42 glue) { _glue = glue; UpdateUI(true); //bounds are optional. With them we will just set initial placement of the application var defaultBounds = new GlueWindowBounds() { X = (int)((SystemParameters.PrimaryScreenWidth / 2) - (Width / 2)), Y = (int)((SystemParameters.PrimaryScreenHeight / 2) - (Height / 2)), Width = (int)Width, Height = (int)Height }; var gwOptions = glue.GetStartupWindowOptions(Title, defaultBounds); glue.GlueWindows?.RegisterWindow(this, gwOptions).ContinueWith(t => { if (t.IsCompleted) { GlueWindow = t.Result; } }, TaskScheduler.FromCurrentSynchronizationContext()); }
public MainWindow() { InitializeComponent(); // Initialize and display data: this.allData = DataLoader.Load(); lbCompanies.ItemsSource = allData.Companies; //Initialize Glue42 and register the current app: var applicationName = "CompanyManager"; var glue = new Glue42(); glue.Initialize(applicationName); //Instantiate the service instance and register to Glue42: var companyService = new CompanyService((code) => { this.handleCompanyCodeChange(code); }); glue.Interop.RegisterService <ICompanyService>(companyService); // Initialize Window Stickiness and read from config: var swOptions = glue.StickyWindows?.GetStartupOptions() ?? new SwOptions(); glue.StickyWindows?.RegisterWindow(this, swOptions); }
internal void RegisterGlue(Glue42 glue) { _glue = glue; UpdateUI(true); //bounds are optional. With them we will just set initial placement of the application var defaultBounds = new GlueWindowBounds() { X = (int)((SystemParameters.PrimaryScreenWidth / 2) - (Width / 2)), Y = (int)((SystemParameters.PrimaryScreenHeight / 2) - (Height / 2)), Width = (int)Width, Height = (int)Height }; var gwOptions = glue.GetStartupWindowOptions("Notification Publisher", defaultBounds); gwOptions.WithType(GlueWindowType.Tab); //register the window glue.GlueWindows?.RegisterWindow(this, gwOptions); //register notification service glue.Interop.RegisterService <INotificationHandler>(this); }
public void Initialize(MainWindow context, State state, Glue42 glue, GDStartingContext startingContext, IGlueWindow glueWindow) { // The method is invoked when the window is restored var colorAsString = state?.RectangleColor ?? "#FFFFFF"; var color = (Color)ColorConverter.ConvertFromString(colorAsString); var items = ColorSelector.Items; Dispatcher.Invoke(() => { for (int i = 0; i < items.Count; i++) { var rectangle = items[i] as Rectangle; var colorBrush = rectangle.Fill as SolidColorBrush; if (colorBrush.Color == color) { ColorSelector.SelectedIndex = i; } } ColorRectangle.Fill = new SolidColorBrush(color); }); }
private void InitializeGlue() { var initializeOptions = new InitializeOptions() { ApplicationName = "My Glue Notification Demo", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { ShowMainWindow(); return; } //register glue var glueInstance = glue.Result; GetMainWindow()?.RegisterGlue(glueInstance); }, TaskScheduler.FromCurrentSynchronizationContext()); }