Esempio n. 1
0
 public void Remove(Server ntw)
 {
     if (ServerList.Remove(ntw))
     {
         ServerRemoved.Fire(this, new ServerEventArgs(ntw));
     }
 }
Esempio n. 2
0
        private async Task UserJoinedGuild(SocketGuildUser user)
        {
            var g      = user.Guild;
            var x      = ServerList.getServer(g);
            var u      = UserList.getUser(user);
            var output = ulong.TryParse(x.ServerLogChannel, out ulong LogID);
            var log    = g.GetTextChannel(LogID);

            if (x.AutoRoleName == "nul")
            {
                Console.WriteLine($"[{g.Name}] A new user has joined. No Autorole is set.");
                return;
            }
            else
            {
                var role = g.GetRole(x.AutoRoleID);
                if (role == null)
                {
                    EmbedBuilder e = Error.avb09();
                    await log.SendMessageAsync("", false, e.Build());
                }
                else
                {
                    await user.AddRoleAsync(role);

                    Console.WriteLine($"[{g.Name}] A new user has joined. Assigned {user.Username} the {role.Name} role.");
                }
            }
            UserList.SaveUser();
            ServerList.SaveServer();
        }
Esempio n. 3
0
 public int Delete(ServerList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Delete(entityToInsert));
     }
 }
Esempio n. 4
0
        private void SetupServerList()
        {
            if (Config.AuthListType != AuthListType.All)
            {
                return;
            }

            foreach (var s in Config.Servers)
            {
                if (!byte.TryParse(s.Key, out byte id))
                {
                    continue;
                }

                ServerList.Add(new ServerInfo
                {
                    AgeLimit       = 0,
                    CurrentPlayers = 0,
                    GamePort       = 0,
                    Ip             = IPAddress.None,
                    MaxPlayers     = 0,
                    PKFlag         = 0,
                    QueuePort      = 0,
                    ServerId       = id,
                    Status         = 0
                });
            }
        }
Esempio n. 5
0
    static void Main(string[] args)
    {
        ServerList   serverList   = new ServerList();
        ActiveServer activeServer = new ActiveServer();

        activeServer.SetState("Sicilia", "66.77.88.999");

        serverList.Add(activeServer.GetSnaphot());

        activeServer.SetState("Ireland", "55.66.77.999");

        serverList.Add(activeServer.GetSnaphot());

        activeServer.Restore(serverList.Get(0));

        activeServer.Restore(serverList.Get(1));

        activeServer.SetState("Oregon", "88.99.77.999");

        serverList.Add(activeServer.GetSnaphot());

        activeServer.Restore(serverList.Get(1));

        activeServer.Restore(serverList.Get(2));

        Console.ReadKey();
    }
 void StartTcpServer()
 {
     try
     {
         while (true)
         {
             string data = null;
             int    j    = 0;
             while (true)
             {
                 byte[] bytes = new byte[11000000];
                 int    i;
                 stream = List[j].Client.GetStream();
                 if (stream.DataAvailable)
                 {
                     i    = stream.Read(bytes, 0, bytes.Length);
                     data = Encoding.ASCII.GetString(bytes, 0, i);
                     if (data.Contains("PNG"))
                     {
                         SentClient(bytes, List[j].Id);
                         ServerEntity serverEntity = new ServerEntity();
                         serverEntity.Message = data;
                         var action = new Action(() => { ServerList.Add(serverEntity); });
                         Task.Run(() => App.Current.Dispatcher.BeginInvoke(action)).Wait();
                         data  = null;
                         bytes = null;
                     }
                     else
                     {
                         ServerEntity serverEntity = new ServerEntity();
                         string[]     arr          = data.Split('`');
                         serverEntity.Message = arr[0];
                         var action = new Action(() => { ServerList.Add(serverEntity); });
                         Task.Run(() => App.Current.Dispatcher.BeginInvoke(action)).Wait();
                         byte[] msg = Encoding.ASCII.GetBytes(arr[0]);
                         SentClient(msg, List[j].Id);
                     }
                 }
                 j++;
                 if (j == List.Count)
                 {
                     j = 0;
                 }
             }
             client.Close();
         }
     }
     catch (SocketException e)
     {
         MessageBox.Show("SocketException: {0}", e.Message);
     }
     catch (Exception e)
     {
         MessageBox.Show("Exception" + e.Message);
     }
     finally
     {
         server.Stop();
     }
 }
        public ServersViewModel()
        {
            _serverList   = new ServerList();
            _launcher     = new Launcher();
            _popupService = new PopupService();
            _storage      = new JSONStorage();
            if (_storage.Exists("config.json"))
            {
                _configuration = _storage.Read <Configuration>("config.json");
            }
            else
            {
                _configuration = new Configuration();
            }

            _servers     = new KeyedCollection <String, ServerObservable>(SynchronizationContext.Current);
            _serversView = new ServersView(_servers);

            _refresh             = new RelayCommand(_ => true, _ => DoRefresh());
            _pingAll             = new RelayCommand(_ => true, _ => DoPingAll());
            _pingSelected        = new RelayCommand(_ => _selectedServer != null, _ => DoPingOne(_selectedServer));
            _joinSelected        = new RelayCommand(_ => _selectedServer != null, _ => DoJoin(_selectedServer));
            _copyAddressSelected = new RelayCommand(_ => _selectedServer != null, _ => CopyAddress(_selectedServer));

            Mapper.CreateMap <Server, ServerObservable>();
            Mapper.CreateMap <ServerSettings, ServerSettingsObservable>();
            Mapper.CreateMap <ServerObservable, ServerObservable>().ForMember(s => s.Latency, opt => opt.Ignore());
            Mapper.AssertConfigurationIsValid();

            DoRefresh();
            DoCheckUpdate();
        }
