示例#1
0
        public static Window GetDisplayWindow()
        {
            try
            {
                if (_configWindow == null)
                {
                    _configWindow = new Window();
                }

                string assemblyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                string xamlPath     = Path.Combine(assemblyPath, "Plugins", "SimpleFollow", "UI", "Config.xaml");

                string xamlContent = File.ReadAllText(xamlPath);

                // This hooks up our object with our UserControl DataBinding
                _configWindow.DataContext = Settings.Instance;

                UserControl mainControl = (UserControl)XamlReader.Load(new MemoryStream(Encoding.UTF8.GetBytes(xamlContent)));
                _configWindow.Content    = mainControl;
                _configWindow.Width      = 300;
                _configWindow.Height     = 360;
                _configWindow.MinWidth   = 300;
                _configWindow.MinHeight  = 360;
                _configWindow.ResizeMode = ResizeMode.CanResizeWithGrip;

                _configWindow.Title = "SimpleFollow";

                _configWindow.Closed     += ConfigWindow_Closed;
                Application.Current.Exit += ConfigWindow_Closed;

                return(_configWindow);
            }
            catch (Exception ex)
            {
                Logr.Error("Unable to open Config window: " + ex);
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// Called by followers through FollowTag->Communicate()
        /// </summary>
        private static void ClientUpdate()
        {
            if (Enabled)
            {
                _updateRunning = true;
                try
                {
                    if (Host != null && Host.State == CommunicationState.Opened)
                    {
                        Logr.Log("Shutting down Server Service");
                        Host.Close();
                        Host = null;
                    }
                }
                catch (Exception ex)
                {
                    Logr.Error("Error shutting down server service: " + ex);
                }

                StartClient();

                try
                {
                    if (Initialized && Leader.GetMillisecondsSinceLastUpdate() >= 250)
                    {
                        // Get the leader message and store it
                        Leader = HttpProxy.GetUpdate();

                        // Send our follower message to the leader
                        HttpProxy.SendUpdate(_lastMessage);


                        if (LastLeaderUpdateMessage == null || LastLeaderUpdateMessage != Leader)
                        {
                            LastLeaderUpdateMessage = Leader;

                            SetQuestToolsOptionsFromLeader();

                            if (Settings.Instance.DebugLogging)
                            {
                                Logr.Debug("Leader {0}", Leader.ToString());
                            }
                        }
                    }
                }
                catch (EndpointNotFoundException ex)
                {
                    Logr.Error("Error 201: Could not get an update from the leader using {0}. Is the leader running? ({1})", HttpFactory.Endpoint.Address.Uri.AbsoluteUri, ex.Message);
                    Initialized = false;
                }
                catch (CommunicationException ex)
                {
                    Logr.Error("Error 202: Could not get an update from the leader using {0}. Is the leader running? ({1})", HttpFactory.Endpoint.Address.Uri.AbsoluteUri, ex.Message);
                    Initialized = false;
                }
                catch (Exception ex)
                {
                    Logr.Error("Error 203: Could not get an update from the leader using {0}. Is the leader running?", HttpFactory.Endpoint.Address.Uri.AbsoluteUri);
                    Initialized = false;
                    Logr.Log(ex.ToString());
                }
                _updateRunning = false;
            }
        }