예제 #1
0
        internal LauncherClient(Finsemble bridge)
        {
            this.bridge  = bridge;
            routerClient = bridge.RouterClient;
            windowClient = bridge.WindowClient;
            // Window Groups
            windowClient.GetComponentState(new JObject
            {
                ["field"] = "finsemble:windowGroups"
            }, (err, groups) => {
                if (groups.response != null)
                {
                    AddToGroups(new JObject
                    {
                        ["groupNames"] = groups.response
                    }, SubscribeToGroupUpdates);
                }
            });

            // Heartbeat
            timer.Interval = 1000;
            timer.Elapsed += (sender, e) => {
                routerClient.Transmit("Finsemble.heartbeat", new JObject
                {
                    ["type"]          = "component",
                    ["componentType"] = "finsemble",
                    ["windowName"]    = bridge.windowName
                });
            };
            timer.Enabled = true;
        }
예제 #2
0
        internal Docking(Finsemble _bridge, string channel)
        {
            Application.Current.Dispatcher.Invoke(delegate             //main thread
            {
                this.bridge                 = _bridge;
                routerClient                = bridge.RouterClient;
                this.dockingChannel         = channel;
                this.dockingWindow          = bridge.window;
                this.dockingWindowName      = bridge.windowName;
                dockingWindow.Loaded       += Window_Loaded;
                dockingWindow.Closing      += Window_Closing;
                dockingWindow.Activated    += Window_Activated;
                dockingWindow.StateChanged += DockingWindow_StateChanged;
                bridge.Subscribe(dockingChannel, Got_Docking_Message);                                                    // Finsemble 2.3
                routerClient.AddListener("FinsembleNativeActions." + bridge.windowName, Got_Docking_Message_Over_Router); // Finsemble 2.5+
                //dockingWindow.GotMouseCapture += DockingWindow_GotMouseCapture;
                //dockingWindow.LostMouseCapture += DockingWindow_LostMouseCapture;
                //MouseWatcher.OnMouseInput += MouseWatcher_OnMouseInput;

                /*routerClient.AddListener("LauncherService.shutdownRequest", (s, e) =>
                 * {
                 *      sendCloseToFinsemble = false;
                 * });*/
            });
        }
 public void SetBridge(Finsemble finsemble)
 {
     bridge = finsemble;
     bridge.docking.DockingGroupUpdateHandler += Docking_GroupUpdate;
     bridge.LinkerClient.OnStateChange(Linker_StateChange);
     if (bridge.componentConfig?["foreign"]?["components"]?["Window Manager"]?["showLinker"] != null)
     {
         showLinker = (bool)bridge.componentConfig["foreign"]["components"]["Window Manager"]["showLinker"];
     }
     if (!showLinker)
     {
         Linker.Visibility = Visibility.Hidden;
     }
     Application.Current.Dispatcher.Invoke(delegate //main thread
     {
         bridge.window.Activated   += Window_Activated;
         bridge.window.Deactivated += Window_Deactivated;
         bridge.window.MouseDown   += Window_MouseDown;
     });
     bridge.DragAndDropClient.AddEmitterChangeListener((s, e) =>
     {
         Application.Current.Dispatcher.Invoke(delegate
         {
             if (e)
             {
                 Emitter.Visibility = Visibility.Visible;
             }
             else
             {
                 Emitter.Visibility = Visibility.Hidden;
             }
         });
     });
 }
예제 #4
0
 public Logger(Finsemble bridge)
 {
     routerClient = bridge.RouterClient;
     this.bridge  = bridge;
     routerClient.Query("logger.service.register", new JObject
     {
         ["clientName"]    = bridge.windowName,
         ["clientChannel"] = "finsemble.logger.client." + bridge.windowName,
         ["uuid"]          = bridge.uuid,
         ["windowName"]    = bridge.windowName
     }, new JObject {
     }, (s, a) => { });
 }
예제 #5
0
        internal StoreModel(JObject parameters, Finsemble bridge)
        {
            //store, name, global, values, clients
            if (parameters != null)
            {
                this.name    = (string)parameters["name"];
                this.global  = (bool)parameters["global"];
                this.values  = parameters["values"] as JObject; // these come back but are currently not used for global stores.
                this.clients = parameters["clients"] as JObject;
            }

            routerClient = bridge.RouterClient;
        }
예제 #6
0
        internal WindowClient(Finsemble bridge)
        {
            this.bridge        = bridge;
            this.storageClient = bridge.storageClient;
            this.windowHash    = "activeWorkspace" + InternalHelper.TitleCase(bridge.windowName);
            this.containerHash = "activeWorkspace" + InternalHelper.TitleCase(bridge.windowName + " " + bridge.windowName);

            this.windowIdentifier = new JObject
            {
                ["windowName"]    = bridge.windowName,
                ["uuid"]          = bridge.uuid,
                ["componentType"] = bridge.componentType
            };
        }
예제 #7
0
 internal ConfigClient(Finsemble bridge)
 {
     this.bridge       = bridge;
     this.routerClient = bridge.RouterClient;
 }
예제 #8
0
 internal RouterClient(Finsemble bridge, EventHandler <bool> connectHandler)
 {
     this.bridge         = bridge;
     this.connectHandler = connectHandler;
 }
예제 #9
0
 internal AuthenticationClient(Finsemble bridge)
 {
     this.bridge  = bridge;
     routerClient = bridge.RouterClient;
 }