Esempio n. 8
0
        public async Task MessageDeleted(Cacheable <IMessage, ulong> cache, ISocketMessageChannel channel)
        {
            try
            {
                SocketGuild guild  = ((SocketGuildChannel)channel).Guild;
                ServerList  server = ServerListsManager.GetServer(guild);
                if (cache.Id == server.RuleMessageId)
                {
                    //The rule reaction will be disabled and the owner of the guild will be notified.
                    server.RuleEnabled = false;

                    ServerListsManager.SaveServerList();

                    IDMChannel dm = await guild.Owner.GetOrCreateDMChannelAsync();

                    await dm.SendMessageAsync(
                        $"Your rule reaction on the Discord server **{guild.Name}** has been disabled due to the message being deleted.\n" +
                        "You can enable it again after setting a new reaction message with the command `setuprulesmessage` and then enabling the feature again with `togglerulereaction`.");
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                Logger.Log(ex.ToString(), LogVerbosity.Error);
#else
                Logger.Log(ex.Message, LogVerbosity.Error);
#endif
            }
        }
Esempio n. 9
0
        protected virtual void LoggedIn()
        {
            GHub.Settings.ACCOUNTS.account acc = GHub.Settings.ACCOUNTS.usersAccounts.GetAccount(this.nick);
            if (acc == null)
            {
                this.SendMessage("<GHub> " + GHub.Settings.ACCOUNTS.profiles.DefaultProfile.OnJoinMessage + "|");
            }
            else
            {
                this.SendMessage("<GHub> " + GHub.Settings.ACCOUNTS.usersAccounts.GetAccount(this.nick).Profile.OnJoinMessage + "|");
            }

            string newUser = "******" + this.isOP.ToString() + " " + this.rawUserInfo + "|";

            // we can't use the normle serach to send this message because the user is not fully
            // logged in yet. therefor we have to send it the old way

            GHub.client.server.Server client;
            for (int i = 0; i < this.ServerList.Size(); i++)
            {
                client = (GHub.client.server.Server)ServerList.Get(i);
                if (client.isLoggedIn)
                {
                    client.SendMessage(newUser);
                }
            }
        }
        /// <summary>
        /// 服务器列表分页
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public async Task AddServer(ServerList model)
        {
            model.ServerPass = AESDEncrypt.Encrypt(model.ServerPass);
            await _iserverlistrepository.Insert(model);

            await _iserverlistrepository.Save();
        }
        /// <summary>
        /// Function that finds a server with space for additional clients to be added.
        /// </summary>
        /// <param name="serverType">The type of server to search for</param>
        /// <returns></returns>
        public override ServerModel GetAvailableServer(ServerTypes serverType)
        {
            // Is there a server with room on it?
            var available            = false;
            var availableServerIndex = -1;

            foreach (var server in ServerList
                     .Where(server => server.Value.ConnectedClientModelList.Count < ReversiSettings.MaxReversiServerConnections - 1)
                     .Where(server => server.Value.Type == serverType))
            {
                available            = true;
                availableServerIndex = server.Key;
                break;
            }

            // If no servers are available, create a new server;
            ServerModel newServer;

            if (!available)
            {
                // TODO:  Will this crash if there is already a reversi game server running?
                newServer = new ReversiGameServerModel(GlobalSettings.ServerAddress, GlobalSettings.Port_GameServer);
                AddServerToManager(newServer);
            }
            else
            {
                // Retrieve the server by its index value
                newServer = GetServerFromListById(availableServerIndex);
            }

            return(newServer);
        }
Esempio n. 12
0
        private void MenuItemServerToBrowser_Click(object sender, RoutedEventArgs e)
        {
            SmartItem[] items = ServerList.SelectedItems(ClientHelper.Items);
            if (items == null)
            {
                return;
            }

            string uRL = null, host = null;

            try { host = "http://" + Regex.Replace(ClientHelper.Server, @"^(www|ftp)\.", "", RegexOptions.Compiled); }
            catch (Exception exp) { ExceptionHelper.Log(exp); }

            try { uRL = Regex.Replace(ClientHelper.CurrentPath, "^/(public_html|www)/(.*)", host + @"/$2", RegexOptions.IgnoreCase | RegexOptions.Compiled); }
            catch (Exception exp) { ExceptionHelper.Log(exp); }

            if ((host == null) || (uRL == null))
            {
                return;
            }

            for (int i = 0; i < items.Length; i++)
            {
                try
                {
                    string url = uRL + items[i].ItemName.Replace(" ", "%20");
                    System.Diagnostics.Process.Start(url);
                }
                catch (Exception exp) { ExceptionHelper.Log(exp); }
            }
        }
Esempio n. 13
0
        private void MenuItemServerDownload_Click(object sender, RoutedEventArgs e)
        {
            HideServerToolbar();
            SmartItem[] ritems = ServerList.SelectedItems(ClientHelper.Items);
            if (ritems == null)
            {
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.InitialDirectory = AppSettings.Get("Path", "LastDownload", DirectoryHelper.DesktopDirectory);
            sfd.CheckFileExists  = false;
            sfd.OverwritePrompt  = false;
            sfd.FileName         = ritems[0].ItemName;

            if ((bool)sfd.ShowDialog())
            {
                string path = DirectoryHelper.GetPath(sfd.FileName);
                AppSettings.Set("Path", "LastDownload", path);
                if (!path.NullEmpty())
                {
                    ClientHelper.TransferItemsAsync(ritems, path, false);
                }
            }
        }
        internal override void SavePerformanceMetrics()
        {
            using (var dataContext = new PDDModelDataContext())
            {
                Logger.LogVerbose("SavePerformanceMetrics Called for RAM", GetType().Name);

                try
                {
                    if (ServerList.Count > 0)
                    {
                        dataContext.ServerDWs.InsertAllOnSubmit(ServerList.OfType <ServerDW>().ToList());
                        dataContext.SubmitChanges();
                    }

                    Logger.LogVerbose(string.Format("SavePerformanceMetrics Called for RAM - Success. Server Count: {0}", ServerList.Count),
                                      GetType().Name);
                }
                catch (Exception ex)
                {
                    Logger.LogError(string.Format("SavePerformanceMetrics Called for RAM - Failure. Details: {0}", ex.Message),
                                    GetType().Name);
                    throw ex;
                }
            }
        }
Esempio n. 15
0
 public bool Equals(VBucketServerMapDto?other)
 {
     return((other != null &&
             ServerList.AreEqual <string>(other.ServerList) &&
             VBucketMap.AreEqual(other.VBucketMap)) &&
            VBucketMapForward.AreEqual(other.VBucketMapForward));
 }
Esempio n. 16
0
        static void Main(string[] args)
        {
            ServerList serverList = new ServerList();

            var servers = serverList.Refresh();

            servers.Wait();
            foreach (Server server in servers.Result)
            {
                Console.WriteLine(server.Name);
            }

            var pings = serverList.Ping(servers.Result.Select(s => s.Address));

            pings.Wait();
            foreach (PingResult result in pings.Result)
            {
                if (result == null)
                {
                    continue;
                }
                Console.WriteLine("{0}: {1}", result.Reply.Status, result.Address);
            }

            IClient           ircClient  = new Client();
            IClientConnection connection = ircClient.CreateClientConnection("irc.freenode.net", 6666, null);

            connection.Connect().Wait();
            connection.Login("Harvester", "Harvester", "Harvester").Wait();
            connection.Join("#tz");

            Console.ReadKey();
        }
Esempio n. 17
0
        public async Task Scp(CommandContext ctx)
        {
            List <SCPServer> ServerList;

            try
            {
                ServerList = await Rest.GetOwnServersAsync(discordUrie.SCPID, discordUrie.SCPKey, Players : true, Info : true, Version : true, Online : true);
            }
            catch (Exception ex)
            {
                await ctx.RespondAsync(ex.Message);

                return;
            }
            var TargetServer            = ServerList.First();
            var FixedInfo               = Regex.Replace(TargetServer.Info, "<[^>]+>", "");
            DiscordEmbedBuilder builder = new DiscordEmbedBuilder();

            builder.Title = FixedInfo;
            builder.WithColor(new DiscordColor("#00ffff"));
            builder.AddField("Online", TargetServer.Online.ToString());
            builder.AddField("Players", TargetServer.Players);
            builder.AddField("Friendly fire", TargetServer.FF.ToString());
            builder.AddField("Version", TargetServer.Version);
            builder.AddField("Modded", TargetServer.Modded.ToString());
            await ctx.RespondAsync(embed : builder.Build());
        }
Esempio n. 18
0
        public async Task MessageBulkDeleted(IReadOnlyCollection <Cacheable <IMessage, ulong> > cacheable,
                                             ISocketMessageChannel channel)
        {
            try
            {
                SocketGuild guild  = ((SocketGuildChannel)channel).Guild;
                ServerList  server = ServerListsManager.GetServer(guild);

                //Depending on how many message were deleted, this could take awhile. Or well I assume that, it would need to be tested
                foreach (Cacheable <IMessage, ulong> cache in cacheable)
                {
                    if (cache.Id != server.RuleMessageId)
                    {
                        continue;
                    }

                    //The rule reaction will be disabled and the owner of the guild will be notified.
                    server.RuleEnabled = false;

                    ServerListsManager.SaveServerList();

                    IDMChannel dm = await guild.Owner.GetOrCreateDMChannelAsync();

                    await dm.SendMessageAsync(
                        $"Your rule reaction on the Discord server **{guild.Name}** has been disabled due to the message being deleted.\n" +
                        "You can enable it again after setting setting a new reaction message with the command `setuprulesmessage` and then enabling the feature again with `togglerulereaction`.");

                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("An error occured while managing a message bulk deleted event! {@Exception}", ex);
            }
        }
Esempio n. 19
0
 public cServer this[string COD3]
 {
     get
     {
         return(ServerList.FirstOrDefault(x => x.COD3 == COD3));
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Executes the command
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="context"></param>
        /// <param name="server"></param>
        /// <returns>Returns false if it isn't a command with a prefix</returns>
        private bool HandleCommand(IUserMessage msg, SocketCommandContext context, ServerList server)
        {
            int argPos = 0;

            if (!msg.HasStringPrefix(Global.BotPrefix, ref argPos) &&
                !msg.HasMentionPrefix(Global.BotUser, ref argPos))
            {
                return(false);
            }

            //Check user's permission to use command
            if (!CheckUserPermission(context, server, argPos))
            {
                context.Channel.SendMessageAsync(
                    "You do not have permission to use that command on this guild!").GetAwaiter().GetResult();
                return(true);
            }

            //Execute the command and handle the result
            IResult result = commands.ExecuteAsync(context, argPos, services).GetAwaiter().GetResult();

            HandleCommandResult(context, msg, result).GetAwaiter().GetResult();

            return(true);
        }
Esempio n. 21
0
        internal override void ProcessServer(Server server)
        {
            try
            {
                Logger.LogVerbose("ProcessServer Called for SQL", GetType().Name);
                var pageLifeExpectancy = SqlService.GetPageLifeExpectancyFromServerInstance(server);
                var lowMemory          = SqlService.GetLowMemorySignalStateFromServerInstance(server);

                ServerList.Add(new SQLServerDW
                {
                    CreatedOn             = DateTime.UtcNow,
                    ServerID              = server.ServerId,
                    SQLPageLifeExpectancy = pageLifeExpectancy,
                    LowMemorySignalState  = lowMemory
                });

                Logger.LogVerbose("ProcessServer Called for SQL - Success", GetType().Name);
            }
            catch (Exception ex)
            {
                var message = ex.GetExceptionDetails();
                Logger.LogError(string.Format("ProcessServer Called for SQL - Failure. Server: {0}. Details: {1}", server.ServerName, message), GetType().Name);
                throw ex;
            }
        }
Esempio n. 22
0
        public static string Output(string[] args)
        {
            //Update the authentication codes
            Authentication.UpdateAuth();
            //Convert HTTP GET data into a dictionary collection

            //Set _getDataString with the HTTP GET data from the server
            if (args.Length > 0)
            {
                _getDataString = args[0];
            }
            else
            {
                _getDataString = "";
            }

            //Build a Dictionary with the GET data for easier access
            m_GetData = Utility.RetrieveGetData(args);

            //Check if sortby is in the GET data
            string sortBy = RequestData("sortby");

            //If it is, Sort the list.
            if (sortBy.Length > 0)
            {
                ServerList.PublicServerList = ServerList.GetSortedPublicServers(sortBy);
            }

            /*START PAGE DATA*/
            { 0 }          //DO NOT REMOVE THIS
                           /*END PAGE DATA*/

            return(_output);
        }
Esempio n. 23
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (basicConfig_ != null)
        {
            hash ^= BasicConfig.GetHashCode();
        }
        if (database_ != null)
        {
            hash ^= Database.GetHashCode();
        }
        if (serverList_ != null)
        {
            hash ^= ServerList.GetHashCode();
        }
        if (zoneList_ != null)
        {
            hash ^= ZoneList.GetHashCode();
        }
        if (_unknownFields != null)
        {
            hash ^= _unknownFields.GetHashCode();
        }
        return(hash);
    }
Esempio n. 24
0
        /// <summary>
        /// Checks a user's warn status
        /// </summary>
        /// <param name="user"></param>
        public static void CheckUserWarnStatus(SocketGuildUser user)
        {
            if (user.IsBot)
            {
                return;
            }

            if (user.GuildPermissions.Administrator)
            {
                return;
            }

            UserAccountServerData userAccount = GetAccount(user).GetOrCreateServer(user.Guild.Id);
            ServerList            server      = ServerListsManager.GetServer(user.Guild);

            //Warnings needed for kick and ban are set to the same amount, and the user has enough warnings so just straight ban
            if (server.WarningsKickAmount == server.WarningsBanAmount &&
                userAccount.Warnings >= server.WarningsKickAmount)
            {
                user.BanUser((SocketUser)Global.BotUser, $"Banned for having {server.WarningsKickAmount} warnings.");
            }

            //Enough warnings for a kick
            else if (userAccount.Warnings == server.WarningsKickAmount)
            {
                user.KickUser((SocketUser)Global.BotUser, $"Kicked for having {server.WarningsKickAmount} warnings.");
            }

            //Enough warnings for a ban
            else if (userAccount.Warnings >= server.WarningsBanAmount)
            {
                user.BanUser((SocketUser)Global.BotUser, $"Banned for having {server.WarningsBanAmount} warnings.");
            }
        }
Esempio n. 25
0
        public async Task SetupSpam()
        {
            IDMChannel dm = await Context.User.GetOrCreateDMChannelAsync();

            ServerList   server = ServerListsManager.GetServer(Context.Guild);
            EmbedBuilder embed  = new EmbedBuilder();

            await Context.Channel.SendMessageAsync("Setup anti-spam status was sent to your dms.");

            //Initial embed setup
            embed.WithTitle("Anti-Spam Setup Status");
            embed.WithColor(new Color(255, 81, 168));
            embed.WithDescription(
                $"<:Menu:537572055760109568> Here is your anti-spam setup status for **{Context.Guild.Name}**.\nSee [here]({Global.websiteServerSetup + "anti-spam/"}) for more help.\n\n");
            embed.WithThumbnailUrl(Context.Guild.IconUrl);
            embed.WithCurrentTimestamp();

            //Mention user spam
            string mentionUserTitle = "<:Cross:537572008574189578> Mention user spam is disabled!";
            string mentionUserDes   =
                $"If a message with more then {server.AntiSpamSettings.MentionUsersPercentage}% of the server's users are mentioned, they will be warned.";

            if (server.AntiSpamSettings.MentionUserEnabled)
            {
                mentionUserTitle = "<:Check:537572054266806292> Mention user spam is enabled!";
            }

            //Role to role mentions
            embed.AddField(mentionUserTitle, mentionUserDes);
            embed.AddField("Role to Role mention",
                           $"**{server.AntiSpamSettings.RoleToRoleMentionWarnings}** mentions of the same user will result in one warning");

            await dm.SendMessageAsync("", false, embed.Build());
        }
Esempio n. 26
0
 public Guid Insert(ServerList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Insert <Guid>(entityToInsert));
     }
 }
Esempio n. 27
0
        internal override void SavePerformanceMetrics()
        {
            using (var dataContext = new PDDModelDataContext())
            {
                Logger.LogVerbose("SavePerformanceMetrics Called for CPU", this.GetType().Name);
                try
                {
                    if (ServerList.Count > 0)
                    {
                        dataContext.ServerProcessorDWs.InsertAllOnSubmit(ServerList.OfType <ServerProcessorDW>().ToList());
                        dataContext.SubmitChanges();
                    }

                    Logger.LogVerbose($"SavePerformanceMetrics Called for CPU - Success. Server Count: {ServerList.Count}",
                                      this.GetType().Name);
                }
                catch (Exception ex)
                {
                    var message = ex.GetExceptionDetails();
                    Logger.LogError($"SavePerformanceMetrics Called for CPU - Failure. Details: {message}",
                                    GetType().Name);
                    throw ex;
                }
            }
        }
Esempio n. 28
0
 public int Update(ServerList entityToInsert)
 {
     using (Conn)
     {
         return(Conn.Update(entityToInsert));
     }
 }
        private void OnDialogClosed(IDialogResult result)
        {
            // Check for exception
            if (result.Exception != null)
            {
                var e = result.Exception;
                Console.WriteLine($"Dialog failed. {(e.InnerException ?? e).Message}");
                return;
            }

            // Fetch parameters returned by the dialog view
            if (result.Parameters.ContainsKey("ServerName"))
            {
                string newServer = result.Parameters.GetValue <string>("ServerName");
                if (ServerList.Contains(newServer))
                {
                    Console.WriteLine($"Server exists");
                }
                else
                {
                    ServerList.Add(newServer);
                    Settings.ServerList = String.Join(",", ServerList);

                    Server = newServer;
                }
            }
        }
Esempio n. 30
0
        async Task OnActivateInternal()
        {
            await RefreshFilterCommand.ExecuteAsyncTask().ConfigureAwait(false);

            var ag = DomainEvilGlobal.SelectedGame.ActiveGame;

            if (ag.CalculatedSettings.InitialSynced && !ServerList.InitialSync)
            {
                await _contentManager.InitialServerSync().ConfigureAwait(false);

                return;
            }

            var am = ag == null ? null : ag.CalculatedSettings.Collection;

            if (_lastContent == am && _lastGame == ag)
            {
                return;
            }
            _lastGame    = ag;
            _lastContent = am;
            if (ServerList.InitialSync)
            {
                await ServerList.UpdateServers().ConfigureAwait(false);
            }
        }
Esempio n. 31
0
        public void InsertIntoTableInsertsIntoTableIfKeyNotFound()
        {
            var list = new ServerList();
            const string hostname = "somehostname";

            Assert.Throws<KeyNotFoundException>(() => { var server = list[hostname]; });
            list.InsertOrUpdate(new ServerRegistration {Hostname = hostname, Port = 4200});
            Assert.IsNotNull(list[hostname]);
        }
Esempio n. 32
0
 public void InsertIntoTableThrowsExceptionIfHostnameIsNull()
 {
     Assert.Throws<ArgumentNullException>(() =>
                                          {
                                              var list = new ServerList();
                                              list.InsertOrUpdate(new ServerRegistration
                                                                  {
                                                                      Hostname = null,
                                                                      Port = 4200
                                                                  });
                                          });
 }
Esempio n. 33
0
 public void InsertIntoTableThrowsExceptionIfHostNameIsEmpty()
 {
     Assert.Throws<ArgumentException>(() =>
                                      {
                                          var list = new ServerList();
                                          list.InsertOrUpdate(new ServerRegistration
                                                              {
                                                                  Hostname = string.Empty,
                                                                  Port = 4200
                                                              });
                                      });
 }
Esempio n. 34
0
        public void ExpireServersExpiresIfServerHasNotBeenUpdated()
        {
            var list = new ServerList();
            const string hostname = "somehostname";
            list.InsertOrUpdate(new ServerRegistration {Hostname = hostname, Port = 4200});
            var server = list[hostname];
            var updateTime = server.LastUpdateTime;
            list.ExpireServers(updateTime);
            Assert.IsNotNull(list[hostname]);

            list.ExpireServers(updateTime + TimeSpan.FromMinutes(11));
            Assert.Throws<KeyNotFoundException>(() => { var notThere = list[hostname]; });
        }
Esempio n. 35
0
 /// <summary>
 /// Moves the code to server.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="destinationLocation">The destination location.</param>
 /// <returns></returns>
 private Task MoveCodeToServer(ServerList server,string destinationLocation)
 {
     var dir = new DirectoryInfo(destinationLocation);
     FileInfo fileDetails = dir.EnumerateFiles("*.zip", SearchOption.AllDirectories).First();
     var client = new HttpClient();
     var message = new HttpRequestMessage();
     var content = new MultipartFormDataContent();
     var filestream = new FileStream(fileDetails.FullName, FileMode.Open);
     string fileName = Path.GetFileName(fileDetails.FullName);
     content.Add(new StreamContent(filestream), "file", fileName);
     content.Add(new StringContent(server.DeployDirectory), "Directory");
     message.Method = HttpMethod.Post;
     message.Content = content;
     message.RequestUri = new Uri(server.ServerUrl + "/api/Deploy");
     return client.SendAsync(message).ContinueWith(task => { task.Result.EnsureSuccessStatusCode(); });
 }
Esempio n. 36
0
 public DataModel(MainWindow mainWindow)
 {
     MainWindow = mainWindow;
     ServerList = new ServerList();
     ServerSession = new ServerSession(this);
     ServerStatus = new ServerStatus(this);
     Database = new Database(this);
     QuickSearch = new QuickSearch(this);
     AdvancedSearch = new AdvancedSearch(this);
     DatabaseView = new DatabaseView(this);
     StreamsCollection = new StreamsCollection();
     SavedPlaylists = new SavedPlaylists(this);
     CurrentSong = new CurrentSong(this);
     Playlist = new Playlist(this);
     OutputCollection = new OutputCollection(this);
     CustomDateNormalizer = new DateNormalizer();
     CustomDateNormalizer.ReadFromSettings();
     YearNormalizer = new DateNormalizer(new string[] {"YYYY"});
 }
Esempio n. 37
0
        public AggregationPoller(ServerList serverList, DataManager dataManager, TimeSpan pollingInterval)
        {
            if (serverList == null)
            {
                throw new ArgumentNullException("serverList");
            }

            if (dataManager == null)
            {
                throw new ArgumentNullException("dataManager");
            }

            if (pollingInterval <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("pollingInterval");
            }

            serverList.LatestCounterTimeUpdated += this.UpdateServerCounterTime;
            this.dataManager = dataManager;
            this.pollingInterval = pollingInterval;
            this.taskRunner = new SemaphoreTaskRunner(this.dataManager.Counters.Count());
        }
Esempio n. 38
0
 public ListServersRequestHandler(ServerList serverList)
 {
     this.serverList = serverList;
 }
Esempio n. 39
0
        private bool PublishToSavedUri(IPanoramaPublishClient publishClient, Uri panoramaSavedUri, string fileName,
            ServerList servers)
        {
            var message = TextUtil.LineSeparate(Resources.SkylineWindow_ShowPublishDlg_This_file_was_last_published_to___0_,
                Resources.SkylineWindow_ShowPublishDlg_Publish_to_the_same_location_);
            if (MultiButtonMsgDlg.Show(this, string.Format(message, panoramaSavedUri),
                    MultiButtonMsgDlg.BUTTON_YES, MultiButtonMsgDlg.BUTTON_NO, false) != DialogResult.Yes)
                return false;

            var server = servers.FirstOrDefault(s => s.URI.Host.Equals(panoramaSavedUri.Host));
            if (server == null)
                return false;

            JToken folders;
            var folderPath = panoramaSavedUri.AbsolutePath;
            try
            {
                folders = publishClient.GetInfoForFolders(server, folderPath.TrimEnd('/').TrimStart('/'));
            }
            catch (WebException)
            {
                return false;
            }

            // must escape uri string as panorama api does not and strings are escaped in schema
            if (folders == null || !folderPath.Contains(Uri.EscapeUriString(folders["path"].ToString()))) // Not L10N
                return false;

            if (!PanoramaUtil.CheckFolderPermissions(folders) || !PanoramaUtil.CheckFolderType(folders))
                return false;

            var fileInfo = new FolderInformation(server, true);
            if (!publishClient.ServerSupportsSkydVersion(fileInfo, this, this))
                return false;

            var zipFilePath = FileEx.GetTimeStampedFileName(fileName);
            if (!ShareDocument(zipFilePath, false))
                return false;

            var serverRelativePath = folders["path"].ToString() + '/'; // Not L10N
            serverRelativePath = serverRelativePath.TrimStart('/');
            publishClient.UploadSharedZipFile(this, server, zipFilePath, serverRelativePath);
            return true; // success!
        }
Esempio n. 40
0
        public void Dispose()
        {
            this.Stop();

            if (this.aggregationPoller != null)
            {
                this.aggregationPoller.Dispose();
                this.aggregationPoller = null;
            }

            if (this.server != null)
            {
                this.server.Dispose();
                this.server = null;
            }

            if (this.registrationClient != null)
            {
                this.registrationClient.Dispose();
                this.registrationClient = null;
            }

            foreach (var handler in this.requestHandlers.Values)
            {
                if (handler.taskRunner != this.taskRunner)
                {
                    handler.taskRunner.Dispose();
                    handler.taskRunner = null;
                }
            }

            if (this.ServerList != null)
            {
                this.ServerList.Dispose();
                this.ServerList = null;
            }

            if (this.taskRunner != null)
            {
                this.taskRunner.Dispose();
                this.taskRunner = null;
            }
        }
        public void RefreshAll()
        {
            if(_isUpdating)
                return;

            object incrementLock = new object();

            _isUpdating = true;
            ProcessedServersCount = 0;
            _processed = 0;

            var items = new ServerList().GetAllSync(); // redownload list.
            var totalCount = items.Count;
            var t = new Thread(() =>
                               	{
                               		try
                               		{
                               			while(_processed <= totalCount)
                               			{
                               				Execute.OnUiThread(() =>
                               				                   	{
                               				                   		ProcessedServersCount = _processed;
                               				                   	});
                               				Thread.Sleep(150);
                               				if(_processed == totalCount)
                               				{
                               					_isUpdating = false;
                               					break;
                               				}
                               			}
                               		}
                               		finally
                               		{
                               			Execute.OnUiThread(() =>
                               			                   	{
                               			                   		ProcessedServersCount = totalCount;
                               			                   	});
                                        if(RefreshAllComplete != null)
                                            RefreshAllComplete();
                               			_isUpdating = false;
                               		}
                               	});
            t.IsBackground = true;
            t.Start();

            var serverUpdates = items
                .Select<Server, Action<Action>>(server =>
                                                onComplete =>
                                                server.BeginUpdate(doubleDispatchServer =>
                                                                   	{
                                                                   		try
                                                                   		{
                                                                   			onComplete();
                                                                   		}
                                                                   		finally
                                                                   		{
                                                                   			lock (incrementLock)
                                                                   			{
                                                                   				_processed++;
                                                                   			}
                                                                   		}
                                                                   	}))
                .ToArray();
            ServerRefreshQueue.Instance.Enqueue(serverUpdates);
        }
Esempio n. 42
0
        internal MainForm(string strView,
            string strGeoTiff, string strGeotiffName, bool bGeotiffTmp,
            string strKMLFile, string strKMLName, bool blKMLTmp,
            string strLastView, Dapple.Extract.Options.Client.ClientType eClientType, RemoteInterface oMRI, GeographicBoundingBox oAoi, string strAoiCoordinateSystem, string strMapFileName)
        {
            if (String.Compare(Path.GetExtension(strView), ViewExt, true) == 0 && File.Exists(strView))
                this.openView = strView;

            m_strOpenGeoTiffFile = strGeoTiff;
            m_strOpenGeoTiffName = strGeotiffName;
            m_blOpenGeoTiffTmp = bGeotiffTmp;

            m_strOpenKMLFile = strKMLFile;
            m_strOpenKMLName = strKMLName;
            m_blOpenKMLTmp = blKMLTmp;

            this.lastView = strLastView;
            s_oMontajRemoteInterface = oMRI;

            // Establish the version number string used for user display,
            // such as the Splash and Help->About screens.
            // To change the Application.ProductVersion make the
            // changes in \WorldWind\AssemblyInfo.cs
            // For alpha/beta versions, include " alphaN" or " betaN"
            // at the end of the format string.
            Version ver = new Version(Application.ProductVersion);
            Release = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
            if (ver.Build % 2 != 0)
                Release += " (BETA)";

            // Name the main thread.
            System.Threading.Thread.CurrentThread.Name = ThreadNames.EventDispatch;

            // Copy/Update any configuration files and other files if needed now
            CurrentSettingsDirectory = Path.Combine(UserPath, "Config");
            Directory.CreateDirectory(CurrentSettingsDirectory);
            Settings.CachePath = Path.Combine(UserPath, "Cache");
            Directory.CreateDirectory(Settings.CachePath);
            this.metaviewerDir = Path.Combine(UserPath, "Metadata");
            Directory.CreateDirectory(this.metaviewerDir);
            string[] cfgFiles = Directory.GetFiles(Path.Combine(DirectoryPath, "Config"), "*.xml");
            foreach (string strCfgFile in cfgFiles)
            {
                string strUserCfg = Path.Combine(CurrentSettingsDirectory, Path.GetFileName(strCfgFile));
                if (!File.Exists(strUserCfg))
                    File.Copy(strCfgFile, strUserCfg);
            }
            string[] metaFiles = Directory.GetFiles(Path.Combine(Path.Combine(DirectoryPath, "Data"), "MetaViewer"), "*.*");
            foreach (string strMetaFile in metaFiles)
            {
                string strUserMeta = Path.Combine(this.metaviewerDir, Path.GetFileName(strMetaFile));
                File.Copy(strMetaFile, strUserMeta, true);
            }

            // --- Set up a new user's favorites list and home view ---

            /*if (!File.Exists(Path.Combine(CurrentSettingsDirectory, "user.dapple_serverlist")))
            {
                File.Copy(Path.Combine(Path.Combine(DirectoryPath, "Data"), "default.dapple_serverlist"), Path.Combine(CurrentSettingsDirectory, "user.dapple_serverlist"));
            }*/
            HomeView.CreateDefault();

            InitSettings();

            if (Settings.NewCachePath.Length > 0)
            {
                try
                {
                    // We want to make sure the new cache path is writable
                    Directory.CreateDirectory(Settings.NewCachePath);
                    if (Directory.Exists(Settings.CachePath))
                        Utility.FileSystem.DeleteFolderGUI(this, Settings.CachePath, "Deleting Existing Cache");
                    Settings.CachePath = Settings.NewCachePath;
                }
                catch
                {
                }
                Settings.NewCachePath = "";
            }

            if (Settings.ConfigurationWizardAtStartup)
            {
                Wizard frm = new Wizard(Settings);
                frm.ShowDialog(this);
                Settings.ConfigurationWizardAtStartup = false;
            }

            if (Settings.ConfigurationWizardAtStartup)
            {
                // If the settings file doesn't exist, then we are using the
                // default settings, and the default is to show the Configuration
                // Wizard at startup. We only want that to happen the first time
                // World Wind is started, so change the setting to false(the user
                // can change it to true if they want).
                if (!File.Exists(Settings.FileName))
                {
                    Settings.ConfigurationWizardAtStartup = false;
                }
                ConfigurationWizard.Wizard wizard = new ConfigurationWizard.Wizard(Settings);
                wizard.TopMost = true;
                wizard.ShowInTaskbar = true;
                wizard.ShowDialog();
                // TODO: should settings be saved now, in case of program crashes,
                //	   and so that XML file on disk matches in-memory settings?
            }

            //#if !DEBUG
            using (this.splashScreen = new Splash())
            {
                this.splashScreen.Owner = this;
                this.splashScreen.Show();

                Application.DoEvents();
                //#endif

                // --- setup the list of images used for the different datatypes ---

                s_oImageList.ColorDepth = ColorDepth.Depth32Bit;
                s_oImageList.ImageSize = new Size(16, 16);
                s_oImageList.TransparentColor = Color.Transparent;

                s_oImageList.Images.Add(EnabledServerIconKey, Resources.enserver);
                s_oImageList.Images.Add(DisabledServerIconKey, Resources.disserver);
                s_oImageList.Images.Add(OfflineServerIconKey, Resources.offline);
                s_oImageList.Images.Add(DapIconKey, Resources.dap);
                s_oImageList.Images.Add(DapDatabaseIconKey, Resources.dap_database);
                s_oImageList.Images.Add(DapDocumentIconKey, Resources.dap_document);
                s_oImageList.Images.Add(DapGridIconKey, Resources.dap_grid);
                s_oImageList.Images.Add(DapMapIconKey, Resources.dap_map);
                s_oImageList.Images.Add(DapPictureIconKey, Resources.dap_picture);
                s_oImageList.Images.Add(DapPointIconKey, Resources.dap_point);
                s_oImageList.Images.Add(DapSpfIconKey, Resources.dap_spf);
                s_oImageList.Images.Add(DapVoxelIconKey, Resources.dap_voxel);
                s_oImageList.Images.Add(FolderIconKey, Resources.folder);
                s_oImageList.Images.Add(DapArcGisIconKey, global::Dapple.Properties.Resources.dap_arcgis);
                s_oImageList.Images.Add(KmlIconKey, Resources.kml);
                s_oImageList.Images.Add(ErrorIconKey, global::Dapple.Properties.Resources.error);
                s_oImageList.Images.Add(LayerIconKey, global::Dapple.Properties.Resources.layer);
                s_oImageList.Images.Add(LiveMapsIconKey, global::Dapple.Properties.Resources.live);
                s_oImageList.Images.Add(TileIconKey, global::Dapple.Properties.Resources.tile);
                s_oImageList.Images.Add(GeorefImageIconKey, global::Dapple.Properties.Resources.georef_image);
                s_oImageList.Images.Add(WmsIconKey, Resources.wms);
                s_oImageList.Images.Add(ArcImsIconKey, global::Dapple.Properties.Resources.arcims);
                s_oImageList.Images.Add(BlueMarbleIconKey, Dapple.Properties.Resources.blue_marble);
                s_oImageList.Images.Add(DesktopCatalogerIconKey, Dapple.Properties.Resources.dcat);

                c_oWorldWindow = new WorldWindow();
            #if !DEBUG
                Utility.AbortUtility.ProgramAborting += new MethodInvoker(c_oWorldWindow.KillD3DAndWorkerThread);
            #endif
                c_oWorldWindow.AllowDrop = true;
                c_oWorldWindow.DragOver += new DragEventHandler(c_oWorldWindow_DragOver);
                c_oWorldWindow.DragDrop += new DragEventHandler(c_oWorldWindow_DragDrop);
                c_oWorldWindow.Resize += new EventHandler(c_oWorldWindow_Resize);
                InitializeComponent();
                this.SuspendLayout();
                c_oLayerList.ImageList = s_oImageList;

            /*#if DEBUG
                // --- Make the server tree HOOGE ---
                this.splitContainerMain.SplitterDistance = 400;
                this.splitContainerLeftMain.SplitterDistance = 400;
            #endif*/

                this.Icon = new System.Drawing.Icon(@"app.ico");
                DappleToolStripRenderer oTSR = new DappleToolStripRenderer();
                c_tsSearch.Renderer = oTSR;
                c_tsLayers.Renderer = oTSR;
                c_tsOverview.Renderer = oTSR;
                c_tsMetadata.Renderer = oTSR;

                c_tsNavigation.Renderer = new BorderlessToolStripRenderer();

                // set Upper and Lower limits for Cache size control, in bytes
                long CacheUpperLimit = (long)Settings.CacheSizeGigaBytes * 1024L * 1024L * 1024L;
                long CacheLowerLimit = (long)Settings.CacheSizeGigaBytes * 768L * 1024L * 1024L;	//75% of upper limit

                try
                {
                    Directory.CreateDirectory(Settings.CachePath);
                }
                catch
                {
                    // We get here when people used a cache drive that since dissappeared (e.g. USB flash)
                    // Revert to default cache directory in this case

                    Settings.CachePath = Path.Combine(UserPath, "Cache");
                    Directory.CreateDirectory(Settings.CachePath);
                }

                //Set up the cache
                c_oWorldWindow.Cache = new Cache(
                    Settings.CachePath,
                    CacheLowerLimit,
                    CacheUpperLimit,
                    Settings.CacheCleanupInterval,
                    Settings.TotalRunTime);

                #region Plugin + World Init.

                WorldWind.Terrain.TerrainTileService terrainTileService = new WorldWind.Terrain.TerrainTileService("http://worldwind25.arc.nasa.gov/wwelevation/wwelevation.aspx", "srtm30pluszip", 20, 150, "bil", 12, Path.Combine(Settings.CachePath, "Earth\\TerrainAccessor\\SRTM"), TimeSpan.FromMinutes(30), "Int16");
                WorldWind.Terrain.TerrainAccessor terrainAccessor = new WorldWind.Terrain.NltTerrainAccessor("SRTM", -180, -90, 180, 90, terrainTileService, null);

                WorldWind.World world = new WorldWind.World("Earth",
                    new Point3d(0, 0, 0), Quaternion4d.RotationYawPitchRoll(0, 0, 0),
                    (float)6378137,
                    System.IO.Path.Combine(c_oWorldWindow.Cache.CacheDirectory, "Earth"),
                    terrainAccessor);

                c_oWorldWindow.CurrentWorld = world;
                c_oWorldWindow.DrawArgs.WorldCamera.CameraChanged += new EventHandler(c_oWorldWindow_CameraChanged);

                string strPluginsDir = Path.Combine(DirectoryPath, "Plugins");

                this.scalebarPlugin = new NASA.Plugins.ScaleBarLegend();
                this.scalebarPlugin.PluginLoad(this, strPluginsDir);
                this.scalebarPlugin.IsVisible = World.Settings.ShowScaleBar;

                this.starsPlugin = new Stars3D.Plugin.Stars3D();
                this.starsPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "Stars3D"));

                this.compassPlugin = new Murris.Plugins.Compass();
                this.compassPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "Compass"));

                String szGlobalCloudsCacheDir = Path.Combine(Settings.CachePath, @"Plugins\GlobalClouds");
                Directory.CreateDirectory(szGlobalCloudsCacheDir);
                String szGlobalCloudsPluginDir = Path.Combine(CurrentSettingsDirectory, @"Plugins\GlobalClouds");
                Directory.CreateDirectory(szGlobalCloudsPluginDir);

                if (!File.Exists(Path.Combine(szGlobalCloudsPluginDir, Murris.Plugins.GlobalCloudsLayer.serverListFileName)))
                {
                    File.Copy(Path.Combine(Path.Combine(strPluginsDir, "GlobalClouds"), Murris.Plugins.GlobalCloudsLayer.serverListFileName), Path.Combine(szGlobalCloudsPluginDir, Murris.Plugins.GlobalCloudsLayer.serverListFileName));
                }

                this.cloudsPlugin = new Murris.Plugins.GlobalClouds(szGlobalCloudsCacheDir);
                this.cloudsPlugin.PluginLoad(this, szGlobalCloudsPluginDir);

                this.skyPlugin = new Murris.Plugins.SkyGradient();
                this.skyPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "SkyGradient"));

                this.threeDConnPlugin = new ThreeDconnexion.Plugin.TDxWWInput();
                this.threeDConnPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "3DConnexion"));

                ThreadPool.QueueUserWorkItem(LoadPlacenames);

                c_scWorldMetadata.Panel1.Controls.Add(c_oWorldWindow);
                c_oWorldWindow.Dock = DockStyle.Fill;

                #endregion

                float[] verticalExaggerationMultipliers = { 0.0f, 1.0f, 1.5f, 2.0f, 3.0f, 5.0f, 7.0f, 10.0f };
                foreach (float multiplier in verticalExaggerationMultipliers)
                {
                    ToolStripMenuItem curItem = new ToolStripMenuItem(multiplier.ToString("f1", System.Threading.Thread.CurrentThread.CurrentCulture) + "x", null, new EventHandler(menuItemVerticalExaggerationChange));
                    c_miVertExaggeration.DropDownItems.Add(curItem);
                    curItem.CheckOnClick = true;
                    if (Math.Abs(multiplier - World.Settings.VerticalExaggeration) < 0.1f)
                        curItem.Checked = true;
                }

                this.c_miShowCompass.Checked = World.Settings.ShowCompass;
                this.c_miShowDLProgress.Checked = World.Settings.ShowDownloadIndicator;
                this.c_miShowCrosshair.Checked = World.Settings.ShowCrosshairs;
                this.c_miShowInfoOverlay.Checked = World.Settings.ShowPosition;
                this.c_miShowGridlines.Checked = World.Settings.ShowLatLonLines;
                this.c_miShowGlobalClouds.Checked = World.Settings.ShowClouds;
                if (World.Settings.EnableSunShading)
                {
                    if (!World.Settings.SunSynchedWithTime)
                        this.c_miSunshadingEnabled.Checked = true;
                    else
                        this.c_miSunshadingSync.Checked = true;
                }
                else
                    this.c_miSunshadingDisabled.Checked = true;
                this.c_miShowAtmoScatter.Checked = World.Settings.EnableAtmosphericScattering;

                this.c_miAskLastViewAtStartup.Checked = Settings.AskLastViewAtStartup;
                if (!Settings.AskLastViewAtStartup)
                    this.c_miOpenLastViewAtStartup.Checked = Settings.LastViewAtStartup;

                #region OverviewPanel

                // Fix: earlier versions of Dapple set the DataPath as an absolute reference, so if Dapple was uninstalled, OMapple could not find
                // the file for the overview control.  To fix this, switch the variable to a relative reference if the absolute one doesn't resolve.
                // Dapple will still work; the relative reference will be from whatever directory Dapple is being run.
                if (!Directory.Exists(Settings.DataPath)) Settings.DataPath = "Data";

                #endregion

                c_oWorldWindow.MouseEnter += new EventHandler(this.c_oWorldWindow_MouseEnter);
                c_oWorldWindow.MouseLeave += new EventHandler(this.c_oWorldWindow_MouseLeave);
                c_oOverview.AOISelected += new Overview.AOISelectedDelegate(c_oOverview_AOISelected);

                #region Search view setup

                this.c_oServerList = new ServerList();
                m_oModel = new DappleModel(c_oLayerList);
                m_oModel.SelectedNodeChanged += new EventHandler(m_oModel_SelectedNodeChanged);
                c_oLayerList.Attach(m_oModel);
                NewServerTree.View.ServerTree newServerTree = new NewServerTree.View.ServerTree();
                newServerTree.Attach(m_oModel);
                c_oServerList.Attach(m_oModel);
                c_oLayerList.LayerSelectionChanged += new EventHandler(c_oLayerList_LayerSelectionChanged);

                m_oMetadataDisplay = new MetadataDisplayThread(this);
                m_oMetadataDisplay.AddBuilder(null);
                c_oServerList.LayerList = c_oLayerList;
                c_oLayerList.GoTo += new LayerList.GoToHandler(this.GoTo);

                c_oLayerList.ViewMetadata += new ViewMetadataHandler(m_oMetadataDisplay.AddBuilder);
                c_oServerList.ViewMetadata += new ViewMetadataHandler(m_oMetadataDisplay.AddBuilder);
                c_oServerList.LayerSelectionChanged += new EventHandler(c_oServerList_LayerSelectionChanged);

                this.cServerViewsTab = new JanaTab();
                this.cServerViewsTab.SetImage(0, Resources.tab_tree);
                this.cServerViewsTab.SetImage(1, Resources.tab_list);
                this.cServerViewsTab.SetToolTip(0, "Server tree view");
                this.cServerViewsTab.SetToolTip(1, "Server list view");
                this.cServerViewsTab.SetNameAndText(0, "TreeView");
                this.cServerViewsTab.SetNameAndText(1, "ListView");
                this.cServerViewsTab.SetPage(0, newServerTree);
                this.cServerViewsTab.SetPage(1, this.c_oServerList);
                cServerViewsTab.PageChanged += new JanaTab.PageChangedDelegate(ServerPageChanged);

                c_oDappleSearch = new DappleSearchList();
                c_oDappleSearch.LayerSelectionChanged += new EventHandler(c_oDappleSearch_LayerSelectionChanged);
                c_oDappleSearch.Attach(m_oModel, c_oLayerList);

                c_tcSearchViews.TabPages[0].Controls.Add(cServerViewsTab);
                cServerViewsTab.Dock = DockStyle.Fill;
                c_tcSearchViews.TabPages[1].Controls.Add(c_oDappleSearch);
                c_oDappleSearch.Dock = DockStyle.Fill;

                c_oLayerList.SetBaseLayer(new BlueMarbleBuilder());

                this.ResumeLayout(false);

                #endregion

                this.PerformLayout();

                while (!this.splashScreen.IsDone)
                    System.Threading.Thread.Sleep(50);

                // Force initial render to avoid showing random contents of frame buffer to user.
                c_oWorldWindow.Render();
                WorldWindow.Focus();

                #region OM Forked Process configuration

                if (IsRunningAsDapClient)
                {
                    c_oLayerList.OMFeaturesEnabled = true;
                    this.MinimizeBox = false;

                    if (oAoi != null && !string.IsNullOrEmpty(strAoiCoordinateSystem))
                    {
                        s_oOMMapExtentNative = oAoi;
                        s_strAoiCoordinateSystem = strAoiCoordinateSystem;
                        s_strOpenMapFileName = strMapFileName;

                        s_oOMMapExtentWGS84 = s_oOMMapExtentNative.Clone() as GeographicBoundingBox;
                        s_oMontajRemoteInterface.ProjectBoundingRectangle(strAoiCoordinateSystem, ref s_oOMMapExtentWGS84.West, ref s_oOMMapExtentWGS84.South, ref s_oOMMapExtentWGS84.East, ref s_oOMMapExtentWGS84.North, Dapple.Extract.Resolution.WGS_84);
                    }
                    s_eClientType = eClientType;

                    c_miLastView.Enabled = false;
                    c_miLastView.Visible = false;
                    c_miDappleHelp.Visible = false;
                    c_miDappleHelp.Enabled = false;
                    toolStripSeparator10.Visible = false;
                    c_miOpenImage.Visible = false;
                    c_miOpenImage.Enabled = false;
                    c_miOpenKeyhole.Visible = false;
                    c_miOpenKeyhole.Enabled = false;

                    // Hide and disable the file menu
                    c_miFile.Visible = false;
                    c_miFile.Enabled = false;
                    c_miOpenSavedView.Visible = false;
                    c_miOpenSavedView.Enabled = false;
                    c_miOpenHomeView.Visible = false;
                    c_miOpenHomeView.Enabled = false;
                    c_miSetHomeView.Visible = false;
                    c_miSetHomeView.Enabled = false;
                    c_miSaveView.Visible = false;
                    c_miSaveView.Enabled = false;
                    c_miSendViewTo.Visible = false;
                    c_miSendViewTo.Enabled = false;
                    c_miOpenKeyhole.Visible = false;
                    c_miOpenKeyhole.Enabled = false;

                    // Show the OM help menu
                    c_miGetDatahelp.Enabled = true;
                    c_miGetDatahelp.Visible = true;

                    // Don't let the user check for updates.  EVER.
                    c_miCheckForUpdates.Visible = false;
                    c_miCheckForUpdates.Enabled = false;
                }
                else
                {
                    c_miExtractLayers.Visible = false;
                    c_miExtractLayers.Enabled = false;
                }

                #endregion

                loadCountryList();
                populateAoiComboBox();
                LoadMRUList();
                CenterNavigationToolStrip();
                //#if !DEBUG

                c_tbSearchKeywords.Text = NO_SEARCH;
            }
            //#endif
        }
 private void BTN_SERVERLIST_Click(object sender, RoutedEventArgs e)
 {
     ServerList List = new ServerList()
     {
         Owner = this,
     };
     List.ShowDialog();
 }
Esempio n. 44
0
 public RegisterRequestHandler(ServerList serverList)
 {
     this.serverList = serverList;
 }
Esempio n. 45
0
 public Network()
 {
     ServersValue = new ServerList();
     ServersValue.AssociatedNetwork = this;
 }