Esempio n. 1
0
        /// <summary>
        /// Prompt the user to select a report group.
        /// </summary>
        private void SelectReportGroup()
        {
            if (UserLoggedIn())
            {
                ManageReportGroups rptGroup = new ManageReportGroups();
                DialogResult result = rptGroup.ShowDialog();
                if (result == DialogResult.Cancel && UserAccount.CurrentGroup == null)
                {
                    _status = SystemStatus.NoReportGroupSelected;
                    InitaliseUpdatesRunning();
                    RefreshDisplay();
                }
                else if (result == DialogResult.Cancel && UserAccount.CurrentGroup != null)
                {                    _status = SystemStatus.Complete;
                    RefreshDisplay();
                }
                else if (result != DialogResult.Cancel)
                {
                    try
                    {
                        UserAccount.CurrentGroup = rptGroup.SelectedGroup;
                        UserAccount.Settings.FirstRun = false;
                        _status = SystemStatus.Complete;
                        InitaliseUpdatesRunning();
                        if (_updateStatus != null && _updateStatus.Visible)
                        {
                            _updateStatus.Close();
                            _updateStatus = null;
                        }
                        if (_unackOrders != null && _unackOrders.Visible)
                        {
                            _unackOrders.Close();
                            _unackOrders = null;
                        }
                        if (_unackAssets != null && _unackAssets.Visible)
                        {
                            _unackAssets.Close();
                            _unackAssets = null;
                        }
                        RefreshDisplay();
                    }
                    catch (Exception ex)
                    {
                        if (!(ex is EMMAException)) { new EMMAException(ExceptionSeverity.Error,
                            "Error while trying to change report group", ex); }
                        MessageBox.Show("Error while trying to change report group: " + ex.Message,
                            "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                }
            }
        }
Esempio n. 2
0
        void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            bool closeMain = false;
            Cursor = Cursors.WaitCursor;

            try
            {
                EveMarketMonitorApp.Properties.Settings.Default.WindowState = this.WindowState;
                if (WindowState != FormWindowState.Minimized)
                {
                    EveMarketMonitorApp.Properties.Settings.Default.WindowPos = this.Location;
                    EveMarketMonitorApp.Properties.Settings.Default.WindowSize = this.Size;
                }
                EveMarketMonitorApp.Properties.Settings.Default.Save();

                Logout();
                if (_controlPanel == null && _updateStatus == null)
                {
                    closeMain = true;
                }
                if (_controlPanel != null)
                {
                    // Have to put this slightly wierd bit of code here to get the control panel to
                    // close properly and allow the main window to close.
                    _controlPanel.AllowClose = true;
                    _controlPanel.Close();
                    _controlPanel = null;
                    closeMain = true;
                }
                if (_updateStatus != null)
                {
                    _updateStatus.AllowClose = true;
                    _updateStatus.Close();
                    _updateStatus = null;
                    closeMain = true;
                }
                if (_tutorialActive)
                {
                    _tutorialThread.Abort();
                    _tutorialThread.Join();
                }

                string tmpDir = Globals.AppDataDir + "Temp";
                if (Directory.Exists(tmpDir)) { Directory.Delete(tmpDir, true); }
                string updateDir = Globals.AppDataDir + "Update";
                if (Directory.Exists(updateDir)) { Directory.Delete(updateDir, true); }
            }
            finally
            {
                e.Cancel = !closeMain;
            }
        }
Esempio n. 3
0
        private void RefreshDisplay()
        {
            if (this.InvokeRequired)
            {
                UpdateViewCallback callback = new UpdateViewCallback(RefreshDisplay);
                this.Invoke(callback, null);
            }
            else
            {
                switch (_status)
                {
                    case SystemStatus.NoUserLoggedIn:
                        Text = "EMMA - Please login";
                        btnAssets.Enabled = false;
                        btnInvestments.Enabled = false;
                        btnJournal.Enabled = false;
                        btnOrders.Enabled = false;
                        btnReports.Enabled = false;
                        btnTransactions.Enabled = false;
                        btnItemDetail.Enabled = false;
                        btnContracts.Enabled = false;
                        btnRoutePlanner.Enabled = false;
                        btnReprocessor.Enabled = false;
                        if (_updateStatus != null)
                        {
                            _updateStatus.AllowClose = true;
                            _updateStatus.Close();
                            _updateStatus = null;
                        }
                        if (Globals.calculator != null)
                        {
                            Globals.calculator.Close();
                            Globals.calculator = null;
                        }
                        break;
                    case SystemStatus.NoReportGroupSelected:
                        Text = "EMMA - Please select a report group";
                        btnAssets.Enabled = false;
                        btnInvestments.Enabled = false;
                        btnJournal.Enabled = false;
                        btnOrders.Enabled = false;
                        btnReports.Enabled = false;
                        btnTransactions.Enabled = false;
                        btnItemDetail.Enabled = false;
                        btnContracts.Enabled = false;
                        btnRoutePlanner.Enabled = false;
                        btnReprocessor.Enabled = false;
                        if (_updateStatus != null)
                        {
                            _updateStatus.AllowClose = true;
                            _updateStatus.Close();
                            _updateStatus = null;
                        }
                        if (Globals.calculator != null)
                        {
                            Globals.calculator.Close();
                            Globals.calculator = null;
                        }
                        // Set control panel location.
                        Point ctrlPanelLoc = UserAccount.Settings.ControlPanelPos;
                        _controlPanel.Location = ctrlPanelLoc.X == 0 && ctrlPanelLoc.Y == 0 ?
                            _controlPanel.Location : ctrlPanelLoc;

                        break;
                    case SystemStatus.Complete:
                        WasteTime();
                        bool allEnabled = true;
                        Text = "EMMA - " + UserAccount.CurrentGroup.Name;

                        List<long> ids = _updatesRunning[APIDataType.Assets];
                        if (ids.Count == 0) { btnAssets.Enabled = true; }
                        else { btnAssets.Enabled = false; allEnabled = false; }
                        ids = _updatesRunning[APIDataType.Journal];
                        if (ids.Count == 0) { btnJournal.Enabled = true; }
                        else { btnJournal.Enabled = false; allEnabled = false; }
                        ids = _updatesRunning[APIDataType.Orders];
                        if (ids.Count == 0) { btnOrders.Enabled = true; }
                        else { btnOrders.Enabled = false; allEnabled = false; }
                        ids = _updatesRunning[APIDataType.Transactions];
                        if (ids.Count == 0) { btnTransactions.Enabled = true; }
                        else { btnTransactions.Enabled = false; allEnabled = false; }
                        if (allEnabled) { btnReports.Enabled = true; }
                        else { btnReports.Enabled = false; }
                        btnItemDetail.Enabled = btnAssets.Enabled && btnOrders.Enabled && btnTransactions.Enabled;
                        btnContracts.Enabled = btnAssets.Enabled && btnTransactions.Enabled;
                        btnReprocessor.Enabled = btnAssets.Enabled && btnTransactions.Enabled;
                        btnInvestments.Enabled = true;
                        btnRoutePlanner.Enabled = true;

                        if (_updateStatus == null)
                        {
                            _updateStatus = new UpdateStatus();
                            Point userUpdLoc = UserAccount.Settings.UpdatePanelPos;
                            Size userUpdSize = UserAccount.Settings.UpdatePanelSize;
                            if (userUpdLoc.X < 0 || userUpdLoc.X + userUpdSize.Width > this.Width) { userUpdLoc.X = 10; }
                            if (userUpdLoc.Y < 0 || userUpdLoc.Y + userUpdSize.Height > this.Height) { userUpdLoc.Y = 10; }
                            _updateStatus.Location = userUpdLoc.X == 0 && userUpdLoc.Y == 0 ?
                                new Point(10, 10) : userUpdLoc;
                            _updateStatus.Size = userUpdSize.Width == 0 && userUpdSize.Height == 0 ?
                                _updateStatus.Size : userUpdSize;
                            _updateStatus.MdiParent = this;
                            _updateStatus.ResizeEnd += new EventHandler(UpdateStatus_ResizeEnd);
                            _updateStatus.Move += new EventHandler(UpdateStatus_Move);
                            _updateStatus.UpdateEvent += new APIUpdateEvent(UpdateStatus_UpdateEvent);
                            _updateStatus.Show();
                        }
                        if (Globals.calculator == null)
                        {
                            GridCalculator calc = new GridCalculator();
                            calc.MdiParent = this;
                            Globals.calculator = calc;
                        }

                        RefreshUnackOrders(false);
                        break;
                    default:
                        break;
                }

                if (_controlPanel != null) { _controlPanel.Refresh(_status); }
            }
        }