Exemple #1
0
        // 分享按钮点击事件
        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (isShare == 0)
            {
                return;
            }

            if (isShare == 2)
            {   // 复位
                isShare = 0;
                label_drag.Foreground = new SolidColorBrush(Color.FromRgb(28, 149, 205));
                label_drag.FontSize   = 16;
                label_drag.Content    = "拖放文件到此处";
                label_drag.AllowDrop  = true;
                button_share.Source   = new BitmapImage(
                    new Uri(@"imageAssets/Button_Mainpage_01_unable.png", UriKind.Relative));
                hint.Visibility = System.Windows.Visibility.Hidden;
                return;
            }

            // 分享文件, 异步上传
            ShareFiles sf = new ShareFiles(Share);

            sf.BeginInvoke(new AsyncCallback(CallBackShare), null);

            // 关闭分享按钮
            isShare             = 0;
            button_share.Source = new BitmapImage(
                new Uri(@"imageAssets/Button_Mainpage_01_unable.png", UriKind.Relative));

            label_drag.Content = "上传至服务器...";
        }
        private void GetShareInfo(object sender, ModelEventArgs e)
        {
            _sh = ShareFiles.Deserialize(_shareInfoPath);
            _sh.SharePathChanged += ((sender1, eventArg) => OnPropertyChanged("SharePath"));
            _sh.HashingPath      += ((sender1, arg) => AddHashingInfo(arg.Path));
            _sh.OnePathComplete  += ((sender1, arg) => AddHashCompleteInfo(arg.Path));

            Thread t = _sh.ListFile();

            t.Join();
            try
            {
                MaintenanceShareInfo();
                _client.UploadShareInfo(_sh.FileList);
                _client.RemoveOldFile(_sh.RemoveList);
                _sh.SetUploaded(_sh.FileList);
            }
            catch (Exception)
            {
                //throw;
            }

            SaveShareInfo();
            Show_ShareFile(null, ShareLoact);
        }
Exemple #3
0
        // 异步回调函数
        private void CallBackShare(IAsyncResult result)
        {
            ShareFiles sf = (ShareFiles)
                            ((System.Runtime.Remoting.Messaging.AsyncResult)result).AsyncDelegate;
            // 获取异步操作结果
            string res = sf.EndInvoke(result);

            // 上传成功则显示分享码
            if (res != null)
            {
                syncContext.Post(ShareCode, res);
            }
            else
            {
                syncContext.Post(Fail, "上传失败");
            }
        }