Exemplo n.º 1
0
        /// <summary>
        /// Open a box to pick a client with the desired options.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static Client ShowBox(ClientChooserOptions options)
        {
            List<Objects.Client> clients = null;
            if (options.LookUpClients)
            {
                clients = Objects.Client.GetClients(options.Version, options.OfflineOnly);
            }
            if (options.Smart &&
                options.LookUpClients &&
                !options.ShowOTOption &&
                clients != null &&
                clients.Count == 1)
            {
                return clients[0];
            }
            else
            {
                newClientChooser = new ClientChooserWPF();
                newClientChooser.Title = String.IsNullOrEmpty(options.Title) ? "Choose a client." : options.Title;

                if (options.LookUpClients)
                {
                    foreach (Client c in clients)
                    {
                        newClientChooser.uxClients.Items.Add(c);
                    }
                }

                if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Tibia\tibia.exe")))
                {
                    newClientChooser.uxClients.Items.Add(ClientChooserBase.NewClientDefaultText);
                }

                foreach (ClientPathInfo cpi in
                    ClientChooserBase.GetClientPaths(options.SavedClientPathsLocation))
                {
                    newClientChooser.uxClients.Items.Add(cpi);
                }

                newClientChooser.uxClients.Items.Add(ClientChooserBase.NewClientCustomText);
                newClientChooser.uxClients.SelectedIndex = 0;

                foreach (var ot in ClientChooserBase.GetServers(options.SavedServersLocation))
                {
                    newClientChooser.uxLoginServer.Items.Add(ot.LoginServer.Server + ":" + ot.LoginServer.Port);
                }

                if (newClientChooser.uxLoginServer.Items.Count > 0)
                    newClientChooser.uxLoginServer.SelectedIndex = 0;

                newClientChooser.uxUseOT.IsExpanded = options.UseOT;
                if (options.UseOT)
                {
                    newClientChooser.uxLoginServer.Text = options.Server + ":" + options.Port.ToString();
                }

                newClientChooser.options = options;
                newClientChooser.Topmost = options.Topmost;
                newClientChooser.ShowDialog();
                return client;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Open a box to pick a client with the desired options.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static Client ShowBox(ClientChooserOptions options)
        {
            List <Objects.Client> clients = null;

            if (options.LookUpClients)
            {
                clients = Objects.Client.GetClients(options.Version, options.OfflineOnly);
            }
            if (options.Smart &&
                options.LookUpClients &&
                !options.ShowOTOption &&
                clients != null &&
                clients.Count == 1)
            {
                return(clients[0]);
            }
            else
            {
                newClientChooser       = new ClientChooserWPF();
                newClientChooser.Title = String.IsNullOrEmpty(options.Title) ? "Choose a client." : options.Title;

                if (options.LookUpClients)
                {
                    foreach (Client c in clients)
                    {
                        newClientChooser.uxClients.Items.Add(c);
                    }
                }

                if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Tibia\tibia.exe")))
                {
                    newClientChooser.uxClients.Items.Add(ClientChooserBase.NewClientDefaultText);
                }

                foreach (ClientPathInfo cpi in
                         ClientChooserBase.GetClientPaths(options.SavedClientPathsLocation))
                {
                    newClientChooser.uxClients.Items.Add(cpi);
                }

                newClientChooser.uxClients.Items.Add(ClientChooserBase.NewClientCustomText);
                newClientChooser.uxClients.SelectedIndex = 0;

                foreach (var ot in ClientChooserBase.GetServers(options.SavedServersLocation))
                {
                    newClientChooser.uxLoginServer.Items.Add(ot.LoginServer.Server + ":" + ot.LoginServer.Port);
                }

                if (newClientChooser.uxLoginServer.Items.Count > 0)
                {
                    newClientChooser.uxLoginServer.SelectedIndex = 0;
                }

                newClientChooser.uxUseOT.IsExpanded = options.UseOT;
                if (options.UseOT)
                {
                    newClientChooser.uxLoginServer.Text = options.Server + ":" + options.Port.ToString();
                }

                newClientChooser.options = options;
                newClientChooser.Topmost = options.Topmost;
                newClientChooser.ShowDialog();
                return(client);
            }
        }