コード例 #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);
                }
            }
        }
コード例 #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);
        }
コード例 #3
0
ファイル: Info.xaml.cs プロジェクト: RoyalTux/FTP-Client
        public Info(string size, string type, string name, string date, string address)
        {
            InitializeComponent();

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