public void CreateCourse(Course course)
 {
     try
     {
         database.GetCollection<Course>("courses").InsertOneAsync(course);
     }
     catch (Exception exception)
     {
         throw new Exception("Error during new course creating", exception);
     }
 }
Esempio n. 2
0
 // edit/redo menu item handler
 private void redoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     working(true);
     saveText();
     course = course.ReDo();
     updateScreen();
     working(false);
 }
Esempio n. 3
0
 // generalized method to paste clip without scaling in one of 4 corners of picture
 private void pasteClip(Course.ImagePlacement place)
 {
     working(true);
     saveText();
     course.Paste(place);
     saveCourse();
     updateScreen();
     working(false);
 }
Esempio n. 4
0
 // method to open a course, either new or existing
 //    desc - text instructions for the user
 //    isnew - true if this should be a new course
 // returns true if course was successfully opened
 private bool openCourse(string desc, bool isnew)
 {
     string dir = openDialog(desc);
     bool r = false;
     if (dir != "")
     { // if not canceled in directory selection dialog...
         Course c = (new Course()).Open(dir, isnew);
         // returns null if unable to open a new course at this directory, i.e. one already exists there
         if (c != null)
         {
             course = c;
             saveDirectorySetting(dir);
             updateScreen();
             r = true;
         }
         else
         {
             MessageBox.Show("A course already exists in this directory.  Please create a new directory.");
         }
     }
     return r;
 }
Esempio n. 5
0
 // Form1_Load method
 // initialization of the form
 private void Form1_Load(object sender, EventArgs e)
 {
     // backgroundWorker2 saves changes to the Text and Answer fields every 15 seconds
     backgroundWorker2.RunWorkerAsync();
     sessions.BringToFront();  // when editing in design view it may have been left in the back
     // dir is the directory where the course will be found
     // it's saved in the configuration settings for this program
     string dir = (new Properties.Settings()).Course;
     // decode the appName ("Cyryx Self Study")
     for (int i = 0; i < a.Length; i++)
         c[i] = (byte)(a[i] ^ b[i]);
     ASCIIEncoding enc = new ASCIIEncoding();
     appName = enc.GetString(c);
     // open the course and assign the instance variable for it
     course = (new Course()).Open(dir);
     // get the saved window location and state and apply them to the form
     Location = course.Location;
     WindowState = course.WindowState;
     help.LoadFile("help.rtf");
     helpShow(course.Help);
     // standardized update routine that writes the form depending on the current state
     updateScreen();
 }
Esempio n. 6
0
 // Method to clip the image without resizing, depending on which corner it is aligned to.
 private Bitmap clipImage(Bitmap bm, int w, int h, Course.ImagePlacement place)
 {
     Bitmap result = new Bitmap(w, h);
     // first rotate / flip depending on ultimate placement
     switch (place) {
         case Course.ImagePlacement.lowerLeft:
             bm.RotateFlip(RotateFlipType.RotateNoneFlipY);
             break;
         case Course.ImagePlacement.lowerRight:
             bm.RotateFlip(RotateFlipType.RotateNoneFlipXY);
             break;
         case Course.ImagePlacement.upperRight:
             bm.RotateFlip(RotateFlipType.RotateNoneFlipX);
             break;
     }
     // unscaled clip, always to upper left corner
     using (Graphics g = Graphics.FromImage((System.Drawing.Image)result))
         g.DrawImageUnscaled(bm,0, 0, w, h);
     bm.Dispose();
     // do the inverse of the rotate / flip
     switch (place){
         case Course.ImagePlacement.lowerLeft:
             result.RotateFlip(RotateFlipType.RotateNoneFlipY);
             break;
         case Course.ImagePlacement.lowerRight:
             result.RotateFlip(RotateFlipType.RotateNoneFlipXY);
             break;
         case Course.ImagePlacement.upperRight:
             result.RotateFlip(RotateFlipType.RotateNoneFlipX);
             break;
     }
     return result;
 }
Esempio n. 7
0
 // Method to set the image bitmap depending on placement option
 public void SetImage(Bitmap image, Course.ImagePlacement place)
 {
     switch (place) {
         case Course.ImagePlacement.fit:
             saveImage(resizeImage(image,imageWidth,imageHeight));
             break;
         default:
             saveImage(clipImage(image,imageWidth,imageHeight,place));
             break;
     }
 }
 public void EditCourse(Course course)
 {
     try
     {
         database.GetCollection<Course>("courses").ReplaceOneAsync(a => a.Id == course.Id, course);
     }
     catch (Exception exception)
     {
         throw new Exception("Error during course edit", exception);
     }
 }