예제 #10
0
 internal StorageClient(Finsemble bridge)
 {
     this.routerClient = bridge.RouterClient;
 }
예제 #11
0
        public DragAndDropClient(Finsemble bridge)
        {
            this.bridge  = bridge;
            routerClient = bridge.RouterClient;

            routerClient.AddListener(DRAG_START_CHANNEL, (s, args) =>
            {
                if (scrim == null)
                {
                    return;
                }
                var dataBeingShared = (args.response?["data"] as JArray).ToObject <List <string> >();
                dynamic a           = scrim;
                if ((string)args.response["header"]["origin"] != "RouterClient." + bridge.windowName && CanReceiveData(dataBeingShared))
                {
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        scrim.AllowDrop = true;
                        try
                        {
                            a.Text = "*";
                        }
                        catch
                        {
                            try
                            {
                                a.Content = "*";
                            }
                            catch
                            {
                            }
                        }
                        scrim.Background = new SolidColorBrush(Color.FromArgb(237, 32, 104, 195));
                        scrim.Visibility = Visibility.Visible;
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        scrim.AllowDrop = false;
                        try
                        {
                            a.Text = "D";
                        }
                        catch
                        {
                            try
                            {
                                a.Content = "D";
                            }
                            catch
                            {
                            }
                        }
                        scrim.Background = new SolidColorBrush(Color.FromArgb(237, 150, 10, 5));
                        scrim.Visibility = Visibility.Visible;
                    });
                }
            });

            routerClient.AddListener(DRAG_END_CHANNEL, (s, args) =>
            {
                if (scrim == null)
                {
                    return;
                }
                Application.Current.Dispatcher.Invoke(delegate
                {
                    scrim.Visibility = Visibility.Hidden;
                });
            });
        }
예제 #12
0
        //private bool _useExplicitChannels = false;
        internal LinkerClient(Finsemble bridge, EventHandler <bool> readyCallback)
        {
            this.bridge    = bridge;
            windowClient   = bridge.WindowClient;
            routerClient   = bridge.RouterClient;
            launcherClient = bridge.LauncherClient;
            key            = (bridge.windowName + "::" + bridge.uuid).Replace('.', '_');

            var storehandler = (EventHandler <StoreModel>) delegate(object sender, StoreModel store)
            {
                linkerStore = store;
                linkerStore.GetValue(new JObject {
                    ["field"] = "channels"
                }, delegate(object sender2, FinsembleEventArgs args)
                {
                    allChannels = args.response?["data"] as JArray;

                    var linkerStateHandler = (EventHandler <FinsembleEventArgs>) delegate(object sender3, FinsembleEventArgs args3)
                    {
                        //MessageBox.Show(args3?.response.ToString());
                        if (args3.response != null && args3.response.HasValues)
                        {
                            channels = args3.response as JArray;
                        }
                        else
                        {
                            channels = new JArray {
                            };
                        }

                        //MessageBox.Show(bridge.window, channels.ToString(), "", MessageBoxButton.YesNo);
                        //if (channels == null)
                        var clientsInStore = new JObject {
                        };
                        foreach (var item in channels)
                        {
                            clientsInStore[(string)item] = true;
                        }
                        clients[key] = new JObject
                        {
                            ["client"]   = windowClient.windowIdentifier,
                            ["active"]   = true,
                            ["channels"] = clientsInStore
                        };

                        readyToPersistState = true;
                        UpdateClientInStore(key);

                        stateChangeListeners?.Invoke(this, new FinsembleEventArgs
                                                     (
                                                         null, new JObject
                        {
                            ["channels"]    = channels,
                            ["allChannels"] = allChannels
                        }
                                                     ));

                        readyCallback(this, true);
                    };
                    bridge.WindowClient.GetComponentState(new JObject {
                        ["field"] = "Finsemble_Linker"
                    }, linkerStateHandler);
                });

                linkerStore.AddListener(new JObject
                {
                    ["field"] = "clients." + key
                }, delegate(object sender4, FinsembleEventArgs args4)
                {
                    var newChannelsObject = args4.response?["data"]?["value"]?["channels"] as JObject;
                    var newChannelsArray  = new JArray {
                    };
                    if (newChannelsObject != null)
                    {
                        foreach (var item in newChannelsObject)
                        {
                            newChannelsArray.Add(item.Key);
                        }
                    }
                    channels = newChannelsArray;

                    stateChangeListeners?.Invoke(this, new FinsembleEventArgs
                                                 (
                                                     null, new JObject
                    {
                        ["channels"]    = channels,
                        ["allChannels"] = allChannels
                    }
                                                 ));

                    if (readyToPersistState)
                    {
                        PersistState();
                    }

                    UpdateListeners();
                });

                linkerStore.AddListener(null,
                                        delegate(object sender4, FinsembleEventArgs args4)
                {
                    var newAllChannels = args4.response?["data"]?["storeData"]?["values"]?["channels"] as JArray;
                    if (newAllChannels != null)
                    {
                        allChannels = newAllChannels;
                    }
                    clients = args4.response?["data"]?["storeData"]?["values"]?["clients"] as JObject;
                    if (clients == null)
                    {
                        clients = new JObject {
                        }
                    }
                    ;
                });
            };

            bridge.distributedStoreClient.GetStore(new JObject {
                ["store"] = "Finsemble_Linker", ["global"] = true
            }, storehandler);
        }
 internal DistributedStoreClient(Finsemble bridge)
 {
     this.bridge = bridge;
 }