protected override void Initialize() { base.Initialize(); var exceptionDialog = new ExceptionDialog(); try { using (var catalog = new AssemblyCatalog(GetType().Assembly)) using (var container = new CompositionContainer(catalog)) { var menuCommandService = (IMenuCommandService)GetService(typeof(IMenuCommandService)); var errorListProvider = new ErrorListProvider(ServiceProvider.GlobalProvider); container.ComposeExportedValue(exceptionDialog); container.ComposeExportedValue(menuCommandService); container.ComposeExportedValue(errorListProvider); container.GetExportedValue <MenuConfigure>().RegisterMenus(); container.GetExportedValue <SolutionEvents>().RegisterSolutionEvents(); container.GetExportedValue <TaskFileReplacer>().CheckForFilesToUpdate(); } } catch (Exception exception) { exceptionDialog.HandleException(exception); } }
protected virtual void OnCellMouseDown(int col, int row, MouseEventArgs mouseEvent) { try { switch (SelectState) { case GridSelectingState.None: case GridSelectingState.Selected: if (CanSelect(col, row)) { SelectState = GridSelectingState.Selecting; SelectionStart = Tuple.Create(col, row); SelectionEnd = SelectionStart; FireSelectingStarted(col, row); FireSelecting(col, row); } break; case GridSelectingState.Selecting: default: break; } } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(this, error); } }
private static void SetupRollbar() { Rollbar.Init(new RollbarConfig { AccessToken = "5525758f15504199b7125d35d2058cfe", Environment = "production" }); var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); var userName = $"{version} on {GetWindowsVersion()} with {Get45PlusFromRegistry()}"; Rollbar.PersonData(() => new Person(version) { UserName = userName }); Rollbar.Report($"Jexus Manager started", ErrorLevel.Info); Application.ThreadException += (sender, args) => { Rollbar.Report(args.Exception); ExceptionDialog.Report(userName, args.Exception.ToString()); }; AppDomain.CurrentDomain.UnhandledException += (sender, args) => { Rollbar.Report(args.ExceptionObject as Exception); ExceptionDialog.Report(userName, args.ExceptionObject.ToString()); }; TaskScheduler.UnobservedTaskException += (sender, args) => { Rollbar.Report(args.Exception); ExceptionDialog.Report(userName, args.Exception.ToString()); }; }
private HistoryMemento DoCanvasResize(DocumentWorkspace documentWorkspace, Size newLayerSize) { Document document; int activeLayerIndex = documentWorkspace.ActiveLayerIndex; Size newSize = new Size(Math.Max(newLayerSize.Width, documentWorkspace.Document.Width), Math.Max(newLayerSize.Height, documentWorkspace.Document.Height)); try { using (new WaitCursorChanger(documentWorkspace)) { CleanupManager.RequestCleanup(); document = CanvasSizeAction.ResizeDocument(documentWorkspace.Document, newSize, AnchorEdge.TopLeft, documentWorkspace.ToolSettings.SecondaryColor.Value); } } catch (OutOfMemoryException exception) { ExceptionDialog.ShowErrorDialog(documentWorkspace, PdnResources.GetString("ImportFromFileAction.AskForCanvasResize.OutOfMemory"), exception); document = null; } if (document == null) { return(null); } HistoryMemento memento = new ReplaceDocumentHistoryMemento(string.Empty, null, documentWorkspace); using (new WaitCursorChanger(documentWorkspace)) { documentWorkspace.Document = document; } documentWorkspace.ActiveLayer = (Layer)documentWorkspace.Document.Layers[activeLayerIndex]; return(memento); }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { if (qualitySelectListBox.SelectedItem == null) { PrimaryButtonText = "请选择清晰度"; await Task.Delay(2000); PrimaryButtonText = "下载"; return; } this.needToClose = true; this.Hide(); try { await DownloadHelper.CreateDownloadAsync (vm.Bv, vm.Cid, this.QualitySelectionProperty, ApplicationData.Current.LocalSettings.Values["biliUserSESSDATA"] as string, XamlRoot); } catch (ParsingVideoException ex) { var dialog = new ErrorDialog(ex.Message, XamlRoot); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { MainPage.ContentFrame.Navigate(typeof(UserPage)); MainPage.NavView.SelectedItem = MainPage.NavViewItems[2]; } } catch (DirectoryNotFoundException ex) { var dialog = new ExceptionDialog(ex.Message, XamlRoot); _ = await dialog.ShowAsync(); } }
private static void InitLogging() { try { DirectoryInfo archiveDir = new DirectoryInfo(Path.Combine(launchData.PhoenixDir, "LogArchive")); if (!archiveDir.Exists) { archiveDir.Create(); } DateTime time = DateTime.Now; string archiveFileName = String.Format("phoenix_log {0}.{1}.{2} {3}.{4}.gzip", time.Day, time.Month, time.Year.ToString().Substring(2), time.Hour, time.Minute); string archiveFile = Path.Combine(archiveDir.FullName, archiveFileName); if (File.Exists(archiveFile)) { archiveFile = null; } string logFile = Path.Combine(launchData.PhoenixDir, "phoenix_log.txt"); Stream logStream = Phoenix.Logging.Log.OpenFile(logFile, true, archiveFile, MaxLogSize); Trace.Listeners.Add(new TextFileTraceListener(logStream)); Log.AutoFlushInterval = 5000; } catch (Exception e) { Trace.WriteLine("Unhandled exception during log initialization. Log probably won't be saved. Details:\n" + e.ToString(), "Phoenix"); ExceptionDialog.Show(e, "Unhandled exception during log initialization. Log probably won't be saved."); } }
internal void ShowException(Exception exception) { lock (_lock) { //Avoid displaying an exception that is already being displayed. if (_exceptionList.Any(a => a.Message == exception.Message)) { return; } //Adding to the list, so a second exception with the same name won't be displayed. _exceptionList.Add(exception); if (Global.IsHotFix4055002Installed && exception is XamlParseException && exception.InnerException is TargetInvocationException) { ExceptionDialog.Ok(exception, "ScreenToGif", "Error while rendering visuals", exception.Message); } else { ExceptionDialog.Ok(exception, "ScreenToGif", "Unhandled exception", exception.Message); } //By removing the exception, the same exception can be displayed later. _exceptionList.Remove(exception); } }
private void LoadReport() { try { // Create Report this._dataReport.Export(); if (string.IsNullOrEmpty(this._dataReport.Html)) { return; } // Update Web Browser Contents if (this.webBrowser1 == null) { return; } if (this.webBrowser1.IsDisposed) { return; } if (this.webBrowser1.Disposing) { return; } this.webBrowser1.Navigate(this._dataReport.Html); } catch (Exception ex) { ExceptionDialog.HandleException(ex); } }
/// <summary> /// Manage an exception /// </summary> /// <param name="exception">The exception to manage</param> private void ManageException(Exception exception) { if (_isManagingException) { return; } _isManagingException = true; IsMovieFlyoutOpen = false; IsSettingsFlyoutOpen = false; if (exception is WebException || exception is SocketException) { ApplicationState.IsConnectionInError = true; } DispatcherHelper.CheckBeginInvokeOnUI(async() => { var exceptionDialog = new ExceptionDialog( new ExceptionDialogSettings( LocalizationProviderHelper.GetLocalizedValue <string>("EmbarrassingError"), exception.Message)); await _dialogCoordinator.ShowMetroDialogAsync(this, exceptionDialog); await exceptionDialog.WaitForButtonPressAsync(); _isManagingException = false; await _dialogCoordinator.HideMetroDialogAsync(this, exceptionDialog); }); }
internal void FireAppointmentResizingStarted(int col, int row, ResizedAppointmentBorder borderType) { try { var cell = GetCell(col, row); _resizingStart = Tuple.Create(col, row); _resizingEnd = Tuple.Create(col, row); _resizing = true; //_resizingAppointment = ViewModel.GetAppointmentBlockAt(col, row); _resizingBorder = borderType; var appointment = ViewModel.GetAppointmentBlockAt(_resizingStart.Item1, _resizingStart.Item2); Debug.Assert(appointment != null); Debug.Assert(_resizingStart.Item1 == _resizingEnd.Item1); var column = ViewModel.GetColumnAt(_resizingStart.Item1); OnAppointmentResizingStart(column.ColumnDataObject, appointment.AppointmentDataObject); if (AppointmentResizingStarted != null) { AppointmentResizingStarted( new AppointmentEvent { Source = this, SourceColumn = column.ColumnDataObject, Appointment = appointment.AppointmentDataObject } ); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
public void GivenExceptionDialog_WhenOpenLogButtonClicked_ThenPerformsOpenLogClickedAction() { // Setup var counter = 0; var mocks = new MockRepository(); var window = mocks.Stub <IWin32Window>(); mocks.ReplayAll(); using (var dialog = new ExceptionDialog(window, null, null) { OpenLogClicked = () => counter++ }) { dialog.Show(); var button = new ButtonTester("buttonOpenLog"); // Call button.Click(); // Assert Assert.AreEqual(1, counter); } mocks.VerifyAll(); }
private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) { try { if (e.Node is TreeNodeGeodatabase) { TreeNodeGeodatabase treeNodeGeodatabase = (TreeNodeGeodatabase)e.Node; EsriModel model = treeNodeGeodatabase.Model; model.SelectElements(false); } else if (e.Node is TreeNodeTable) { TreeNodeTable treeNodeTable = (TreeNodeTable)e.Node; EsriTable table = treeNodeTable.Table; EsriModel model = (EsriModel)table.Container; model.SelectElements(false); table.Selected = true; } else if (e.Node is TreeNodeGroup) { } } catch (Exception ex) { ExceptionDialog.HandleException(ex); } }
internal void FireAppointmentDraggedEvent(AppointmentDragObject dragObject) { try { var sourceColumn = dragObject.SourceColumn; var appointment = dragObject.Appointment; if (appointment == null) { throw new ArgumentException("dragObject", "Appointment property is null"); } OnAppointmentDrag(sourceColumn, appointment); if (AppointmentDragged != null) { AppointmentDragged( new AppointmentDraggedEvent { Source = this, SourceColumn = sourceColumn, Appointment = appointment, } ); } } catch (Exception error) { ExceptionDialog.Show(this, error); } }
private void Timer_Tick(object sender, EventArgs e) { try { if (this.IsDisposed) { return; } if (this.Disposing) { return; } if (!(this.Visible)) { return; } if (this.WindowState == FormWindowState.Minimized) { return; } this.buttonApply.Enabled = this.m_edited; this.buttonCancel.Enabled = true; this.buttonReset.Enabled = true; this.buttonOK.Enabled = true; } catch (Exception ex) { ExceptionDialog.HandleException(ex); } }
private void MenuItem_BeforePopup(object sender, MenuPopupEventArgs e) { try { if (sender == this.contextMenuBarItemGrid) { // Get Selected Property Grid PropertyGrid propertyGrid = null; if (e.Control != null && e.Control is PropertyGrid) { propertyGrid = (PropertyGrid)e.Control; } // Enable/Check Menu Items this.menuButtonItemReset.Enabled = propertyGrid != null && propertyGrid.SelectedGridItem != null; this.menuButtonItemDescription.Enabled = propertyGrid != null; this.menuButtonItemDescription.Checked = propertyGrid != null && propertyGrid.HelpVisible; // Store Reference of Selected PropertyGrid this.menuButtonItemReset.Tag = propertyGrid; this.menuButtonItemDescription.Tag = propertyGrid; } } catch (Exception ex) { ExceptionDialog.HandleException(ex); } }
private void MenuItem_Activate(object sender, EventArgs e) { try { if (sender == this.menuButtonItemReset) { if (this.menuButtonItemReset.Tag != null) { if (this.menuButtonItemReset.Tag is PropertyGrid) { PropertyGrid propertyGrid = (PropertyGrid)this.menuButtonItemReset.Tag; propertyGrid.ResetSelectedProperty(); } } } else if (sender == this.menuButtonItemDescription) { if (this.menuButtonItemDescription.Tag != null) { if (this.menuButtonItemDescription.Tag is PropertyGrid) { PropertyGrid propertyGrid = (PropertyGrid)this.menuButtonItemDescription.Tag; propertyGrid.HelpVisible = !(propertyGrid.HelpVisible); } } } } catch (Exception ex) { ExceptionDialog.HandleException(ex); } }
private void OnListViewExpressionsKeyDown(object sender, KeyEventArgs e) { try { if (this.listViewExpressions.SelectedItems.Count < 1) { return; } XPathExpressionListViewItem item = this.listViewExpressions.SelectedItems[0] as XPathExpressionListViewItem; if (item == null) { return; } switch (e.KeyCode) { case Keys.Delete: this.DeleteSelectedExpressionItems(e.Shift); break; } } catch (Exception ex) { Debug.WriteLine(ex); ExceptionDialog.ShowDialog(this, ex); } }
public void DefaultConstructor_ExpectedValue() { // Setup var mocks = new MockRepository(); var window = mocks.Stub <IWin32Window>(); mocks.ReplayAll(); // Call using (var dialog = new ExceptionDialog(window, null, null)) { // Assert Assert.IsNotNull(dialog.Icon); Assert.IsTrue(dialog.ShowIcon); Assert.AreEqual(0, dialog.MinimumSize.Width); // Set during load Assert.AreEqual(0, dialog.MinimumSize.Height); // Set during load Assert.AreEqual(FormBorderStyle.Sizable, dialog.FormBorderStyle); Assert.AreEqual(FormStartPosition.CenterParent, dialog.StartPosition); Assert.IsFalse(dialog.ShowInTaskbar); Assert.IsTrue(dialog.ControlBox); Assert.IsFalse(dialog.MaximizeBox); Assert.IsFalse(dialog.MinimizeBox); Assert.IsNull(dialog.CancelButton); } mocks.VerifyAll(); }
private static void messageBox_SubmitError(object sender, ExceptionDetailEventArgs e) { ExceptionDialog dialog = sender as ExceptionDialog; if (string.IsNullOrWhiteSpace(dialog.UserNotes)) { MessageBox.Show("Please enter some details to help us debug this issue.", "Details Required", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } MailAddress ccAddress = null; if (!string.IsNullOrEmpty(dialog.UserEmail)) { try { ccAddress = new MailAddress(dialog.UserEmail); } catch (FormatException ex) { MessageBox.Show(ex.Message, "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } SendEmail(ConstructMessage(dialog), ccAddress); dialog.SubmitSuccessful = true; }
private static string ConstructMessage(ExceptionDialog messageBox) { StringBuilder message = new StringBuilder(); // Add the exception message and user details message.AppendFormat("The following error occurred in {0} at {1}:\n", messageBox.AssemblyName, _timeStamp); message.AppendLine(messageBox.ExceptionMessage); message.AppendLine(); message.AppendLine("USER INFORMATION:"); message.AppendLine(messageBox.UserNotes); message.AppendLine(); // Add the environment details message.AppendLine("ENVIRONMENT DETAILS:"); message.AppendLine("User Name: " + messageBox.UserName); message.AppendLine("Host Name: " + messageBox.HostName); message.AppendLine("Host User: "******"Address: " + messageBox.Address); message.AppendLine("Assembly: " + messageBox.AssemblyName); message.AppendLine("Version: " + messageBox.AssemblyVersion); message.AppendLine(); // Add the exception detail message.AppendLine("EXCEPTION DETAILS:"); message.AppendLine(messageBox.ExceptionDetail); return(message.ToString()); }
private void OnListViewExpressionsAfterLabelEdit(object sender, LabelEditEventArgs e) { try { if (e.CancelEdit || e.Label == null) { return; } XPathExpressionListViewItem item = this.listViewExpressions.Items[e.Item] as XPathExpressionListViewItem; if (item == null) { return; } item.XPathExpression.Name = e.Label; item.Text = e.Label; this.listViewExpressions.AutoResizeColumns(); } catch (Exception ex) { Debug.WriteLine(ex); ExceptionDialog.ShowDialog(this, ex); } }
/** * Is invoked when application launches. Connects the Client to the Server */ public void OnUserConnect(string address, int port) { ChannelDispatcher dispatcher = new ChannelDispatcher(); this.transport = new TransportClient(dispatcher); sessionClient = new SessionClient(this.transport, this); dispatcher.RegisterChannel(sessionClient); surfaceClient = new SurfaceClient(this, this.transport); dispatcher.RegisterChannel(surfaceClient); inputClient = new InputClient(this.transport); dispatcher.RegisterChannel(inputClient); try { this.transport.Connect(address, port); DisplayStatusText("Welcome! You are connected to Screenary server at " + address + " : " + port); } catch (TransportException e) { ExceptionDialog exception = new ExceptionDialog("Operation Fail", "Could not connect to Screenary server at " + address + " : " + port + "\nVerify connections."); } }
/// <summary> /// Read all settings from Configuration class and initialize the Controls /// </summary> private void _LoadSettings() { try { // Language if (cbxLanguage.Items.Contains(LanguageManager.Instance.Language)) { cbxLanguage.SelectedItem = LanguageManager.Instance.Language; } else { cbxLanguage.SelectedIndex = 0; } sedtDomainFilter.Document.Text = clsMain.Instance.DomainFilter; // Errors only chbxErrorOnly.Checked = clsMain.Instance.ErrorOnly; // timeout udTimeOut.Value = clsMain.Instance.TimeOut; } catch (Exception ex) { ExceptionDialog.Show(this, ex); } }
protected override void Initialize() { base.Initialize(); var exceptionDialog = new ExceptionDialog("http://code.google.com/p/notifypropertyweaver/issues/list", "NotifyPropertyWeaver"); try { using (var catalog = new AssemblyCatalog(GetType().Assembly)) using (var container = new CompositionContainer(catalog)) { var menuCommandService = (IMenuCommandService) GetService(typeof (IMenuCommandService)); var errorListProvider = new ErrorListProvider(ServiceProvider.GlobalProvider); container.ComposeExportedValue(exceptionDialog); container.ComposeExportedValue(menuCommandService); container.ComposeExportedValue(errorListProvider); container.GetExportedValue<MenuConfigure>().RegisterMenus(); container.GetExportedValue<SolutionEvents>().RegisterSolutionEvents(); container.GetExportedValue<TaskFileReplacer>().CheckForFilesToUpdate(); } } catch (Exception exception) { exceptionDialog.HandleException(exception); } }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var sESSDATA = ApplicationData.Current.LocalSettings.Values["biliUserSESSDATA"] as string; var list = new List <BiliVideoInfo>(); foreach (var item in vm.VideoList) { if (item.ToDownload == false) { continue; } list.Add(item.Info); } if (list.Count < 1) { PrimaryButtonText = "请选择至少一个视频"; await Task.Delay(2000); if (PrimaryButtonText == "请选择至少一个视频") { PrimaryButtonText = "下载所选项"; } return; } if (this.qualityComboBox.SelectedValue == null) { PrimaryButtonText = "请选择清晰度"; await Task.Delay(2000); if (PrimaryButtonText == "请选择清晰度") { PrimaryButtonText = "下载所选项"; } return; } this.needToClose = true; var quality = (int)this.qualityComboBox.SelectedValue; try { await DownloadHelper.CreateDownloadsAsync(list, quality, sESSDATA, XamlRoot); } catch (DirectoryNotFoundException ex) { var dialog = new ExceptionDialog(ex.Message, XamlRoot); _ = await dialog.ShowAsync(); } catch (ParsingVideoException ex) { var dialog = new ErrorDialog(ex.Message, XamlRoot); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { MainPage.NavView.SelectedItem = MainPage.NavViewItems[2]; MainPage.ContentFrame.Navigate(typeof(UserPage)); } } }
protected virtual void OnCellMouseUp(int col, int row, MouseEventArgs mouseEvent) { try { const bool allowMultiColumnSelect = false; switch (SelectState) { case GridSelectingState.Selecting: col = allowMultiColumnSelect ? col : SelectionStart.Item1; if (CanSelect(col, row)) { SelectionEnd = Tuple.Create(col, row); } if (AcceptSelection(SelectionStart, SelectionEnd)) { SelectState = GridSelectingState.Selected; FireSelectionChanged(col, row); FireSelectionFinished(SelectionStart.Item1, SelectionStart.Item2, col, row); } else { ClearSelection(); FireSelectionFinished(SelectionStart.Item1, SelectionStart.Item2, col, row); } break; case GridSelectingState.Selected: case GridSelectingState.None: default: break; } } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(this, error); } }
protected virtual void OnCellMouseMoved(int col, int row, MouseEventArgs mouseEvent) { try { const bool allowMultiColumnSelect = false; switch (SelectState) { case GridSelectingState.Selecting: col = allowMultiColumnSelect ? col : SelectionStart.Item1; if (CanSelect(col, row)) { SelectionEnd = Tuple.Create(col, row); } FireSelecting(SelectionEnd.Item1, SelectionEnd.Item2); break; default: if (_lastMouseDown != null) { if (mouseEvent.Button.HasFlag(MouseButtons.Left) && _grid.PointToClient(Cursor.Position).DistanceTo(_lastMouseDown.Item4) >= DistanceMovedToInitiateDragging && CanDragCell(_lastMouseDown.Item1, _lastMouseDown.Item2) ) { BeginDragging(_lastMouseDown.Item1, _lastMouseDown.Item2, _lastMouseDown.Item4); } } break; } } catch (Exception error) { SystemLog.Exception(error); ExceptionDialog.Show(this, error); } }
protected override void Initialize() { base.Initialize(); var exceptionDialog = new ExceptionDialog(); try { var menuCommandService = (IMenuCommandService) GetService(typeof (IMenuCommandService)); var errorListProvider = new ErrorListProvider(ServiceProvider.GlobalProvider); var currentProjectFinder = new CurrentProjectFinder(); var contentsFinder = new ContentsFinder(); var configureMenuCallback = new ConfigureMenuCallback(currentProjectFinder, contentsFinder, exceptionDialog); var messageDisplayer = new MessageDisplayer(errorListProvider); var disableMenuConfigure = new DisableMenuConfigure(currentProjectFinder, messageDisplayer, exceptionDialog); var containsFodyChecker = new ContainsFodyChecker(); var menuStatusChecker = new MenuStatusChecker(currentProjectFinder, exceptionDialog, containsFodyChecker); new MenuConfigure(configureMenuCallback, disableMenuConfigure, menuCommandService, menuStatusChecker).RegisterMenus(); var taskFileReplacer = new TaskFileReplacer(messageDisplayer, contentsFinder); var taskFileProcessor = new TaskFileProcessor(taskFileReplacer, messageDisplayer); var msBuildKiller = new MSBuildKiller(); new SolutionEvents(taskFileProcessor, exceptionDialog, msBuildKiller).RegisterSolutionEvents(); new TaskFileReplacer(messageDisplayer, contentsFinder).CheckForFilesToUpdate(); } catch (Exception exception) { exceptionDialog.HandleException(exception); } }
public SolutionEvents(TaskFileProcessor taskFileProcessor, ExceptionDialog exceptionDialog, ErrorDisplayer errorDisplayer, AllProjectFinder allProjectFinder) { this.taskFileProcessor = taskFileProcessor; this.exceptionDialog = exceptionDialog; this.errorDisplayer = errorDisplayer; this.allProjectFinder = allProjectFinder; }
void listViewExpressions_ItemActivate(object sender, EventArgs e) { try { if (this.listView.SelectedItems.Count < 1) { return; } ListViewItem item = this.listView.SelectedItems[0]; Error error = item.Tag as Error; if (error == null) { return; } this.ErrorActivated(this, new EventArgs <Error>(error)); } catch (Exception ex) { Debug.WriteLine(ex); ExceptionDialog.ShowDialog(this, ex); } }
public static async Task <bool> CheckSESSDATAStatusAsync(string sessdata) { if (string.IsNullOrWhiteSpace(sessdata)) { return(false); } var client = new HttpClient(); client.DefaultRequestHeaders.Add("cookie", $"SESSDATA={sessdata}"); try { var resp = await client.GetStringAsync("https://api.bilibili.com/x/space/myinfo"); var json = JsonConvert.DeserializeObject <dynamic>(resp); if (json.code == 0) { Settings.Uid = json.data.mid; _logger.Info("SESSDATA检测结果:有效"); return(true); } else { _logger.Info($"SESSDATA已失效,值为{sessdata}"); return(false); } } catch (Exception ex) { _logger.Error(ex); var dialog = new ExceptionDialog(ex); await dialog.ShowAsync(); return(false); } }
public static DialogResult ShowCrashLogDialog(string crashLogPath) { object sync = CrashManager.sync; lock (sync) { alreadyReported = true; } string directoryName = Path.GetDirectoryName(crashLogPath); string crashLogText = File.ReadAllText(crashLogPath); using (ExceptionDialog dialog = new ExceptionDialog()) { dialog.Text = PdnResources.GetString("CrashLogDialog.Title.Text"); dialog.Message = PdnResources.GetString("CrashLogDialog.Message"); dialog.Message2 = GetSecondParagraphForMessage(crashLogText); dialog.Button1Text = PdnResources.GetString("CrashLogDialog.RestartButton.Text"); dialog.IsButton1Visible = true; dialog.Button2Text = PdnResources.GetString("CrashLogDialog.QuitButton.Text"); dialog.ExceptionText = crashLogText; dialog.CrashLogDirectory = directoryName; dialog.ShowInTaskbar = true; return(dialog.ShowDialog()); } }
protected override void OkCommandExecuted(object obj) { InProgress = true; ProgressIsIndeterminate = true; _service.ActionHelper.Async(() => { try { if (_service.DatabaseHelper.IsPHmiDatabase(ConnectionParameters)) { _service.ActionHelper.Dispatch(() => base.OkCommandExecuted(obj)); } else { MessageDialog.Show( string.Format(Res.NotPHmiDatabaseMessage, ConnectionParameters.Database), Res.Error, owner: View); } } catch (Exception exception) { ExceptionDialog.Show(exception, View); } finally { _service.ActionHelper.Dispatch(() => { InProgress = false; ProgressIsIndeterminate = false; }); } }); }
public MenuConfigure(CurrentProjectFinder currentProjectFinder, ExceptionDialog exceptionDialog, ConfigureMenuCallback configureMenuCallback, DisableMenuConfigure disableMenuConfigure, IMenuCommandService menuCommandService) { this.exceptionDialog = exceptionDialog; this.configureMenuCallback = configureMenuCallback; this.disableMenuConfigure = disableMenuConfigure; this.menuCommandService = menuCommandService; this.currentProjectFinder = currentProjectFinder; }
public ConfigureMenuCallback(CurrentProjectFinder currentProjectFinder, CosturaFileExporter fileExporter, TaskFileReplacer taskFileReplacer, FullPathResolver fullPathResolver, ExceptionDialog exceptionDialog) { this.currentProjectFinder = currentProjectFinder; this.fullPathResolver = fullPathResolver; this.exceptionDialog = exceptionDialog; this.taskFileReplacer = taskFileReplacer; this.fileExporter = fileExporter; }
public SolutionEvents(TaskFileProcessor taskFileProcessor, AttributeFileProcessor attributeFileProcessor, ExceptionDialog exceptionDialog, ErrorDisplayer errorDisplayer, AllProjectFinder allProjectFinder, MSBuildKiller msBuildKiller) { this.taskFileProcessor = taskFileProcessor; this.attributeFileProcessor = attributeFileProcessor; this.exceptionDialog = exceptionDialog; this.errorDisplayer = errorDisplayer; this.allProjectFinder = allProjectFinder; this.msBuildKiller = msBuildKiller; }
public AlertButton ShowException (Gtk.Window parent, string title, string message, Exception e, params AlertButton[] buttons) { var exceptionDialog = new ExceptionDialog () { Buttons = buttons, Title = title, Message = message, Exception = e, TransientFor = parent, }; exceptionDialog.Run (); return exceptionDialog.ResultButton; }
public DisableMenuCallback(CurrentProjectFinder currentProjectFinder, MessageDisplayer messageDisplayer, ExceptionDialog exceptionDialog) { this.exceptionDialog = exceptionDialog; this.messageDisplayer = messageDisplayer; this.currentProjectFinder = currentProjectFinder; }
public void ShowException (Gtk.Window parent, Exception e, string primaryText) { var exceptionDialog = new ExceptionDialog () { Message = primaryText, Exception = e, TransientFor = parent, }; exceptionDialog.Run (); }
public AlertButton ShowException (Gtk.Window parent, string title, string message, Exception e, params AlertButton[] buttons) { if (buttons.Length == 0 && (e is UserException) && ((UserException)e).AlreadyReportedToUser) return AlertButton.Ok; var exceptionDialog = new ExceptionDialog () { Buttons = buttons ?? new AlertButton[] { AlertButton.Ok }, Title = title ?? GettextCatalog.GetString ("An error has occurred"), Message = message, Exception = e, TransientFor = parent, }; exceptionDialog.Run (); return exceptionDialog.ResultButton; }
public ConfigureMenuCallback(CurrentProjectFinder currentProjectFinder, ContentsFinder contentsFinder, ExceptionDialog exceptionDialog) { this.currentProjectFinder = currentProjectFinder; this.exceptionDialog = exceptionDialog; this.contentsFinder = contentsFinder; }
public DisableMenuConfigure(CurrentProjectFinder currentProjectFinder, ErrorDisplayer errorDisplayer, ExceptionDialog exceptionDialog) { this.exceptionDialog = exceptionDialog; this.errorDisplayer = errorDisplayer; this.currentProjectFinder = currentProjectFinder; }
public MenuStatusChecker(CurrentProjectFinder currentProjectFinder, ExceptionDialog exceptionDialog, ContainsFodyChecker containsFodyChecker) { this.currentProjectFinder = currentProjectFinder; this.exceptionDialog = exceptionDialog; this.containsFodyChecker = containsFodyChecker; }
/** * When a session is terminated succesfully, change to the starter state, refresh, and update notification bar */ public void OnSessionTerminationSuccess(char[] sessionKey) { currentState = clientStates[STARTED_STATE]; currentState.refresh(); this.Title = "Screenary"; ExceptionDialog exception = new ExceptionDialog("Alert", "The session has been terminated."); DisplayStatusText("The session has been terminated."); }
public void ShowException (Gtk.Window parent, string title, string message, Exception e) { var exceptionDialog = new ExceptionDialog () { Title = title, Message = message, Exception = e, TransientFor = parent, }; exceptionDialog.Run (); }
static int Main(string [] args) { bool empty = false; List<string> uris = new List<string> (); Unix.SetProcessName (Defines.PACKAGE); // Options and Option parsing bool shutdown = false; bool view = false; bool slideshow = false; string import_uri = null; GLib.GType.Init (); Catalog.Init ("f-spot", Defines.LOCALE_DIR); FSpot.Global.PhotoDirectory = Preferences.Get<string> (Preferences.STORAGE_PATH); for (int i = 0; i < args.Length && !shutdown; i++) { switch (args [i]) { case "-h": case "-?": case "-help": case "--help": case "-usage": Help (); return 0; case "-shutdown": case "--shutdown": Log.Information ("Shutting down existing F-Spot server..."); shutdown = true; break; case "-b": case "-basedir": case "--basedir": if (i+1 == args.Length || args[i+1].StartsWith ("-")) { Log.Error ("f-spot: -basedir option takes one argument"); return 1; } FSpot.Global.BaseDirectory = args [++i]; Log.Information ("BaseDirectory is now {0}", FSpot.Global.BaseDirectory); break; case "-p": case "-photodir": case "--photodir": if (i+1 == args.Length || args[i+1].StartsWith ("-")) { Log.Error ("f-spot: -photodir option takes one argument"); return 1; } FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath (args [++i]); Log.Information ("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory); break; case "-i": case "-import": case "--import": if (i+1 == args.Length) { Log.Error ("f-spot: -import option takes one argument"); return 1; } import_uri = args [++i]; break; case "-slideshow": case "--slideshow": slideshow = true; break; case "-v": case "-view": case "--view": if (i+1 == args.Length || args[i+1].StartsWith ("-")) { Log.Error ("f-spot: -view option takes (at least) one argument"); return 1; } view = true; while (!(i+1 == args.Length) && !args[i+1].StartsWith ("-")) uris.Add (args [++i]); // if (!System.IO.Directory.Exists (args[i+1]) && !System.IO.File.Exists (args[i+1])) { // Log.Error ("f-spot: -view argument must be an existing file or directory"); // return 1; // } break; case "-versions": case "--versions": Versions (); return 0; case "-V": case "-version": case "--version": Version (); return 0; case "--strace": Log.Tracing = true; break; case "--debug": Log.Debugging = true; // Debug GdkPixbuf critical warnings GLib.LogFunc logFunc = new GLib.LogFunc (GLib.Log.PrintTraceLogFunction); GLib.Log.SetLogHandler ("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc); // Debug Gtk critical warnings GLib.Log.SetLogHandler ("Gtk", GLib.LogLevelFlags.Critical, logFunc); // Debug GLib critical warnings GLib.Log.SetLogHandler ("GLib", GLib.LogLevelFlags.Critical, logFunc); //Debug GLib-GObject critical warnings GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.Critical, logFunc); break; case "--uninstalled": case "--gdb": case "--valgrind": case "--sync": break; default: if (args [i].StartsWith ("--profile")) break; if (args [i].StartsWith ("--trace")) break; Log.Debug ("Unparsed argument >>{0}<<", args [i]); break; } } // Validate command line options if ( (import_uri != null && (view || shutdown || slideshow)) || (view && (shutdown || slideshow)) || (shutdown && slideshow) ) { Log.Error ("Can't mix -import, -view, -shutdown or -slideshow"); return 1; } //Initialize Mono.Addins uint timer = Log.InformationTimerStart ("Initializing Mono.Addins"); AddinManager.Initialize (FSpot.Global.BaseDirectory); AddinManager.Registry.Update (null); SetupService setupService = new SetupService (AddinManager.Registry); string maj_version = String.Join (".", Defines.VERSION.Split ('.'), 0, 3); foreach (AddinRepository repo in setupService.Repositories.GetRepositories ()) if (repo.Url.StartsWith ("http://addins.f-spot.org/") && !repo.Url.StartsWith ("http://addins.f-spot.org/" + maj_version)) { Log.Information ("Unregistering {0}", repo.Url); setupService.Repositories.RemoveRepository (repo.Url); } setupService.Repositories.RegisterRepository (null, "http://addins.f-spot.org/" + maj_version, false); Log.DebugTimerPrint (timer, "Mono.Addins Initialization took {0}"); //Gtk initialization Gtk.Application.Init (Defines.PACKAGE, ref args); Gnome.Vfs.Vfs.Initialize (); // init web proxy globally Platform.WebProxy.Init (); if (File.Exists (Preferences.Get<string> (Preferences.GTK_RC))) { if (File.Exists (Path.Combine (Global.BaseDirectory, "gtkrc"))) Gtk.Rc.AddDefaultFile (Path.Combine (Global.BaseDirectory, "gtkrc")); Global.DefaultRcFiles = Gtk.Rc.DefaultFiles; Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC)); Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true); } try { Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] { GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 16, (Gtk.IconLookupFlags)0), GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 22, (Gtk.IconLookupFlags)0), GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags)0), GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags)0) }; } catch {} try { if (slideshow == true) { App.Instance.Slideshow (null); } else if (shutdown) { try { App.Instance.Shutdown (); } catch (System.Exception) { // trap errors } System.Environment.Exit (0); } else if (view) { UriList list = new UriList (); foreach (string s in uris) list.AddUnknown (s); if (list.Count == 0) { Help (); return 1; } App.Instance.View (list); } else if (import_uri != null) { App.Instance.Import (import_uri); } else { App.Instance.Organize (); } if (App.Instance.IsRunning) return 0; Gtk.Application.Run (); } catch (System.Exception e) { Log.Exception (e); ExceptionDialog dlg = new ExceptionDialog(e); dlg.Run(); dlg.Destroy(); System.Environment.Exit(1); } return 0; }
/// <summary> /// Manage an exception /// </summary> /// <param name="exception">The exception to manage</param> private void ManageException(Exception exception) { if (_isManagingException) return; _isManagingException = true; IsMovieFlyoutOpen = false; IsSettingsFlyoutOpen = false; if (exception is WebException || exception is SocketException) ApplicationState.IsConnectionInError = true; DispatcherHelper.CheckBeginInvokeOnUI(async () => { var exceptionDialog = new ExceptionDialog( new ExceptionDialogSettings( LocalizationProviderHelper.GetLocalizedValue<string>("EmbarrassingError"), exception.Message)); await _dialogCoordinator.ShowMetroDialogAsync(this, exceptionDialog); await exceptionDialog.WaitForButtonPressAsync(); _isManagingException = false; await _dialogCoordinator.HideMetroDialogAsync(this, exceptionDialog); }); }
public AlertButton ShowException (Gtk.Window parent, string title, string message, Exception e, params AlertButton[] buttons) { var exceptionDialog = new ExceptionDialog () { Buttons = buttons ?? new AlertButton[] { AlertButton.Ok }, Title = title ?? GettextCatalog.GetString ("An error has occurred"), Message = message, Exception = e, TransientFor = parent, }; exceptionDialog.Run (); return exceptionDialog.ResultButton; }
/** * Is invoked when application launches. Connects the Client to the Server */ public void OnUserConnect(string address, int port) { ChannelDispatcher dispatcher = new ChannelDispatcher(); this.transport = new TransportClient(dispatcher); sessionClient = new SessionClient(this.transport, this); dispatcher.RegisterChannel(sessionClient); surfaceClient = new SurfaceClient(this, this.transport); dispatcher.RegisterChannel(surfaceClient); inputClient = new InputClient(this.transport); dispatcher.RegisterChannel(inputClient); try { this.transport.Connect(address, port); DisplayStatusText("Welcome! You are connected to Screenary server at " + address + " : " + port); } catch (TransportException e) { ExceptionDialog exception = new ExceptionDialog("Operation Fail", "Could not connect to Screenary server at " + address + " : " + port + "\nVerify connections."); } }
private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton) { ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails); var objForm = new ExceptionDialog(); objForm.Text = ReplaceStringVals(objForm.Text); objForm.ErrorBox.Text = strWhatHappened; objForm.ScopeBox.Text = strHowUserAffected; objForm.ActionBox.Text = strWhatUserCanDo; objForm.txtMore.Text = strMoreDetails; switch (((int) Buttons)) { case 0: objForm.btn3.Text = "OK"; objForm.btn2.Visible = false; objForm.btn1.Visible = false; objForm.AcceptButton = objForm.btn3; break; case 1: objForm.btn3.Text = "Cancel"; objForm.btn2.Text = "OK"; objForm.btn1.Visible = false; objForm.AcceptButton = objForm.btn2; objForm.CancelButton = objForm.btn3; break; case 2: objForm.btn1.Text = "&Abort"; objForm.btn2.Text = "&Retry"; objForm.btn3.Text = "&Ignore"; objForm.AcceptButton = objForm.btn2; objForm.CancelButton = objForm.btn3; break; case 3: objForm.btn3.Text = "Cancel"; objForm.btn2.Text = "&No"; objForm.btn1.Text = "&Yes"; objForm.CancelButton = objForm.btn3; break; case 4: objForm.btn3.Text = "&No"; objForm.btn2.Text = "&Yes"; objForm.btn1.Visible = false; break; case 5: objForm.btn3.Text = "Cancel"; objForm.btn2.Text = "&Retry"; objForm.btn1.Visible = false; objForm.AcceptButton = objForm.btn2; objForm.CancelButton = objForm.btn3; break; } if (Icon == MessageBoxIcon.Hand) { objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap(); } else if (Icon == MessageBoxIcon.Hand) { objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap(); } else if (Icon == MessageBoxIcon.Exclamation) { objForm.PictureBox1.Image = SystemIcons.Exclamation.ToBitmap(); } else if (Icon == MessageBoxIcon.Asterisk) { objForm.PictureBox1.Image = SystemIcons.Information.ToBitmap(); } else if (Icon == MessageBoxIcon.Question) { objForm.PictureBox1.Image = SystemIcons.Question.ToBitmap(); } else { objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap(); } switch (((int) DefaultButton)) { case 1: objForm.AcceptButton = objForm.btn1; objForm.btn1.TabIndex = 0; break; case 2: objForm.AcceptButton = objForm.btn2; objForm.btn2.TabIndex = 0; break; case 3: objForm.AcceptButton = objForm.btn3; objForm.btn3.TabIndex = 0; break; } return objForm.ShowDialog(); }
public SolutionEvents(TaskFileProcessor taskFileProcessor, ExceptionDialog exceptionDialog, MSBuildKiller msBuildKiller) { this.taskFileProcessor = taskFileProcessor; this.exceptionDialog = exceptionDialog; this.msBuildKiller = msBuildKiller; }
//-- //-- internal method to show error dialog //-- private static DialogResult ShowDialogInternal(string strWhatHappened, string strHowUserAffected, string strWhatUserCanDo, string strMoreDetails, MessageBoxButtons Buttons, MessageBoxIcon Icon, UserErrorDefaultButton DefaultButton) { //-- set default values, etc ProcessStrings(ref strWhatHappened, ref strHowUserAffected, ref strWhatUserCanDo, ref strMoreDetails); ExceptionDialog objForm = new ExceptionDialog(); var _with3 = objForm; _with3.Text = ReplaceStringVals(objForm.Text); _with3.ErrorBox.Text = strWhatHappened; _with3.ScopeBox.Text = strHowUserAffected; _with3.ActionBox.Text = strWhatUserCanDo; _with3.txtMore.Text = strMoreDetails; //-- determine what button text, visibility, and defaults are var _with4 = objForm; switch (Buttons) { case MessageBoxButtons.AbortRetryIgnore: _with4.btn1.Text = "&Abort"; _with4.btn2.Text = "&Retry"; _with4.btn3.Text = "&Ignore"; _with4.AcceptButton = objForm.btn2; _with4.CancelButton = objForm.btn3; break; case MessageBoxButtons.OK: _with4.btn3.Text = "OK"; _with4.btn2.Visible = false; _with4.btn1.Visible = false; _with4.AcceptButton = objForm.btn3; break; case MessageBoxButtons.OKCancel: _with4.btn3.Text = "Cancel"; _with4.btn2.Text = "OK"; _with4.btn1.Visible = false; _with4.AcceptButton = objForm.btn2; _with4.CancelButton = objForm.btn3; break; case MessageBoxButtons.RetryCancel: _with4.btn3.Text = "Cancel"; _with4.btn2.Text = "&Retry"; _with4.btn1.Visible = false; _with4.AcceptButton = objForm.btn2; _with4.CancelButton = objForm.btn3; break; case MessageBoxButtons.YesNo: _with4.btn3.Text = "&No"; _with4.btn2.Text = "&Yes"; _with4.btn1.Visible = false; break; case MessageBoxButtons.YesNoCancel: _with4.btn3.Text = "Cancel"; _with4.btn2.Text = "&No"; _with4.btn1.Text = "&Yes"; _with4.CancelButton = objForm.btn3; break; } ////-- set the proper dialog icon //switch (Icon) { // case MessageBoxIcon.Error: // objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap(); // break; // case MessageBoxIcon.Stop: // objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap(); // break; // case MessageBoxIcon.Exclamation: // objForm.PictureBox1.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap(); // break; // case MessageBoxIcon.Information: // objForm.PictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap(); // break; // case MessageBoxIcon.Question: // objForm.PictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap(); // break; // default: // objForm.PictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap(); // break; //} //'-- set the proper dialog icon MessageBoxIcon PictureBox1 = Icon; if (PictureBox1 == MessageBoxIcon.Hand) { objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap(); } else if (PictureBox1 == MessageBoxIcon.Hand) { objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap(); } else if (PictureBox1 == MessageBoxIcon.Exclamation) { objForm.PictureBox1.Image = SystemIcons.Exclamation.ToBitmap(); } else if (PictureBox1 == MessageBoxIcon.Asterisk) { objForm.PictureBox1.Image = SystemIcons.Information.ToBitmap(); } else if (PictureBox1 == MessageBoxIcon.Question) { objForm.PictureBox1.Image = SystemIcons.Question.ToBitmap(); } else { objForm.PictureBox1.Image = SystemIcons.Error.ToBitmap(); } //-- override the default button switch (DefaultButton) { case UserErrorDefaultButton.Button1: objForm.AcceptButton = objForm.btn1; objForm.btn1.TabIndex = 0; break; case UserErrorDefaultButton.Button2: objForm.AcceptButton = objForm.btn2; objForm.btn2.TabIndex = 0; break; case UserErrorDefaultButton.Button3: objForm.AcceptButton = objForm.btn3; objForm.btn3.TabIndex = 0; break; } if (_blnEmailError) { SendNotificationEmail(strWhatHappened, strHowUserAffected, strWhatUserCanDo, strMoreDetails); } //-- show the user our error dialog return objForm.ShowDialog(); }
/** * Default Exception [FOR NOW] */ public void OnSessionOperationFail(String errorMessage) { ExceptionDialog exception = new ExceptionDialog("Operation Fail", errorMessage); }
static int Main (string [] args) { bool empty = false; Program program = null; ICore control = null; List<string> uris = new List<string> (); Unix.SetProcessName (Defines.PACKAGE); // Options and Option parsing bool shutdown = false; bool view = false; bool slideshow = false; string import_uri = null; program = new Program (Defines.PACKAGE, Defines.VERSION, Modules.UI, args); FSpot.Global.PhotoDirectory = Preferences.Get<string> (Preferences.STORAGE_PATH); for (int i = 0; i < args.Length && !shutdown; i++) { switch (args [i]) { case "-h": case "-?": case "-help": case "--help": case "-usage": Help (); return 0; case "-shutdown": case "--shutdown": Log.Information ("Shutting down existing F-Spot server..."); shutdown = true; break; case "-b": case "-basedir": case "--basedir": if (i+1 == args.Length || args[i+1].StartsWith ("-")) { Log.Error ("f-spot: -basedir option takes one argument"); return 1; } FSpot.Global.BaseDirectory = args [++i]; Log.InformationFormat ("BaseDirectory is now {0}", FSpot.Global.BaseDirectory); break; case "-p": case "-photodir": case "--photodir": if (i+1 == args.Length || args[i+1].StartsWith ("-")) { Log.Error ("f-spot: -photodir option takes one argument"); return 1; } FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath (args [++i]); Log.InformationFormat ("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory); break; case "-i": case "-import": case "--import": if (i+1 == args.Length) { Log.Error ("f-spot: -import option takes one argument"); return 1; } import_uri = args [++i]; break; case "-slideshow": case "--slideshow": slideshow = true; break; case "-v": case "-view": case "--view": if (i+1 == args.Length || args[i+1].StartsWith ("-")) { Log.Error ("f-spot: -view option takes (at least) one argument"); return 1; } view = true; while (!(i+1 == args.Length) && !args[i+1].StartsWith ("-")) uris.Add (args [++i]); // if (!System.IO.Directory.Exists (args[i+1]) && !System.IO.File.Exists (args[i+1])) { // Log.Error ("f-spot: -view argument must be an existing file or directory"); // return 1; // } break; case "-versions": case "--versions": Versions (); return 0; case "-V": case "-version": case "--version": Version (); return 0; case "--debug": Log.Debugging = true; // Debug GdkPixbuf critical warnings GLib.LogFunc logFunc = new GLib.LogFunc (GLib.Log.PrintTraceLogFunction); GLib.Log.SetLogHandler ("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc); // Debug Gtk critical warnings GLib.Log.SetLogHandler ("Gtk", GLib.LogLevelFlags.Critical, logFunc); break; case "--uninstalled": case "--gdb": break; default: if (args [i].StartsWith ("--profile")) break; if (args [i].StartsWith ("--trace")) break; Log.DebugFormat ("Unparsed argument >>{0}<<", args [i]); Help (); return 1; } } // Validate command line options if ( (import_uri != null && (view || shutdown || slideshow)) || (view && (shutdown || slideshow)) || (shutdown && slideshow) ) { Log.Error ("Can't mix -import, -view, -shutdown or -slideshow"); return 1; } if (slideshow == true) { Catalog.Init ("f-spot", Defines.LOCALE_DIR); Core core = new Core (); core.ShowSlides (null); program.Run (); Log.Debug ("done"); return 0; } try { uint timer = Log.InformationTimerStart ("Initializing DBus"); try { NDesk.DBus.BusG.Init(); } catch (Exception e) { throw new ApplicationException ("F-Spot cannot find the Dbus session bus. Make sure dbus is configured properly or start a new session for f-spot using \"dbus-launch f-spot\"", e); } Log.DebugTimerPrint (timer, "DBusInitialization took {0}"); uint ma_timer = Log.InformationTimerStart ("Initializing Mono.Addins"); AddinManager.Initialize (FSpot.Global.BaseDirectory); AddinManager.Registry.Update (null); SetupService setupService = new SetupService (AddinManager.Registry); string maj_version = String.Join (".", Defines.VERSION.Split ('.'), 0, 3); foreach (AddinRepository repo in setupService.Repositories.GetRepositories ()) if (repo.Url.StartsWith ("http://addins.f-spot.org/") && !repo.Url.StartsWith ("http://addins.f-spot.org/" + maj_version)) { Log.InformationFormat ("Unregistering {0}", repo.Url); setupService.Repositories.RemoveRepository (repo.Url); } setupService.Repositories.RegisterRepository (null, "http://addins.f-spot.org/" + maj_version, false); Log.DebugTimerPrint (ma_timer, "Mono.Addins Initialization took {0}"); bool create = true; int retry_count = 0; while (control == null) { try { control = Core.FindInstance (); Log.InformationFormat ("Found active FSpot server: {0}", control); program = null; } catch (System.Exception) { if (!shutdown) Log.Information ("Starting new FSpot server"); } Core core = null; try { if (control == null && create) { create = false; Gnome.Vfs.Vfs.Initialize (); if (File.Exists (Preferences.Get<string> (Preferences.GTK_RC))) { #if GTK_2_12_2 if (!File.Exists (Path.Combine (Global.BaseDirectory, "gtkrc"))) (File.Create (Path.Combine (Global.BaseDirectory, "gtkrc"))).Dispose (); Gtk.Rc.AddDefaultFile (Path.Combine (Global.BaseDirectory, "gtkrc")); Global.DefaultRcFiles = Gtk.Rc.DefaultFiles; #endif Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC)); } Catalog.Init ("f-spot", Defines.LOCALE_DIR); try { Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] { GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 16, (Gtk.IconLookupFlags)0), GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 22, (Gtk.IconLookupFlags)0), GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags)0), GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags)0) }; } catch {} core = new Core (view); core.RegisterServer (); empty = view || Core.Database.Empty; control = core; } } catch (System.Exception e) { System.Console.WriteLine ("XXXXX{1}{0}{1}XXXXX", e, Environment.NewLine); control = null; if (core != null) core.UnregisterServer (); // if there is a problem with the DB, so is no way we can survive if (e is DbException) { throw; } } if (control == null) { Log.Warning ("Can't get a connection to the dbus. Trying again..."); if (++ retry_count > 5) { Log.Error ("Sorry, couldn't start F-Spot"); return 1; } } } UriList list = new UriList (); if (shutdown) { try { control.Shutdown (); } catch (System.Exception) { // trap errors } System.Environment.Exit (0); } if (import_uri != null) { control.Import (import_uri); } if (view) { foreach (string s in uris) list.AddUnknown (s); if (list.Count == 0) { Help (); return 1; } control.View (list.ToString ()); } if (empty && import_uri == null && !view) control.Import (null); if (import_uri != null || !view) { control.Organize (); Gdk.Global.NotifyStartupComplete (); foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) { service.Initialize (); service.Start (); } } #if GSD_2_24 Log.Information ("Hack for gnome-settings-daemon engaged"); int max_age, max_size; if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_AGE, out max_age)) { if (max_age < 0) Log.Debug ("maximum_age check already disabled, good"); else if (max_age == 0) Log.Warning ("maximum_age is 0 (tin-hat mode), not overriding"); else if (max_age < 180) { Log.Debug ("Setting maximum_age to a saner value"); Preferences.Set (Preferences.GSD_THUMBS_MAX_AGE, 180); } } if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_SIZE, out max_size)) { int count = Core.Database.Photos.Count ("photos"); // average thumbs are taking 70K, so this will push the threshold //if f-spot takes more than 70% of the thumbs space int size = count / 10; if (max_size < 0) Log.Debug ("maximum_size check already disabled, good"); else if (max_size == 0) Log.Warning ("maximum_size is 0 (tin-hat mode), not overriding"); else if (max_size < size) { Log.DebugFormat ("Setting maximum_size to a saner value ({0}MB), according to your db size", size); Preferences.Set (Preferences.GSD_THUMBS_MAX_SIZE, size); } } #endif if (program != null) program.Run (); Log.Information ("exiting"); } catch (System.Exception e) { Log.Exception (e); ExceptionDialog dlg = new ExceptionDialog(e); dlg.Run(); dlg.Destroy(); System.Environment.Exit(1); } return 0; }
/// <summary> /// Shows the exception dialog. /// </summary> private void ShowExceptionDialog() { if (this.listErrors.SelectedItems.Count > 0) { TestError testError = listErrors.SelectedItems[0].Tag as TestError; if (testError != null) { ExceptionDialog exceptionDialog = new ExceptionDialog(testError); exceptionDialog.ShowDialog(this); } } }