Ejemplo n.º 1
0
        private void DownloadFile()
        {
            Info info = (Info)listbox.SelectedItem;

            if (info == null)
            {
                return;
            }

            InfoContext context = (InfoContext)info.DataContext;

            if (context.type != "FILE")
            {
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.FileName = context.Name;

            bool?result = dlg.ShowDialog();

            if (result == true)
            {
                try
                {
                    client.DownloadFile(context.Address + context.Name, dlg.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString() + ": \n" + ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        private void Info_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            InfoContext context = (InfoContext)(sender as Info).DataContext;

            switch (context.type)
            {
            case "FILE":
                return;

            case "DIR":
                txtboxAddress.Text = context.Address + context.Name + "/";
                btnConnect_Click(null, null);
                break;

            case "PREV":
                context.Address    = context.Address.TrimEnd('/');
                txtboxAddress.Text = context.Address.Remove(context.Address.LastIndexOf('/') + 1);
                break;
            }
            btnConnect_Click(null, null);
        }
Ejemplo n.º 3
0
        public Info(string size, string type, string name, string date, string address)
        {
            InitializeComponent();

            DataContext = new InfoContext(size, type, name, date, address);
        }