crashanalysercmd/UI/Graphical/UI/CAGraphicalUIManager.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 using System;
       
    19 using System.IO;
       
    20 using System.Text;
       
    21 using System.Collections.Generic;
       
    22 using System.Data;
       
    23 using System.Windows.Forms;
       
    24 using SymbianUtils.Settings;
       
    25 using SymbianUtilsUi.Dialogs;
       
    26 using CrashAnalyserEngine.Engine;
       
    27 using CrashAnalyserEngine.Plugins;
       
    28 
       
    29 namespace CrashAnalyser.UI
       
    30 {
       
    31     public class CAGraphicalUIManager : ApplicationContext
       
    32 	{
       
    33 		#region Constructors
       
    34         public CAGraphicalUIManager()
       
    35 		{
       
    36             Application.ApplicationExit += new EventHandler( Application_ApplicationExit );
       
    37             
       
    38             // Create engine
       
    39             iEngine = new CAEngine( new string[] {} );
       
    40         }
       
    41 		#endregion
       
    42 
       
    43         #region API
       
    44         public void Run()
       
    45         {
       
    46             // Enable visual styles if supported
       
    47             if ( OSFeature.Feature.IsPresent( OSFeature.Themes ) )
       
    48             {
       
    49                 Application.EnableVisualStyles();
       
    50                 Application.DoEvents();
       
    51             }
       
    52 
       
    53             CAGraphicalUI graphicalUi = new CAGraphicalUI( iEngine );
       
    54 
       
    55             // Run the UI asynchronously
       
    56             base.MainForm = graphicalUi;
       
    57             Application.Run( this );
       
    58         }
       
    59 		#endregion
       
    60 
       
    61         #region Properties
       
    62         #endregion
       
    63 
       
    64         #region Event handlers
       
    65         protected override void OnMainFormClosed( object aSender, EventArgs aArgs )
       
    66         {
       
    67             if ( aSender is CAGraphicalUI )
       
    68             {
       
    69             }
       
    70 
       
    71             base.OnMainFormClosed( aSender, aArgs );
       
    72             Application.Exit();
       
    73         }
       
    74 
       
    75         private void Application_ApplicationExit( object aSender, EventArgs aArgs )
       
    76         {
       
    77             try
       
    78             {
       
    79                 if ( iEngine.Settings != null )
       
    80                 {
       
    81                     iEngine.Settings.Store();
       
    82                 }
       
    83             }
       
    84             catch ( Exception )
       
    85             {
       
    86             }
       
    87         }
       
    88         #endregion
       
    89 
       
    90         #region Internal methods
       
    91         #endregion
       
    92 
       
    93         #region From ApplicationContext
       
    94         protected override void Dispose( bool disposing )
       
    95         {
       
    96             try
       
    97             {
       
    98                 base.Dispose( disposing );
       
    99             }
       
   100             finally
       
   101             {
       
   102                 if ( disposing )
       
   103                 {
       
   104                     iEngine.Dispose();
       
   105                 }
       
   106             }
       
   107         }
       
   108         #endregion
       
   109 
       
   110         #region Data members
       
   111         private readonly CAEngine iEngine;
       
   112         #endregion
       
   113     }
       
   114 }