private static void LightAnglePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { BevelBitmapEffect target = ((BevelBitmapEffect)d); target.PropertyChanged(LightAngleProperty); }
private static void SmoothnessPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { BevelBitmapEffect target = ((BevelBitmapEffect)d); target.PropertyChanged(SmoothnessProperty); }
// When the note is 'saved', it get's saved into an RTF file, and marked for being attached to a session note. private void save_Click(object sender, RoutedEventArgs e) { Logger.record("[save_Click]: RTF Note to be saved", "RTFNote", "info"); bool exDrRetry = false; TextRange tr = new TextRange(richTextNote.Document.ContentStart, richTextNote.Document.ContentEnd); // How do we kow the '3' minimum? By trial and error. Any character entered in the area makes it go 3+. Empty area is 0<=x<=2 if (3 <= tr.Text.Length) { Logger.record("\t[save_Click]: RTF Note not empty, will save", "RTFNote", "info"); // Name the note, save to file sm.rtfNoteName = currentRTFNote++.ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".rtf"; do { exDrRetry = false; try { // Process is: // 1. Save the file // 2. Change the visual cue // 3. Add an autogenerated line to the session CSV // Saves the file FileStream fs = new FileStream(workingDir + sm.rtfNoteName, FileMode.OpenOrCreate, FileAccess.Write); TextRange RTF = new TextRange(richTextNote.Document.ContentStart, richTextNote.Document.ContentEnd); RTF.Save(fs, System.Windows.DataFormats.Rtf); // Set the visual effect to clue the tester there's a note attached BevelBitmapEffect effect = new BevelBitmapEffect(); effect.BevelWidth = 2; effect.EdgeProfile = EdgeProfile.BulgedUp; sm.RTFNoteBtn.BitmapEffect = effect; // Adds an 'autogenerated' line to the session CSV sm.AutoSaveNote(sm.rtfNoteName); Logger.record("\t\t[save_Click]: RTF Note saved: " + sm.rtfNoteName, "RTFNote", "info"); } catch (Exception ex) { Logger.record("\t\t[save_Click]: EXCEPTION reached - RTF Note file could not be saved (" + sm.rtfNoteName + ")", "RTFNote", "error"); exDrRetry = Logger.FileErrorMessage(ex, "save_Click", sm.rtfNoteName); } } while (exDrRetry); } Logger.record("[save_Click]: RTF Note saving mechanism done. Will close (hide).", "RTFNote", "info"); // We not really 'close' the window. Close function deals with whether hiding or closing it. this.Close(); Logger.record("[save_Click]: RTF Note saving mechanism done. Closed (hidden).", "RTFNote", "info"); }
// ClearNote: // Makes space for a new note private void ClearNote() { Logger.record("[ClearNote]: Will delete note content and attachments indication", "SMWidget", "info"); NoteContent.Text = ""; // New note screenshotName = ""; // New pic attachment rtfNoteName = ""; // New note attachment (RTF note area content is left intact!) // Clear visual effects (screenshots are all always saved anyway) BevelBitmapEffect effect = new BevelBitmapEffect(); effect.BevelWidth = 0; effect.EdgeProfile = EdgeProfile.BulgedUp; ScreenShot.BitmapEffect = effect; RTFNoteBtn.BitmapEffect = effect; }
// Adding attached screenshot have dedicated functions that deal with the visual // clues as well private void AddScreenshot2Note(Bitmap bitmap) { Logger.record("[AddScreenshot2Note]: Saving screen to file", "SMWidget", "info"); bool exDrRetry = false; // Name the screenshot, save to disk screenshotName = currentScreenshot++.ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_" + FlickrAddon.hashcode + ".jpg"; // HASCODE ADDED!!!___<-----######### do { exDrRetry = false; try { string strReportFileName = currentSession.GetCurrentSessionFile(); Graphics graphicImage = Graphics.FromImage(bitmap); graphicImage.SmoothingMode = SmoothingMode.AntiAlias; StringFormat format = new System.Drawing.StringFormat(StringFormatFlags.DirectionRightToLeft); graphicImage.DrawString(strReportFileName, new Font("Arial", 14, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Red, new System.Drawing.Point(50, 50)); bitmap.Save(currentSession.workingDir + screenshotName, ImageFormat.Jpeg); AutoSaveScrenshot(screenshotName); string strFileTag = "#Session File: " + strReportFileName; string URL = ""; if (ToggleUploadFlickr) { if (m_flickrLoggedIn) { URL = m_flickr.GetUrl(m_flickr.Upload(screenshotName, "", "", currentSession.GetTags() + strFileTag)); currentSession.UpdateNotes("WebUrl: ", URL); } else { m_flickr.Login(); URL = m_flickr.GetUrl(m_flickr.Upload(screenshotName, "", "", currentSession.GetTags() + strFileTag)); currentSession.UpdateNotes("WebUrl: ", URL); m_flickrLoggedIn = true; } } if (ToggleUploadTwitter) { if (m_twitterLoggedIn) { TwitterAddon.PostOnTwitter(); currentSession.UpdateNotes("WebUrl: ", URL); } else { //TwitterAddon.TwitterLogin(); currentSession.UpdateNotes("WebUrl: ", URL); m_twitterLoggedIn = true; } } } catch (Exception ex) { Logger.record("[AddScreenshot2Note]: EXCEPTION reached - Session Note file could not be saved (" + screenshotName + ")", "SMWidget", "error"); exDrRetry = Logger.FileErrorMessage(ex, "SaveToSessionNotes", screenshotName); } } while (exDrRetry); // Put a visual effect to remember the tester there's an image on the attachment barrel BevelBitmapEffect effect = new BevelBitmapEffect(); effect.BevelWidth = 2; effect.EdgeProfile = EdgeProfile.BulgedUp; ScreenShot.BitmapEffect = effect; }
// Adding attached screenshot have dedicated functions that deal with the visual // clues as well private void AddScreenshot2Note(Bitmap bitmap) { Logger.record("[AddScreenshot2Note]: Saving screen to file", "SMWidget", "info"); bool exDrRetry = false; // Name the screenshot, save to disk screenshotName = currentScreenshot++.ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".jpg"; do { exDrRetry = false; try { bitmap.Save(currentSession.workingDir + screenshotName, ImageFormat.Jpeg); AutoSaveScrenshot(screenshotName); } catch (Exception ex) { Logger.record("[AddScreenshot2Note]: EXCEPTION reached - Session Note file could not be saved (" + screenshotName + ")", "SMWidget", "error"); exDrRetry = Logger.FileErrorMessage(ex, "SaveToSessionNotes", screenshotName); } } while (exDrRetry); // Put a visual effect to remember the tester there's an image on the attachment barrel BevelBitmapEffect effect = new BevelBitmapEffect(); effect.BevelWidth = 2; effect.EdgeProfile = EdgeProfile.BulgedUp; ScreenShot.BitmapEffect = effect; }