@@ -33,8 +33,6 @@ public BcfFile()
3333 Id = Guid . NewGuid ( ) ;
3434 TempPath = System . IO . Path . Combine ( System . IO . Path . GetTempPath ( ) , "BCFier" , Id . ToString ( ) ) ;
3535 Issues = new ObservableCollection < Markup > ( ) ;
36- this . _view = new ListCollectionView ( this . Issues ) ;
37-
3836 }
3937 public bool HasBeenSaved
4038 {
@@ -84,6 +82,7 @@ public ObservableCollection<Markup> Issues
8482 set
8583 {
8684 _issues = value ;
85+ this . _view = new ListCollectionView ( this . Issues ) ;
8786 NotifyPropertyChanged ( "Issues" ) ;
8887 }
8988 }
@@ -102,12 +101,15 @@ public Markup SelectedIssue
102101 }
103102 }
104103
105-
104+
106105 public ICollectionView View
107106 {
108- get { return this . _view ; }
107+ get
108+ {
109+ return this . _view ;
110+ }
109111 }
110-
112+
111113 public string TextSearch
112114 {
113115 get { return _textSearch ; }
@@ -125,13 +127,13 @@ public string TextSearch
125127
126128 private bool Filter ( object o )
127129 {
128- var issue = ( Markup ) o ;
130+ var issue = ( Markup ) o ;
129131 if ( issue == null )
130132 return false ;
131133 if ( issue . Topic != null && ( ( issue . Topic . Title != null && issue . Topic . Title . ToLowerInvariant ( ) . Contains ( TextSearch . ToLowerInvariant ( ) ) ) ||
132- ( issue . Topic . Description != null && issue . Topic . Description . ToLowerInvariant ( ) . Contains ( TextSearch . ToLowerInvariant ( ) ) ) ) ||
134+ ( issue . Topic . Description != null && issue . Topic . Description . ToLowerInvariant ( ) . Contains ( TextSearch . ToLowerInvariant ( ) ) ) ) ||
133135 issue . Comment != null && issue . Comment . Any ( x => x . Comment1 . ToLowerInvariant ( ) . Contains ( TextSearch . ToLowerInvariant ( ) ) )
134-
136+
135137 )
136138 return true ;
137139 return false ;
@@ -171,7 +173,7 @@ public void RemoveView(ViewPoint view, Markup issue, bool delComm)
171173 var guid = view . Guid ;
172174 issue . Viewpoints . Remove ( view ) ;
173175 //remove comments associated with that view
174- var viewcomments = issue . Comment . Where ( x => x . Viewpoint != null && x . Viewpoint . Guid == guid ) . ToList ( ) ;
176+ var viewcomments = issue . Comment . Where ( x => x . Viewpoint != null && x . Viewpoint . Guid == guid ) . ToList ( ) ;
175177
176178 if ( ! viewcomments . Any ( ) )
177179 return ;
@@ -220,61 +222,61 @@ public void MergeBcfFile(IEnumerable<BcfFile> bcfFiles)
220222 {
221223
222224 foreach ( var bcf in bcfFiles )
225+ {
226+ foreach ( var mergedIssue in bcf . Issues )
223227 {
224- foreach ( var mergedIssue in bcf . Issues )
228+ //it's a new issue
229+ if ( ! Issues . Any ( x => x . Topic != null && mergedIssue . Topic != null && x . Topic . Guid == mergedIssue . Topic . Guid ) )
225230 {
226- //it's a new issue
227- if ( ! Issues . Any ( x => x . Topic != null && mergedIssue . Topic != null && x . Topic . Guid == mergedIssue . Topic . Guid ) )
231+ string sourceDir = Path . Combine ( bcf . TempPath , mergedIssue . Topic . Guid ) ;
232+ string destDir = Path . Combine ( TempPath , mergedIssue . Topic . Guid ) ;
233+
234+ Directory . Move ( sourceDir , destDir ) ;
235+ //update path set for binding
236+ foreach ( var view in mergedIssue . Viewpoints )
228237 {
229- string sourceDir = Path . Combine ( bcf . TempPath , mergedIssue . Topic . Guid ) ;
230- string destDir = Path . Combine ( TempPath , mergedIssue . Topic . Guid ) ;
238+ view . SnapshotPath = Path . Combine ( TempPath , mergedIssue . Topic . Guid , view . Snapshot ) ;
239+ }
240+ Issues . Add ( mergedIssue ) ;
231241
232- Directory . Move ( sourceDir , destDir ) ;
233- //update path set for binding
234- foreach ( var view in mergedIssue . Viewpoints )
242+ }
243+ //it exists, let's loop comments and views
244+ else
245+ {
246+ var issue = Issues . First ( x => x . Topic . Guid == mergedIssue . Topic . Guid ) ;
247+ var newComments = mergedIssue . Comment . Where ( x => issue . Comment . All ( y => y . Guid != x . Guid ) ) . ToList ( ) ;
248+ if ( newComments . Any ( ) )
249+ foreach ( var newComment in newComments )
250+ issue . Comment . Add ( newComment ) ;
251+ //sort comments
252+ issue . Comment = new ObservableCollection < Comment > ( issue . Comment . OrderByDescending ( x => x . Date ) ) ;
253+
254+ var newViews = mergedIssue . Viewpoints . Where ( x => issue . Viewpoints . All ( y => y . Guid != x . Guid ) ) . ToList ( ) ;
255+ if ( newViews . Any ( ) )
256+ foreach ( var newView in newViews )
235257 {
236- view . SnapshotPath = Path . Combine ( TempPath , mergedIssue . Topic . Guid , view . Snapshot ) ;
258+ //to avoid conflicts in case both contain a snapshot.png or viewpoint.bcfv
259+ //img to be merged
260+ string sourceFile = newView . SnapshotPath ;
261+ //assign new safe name based on guid
262+ newView . Snapshot = newView . Guid + ".png" ;
263+ //set new temp path for binding
264+ newView . SnapshotPath = Path . Combine ( TempPath , issue . Topic . Guid , newView . Snapshot ) ;
265+ //assign new safe name based on guid
266+ newView . Viewpoint = newView . Guid + ".bcfv" ;
267+ File . Move ( sourceFile , newView . SnapshotPath ) ;
268+ issue . Viewpoints . Add ( newView ) ;
269+
270+
237271 }
238- Issues . Add ( mergedIssue ) ;
239-
240- }
241- //it exists, let's loop comments and views
242- else
243- {
244- var issue = Issues . First ( x => x . Topic . Guid == mergedIssue . Topic . Guid ) ;
245- var newComments = mergedIssue . Comment . Where ( x => issue . Comment . All ( y => y . Guid != x . Guid ) ) . ToList ( ) ;
246- if ( newComments . Any ( ) )
247- foreach ( var newComment in newComments )
248- issue . Comment . Add ( newComment ) ;
249- //sort comments
250- issue . Comment = new ObservableCollection < Comment > ( issue . Comment . OrderByDescending ( x=> x . Date ) ) ;
251-
252- var newViews = mergedIssue . Viewpoints . Where ( x => issue . Viewpoints . All ( y => y . Guid != x . Guid ) ) . ToList ( ) ;
253- if ( newViews . Any ( ) )
254- foreach ( var newView in newViews )
255- {
256- //to avoid conflicts in case both contain a snapshot.png or viewpoint.bcfv
257- //img to be merged
258- string sourceFile = newView . SnapshotPath ;
259- //assign new safe name based on guid
260- newView . Snapshot = newView . Guid + ".png" ;
261- //set new temp path for binding
262- newView . SnapshotPath = Path . Combine ( TempPath , issue . Topic . Guid , newView . Snapshot ) ;
263- //assign new safe name based on guid
264- newView . Viewpoint = newView . Guid + ".bcfv" ;
265- File . Move ( sourceFile , newView . SnapshotPath ) ;
266- issue . Viewpoints . Add ( newView ) ;
267-
268-
269- }
270- }
271272 }
272- Utils . DeleteDirectory ( bcf . TempPath ) ;
273273 }
274+ Utils . DeleteDirectory ( bcf . TempPath ) ;
275+ }
274276 HasBeenSaved = false ;
275277
276278
277-
279+
278280 }
279281 catch ( System . Exception ex1 )
280282 {
0 commit comments