GetEntries() public static method

public static GetEntries ( ) : IEnumerable
return IEnumerable
Ejemplo n.º 1
0
        public static void UpdateTaskbarServers()
        {
            if (!TaskbarManager.IsPlatformSupported)
            {
                return;
            }

            var jl             = JumpList.CreateJumpList();
            var serverCategory = new JumpListCustomCategory("Servers");

            string exe = Process.GetCurrentProcess().MainModule.FileName;

            IList <ServerEntry> servers = Servers.GetEntries().ToList();

            JumpListLink[] links = new JumpListLink[servers.Count];
            for (int i = 0; i < servers.Count; ++i)
            {
                var s = servers[i];
                links[i] = new JumpListLink(exe, s.Name)
                {
                    Arguments     = s.Id.ToString(),
                    IconReference = new IconReference(exe, 1)
                };
            }

            serverCategory.AddJumpListItems(links);

            jl.AddCustomCategories(serverCategory);

            try {
                jl.Refresh();
            } catch (UnauthorizedAccessException) {             // Jumplists disabled
            }
        }
Ejemplo n.º 2
0
        private void LoadServerEntries()
        {
            this.servers.BeginUpdate();
            this.servers.Items.Clear();

            //GablarskiClient.FindLocalServers (0, DisplayLocalServer, () => !(this.IsDisposed || !this.Visible));

            this.servers.Groups.Add("local", "Local Servers");
            var saved = this.servers.Groups.Add("dbentries", "Saved Servers");

            foreach (var entry in Servers.GetEntries())
            {
                var li = this.servers.Items.Add(entry.Name);
                li.Tag      = entry;
                li.ImageKey = "serverQuery";
                saved.Items.Add(li);

                GablarskiClient.QueryAsync(Program.Key.Result, new Target(entry.Host, entry.Port), TimeSpan.FromSeconds(10)).ContinueWith(t => {
                    if (IsDisposed || Disposing || this.closing)
                    {
                        return;
                    }

                    if (t.IsCanceled)
                    {
                        UpdateImage(li, "serverConnectError");
                        return;
                    }

                    UpdateImage(li, "server");
                    var results    = t.Result;
                    li.ToolTipText = String.Format("{0}{1}Users: {2}", results.ServerInfo.Description, Environment.NewLine, results.Users.Count());
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }

            this.servers.EndUpdate();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            if (RaygunKey[0] != '{')
            {
                Raygun = new RaygunClient(RaygunKey);
            }

            AppDomain.CurrentDomain.UnhandledException += (sender, e) => {
                if (StartupLog != null)
                {
                    StartupLog.Error("Fatal Error", (Exception)e.ExceptionObject);
                }

                if (Raygun != null)
                {
                    Raygun.Send((Exception)e.ExceptionObject, null, Settings.CurrentSettings);
                }

                MessageBox.Show("Unexpected error" + Environment.NewLine + (e.ExceptionObject as Exception).ToDisplayString(),
                                "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            };

            //AutomaticErrorReporter errors = new AutomaticErrorReporter();
            //errors.Add (new GablarskiErrorReporter (typeof(Program).Assembly));

            log4net.Config.XmlConfigurator.Configure();
            StartupLog = LogManager.GetLogger("Startup");
            StartupLog.DebugFormat("PID: {0}", Process.GetCurrentProcess().Id);

            FileInfo program = new FileInfo(Process.GetCurrentProcess().MainModule.FileName);

            Environment.CurrentDirectory = program.Directory.FullName;

            string useLocalValue = ConfigurationManager.AppSettings["useLocalDatabase"];
            bool   useLocal;

            Boolean.TryParse(useLocalValue, out useLocal);

            StartupLog.DebugFormat("Local files: {0}", useLocal);
            StartupLog.DebugFormat("Setting up databases..");

            ClientData.Setup(useLocal);

            StartupLog.DebugFormat("Databases setup.");

            CheckForUpdates();

            StartupLog.Debug("Starting key retrieval");
            var keyCancelSource = new CancellationTokenSource();

            Key = ClientData.GetCryptoKeyAsync(keyCancelSource.Token);
            Key.ContinueWith(t => StartupLog.DebugFormat("Key retrieval: {0}{1}{2}", t.Status, Environment.NewLine, t.Exception));

            SetupFirstRun();

            if (Settings.Nickname == null)
            {
                PersonalSetup();
            }

            if (!ShowKeyProgress(keyCancelSource))
            {
                return;
            }

            ResourceWebRequestFactory.Register();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //SetupSocial();

            /*MainWindow window = new MainWindow();
             * window.Show();*/

            var m = new MainForm();

            m.Show();

            UpdateTaskbarServers();

            if (args.Length > 0)
            {
                int id;
                if (Int32.TryParse(args[0], out id))
                {
                    ServerEntry server = Servers.GetEntries().FirstOrDefault(s => s.Id == id);
                    if (server == null)
                    {
                        if (!m.ShowConnect(true))
                        {
                            return;
                        }
                    }
                    else
                    {
                        m.Connect(server);
                    }
                }
                else
                {
                    Uri server = new Uri(args[0]);
                    m.Connect(server.Host, (server.Port != -1) ? server.Port : 42912);
                }
            }
            else if (Settings.ShowConnectOnStart)
            {
                if (!m.ShowConnect(true))
                {
                    return;
                }
            }

            /*System.Windows.Application app = new System.Windows.Application();
             * app.Run (window);*/

            Application.Run(m);

            Settings.Save();
        }