void Connection(string Host, string Port) { host = Host; if (!int.TryParse(Port, out port)) { LoadingAnim.Set(() => this.ShowMessageAsync("Error", "Connectriong port incorrect. Try again.")); Tabs.Set(() => Tabs.Visibility = Visibility.Visible); return; } client = new TcpClient(); try { client.Connect(host, port); //подключение клиента stream = client.GetStream(); // получаем поток string message = userName; byte[] data = Encoding.UTF8.GetBytes(message); stream.Write(data, 0, data.Length); int bytes = 0; data = new byte[256]; bytes = stream.Read(data, 0, data.Length); message = Encoding.UTF8.GetString(data, 0, bytes); //MessageBox.Show(message, "Infomation", MessageBoxButton.OK, MessageBoxImage.Asterisk); LoadingAnim.Set(() => this.ShowMessageAsync("Infomation", message)); DBInjector dbi = new DBInjector(); if (dbi.Servers.ToList().Where(a => a.host == host && a.port == port).ToList().Count <= 0) { dbi.Servers.Add(new ServerItem() { host = Host, port = port, DBDownItems = new List <DBDownItem>() }); dbi.SaveChanges(); } Button_Click_1(null, null); Thread receiveThread = new Thread(new ThreadStart(ReceiveMessage)); receiveThread.Start(); Tabs.Set(() => { Tabs.Visibility = Visibility.Visible; Title = "Client: Connect."; }); DownMan = new DownloadManager.DownloadManager(host, port, this); DMList.Set(() => { DMList.ItemsSource = DownMan.items; SaveFolder.Text = DownMan.DownloadFolder; BtnChangeSaveFolder.IsEnabled = true; }); } catch (Exception ex) { LoadingAnim.Set(() => this.ShowMessageAsync("Error", ex.Message)); Tabs.Set(() => Tabs.Visibility = Visibility.Visible); } Tabs.Set(() => Tabs.SelectedIndex = 1); }
private void FolderTreeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (FolderTreeView.SelectedIndex != -1) { if (!isFileDownload) { if ((FolderTreeView.SelectedItem as TemplateFileElement).isFile == true) { //using (var dialog = new System.Windows.Forms.FolderBrowserDialog()) //{ // if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) // { // return; // } // else // { // DownloadPath = dialog.SelectedPath; // } //} } else { SendMessage("/FolderInfo " + currentFTPpath + (FolderTreeView.SelectedItem as TemplateFileElement).path); return; } if (!DownMan.AddNewItem(currentFTPpath + (FolderTreeView.SelectedItem as TemplateFileElement).path)) { LoadingAnim.Set(() => this.ShowMessageAsync("Error", "The file is already in DownloadManager")); } } } }
public void MahAppsMessage(string message, string header) { LoadingAnim.Set(() => this.ShowMessageAsync(message, header)); }
void Start() { // Parent UI object nedded to set it a gui element _parentUI = GameObject.FindGameObjectWithTag("Menus"); // References to animations _loadingAnim = FindObjectOfType<LoadingAnim>(); // Start fade in BeginFade(true); }