private void OnDeleteAssignment(object sender, RoutedEventArgs e) { if (this._tv_Assignments.SelectedItem != null) { AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem; if (selectedAss == null) { return; } ejsAssignment assToDelete = selectedAss.Assignment; if (assToDelete.OwnerUserId != App._currentEjpStudent.Id) { MessageBox.Show("他人のアサインメントは削除出来ません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Stop); } else { try { int selectedCoursItemId = this._cb_Courses.SelectedIndex; if (MessageBox.Show("選択されたアサインメントを削除しますか?", "削除", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { EjsBridge.ejsBridgeManager.DeleteAssignment( App._currentEjpStudent.SessionToken, assToDelete); this.LoadDataFromEjs(); //Set the combobox to display the documents //of the prev selected course in the list, if there are //any courses in the list. if (this._cb_Courses.Items.Count != 0) { this._cb_Courses.SelectedIndex = selectedCoursItemId; } } } catch (ApplicationException ex) { SiliconStudio.DebugManagers.DebugReporter.Report( SiliconStudio.DebugManagers.MessageType.Error, "eJournalPlus Client - EJS Open Assignment Window", "Deleting Assignment from EJS Failed" + "\nError: " + ex.Message); MessageBox.Show("選択されたアサインメントは削除できません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
private void OnCourseListSelectionChanged(object sender, SelectionChangedEventArgs e) { if (this._cb_Courses.SelectedValue != null) { ejsCourse course = this._cb_Courses.SelectedValue as ejsCourse; this._tv_Assignments.Items.Clear(); //First add all the original assignments AssignmentTreeViewItem tParent = null; foreach (ejsAssignment ass in this._assignments) { //1 = Commented Assignment if (ass.AssignmentContentType == 1) { continue; //We only add the 'real' assignments first } if (ass.CourseId == course._id) //does this assignment belong to the current course? { AssignmentTreeViewItem t = new AssignmentTreeViewItem(ass); t.DefaultImage = new BitmapImage(new Uri("pack://application:,,,/imgData/aTvS.png")); t.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/imgData/aTvD.png")); this._tv_Assignments.Items.Add(t); tParent = t; } } foreach (ejsAssignment ass in this._assignments) { //0 = Normal Assignment if (ass.AssignmentContentType == 0) { continue; //We're only adding the Commented Assignments } if (ass.CourseId == -1) //-1 = commented assignments do not belong to courses { foreach (AssignmentTreeViewItem ParentAssignment in this._tv_Assignments.Items) { this.BuildAssignmentTree(ParentAssignment, ass, ParentAssignment); } } } foreach (AssignmentTreeViewItem ParentAssignment in this._tv_Assignments.Items) { ParentAssignment.TextDetails.Text += " Comments: " + ParentAssignment.Assignment.CommentCount.ToString(); } } }
/// <summary> /// Tell EJS to merge all the comments and open the Assignment /// as a Commented Assignment. /// </summary> private void OnMergeCommentsAndOpen(object sender, RoutedEventArgs e) { if (this._tv_Assignments.SelectedItem != null) { if (this._tv_Assignments.SelectedItem is CommentedAssignmentTreeViewItem) { return; } AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem; if (selectedAss == null) { return; } this._assignmentToOpen = selectedAss.Assignment; if (this._assignmentToOpen != null) { this._cancelled = false; this._openSelectedAssignmentAsCommented = true; this.MergeCommentsAndOpenAssignment = true; List <ejsAssignment> lsAT = new List <ejsAssignment>(); foreach (CommentedAssignmentTreeViewItem catvi in selectedAss.Items) { this.GetAllChildAssignmentsForParent(catvi, lsAT); lsAT.Add(catvi.Assignment); } this.CommentedAssignmentsToMerge = lsAT.ToArray(); this.Close(); } else { MessageBox.Show(Application.Current.Resources["EX_AsgOpenFailed"] as string, //Properties.Resources.EX_AsgOpenFailed, Application.Current.Resources["Str_ErrorTitle"] as string, //Properties.Resources.Str_ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } } else { this._cancelled = true; this.Close(); } }
private void OnDeleteAssignment(object sender, RoutedEventArgs e) { if (this._tv_Assignments.SelectedItem != null) { AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem; if (selectedAss == null) { return; } ejsAssignment assToDelete = selectedAss.Assignment; if (assToDelete.OwnerUserId != App._currentEjpStudent.Id) { MessageBox.Show(Application.Current.Resources["ERR_CannotDelOthersAsg"] as string, //Properties.Resources.ERR_CannotDelOthersAsg, Application.Current.Resources["Str_ErrorTitle"] as string, //Properties.Resources.Str_ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Stop); } else { try { int selectedCoursItemId = this._cb_Courses.SelectedIndex; if (MessageBox.Show(Application.Current.Resources["Q_DelAsg"] as string, Application.Current.Resources["Str_WarnTitle"] as string, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { EjsBridge.ejsBridgeManager.HideAssignment( App._currentEjpStudent.SessionToken, assToDelete); this.LoadDataFromEjs(); //Set the combobox to display the documents //of the prev selected course in the list, if there are //any courses in the list. if (this._cb_Courses.Items.Count != 0) { this._cb_Courses.SelectedIndex = selectedCoursItemId; } } } catch (ApplicationException) { MessageBox.Show(Application.Current.Resources["EX_AsgDelFailed"] as string, //Properties.Resources.EX_AsgDelFailed, Application.Current.Resources["Str_ErrorTitle"] as string, //Properties.Resources.Str_ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } } } }
private void OnOpenAssignmentAsCA(object sender, RoutedEventArgs e) { if (this._tv_Assignments.SelectedItem != null) { AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem; if (selectedAss == null) { return; } //If this value is an empty GUID that means the assignment //was created with version 1 of EJP+EJP. Thus, it cannot //be opened as a Commented Assignment with this version of EJP. if (selectedAss.Assignment.ExternalAssignmentId == Guid.Empty) { MessageBox.Show("\n\nThis assignment was created with an earlier version\n" + "of EJournal Plus, therefor it cannot be opened in \n" + "Comment Mode.\n\n" + "If you wish do upgrade this Assignment, first open it\n" + "in Normal Mode, then re-publish it to E Journal Server.\n" + "After this you can open the new Published version in \n" + "Comment Mode.", "Version Error", MessageBoxButton.OK, MessageBoxImage.Stop); return; } this._assignmentToOpen = selectedAss.Assignment; if (this._assignmentToOpen != null) { this._cancelled = false; this._openSelectedAssignmentAsCommented = true; this.Close(); } else { MessageBox.Show("選択されたアサインメントが開けません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error); } } else { this._cancelled = true; this.Close(); } }
private void OnOpenAssignment(object sender, RoutedEventArgs e) { if (this._tv_Assignments.SelectedItem != null) { AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem; if (selectedAss == null) { return; } if (selectedAss is CommentedAssignmentTreeViewItem) { if ( MessageBox.Show(Application.Current.Resources["Q_OpenAsComAsg"] as string, Application.Current.Resources["Str_WarnTitle"] as string, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } } this._assignmentToOpen = selectedAss.Assignment; if (this._assignmentToOpen != null) { this._cancelled = false; this._openSelectedAssignmentAsCommented = false; this.Close(); } else { MessageBox.Show(Application.Current.Resources["EX_AsgOpenFailed"] as string, //Properties.Resources.EX_AsgOpenFailed, Application.Current.Resources["Str_ErrorTitle"] as string, //Properties.Resources.Str_ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } } else { this._cancelled = true; this.Close(); } }
private void OnOpenAssignment(object sender, RoutedEventArgs e) { if (this._tv_Assignments.SelectedItem != null) { AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem; if (selectedAss == null) { return; } if (selectedAss is CommentedAssignmentTreeViewItem) { if ( MessageBox.Show("選択したファイルにはコメントがあるため" + "\nコメントモードに開きます。\n\n" + "宜しいですか?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } } this._assignmentToOpen = selectedAss.Assignment; if (this._assignmentToOpen != null) { this._cancelled = false; this._openSelectedAssignmentAsCommented = false; this.Close(); } else { MessageBox.Show("選択されたアサインメントが開けません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error); } } else { this._cancelled = true; this.Close(); } }
private void OnOpenAssignmentAsCA(object sender, RoutedEventArgs e) { if (this._tv_Assignments.SelectedItem != null) { AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem; if (selectedAss == null) { return; } //If this value is an empty GUID that means the assignment //was created with version 1 of EJP+EJP. Thus, it cannot //be opened as a Commented Assignment with this version of EJP. if (selectedAss.Assignment.ExternalAssignmentId == Guid.Empty) { MessageBox.Show(Application.Current.Resources["ERR_AsgOpenFailed_Version"] as string, //Properties.Resources.ERR_AsgOpenFailed_Version, Application.Current.Resources["Str_VersionErrorTitle"] as string, //Properties.Resources.Str_VersionErrorTitle, MessageBoxButton.OK, MessageBoxImage.Stop); return; } this._assignmentToOpen = selectedAss.Assignment; if (this._assignmentToOpen != null) { this._cancelled = false; this._openSelectedAssignmentAsCommented = true; this.Close(); } else { MessageBox.Show(Application.Current.Resources["EX_AsgOpenFailed"] as string, //Properties.Resources.EX_AsgOpenFailed, Application.Current.Resources["Str_ErrorTitle"] as string, //Properties.Resources.Str_ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } } else { this._cancelled = true; this.Close(); } }
/// <summary> /// Called to update the branches of the tree once the root nodes /// have been added. This method is meant to be called recursively. /// </summary> /// <param name="root">Root node</param> /// <param name="child">Current Child</param> /// <param name="branchRoot">Original root of this branch</param> private void BuildAssignmentTree(AssignmentTreeViewItem root, ejsAssignment child, AssignmentTreeViewItem branchRoot) { if (root.Assignment.ExternalAssignmentId == child.ParentAssignmentId) { CommentedAssignmentTreeViewItem cat = new CommentedAssignmentTreeViewItem(child); cat.BranchRoot = branchRoot; cat.DefaultImage = new BitmapImage(new Uri("pack://application:,,,/imgData/caTvS.png")); cat.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/imgData/caTvD.png")); root.Items.Add(cat); //Add up the total number of comments in this branch.. branchRoot.Assignment.CommentCount += child.CommentCount; } else { foreach (AssignmentTreeViewItem childItem in root.Items) { this.BuildAssignmentTree(childItem, child, branchRoot); } } }
private void _tv_Assignments_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (e.NewValue is AssignmentTreeViewItem) { AssignmentTreeViewItem selAss = e.NewValue as AssignmentTreeViewItem; this._b_OpenAssignment.IsEnabled = true; //Do not enable anything else... if (this.OpenForMerge) { return; } this._b_OpenCommentedAssignment.IsEnabled = true; if (App._currentEjpStudent.Id == selAss.Assignment.OwnerUserId) { this._b_DeleteAssignment.IsEnabled = true; if (selAss.Items.Count != 0) { this._b_MergeAndOpen.IsEnabled = true; } else { this._b_MergeAndOpen.IsEnabled = false; } } else { this._b_DeleteAssignment.IsEnabled = false; this._b_MergeAndOpen.IsEnabled = false; } //Version Check if (selAss.Assignment.ExternalAssignmentId == Guid.Empty) { this._b_OpenCommentedAssignment.IsEnabled = false; } } if (e.NewValue is CommentedAssignmentTreeViewItem) { //Do not enable anything... if (this.OpenForMerge) { return; } CommentedAssignmentTreeViewItem selAss = e.NewValue as CommentedAssignmentTreeViewItem; this._b_OpenAssignment.IsEnabled = false; this._b_OpenCommentedAssignment.IsEnabled = true; this._b_MergeAndOpen.IsEnabled = false; if (selAss.BranchRoot.Assignment.OwnerUserId == App._currentEjpStudent.Id) { this._b_DeleteAssignment.IsEnabled = true; } else { this._b_DeleteAssignment.IsEnabled = false; } //Version Check if (selAss.Assignment.ExternalAssignmentId == Guid.Empty) { this._b_OpenCommentedAssignment.IsEnabled = false; } } }