示例#1
0
        private void OpenPerfume_Click(object sender, RoutedEventArgs e)
        {
            WindowPerfume wp = new WindowPerfume();

            wp.Show();

            foreach (var item in lp.Perfumes)
            {
                if (listBoxPerfume.SelectedItem.ToString() == item.Name)
                {
                    wp.TextBlockName.Text        = item.Name;
                    wp.TextBlockGender.Text      = item.Gender;
                    wp.TextBlockDescription.Text = item.Description;
                    wp.TextBlockBrand.Text       = item.Brand;
                    wp.TextblockKind.Text        = item.Kind;
                    wp.TextBlockYear.Text        = item.Year.ToString();
                    BitmapImage img;
                    img             = new BitmapImage(new Uri(item.WayToPic.ToString()));
                    wp.Image.Source = img;
                }
            }
        }
示例#2
0
        private void Addpic_Click(object sender, RoutedEventArgs e)
        {
            WindowPerfume  wp             = new WindowPerfume();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.ShowDialog();
            openFileDialog.Filter = "jpeg|*.jpg";

            var fileN   = openFileDialog.FileName;
            var newPath = System.IO.Path.GetFileName(fileN);
            var curPAth = System.Reflection.Assembly.GetExecutingAssembly().Location;

            newPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(curPAth) + "\\img\\", newPath);

            if (!File.Exists(newPath))
            {
                File.Copy(fileN, newPath, true);
            }
            TextBoxImage.Text = newPath;
            BitmapImage sharerimg;

            sharerimg       = new BitmapImage(new Uri(TextBoxImage.Text));
            wp.Image.Source = sharerimg;
        }