コード例 #1
0
 public VMRubbingPhotos(T_Rubbing rubbing)
 {
     _rubbing = rubbing;
     _Cvs_RubbingPhoto = new CollectionViewSource();
     _Cvs_RubbingPhoto.Source = rubbing.T_RubbingPhoto;
     _Cvs_RubbingPhoto.View.SortDescriptions.Add(new System.ComponentModel.SortDescription("PageNumber", System.ComponentModel.ListSortDirection.Ascending));
 }
コード例 #2
0
ファイル: VMRubbings.cs プロジェクト: JiNanCVT/Calligraphy
        public string AddRubbing(T_Rubbing rubbing, string[] photoPaths)
        {
            string errorMsg = IsValidatedPhoto(photoPaths);
            if (!string.IsNullOrEmpty(errorMsg))
                return errorMsg;

            CalligraphyEditor.App.Entities.AddToT_Rubbing(rubbing);
            CalligraphyEditor.App.Entities.SaveChanges();
            var q = from f in photoPaths orderby f select f;
            photoPaths = q.ToArray<string>();
            List<T_RubbingPhoto> rubbingPhotos = new List<T_RubbingPhoto>(photoPaths.Length);
            int pageNumber = 1;
            foreach (var photoPath in photoPaths)
            {
                T_RubbingPhoto rubbingPhoto = UploadPhoto(photoPath);
                if (rubbingPhoto != null)
                {
                    rubbingPhoto.PageNumber = pageNumber;
                    pageNumber++;
                    rubbingPhotos.Add(rubbingPhoto);
                }
            }

            foreach (var rubbingPhoto in rubbingPhotos)
            {
                rubbingPhoto.RubbingID = rubbing.ID;
                rubbingPhoto.T_Rubbing = rubbing;
                rubbing.T_RubbingPhoto.Add(rubbingPhoto);
                CalligraphyEditor.App.Entities.AddToT_RubbingPhoto(rubbingPhoto);

            }

            CalligraphyEditor.App.Entities.SaveChanges();
            _Ocl_Rubbings.Add(rubbing);

            return string.Empty;
        }
コード例 #3
0
ファイル: VMRubbings.cs プロジェクト: JiNanCVT/Calligraphy
 public T_Rubbing NewRubbing()
 {
     T_Rubbing r = new T_Rubbing();
     r.T_Author = _author;
     r.AuthorID = _author.ID;
     Author.T_Rubbing.Add(r);
     return r;
 }
コード例 #4
0
 public DevPRubbingPhotos(T_Rubbing rubbing)
 {
     InitializeComponent();
     _vmrubbingPhotos = new VMRubbingPhotos(rubbing);
     Grd_Photos.DataContext = _vmrubbingPhotos.Cvs_RubbingPhoto;
 }
コード例 #5
0
ファイル: VMRubbings.cs プロジェクト: JiNanCVT/Calligraphy
        public string AddRubbing(T_Rubbing rubbing, string[] Paths)
        {
            string[] photoPaths = GetPhotoPaths(Paths);
            string[] textPaths = GetTextPaths(Paths);

            //string errorMsg = IsValidatedPhoto(photoPaths);
            string errorMsg = GetErrorMsg(Paths, photoPaths, textPaths);
            if (!string.IsNullOrEmpty(errorMsg))
                return errorMsg;

            //MainViewModel mvm = new MainViewModel(photoPaths);
            //foreach (var p in photoPaths)
            //{
            //    if(p!=null)
            //    mvm.Images.Add(p);
            //}

            CalligraphyEditor.App.Entities.AddToT_Rubbing(rubbing);
            CalligraphyEditor.App.Entities.SaveChanges();
            var q = from f in photoPaths orderby f select f;
            photoPaths = q.ToArray<string>();

            rubbingPhotos = new ObservableCollection<T_RubbingPhoto>();
            int pageNumber = 1;
            int i,j;
            for (i = 0, j = 0; i < Math.Max(photoPaths.Length, textPaths.Length) || j < Math.Max(photoPaths.Length, textPaths.Length); i++, j++)
            {
                if (j < textPaths.Length)
                {
                    string PhotoNameWithoutExtension = GetFileNameWithoutExtension(GetSafeFileName(photoPaths[i]));
                    string TextNameWithoutExtension = GetFileNameWithoutExtension(GetSafeFileName(textPaths[j]));
                    T_RubbingPhoto rubbingPhoto = UploadPhoto(photoPaths[i]);
                    string txtString = GetTxtString(textPaths[j]);
                    if (rubbingPhoto != null)
                    {
                        rubbingPhoto.PageNumber = pageNumber;
                        pageNumber++;
                        if (PhotoNameWithoutExtension.Equals(TextNameWithoutExtension))
                        {
                            rubbingPhoto.Name = txtString;
                        }
                    }
                    MessageBox.Show(rubbingPhoto.PhotoBitmapImage);
                    rubbingPhotos.Add(rubbingPhoto);
                }

            }
            Window1 w1 = new Window1();
            w1.ShowDialog();
            ShowPhotoAndText spt = new ShowPhotoAndText();
            //spt.DataContext = mvm;
            spt.ShowDialog();
                //foreach (var photoPath in photoPaths)
                //{
                //    T_RubbingPhoto rubbingPhoto = UploadPhoto(photoPath);
                //    if (rubbingPhoto != null)
                //    {
                //        rubbingPhoto.PageNumber = pageNumber;
                //        pageNumber++;
                //        rubbingPhotos.Add(rubbingPhoto);
                //    }
                //}

            foreach (var rubbingPhoto in rubbingPhotos)
            {
                rubbingPhoto.RubbingID = rubbing.ID;
                rubbingPhoto.T_Rubbing = rubbing;
                rubbing.T_RubbingPhoto.Add(rubbingPhoto);
                CalligraphyEditor.App.Entities.AddToT_RubbingPhoto(rubbingPhoto);

            }

            CalligraphyEditor.App.Entities.SaveChanges();
            _Ocl_Rubbings.Add(rubbing);

            return string.Empty;
        }