Exemplo n.º 1
0
 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;
             });
         }
     });
 }
Exemplo n.º 2
0
        private void MapViewAddLinkMenuItemClick(object sender, EventArgs e)
        {
            try
            {
                if (_parent.CurrentMap == null)
                {
                    MessageBox.Show(this, Resources.NoCurrentMapError);
                    return;
                }
                if (_parent.CurrentFloorIndex == Constant.NoSelectedFloor)
                {
                    MessageBox.Show(this, Resources.NoSelectedFloorError);
                    return;
                }

                var selectedNode = SelectedNode as MapViewTreeNode;
                if (selectedNode == null)
                {
                    return;
                }
                var wizard = new AddLinkWizard(_parent.CurrentMap)
                {
                    Floor = _parent.CurrentFloorIndex,
                };
                switch (selectedNode.Level)
                {
                case Constant.CatalogueNodeLevel:
                {
                    if (selectedNode.Index != Constant.LinksIndex)
                    {
                        wizard.Type = (NodeType)selectedNode.Index;
                    }
                    break;
                }

                case Constant.ElementNodeLevel:
                {
                    if (selectedNode.Parent.Index != Constant.LinksIndex)
                    {
                        wizard.Type = (NodeType)selectedNode.Parent.Index;
                    }
                    wizard.StartIndex = selectedNode.Index;
                    break;
                }
                }
                if (wizard.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                if (!wizard.Ready)
                {
                    return;
                }
                _parent.AddLink(wizard.Make(), wizard.Floor);
            }
            catch (Exception ex)
            {
                ExceptionDialog.Show(this, ex);
            }
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        private void MapViewAddGuideNodeMenuItemClick(object sender, EventArgs e)
        {
            try
            {
                if (_parent.CurrentMap == null)
                {
                    MessageBox.Show(this, Resources.NoCurrentMapError);
                    return;
                }
                if (_parent.CurrentFloorIndex == Constant.NoSelectedFloor)
                {
                    MessageBox.Show(this, Resources.NoSelectedFloorError);
                    return;
                }

                var wizard = new AddNodeWizard(_parent.CurrentMap)
                {
                    Floor = _parent.CurrentFloorIndex,
                    Type  = NodeType.GuideNode
                };
                if (wizard.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                if (!wizard.Ready)
                {
                    return;
                }
                _parent.AddNode(wizard.Make(), wizard.Floor);
            }
            catch (Exception ex)
            {
                ExceptionDialog.Show(this, ex);
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        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.");
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Shows a SaveFileDialog.
        /// </summary>
        /// <param name="filePath">Input/Output: file name and initial directory.</param>
        /// <param name="filter">File extension filter.</param>
        /// <param name="filterIndex">Default filter index.</param>
        /// <returns>DialogResult.OK if the user selected a file.</returns>
        public static bool GetSaveFileName(ref string filePath, string filter, int filterIndex = 0)
        {
            bool result = false;

            try
            {
                using (SaveFileDialog saveFileDialog = new SaveFileDialog())
                {
                    saveFileDialog.Filter = filter;
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        saveFileDialog.InitialDirectory = Path.GetDirectoryName(filePath);
                        saveFileDialog.FileName         = Path.GetFileNameWithoutExtension(filePath);
                        saveFileDialog.FilterIndex      = filterIndex > 0 ? filterIndex : GetFilterIndex(filter, filePath);
                    }
                    else
                    {
                        saveFileDialog.FilterIndex = filterIndex > 0 ? filterIndex : 1;
                    }
                    saveFileDialog.RestoreDirectory = true;
                    result = saveFileDialog.ShowDialog() == DialogResult.OK;
                    if (result)
                    {
                        filePath = saveFileDialog.FileName;
                    }
                }
            }
            catch (BaseException ex)
            {
                ExceptionDialog.Show(ex);
            }
            return(result);
        }
Exemplo n.º 13
0
        private void _DisplayProfilesForServer(TreeListNode tlnServer, int iType)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                // begin update
                tlcProfile.BeginUpdate();

                // remove all old items
                tlcProfile.Nodes.Clear();

                // toggle Buttons
                tbbApplicationProfile.Pushed = iType == 0;
                tbbDriverProfile.Pushed      = iType == 1;
                tbbMachineType.Pushed        = iType == 2;

                // assign to membervariable
                m_tlnServer = tlnServer;

                // a server is selected ???
                if (tlnServer != null)
                {
                    NodeData nd = tlnServer.Tag as NodeData;

                    if (nd.Type == NodeType.Server)
                    {
                        switch (iType)
                        {
                        case 0:
                            _InsertProfiles(NodeType.AppProfile, nd.Data2, nd.Data1);
                            break;

                        case 1:
                            _InsertProfiles(NodeType.DrvProfile, nd.Data2, nd.Data1);
                            break;

                        case 2:
                            _InsertProfiles(NodeType.MacType, nd.Data2, nd.Data1);
                            break;
                        }

                        // start JobQueueThread
                        _InitializeJobQueueThread();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionDialog.Show(this.ParentForm, ex);
            }
            finally
            {
                // end treeupdate
                tlcProfile.EndUpdate();

                Cursor.Current = Cursors.Default;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// ShowExceptionDialog
        /// Displays a message to the user
        /// </summary>
        /// <param name="message"></param>
        public static void ShowExceptionDialog(MessagePacket message)
        {
            ExceptionDialog exceptionDialog = new ExceptionDialog();

            exceptionDialog.Init(message);
            exceptionDialog.Topmost = true;
            exceptionDialog.Show();
        }
Exemplo n.º 15
0
 private void SliceValueUpButton_Click(object sender, EventArgs e)
 {
     try
     {
         SliceValue++;
     }
     catch (BaseException ex) { ExceptionDialog.Show(ex); }
 }
Exemplo n.º 16
0
 private void ViewAxesButton_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         ViewAxes = viewAxesButton.Checked;
     }
     catch (BaseException ex) { ExceptionDialog.Show(ex); }
 }
Exemplo n.º 17
0
 private void IncreasePerspectiveButton_Click(object sender, EventArgs e)
 {
     try
     {
         IncreasePerspectiveClicked?.Invoke(this, new EventArgs());
     }
     catch (BaseException ex) { ExceptionDialog.Show(ex); }
 }
Exemplo n.º 18
0
 private void ZoomInButton_Click(object sender, EventArgs e)
 {
     try
     {
         ZoomInClicked?.Invoke(this, new EventArgs());
     }
     catch (BaseException ex) { ExceptionDialog.Show(ex); }
 }
Exemplo n.º 19
0
 private void SwapTopBottomButton_Click(object sender, EventArgs e)
 {
     try
     {
         SwapTopBottomClicked?.Invoke(this, new EventArgs());
     }
     catch (BaseException ex) { ExceptionDialog.Show(ex); }
 }
Exemplo n.º 20
0
 private void SliceVButton_Click(object sender, EventArgs e)
 {
     try
     {
         SliceMode = SliceModeEnum.SliceV;
     }
     catch (BaseException ex) { ExceptionDialog.Show(ex); }
 }
Exemplo n.º 21
0
 private void _iocButton_Click(object sender, EventArgs e)
 {
     try {
         OpenForm <IoCTestForm>();
     } catch (Exception error) {
         ExceptionDialog.Show(error);
     }
 }
Exemplo n.º 22
0
 private void ResourceCalendar_DragLeave(object sender, EventArgs e)
 {
     try {
         // ...
     } catch (Exception error) {
         ExceptionDialog.Show(this, error);
     }
 }
Exemplo n.º 23
0
 private void ResourceCalendar_DragOver(object sender, DragEventArgs e)
 {
     try {
         ProcessAppointmentDraggedOver(e);
     } catch (Exception error) {
         ExceptionDialog.Show(this, error);
     }
 }
Exemplo n.º 24
0
 private void pathSelectorControl4_PathChanged(object sender, EventArgs e)
 {
     try {
         DialogEx.Show(this, SystemIconType.None, "Result", pathSelectorControl4.Path, "OK");
     } catch (Exception error) {
         ExceptionDialog.Show(this, error);
     }
 }
Exemplo n.º 25
0
        internal bool FireAppointmentDraggingEvent(int col, int row, AppointmentDragObject dragObject)
        {
            var result = _lastDraggedOver.Item3;

            try {
                if (_lastDraggedOver.Item1 == col && _lastDraggedOver.Item2 == row)
                {
                    return(_lastDraggedOver.Item3);
                }

                var dragOverColumn = ViewModel.GetColumnAt(col);
                if (dragOverColumn == null)
                {
                    return(false);
                }

                var sourceColumn = dragObject.SourceColumn;
                var appointment  = dragObject.Appointment;
                if (appointment == null)
                {
                    throw new ArgumentException("dragObject", "Appointment property is null");
                }

                var draggingOverStartTime = base.HasColHeaders && row == -1 ? appointment.StartTime : ViewModel.RowToStartTime(row);
                var draggingOverEndTime   = draggingOverStartTime.Add(appointment.EndTime.Subtract(appointment.StartTime));
                var dragCompatible        = OnAppointmentDragging(appointment, dragOverColumn.ColumnDataObject, draggingOverStartTime, draggingOverEndTime);
                if (dragCompatible)
                {
                    if (AppointmentDragging != null)
                    {
                        foreach (EventHandlerEx <AppointmentDraggingEvent> handler in AppointmentDragging.GetInvocationList())
                        {
                            var eventArgs = new AppointmentDraggingEvent {
                                Source               = this,
                                SourceColumn         = sourceColumn,
                                DestinationColumn    = dragOverColumn.ColumnDataObject,
                                DestinationStartTime = draggingOverStartTime,
                                DestinationEndTime   = draggingOverEndTime,
                                Appointment          = appointment
                            };
                            handler.Invoke(eventArgs);
                            dragCompatible = eventArgs.IsDestinationCompatible;
                            if (!dragCompatible)
                            {
                                break;
                            }
                        }
                    }
                }
                result = dragCompatible;
            } catch (Exception error) {
                ExceptionDialog.Show(this, error);
                result = false;
            } finally {
                _lastDraggedOver = Tuple.Create(col, row, result);
            }
            return(result);
        }
Exemplo n.º 26
0
        private void ReportCrash(Exception exception, string developerMessage = "")
        {
            Log.Error($"Unhandled application exception({developerMessage})", exception);

            AppDomain.CurrentDomain.UnhandledException      -= CurrentDomainOnUnhandledException;
            TaskScheduler.UnobservedTaskException           -= TaskSchedulerOnUnobservedTaskException;
            Dispatcher.CurrentDispatcher.UnhandledException -= DispatcherOnUnhandledException;

            var appDispatcher = Application.Current?.Dispatcher;

            if (appDispatcher != null && Dispatcher.CurrentDispatcher != appDispatcher)
            {
                Log.Warn("Exception occurred on non-UI thread, rescheduling to UI");
                appDispatcher.BeginInvoke(() => ReportCrash(exception, developerMessage), DispatcherPriority.Send);
                Log.Debug($"Sent signal to UI thread to report crash related to exception {exception.Message}");

                return;
            }

            try
            {
                var reporter = new ExceptionDialog();

                var config = new ExceptionDialogConfig()
                {
                    AppName = AppArguments.Instance.AppName,
                    Title   = $"{AppArguments.Instance.AppName} Error Report"
                };

                var configurationFilesToInclude = Directory
                                                  .EnumerateFiles(AppArguments.Instance.AppDataDirectory, "*.cfg", SearchOption.TopDirectoryOnly);

                var logFilesToInclude = new DirectoryInfo(AppArguments.Instance.AppDataDirectory)
                                        .GetFiles("*.log", SearchOption.AllDirectories)
                                        .OrderByDescending(x => x.LastWriteTime)
                                        .Take(2)
                                        .Select(x => x.FullName)
                                        .ToArray();

                config.FilesToAttach = new[]
                {
                    logFilesToInclude,
                    configurationFilesToInclude
                }.SelectMany(x => x)
                .ToArray();
                reporter.Config = config;

                reporter.Show(exception);

                Log.Warn($"Forcefully terminating Environment due to unrecoverable error");
                Environment.Exit(-1);
            }
            catch (Exception e)
            {
                Log.HandleException(new ApplicationException("Exception in ExceptionReporter :-(", e));
            }
        }
Exemplo n.º 27
0
 public override void ShowExceptionDialog(string title, string message, Exception e, params Exception[] additionalExceptions)
 {
     if (Application.Current != null && !Application.Current.Dispatcher.CheckAccess())
     {
         Application.Current.Dispatcher.Invoke(() => ExceptionDialog.Show(null, title, message, e, additionalExceptions));
         return;
     }
     ExceptionDialog.Show(null, title, message, e, additionalExceptions);
 }
Exemplo n.º 28
0
 public override bool CanDragCell(int col, int row)
 {
     try {
         return(ViewModel.GetAppointmentBlockAt(col, row) != null);
     } catch (Exception error) {
         ExceptionDialog.Show(this, error);
         return(false);
     }
 }
Exemplo n.º 29
0
 private void OpenForm <T>() where T : Form, new()
 {
     try {
         T f = new T();
         f.Show(this);
     } catch (Exception error) {
         ExceptionDialog.Show(this, error);
     }
 }
Exemplo n.º 30
0
        private void _InsertDomains(TreeListNode tlnParent, string identParentDomain)
        {
            ISqlFormatter isql = clsMain.Instance.CurrentConnection.Connection.SqlFormatter;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                // create the collection
                IColDbObject dbcolDomains = clsMain.Instance.CurrentConnection.Connection.CreateCol("SDLDomain");

                // assign the where-clause
                if (String.IsNullOrEmpty(identParentDomain))
                {
                    dbcolDomains.Prototype.WhereClause = isql.Comparison("UID_SDLDomainParent", "", ValType.String);
                }
                else
                {
                    dbcolDomains.Prototype.WhereClause = isql.FkComparison("UID_SDLDomainParent", "UID_SDLDomain", "SDLDomain",
                                                                           isql.Comparison("Ident_Domain", identParentDomain, ValType.String));
                }

                // appand the userdefined filter
                if (clsMain.Instance.DomainFilter.Length > 0)
                {
                    dbcolDomains.Prototype.WhereClause = "(" + dbcolDomains.Prototype.WhereClause + ") and (" + clsMain.Instance.DomainFilter + ")";
                }

                // mark as DisplayColumn
                dbcolDomains.Prototype["Ident_Domain"].IsDisplayItem = true;

                // load the collection
                dbcolDomains.Load();

                //now do for each domain
                foreach (IColElem colElem in dbcolDomains)
                {
                    // create a doamin-node
                    TreeListNode tlnDomain = tlnParent.Nodes.Add(colElem.Display, 1);
                    tlnDomain.Tag = new NodeData(NodeType.Domain, colElem.GetValue("Ident_Domain"), "");

                    // insert static subitems of domain
                    _PrepareDomainNode(tlnDomain);

                    // insert all childdomains
                    _InsertDomains(tlnDomain, colElem.Display);
                }
            }
            catch (Exception ex)
            {
                ExceptionDialog.Show(this.ParentForm, ex);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }