protected override void OnClick(EventArgs e) { base.OnClick(e); FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.RootFolder = System.Environment.SpecialFolder.Desktop; if (fbd.ShowDialog() == DialogResult.OK) { //TODO: Prompt for a file format //Execute using (this.m_Model.Workspace.Lock()) { DeckTraversalModel traversal = this.m_Model.Workspace.CurrentDeckTraversal; DefaultDeckTraversalModel ddt = traversal as DefaultDeckTraversalModel; if (ddt == null) { LinkedDeckTraversalModel linked = traversal as LinkedDeckTraversalModel; if (linked != null) { ddt = linked.LinkedModel as DefaultDeckTraversalModel; } } if (ddt != null) { //PPTDeckIO.ExportDeck( ddt, fbd.SelectedPath, System.Drawing.Imaging.ImageFormat.Jpeg ); PPTDeckIO.ExportDeck(ddt, fbd.SelectedPath, System.Drawing.Imaging.ImageFormat.Png); } } } }
private void HandleCurrentDeckTraversalChanged(object sender, PropertyEventArgs args_) { using (Synchronizer.Lock(this)) { DeckTraversalModel current; if (this.m_Instructor == null) { current = null; } else { using (Synchronizer.Lock(this.m_Instructor.SyncRoot)) { current = this.m_Instructor.CurrentDeckTraversal; } } using (this.m_Model.Workspace.Lock()) { if (current != null) { // Check the workspace to see if there exists a linkedDeckTraversal for this ID foreach (DeckTraversalModel model in this.m_Model.Workspace.DeckTraversals) { if (model.Id == current.Id) { current = model; break; } } } } // TODO: Only set the current deck traversal if navigation is unlinked. bool isInstructor = false; using (Synchronizer.Lock(this.m_Model.Participant.SyncRoot)) { if (this.m_Model.Participant.Role is InstructorModel) { isInstructor = true; } } DeckTraversalModel dtm = null; if ((current is LinkedDeckTraversalModel) || (isInstructor) || (current == null)) { dtm = current; } else { dtm = new LinkedDeckTraversalModel(this.m_EventQueue, current.Id, this.m_Model, current); } using (this.m_Model.Workspace.Lock()) { this.m_Model.Workspace.CurrentDeckTraversal.Value = dtm; } } }
protected override object SetUpMember(int index, object member) { using (Synchronizer.Lock(this.m_Service)) { using (this.m_Bucket.Lock()) { DeckTraversalModel traversal = ((DeckTraversalModel)member); if ((traversal.Deck.Disposition & DeckDisposition.Remote) != 0) { // A remote deck, perform deck matching // TODO: DeckMatching Should Occur Here // CURRENT IMPLEMENTATION ASSUMES THERE WAS NO MATCH // NOTE: All DeckTraversals need to ability to be linked since with // deckmatching any deck can become associated with a remote deck. DeckTraversalModel matchedDeckTraversal = null; // Perform the DeckMatching (NOTE: Does Nothing Right Now) matchedDeckTraversal = DeckMatcherService.MatchDeck(traversal); if (matchedDeckTraversal == null) { // No Matched Deck Found // TODO: Evaluate whether it's a good idea to copy the existing traversal's Id. matchedDeckTraversal = new LinkedDeckTraversalModel(this.m_Service.m_EventQueue, traversal.Id, this.m_Service.m_Model, traversal); // Create the DeckMatch this.m_Bucket.DeckMatches.Add(new DeckPairModel(matchedDeckTraversal, traversal)); } else { // Create the DeckMatch this.m_Bucket.DeckMatches.Add(new DeckPairModel(matchedDeckTraversal, traversal)); // NOTE: Don't have to add to the workspace because it's already there. // NOTE: But should we remove and replace with a LinkedDeckTraversalModel?? } traversal = matchedDeckTraversal; } else { // Not a remote deck, just add to the workspace this.m_Bucket.DeckTraversals.Add(traversal); } return(traversal); } } }
/// <summary> /// Setup the change event marshallers when a new matching is added to the set of DeckMatches /// </summary> /// <param name="index">The item index in the collection</param> /// <param name="member">The item added to the collection</param> /// <returns>The object that was added</returns> protected override bool SetUp(int index, DeckPairModel pair, out IDisposable tag) { // Create the matching and setup the change marshallers using (Synchronizer.Lock(this.m_Service)) { DeckTraversalMatch match = new DeckTraversalMatch(this.m_Service.m_Sender, pair.RemoteDeckTraversal, pair.LocalDeckTraversal); if (!this.m_Service.m_DeckTraversalMatchCollection.Contains(match)) { this.m_Service.m_DeckTraversalMatchCollection.Add(match); } } // Replace the existing deck with a linked deck traversal or add a new linked deck traversal using (this.m_Service.m_Workspace.Lock()) { DeckTraversalModel linked = null; bool bCurrent = false; if (pair.SameDeckTraversal) { linked = new LinkedDeckTraversalModel(this.m_Service.m_Sender, pair.RemoteDeckTraversal.Id, this.m_Service.m_Model, pair.RemoteDeckTraversal); } else { // Remove the old item and replace with a linked deck traversal model // NOTE: We need to remember if the deck we're replacing was the current one, // so we can make the new deck also the current one bCurrent = (~this.m_Service.m_Workspace.CurrentDeckTraversal == pair.LocalDeckTraversal); this.m_Service.m_Workspace.DeckTraversals.Remove(pair.LocalDeckTraversal); linked = new LinkedDeckTraversalModel(this.m_Service.m_Sender, pair.LocalDeckTraversal.Id, this.m_Service.m_Model, pair.LocalDeckTraversal); } // Add the deck traversal to the workspace if (linked != null) { this.m_Service.m_Workspace.DeckTraversals.Add(linked); } if (bCurrent) { this.m_Service.m_Workspace.CurrentDeckTraversal.Value = linked; } } tag = null; return(true); }
/// <summary> /// popus up a save dialogue, then creates a folder in the specified /// path containing an HTML file, along with images. /// </summary> /// <param name="e"></param> protected override void OnClick(EventArgs e) { base.OnClick(e); // Choose a destination folder and file name SaveFileDialog exportDeckToHTMLDialog = new SaveFileDialog(); exportDeckToHTMLDialog.Title = "Name the new html file and folder"; exportDeckToHTMLDialog.Filter = "HTML files (*.html;*.htm)|*.html;*.htm"; string humanName = ""; //set default name using (this.model_.Workspace.Lock()) { using (Synchronizer.Lock((~this.model_.Workspace.CurrentDeckTraversal).SyncRoot)) { using (Synchronizer.Lock((~this.model_.Workspace.CurrentDeckTraversal).Deck.SyncRoot)) { if ((~this.model_.Workspace.CurrentDeckTraversal).Deck.Filename != "") { humanName = exportDeckToHTMLDialog.FileName = (~this.model_.Workspace.CurrentDeckTraversal).Deck.Filename; } else { humanName = exportDeckToHTMLDialog.FileName = (~this.model_.Workspace.CurrentDeckTraversal).Deck.HumanName; } } } } ///Create a folder with the HTML file as well as the corresponding image ///files. if (exportDeckToHTMLDialog.ShowDialog() == DialogResult.OK) { ///name of user's HTML file string file_name = exportDeckToHTMLDialog.FileName; ///name of folder that will hold the HTML files string folder_name = Path.GetFullPath(file_name).Replace(Path.GetExtension(file_name), "") + "_files"; ///export the slide images to the folder List <string> file_names; using (this.model_.Workspace.Lock()) { DeckTraversalModel traversal = this.model_.Workspace.CurrentDeckTraversal; DefaultDeckTraversalModel ddt = traversal as DefaultDeckTraversalModel; if (ddt == null) { LinkedDeckTraversalModel linked = traversal as LinkedDeckTraversalModel; if (linked != null) { ddt = linked.LinkedModel as DefaultDeckTraversalModel; } } // file_names = PPTDeckIO.ExportDeck(ddt, folder_name, System.Drawing.Imaging.ImageFormat.Jpeg); file_names = PPTDeckIO.ExportDeck(ddt, folder_name, System.Drawing.Imaging.ImageFormat.Png); } ///export row/column icons if (ExportFancy) { UW.ClassroomPresenter.Properties.Resources.singleslide.Save(folder_name + "\\singleslide.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); UW.ClassroomPresenter.Properties.Resources.doubleslide.Save(folder_name + "\\doubleslide.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } ///Now, all of the images are in the specified folder, so we just need to make ///the HTML file for them string html = BuildHtml(file_names, folder_name, 1, file_name, humanName); if (!ExportFancy) { using (StreamWriter my_stream = new StreamWriter(file_name)) { my_stream.Write(html); } } else { using (StreamWriter my_stream = new StreamWriter(file_name.Insert(file_name.LastIndexOf('.'), "_1"))) { my_stream.Write(html); } html = BuildHtmlTable(file_names, folder_name, 2, file_name, humanName); using (StreamWriter my_stream = new StreamWriter(file_name.Insert(file_name.LastIndexOf('.'), "_2"))) { my_stream.Write(html); } } } }