Example #1
0
 /// <summary>
 /// The connect.
 /// </summary>
 /// <param name="connectionString">
 /// The connection string.
 /// </param>
 public static void Connect(string connectionString)
 {
     lock (SyncRoot)
     {
         Disconnect();
         FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Connecting, connectionString));
         Instance = new DatabaseSession(connectionString);
         FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Connected, connectionString));
     }
 }
Example #2
0
        /// <summary>
        /// The disconnect.
        /// </summary>
        public static void Disconnect()
        {
            DatabaseScanner.Cancel();

            lock (SyncRoot)
            {
                if (Instance != null)
                {
                    FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Disconnecting));
                    Instance.Close();
                    Instance = null;
                    FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Disconnected));
                }
            }
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();

            this.Loaded += (s, e) =>
            {
                var menuDockPanel = (DockPanel)this.menuStrip.Template.FindName("MenuStrip", this.menuStrip);
                this.menuStripItems = menuDockPanel.Children.OfType <TextBlock>().ToList();
                foreach (var menuStripItem in this.menuStripItems)
                {
                    menuStripItem.PreviewMouseDown += this.HandleMenuStripPreviewMouseDown;
                }

                this.pages = new Control[] { new ConnectPage(), new ExplorePage(), new AboutPage() };
                this.SelectMenuStripItem(this.menuStripItems[0]);
            };

            this.Closed += (s, e) =>
            {
                try
                {
                    Settings.Default.Save();
                    DatabaseSession.Disconnect();
                }
                catch
                {
                }
            };

            DatabaseSession.ConnectionStateChanged += (s, e) =>
            {
                if (e.ConnectionState == ConnectionState.Connected)
                {
                    this.SelectMenuStripItem(this.menuStripItems[1]);
                }
            };
        }
Example #4
0
        /// <summary>
        /// The disconnect.
        /// </summary>
        public static void Disconnect()
        {
            DatabaseScanner.Cancel();

            lock (SyncRoot)
            {
                if (Instance != null)
                {
                    FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Disconnecting));
                    Instance.Close();
                    Instance = null;
                    FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Disconnected));
                }
            }
        }
Example #5
0
 /// <summary>
 /// The connect.
 /// </summary>
 /// <param name="connectionString">
 /// The connection string.
 /// </param>
 public static void Connect(string connectionString)
 {
     lock (SyncRoot)
     {
         Disconnect();
         FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Connecting, connectionString));
         Instance = new DatabaseSession(connectionString);
         FireConnectionStateChanged(new NotifyConnectionStateChangedEventArgs(ConnectionState.Connected, connectionString));
     }
 }
Example #6
0
 /// <summary>
 /// The dispose.
 /// </summary>
 public void Dispose()
 {
     DatabaseSession.Disconnect();
 }