private static ImageSource ProcessCommand2(ArgPoint Point, AttachCmd cmd, string Url, ref Attachment a) { a = null; try { switch (cmd) { case AttachCmd.ATTACH_IMG_OR_PDF: a = AttachmentManager.AttachLocalFile(Point); if (a != null) { return(GetAttachmentBitmap3(a)); } break; case AttachCmd.ATTACH_PDF: a = AttachmentManager.AttachPDF(Point); if (a != null) { return(GetAttachmentBitmap3(a)); } break; case AttachCmd.ATTACH_PDF_FROM_URL: a = AttachmentManager.AttachPdfFromURL(Point, Url); if (a != null) { return(GetAttachmentBitmap3(a)); } break; case AttachCmd.ATTACH_IMAGE: a = AttachmentManager.AttachPicture(Point); if (a != null) { return(GetAttachmentBitmap3(a)); } break; case AttachCmd.ATTACH_IMAGE_URL: a = AttachmentManager.AttachFromURL(Point, Url); if (a != null) { return(GetAttachmentBitmap3(a)); } break; case AttachCmd.ATTACH_YOUTUBE: a = AttachmentManager.AttachFromYoutube(Point, Url); if (a != null) { return(new BitmapImage()); //returning stub for external error-checking } break; } } catch (Exception) { MessageDlg.Show( "Cannot process attachment. If it's link, check it's correct. If it's file, ensure program has permissions to access it", "Error"); return(null); } return(null); }
public static object RunViewer(Attachment a, bool localRequest) { if (a == null) { return(null); } if (a.Format == (int)AttachmentFormat.Pdf && a.MediaData != null) { string pdfPathName = Utils.RandomFilePath(".pdf"); try { using (var fs = new FileStream(pdfPathName, FileMode.Create)) { fs.Write(a.MediaData.Data, 0, a.MediaData.Data.Length); } //Process.Start(pdfPathName); Utils.ReportMediaOpened(StEvent.PdfOpened, a); var pdfReader = ReaderWindow2.Instance(pdfPathName, a.Id, a.ArgPoint != null ? (int?)a.ArgPoint.Topic.Id : null, localRequest); pdfReader.Show(); return(pdfReader); } catch { } } else if (MiniAttachmentManager.IsGraphicFormat(a)) { if (a.Format == (int)AttachmentFormat.PngScreenshot) { Utils.ReportMediaOpened(StEvent.ScreenshotOpened, a); } else { Utils.ReportMediaOpened(StEvent.ImageOpened, a); } if (a.MediaData.Data != null) { if (!ExplanationModeMediator.Inst.ImageViewerOpen) { var wnd = ImageWindow.Instance(a.Id, a.ArgPoint != null ? a.ArgPoint.Topic.Id : -1, localRequest); wnd.img.Source = LoadImageFromBlob(a.MediaData.Data); wnd.Show(); wnd.Activate(); return(wnd); } } } else { //office file var ext = Path.GetExtension(a.Link).ToLower(); string pathName = Utils.RandomFilePath(ext); try { using (var fs = new FileStream(pathName, FileMode.Create)) { fs.Write(a.MediaData.Data, 0, a.MediaData.Data.Length); } Process.Start(pathName); } catch (Exception e) { MessageDlg.Show(e.ToString(), "Error"); } } return(null); }
public static void Show(string message) { var dlg = new MessageDlg(message); dlg.ShowDialog(); }
private static void MsgParticipantsShouldSelectDiscussion() { MessageDlg.Show("Participants should choose a discussion they are invited to"); }
//private static void MsgNameRegistered() //{ // MessageBox.Show("This name is already registered in this session", "Error", // MessageBoxButton.OK, MessageBoxImage.Error); //} private static void MsgPlaceReserved() { MessageDlg.Show("Some online user has taken selected seat in current session", "Error", MessageBoxButton.OK, MessageBoxImage.Error); }
public static void startResultViewer() { if (SessionInfo.Get().discussion == null) { MessageDlg.Show("No default discussion"); } else { if (SessionInfo.Get().person.Session == null) { MessageDlg.Show( string.Format( "The function requires experimental mode (session)!", SessionInfo.Get().person.Name)); return; } var tsd = new TopicSelectionDlg(SessionInfo.Get().discussion); tsd.ShowDialog(); if (tsd.topic == null) { return; } if (tsd.Html) { var reportUrl = string.Format( "http://{0}/discsvc/report?discussionId={1}&topicId={2}&sessionId={3}", ConfigManager.ServiceServer, SessionInfo.Get().discussion.Id, tsd.topic.Id, SessionInfo.Get().person.Session.Id); try { System.Diagnostics.Process.Start("chrome", reportUrl); } catch { System.Diagnostics.Process.Start(reportUrl); } //var browser = WebkitBrowserWindow.Instance(reportUrl, tsd.topic.Id); //browser.Show(); //browser.Activate(); } else { BusyWndSingleton.Show("Exporting, please wait..."); try { (new PdfReportDriver()).Run(SessionInfo.Get().person.Session, tsd.topic, SessionInfo.Get().discussion, SessionInfo.Get().person); } finally { BusyWndSingleton.Hide(); } } } }