Ejemplo n.º 1
0
        //private void MenuGroupReName_Click(object sender, RoutedEventArgs e)
        //{
        //    StackPanel stk = currentGroupStack;
        //    TextBox tb = stk.FindName("txtGroupName") as TextBox;
        //    TextBlock tblock = stk.FindName("tblkGroupName") as TextBlock;
        //    tblock.Visibility = System.Windows.Visibility.Collapsed;
        //    tb.Visibility = Visibility.Visible;
        //    tb.Focus();
        //}
        //private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
        //{
        //currentGroup =   (sender as  StackPanel).DataContext as tblProjectGroup;
        //currentGroupStack =  sender as StackPanel;
        // treeView1.SelectItem(currentGroup);
        //}
        //private void txtGroupName_LostFocus(object sender, RoutedEventArgs e)
        //{
        //    StackPanel stk = (sender as TextBox).Parent as StackPanel;
        //    TextBox tb = stk.FindName("txtGroupName") as TextBox;
        //    TextBlock tblock = stk.FindName("tblkGroupName") as TextBlock;
        //    tblock.Visibility = System.Windows.Visibility.Visible;
        //    tb.Visibility = Visibility.Collapsed;
        //    
        //}
        public static void SendFile(slPanel.Web.tblProjectGroup group, int projectid)
        {
            System.Windows.Controls.OpenFileDialog d = new OpenFileDialog();
            d.Filter = "Image (*.png, *.jpg) |*.png;*.jpg";
            //  d.ShowDialog();
            //try
            //{
            //    string filename = d.File.FullName;
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //    return;
            //}
            if (d.ShowDialog() == true)
            {

                Stream stream = d.File.OpenRead();

                Uri u = new Uri(Application.Current.Host.Source, "../Upload.ashx/?filename=" + d.File.Name + "&projectid=" + projectid);

                // MessageBox.Show(u.ToString());
                byte[] buffer = new byte[d.File.Length];
                stream.Read(buffer, 0, (int)d.File.Length);
                stream.Close();
                WebClient wc = new WebClient();
                wc.OpenWriteCompleted += (s, ee) =>
                {
                    if (ee.Error != null)
                    {
                        MessageBox.Show(ee.Error.Message);
                        return;
                    }
                    Stream outputStream = ee.Result;
                    outputStream.Write(buffer, 0, buffer.Length);
                    outputStream.Close();
                    MessageBox.Show("檔案上傳完成!");

                    group.GroupPicture = d.File.Name;
                    group.IsPictureDownload = true;

                    //System.Windows.Media.Imaging.BitmapImage img = new System.Windows.Media.Imaging.BitmapImage(new Uri(group.PicUrl));

                };
                wc.OpenWriteAsync(u);

            }
        }
 public chldLedPlanEdit(slPanel.Web.DomainService1 dbservice)
 {
     InitializeComponent();
     this.dbservice = dbservice;
 }