Exemplo n.º 1
0
 /// <summary>
 /// Update the tracking information if the object supplied is not null
 /// </summary>
 /// <param name="trackedObject"></param>
 private void UpdateTrackingInformation(IUpdaterTracking trackedObject)
 {
     if (trackedObject != null)
     {
         trackedObject.UpdatedAt = DateTime.Now;
         trackedObject.UpdatedBy = WinUtils.GetPrincipal().Identity.Name;
     }
 }
Exemplo n.º 2
0
 void ClickAt(Point point, Action callback = null)
 {
     ActionManager.SendAction(() => { WinUtils.ActivateWindow(Constants.KO_WINDOW); }, 0.01f, () =>
     {
         MouseOperations.Click(point);
         if (callback != null)
         {
             ActionManager.SendAction(() => { }, 0.1f, () => { callback.Invoke(); });
         }
     });
 }
Exemplo n.º 3
0
 private void BasePanel_VisibleChanged(object sender, EventArgs e)
 {
     if (WinUtils.IsComponentInDesignMode(this) || BaseSettings.ScanFormsMode)
     {
         return;
     }
     if (Visible && !m_ReadonlyStateUpdated)
     {
         DisplayReadOnly(false);
     }
 }
Exemplo n.º 4
0
        public static void InitializeBaseSystems()
        {
            Settings.Load();
            PlatformUtils.Initialize();
            DpiScaling.Initialize();
            Theme.Initialize();
            NesApu.Initialize();
#if FAMISTUDIO_WINDOWS
            WinUtils.Initialize();
            PerformanceCounter.Initialize();
#endif
        }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 public BasePanel()
 {
     InitializeComponent();
     if (WinUtils.IsComponentInDesignMode(this))
     {
         return;
     }
     LifeTimeState = LifeTimeState.NotInitialized;
     InitRoutines();
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
 }
Exemplo n.º 6
0
        private void TbRootFolderMouseDoubleClick(object sender, MouseEventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                _tbRootFolder.Text    = fbd.SelectedPath;
                Cursor                = Cursors.WaitCursor;
                _tbRootFolder.Enabled = false;
                fileList              = WinUtils.GetFiles(filters, _tbRootFolder.Text);
                Invoke(new Action(RestoreCursorShowTotalFilesCount));
            }
        }
        private void OnUpdate(object sender, ElapsedEventArgs e)
        {
            if (this.IsDisposed)
            {
                return;
            }

            this.Invoke((MethodInvoker) delegate
            {
                SetPosition();
                lblCurrentWindow.Text = $"Current Window: {WinUtils.GetActiveWindow()}";
            });
        }
Exemplo n.º 8
0
 private void PolygonBufZone_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.Cancel)
     {
         e.Cancel = false;
         return;
     }
     if (string.IsNullOrEmpty(m_ZoneName))
     {
         WinUtils.ShowMandatoryError(labelControl1.Text);
         e.Cancel = true;
     }
 }
Exemplo n.º 9
0
 private void pctrAlreadyConnected_Click(object sender, EventArgs e)
 {
     // Open osu if ctrl is pressed
     if (System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LeftCtrl) || System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.RightCtrl))
     {
         // Get osu dir and check if successful
         string osuDir = Paths.OsuFolder;
         if (osuDir != null)
         {
             WinUtils.StartProcessUnelevated(Path.Combine(osuDir, "osu!.exe"));
         }
     }
 }
Exemplo n.º 10
0
 public BaseGridPanel()
 {
     InitializeComponent();
     if (WinUtils.IsComponentInDesignMode(this))
     {
         return;
     }
     BusinessObject = TypeAccessor.CreateInstanceEx <T>();
     if (Permissions != null)
     {
         m_ReadOnly = Permissions.IsReadOnlyForEdit;
     }
     Init();
 }
Exemplo n.º 11
0
 private void KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.Delete)
     {
         var edit = sender as BaseEdit;
         if (edit != null)
         {
             var cb = edit;
             cb.EditValue = DBNull.Value;
             WinUtils.SetClearTooltip(cb);
             e.Handled = true;
         }
     }
 }
Exemplo n.º 12
0
        public override sealed void OnSuccess(MethodExecutionArgs args)
        {
            // TODO: Determine way of injecting this from AssemblyInfo.cs
            const string RoleName = "MonarchBSConfiguration";

            if (!WinUtils.IsUserInRole(WinUtils.GetPrincipal(), RoleName))
            {
                MessageBox.Show("No authorisation for " + WinUtils.GetPrincipal().Identity.Name + ", not in role " + RoleName, "Authorisation Failed");
                args.FlowBehavior = FlowBehavior.Return;
                args.ReturnValue  = 1;
            }
            else
            {
                args.FlowBehavior = FlowBehavior.Continue;
                args.ReturnValue  = 0;
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// 委托方法的实现
 /// </summary>
 /// <param name="serverMsg"></param>
 public void ShowMsgDelMethodImpl(MessageInfo fromInfo)
 {
     if (fromInfo.msgType == MsgType.私聊)
     {
         if (fromInfo.fromId != SingleUtils.LOGINER.userId && fromInfo.fromNoRead != 1)
         {
             SoundUtils.NewestInfoCome();
         }
         ChatRecordUtils.AppendMsgToClient(this.chatRecords, fromInfo);
     }
     if (fromInfo.msgType == MsgType.系统消息)
     {
         SoundUtils.SystemSound();
         ChatRecordUtils.AppendMsgToClient(this.chatRecords, fromInfo);
     }
     else if (fromInfo.msgType == MsgType.私发红包)
     {
         Thread thread = new Thread((obj) =>
         {
             MessageInfo tmpFromInfo = obj as MessageInfo;
             int money           = Convert.ToInt32(tmpFromInfo.content);
             SingleUtils.redForm = new RedIn();
             SingleUtils.redForm.pictureBox1.Click += (sender, e) =>
             {
                 string str      = string.Format("收到{0}发来的{1}元的红包", GGUserUtils.ShowNickAndId(tmpFromInfo.fromUser), r.Next(1, 10));
                 toInfo.content  = str;
                 toInfo.dateTime = DateTime.Now;
                 ChatRecordUtils.AppendMsgToClient(this.chatRecords, toInfo);
                 SingleUtils.redForm.Close();
                 this.redBtn.Enabled = true;
             };
             SingleUtils.redForm.Text = "金额=" + money;
             Application.Run(SingleUtils.redForm);
         })
         {
             IsBackground = true
         };
         thread.Start(fromInfo);
     }
     else if (fromInfo.msgType == MsgType.私发抖动)
     {
         ChatRecordUtils.AppendMsgToClient(this.chatRecords, fromInfo);
         WinUtils.WindowShake(this);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize( )
        {
            Tuple <Map, Point> tuple = WinUtils.LoadMap("Content/asd.lrmap");

            Map    = tuple.Item1;
            Player = new Player(tuple.Item2);
            Player.SetHero(GraphicsDevice, 1 / 260f);
            Cam = new Camera(new Vector2(0, 0), new Vector2(32f, 32f));
            SimpleUtils.Init(GraphicsDevice);
            // TODO: Renders will be used for more fust drawing of the background... Later
            Renders = new RenderTarget2D[4];
            for (uint i = 0; i < Renders.Length; i++)
            {
                Renders[i] = new RenderTarget2D(GraphicsDevice, Graphics.PreferredBackBufferWidth, Graphics.PreferredBackBufferHeight);
            }

            base.Initialize();
        }
Exemplo n.º 15
0
 /// <summary>
 /// </summary>
 /// <param name="id"></param>
 /// <param name="hAcode"></param>
 public override void LoadData(ref object id, int?hAcode = null)
 {
     if (WinUtils.IsComponentInDesignMode(this))
     {
         return;
     }
     using (DbManagerProxy manager = CreateDbManagerProxy())
     {
         IObjectSelectDetailList accessor = ObjectAccessor.SelectDetailListInterface(typeof(T));
         if (accessor != null)
         {
             LifeTimeState = LifeTimeState.DataLoading;
             SetDataSource(null, new EditableList <T>());
             DataSource.AddRange(accessor.SelectDetailList(manager, id, hAcode));
             Grid.GridControl.DataSource = DataSource;
         }
     }
 }
Exemplo n.º 16
0
 private bool ValidateData()
 {
     //if (!WinUtils.CheckMandatoryField(lbOrganization.Text, txtOrganization.Text))
     //    return false;
     //if (!WinUtils.CheckMandatoryField(lbUserName.Text, txtUserName.Text))
     //    return false;
     if (!WinUtils.CheckMandatoryField(lbPassword.Text, txtPassword.EditValue))
     {
         return(false);
     }
     if (!WinUtils.CheckMandatoryField(lbPassword1.Text, txtNewPassword1.EditValue))
     {
         return(false);
     }
     if (!WinUtils.CheckMandatoryField(lbPassword2.Text, txtNewPassword2.EditValue))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 17
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (m_AskForExit &&
         WinUtils.ConfirmMessage(EidssMessages.Get("msgCloseApp", "Close application?"),
                                 EidssMessages.Get("lbCloseAppCaption", "Close Application")) == false)
     {
         e.Cancel = true;
     }
     if (e.Cancel == false)
     {
         if (!BaseFormManager.CloseAll(true))
         {
             e.Cancel = true;
         }
     }
     if (e.Cancel == false)
     {
         ExitApp(false);
     }
 }
        /// <summary>
        /// Log a support request with the support provider, including the log file
        /// and supplied problem description
        /// </summary>
        /// <param name="supportEmailAddress">The email address to send the support request to</param>
        /// <param name="logfileAppenderName">The name of the log file appender as configured in the log4net configuration for the application</param>
        /// <param name="problemDescription">The user described problem description</param>
        /// <param name="stepsToReproduce">The user described steps to reproduce the issue</param>
        /// <param name="allFiles">Flag indicating if all log files should be extracted</param>
        public void LogSupportRequest(string supportEmailAddress, string logfileAppenderName, string problemDescription, string stepsToReproduce, bool allFiles)
        {
            var emailClient = new EmailClient();

            emailClient.FromAddress = new MailAddress(WinUtils.CurrentUserEmailAddress(), WinUtils.GetCurrentUserNameWithoutDomain());

            var messageBody = string.Format("Problem Description:\n\n{0}\n\n\nSteps to Reproduce:\n\n{1}\n\n", problemDescription, stepsToReproduce);

            MailMessage message = emailClient.CreateMessage("NOES Support Request from " + System.Environment.MachineName, messageBody);

            var files = Log4NetExtensions.GetLogFiles(logfileAppenderName, allFiles);

            // Initialise any progress listeners
            if (InitialiseSupportProgress != null)
            {
                var e = new InitialiseProgressEventArgs()
                {
                    ElementCount = files.Count
                };
                InitialiseSupportProgress(this, e);
            }
            foreach (var logfilePath in files)
            {
                var logfileName = Path.GetFileName(logfilePath);
                using (var stream = new FileStream(logfilePath, FileMode.Open))
                {
                    Attachment logfile = emailClient.CreateGzipAttachment(stream, logfileName + ".gz", EmailClient.ApplicationGzip);
                    message.Attachments.Add(logfile);
                }
                // Update any progress listeners
                if (UpdateSupportProgress != null)
                {
                    UpdateSupportProgress(this, EventArgs.Empty);
                    Application.DoEvents();
                }
            }

            var supportAddress = new MailAddress(supportEmailAddress);

            emailClient.SendEmail(message, supportAddress);
        }
Exemplo n.º 19
0
        private void BtnBrowseSongClick(object sender, EventArgs e)
        {
            string filter = WinUtils.GetMultipleFilter("Audio files", filters);
            OpenFileDialog ofd = new OpenFileDialog { Filter = filter, Multiselect = true };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                _tbSingleFile.Text = null;
                foreach (string file in ofd.FileNames)
                {
                    _tbSingleFile.Text += "\"" + Path.GetFileName(file) + "\" ";
                }

                foreach (string file in ofd.FileNames.Where(file => !fileList.Contains(file)))
                {
                    _btnStart.Enabled = true;
                    fileList.Add(file);
                }

                _nudTotalSongs.Value = fileList.Count;
            }
        }
Exemplo n.º 20
0
        private void BufZonesLayer_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.Cancel)
            {
                e.Cancel = false;
                return;
            }
            if (string.IsNullOrEmpty(m_ZoneLayerName))
            {
                WinUtils.ShowMandatoryError(labelControl1.Text);
                e.Cancel = true;
            }

            var dict = (Dictionary <Guid, string>)UserDbLayersManager.GetLayersNames(UserDbLayerType.BuffZones);

            if (dict.ContainsValue(m_ZoneLayerName))
            {
                ErrorForm.ShowWarningFormat("gisErrBufZoneNameDuplication", "", textName.Text);

                e.Cancel = true;
            }
        }
Exemplo n.º 21
0
        private void BtnBrowseFolderClick(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                Cursor = Cursors.WaitCursor;
                _tbRootFolder.Enabled = false;
                _tbRootFolder.Text = fbd.SelectedPath;
                fileList = WinUtils.GetFiles(filters, _tbRootFolder.Text);

                Invoke(
                    new Action(
                        () =>
                            {
                                Cursor = Cursors.Default;
                                _tbRootFolder.Enabled = true;
                                _nudTotalSongs.Value = fileList.Count;
                                _btnStart.Enabled = true;
                                _tbSingleFile.Text = null;
                            }));
            }
        }
Exemplo n.º 22
0
        public void RegisterActions()
        {
            if (m_MenuManager == null)
            {
                m_MenuManager = MenuActionManager.Instance;
            }
            m_MenuManager.Clear();
            m_MenuManager.LoadAssemblyActions(WinUtils.AppPath() + "\\bvwin_common.dll");
            string[] files = Directory.GetFiles((WinUtils.AppPath()), "eidss*.dll");
            foreach (string file in files)
            {
                m_MenuManager.LoadAssemblyActions(file);
            }
            m_MenuManager.LoadAssemblyActions(WinUtils.AppPath() + "\\eidss.main.exe");

            RegisterDefaultActions();
            m_MenuManager.DisplayActions();
            if (m_TranslationButton != null)
            {
                m_TranslationButton.RefreshPopupMenu();
            }
        }
Exemplo n.º 23
0
        private void OnInitTimer(object sender, ElapsedEventArgs e)
        {
            ActionManager.Start();
            KeyUtils.Start();
            Inventory.Clear();
            MouseOperations.Start();
            _initTimer.Stop();
            _updateTimer.Elapsed -= OnUpdate;
            _updateTimer.Stop();
            ActionManager.SendAction(() =>
            {
                WinUtils.ActivateWindow(Constants.KO_WINDOW);
            }, 0.3f, () =>
            {
                int attempts = 0;
                SkillBar.Reset();
                while (!SkillBar.IsInitialized && attempts++ < MAX_ATTEMPT_INITIALIZE_SKILLBAR)
                {
                    SkillBar.InitSkillsInfo();
                }

                if (SkillBar.IsInitialized)
                {
                    _gos.ForEach(g => { g.Active = true; });

                    Started?.Invoke();
                    _sendStart = false;
                    _updateTimer.Restart();
                    _updateTimer.Elapsed += OnUpdate;
                }
                else
                {
                    Stop();
                    throw new Exception("Failed to initialize SkillBarManager, aborting.");
                }
            });
        }
        private void BtnStartClick(object sender, EventArgs e)
        {
            DefaultFingerprintConfiguration configuration = new DefaultFingerprintConfiguration();

            switch (hashAlgorithm)
            {
            case HashAlgorithm.LSH:
                if (!fileList.Any())
                {
                    MessageBox.Show(Resources.SelectFolderWithSongs, Resources.Songs, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                }

                WinQueryResults winQueryResults = new WinQueryResults(
                    _numSecondsToAnalyze.Enabled ? (int)_numSecondsToAnalyze.Value : 0,
                    _numStartAtSecond.Enabled ? (int)_numStartAtSecond.Value : 0,
                    (int)_nudHashtables.Value,
                    (int)_nudKeys.Value,
                    Convert.ToInt32(_nudThreshold.Value),
                    WinUtils.GetStride((StrideType)_cmbStrideType.SelectedIndex, (int)_nudQueryStrideMax.Value, (int)_nudQueryStrideMin.Value, configuration.SamplesPerFingerprint),
                    tagService,
                    modelService,
                    audioService,
                    queryCommandBuilder);
                winQueryResults.Show();
                winQueryResults.Refresh();
                winQueryResults.ExtractCandidatesWithMinHashAlgorithm(fileList);
                break;

            case HashAlgorithm.NeuralHasher:
                throw new NotImplementedException();

            case HashAlgorithm.None:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 25
0
        public BaseListPanel()
        {
            InitializeComponent();
            if (WinUtils.IsComponentInDesignMode(this))
            {
                return;
            }
            DataSource = new List <T>();
            Grid.GridView.OptionsMenu.EnableColumnMenu      = true;
            Grid.GridView.OptionsMenu.EnableGroupPanelMenu  = false;
            Grid.GridView.OptionsMenu.EnableFooterMenu      = false;
            Grid.GridView.OptionsMenu.ShowAutoFilterRowItem = false;
            var bvGridControl = Grid.GridControl as BvGridControl;

            if (bvGridControl != null)
            {
                bvGridControl.AllowCustomization = true;
            }
            ParentChanged += BaseListPanel_ParentChanged;
            //LoadGridLayout();
            //Grid.GridView.PopupMenuShowing += OnGridViewPopupMenuShowing;
            //Grid.GridView.ShowCustomizationForm += OnShowCustomizationForm;
            //Grid.GridView.DragObjectOver += OnDragObjectOver;
        }
Exemplo n.º 26
0
 public static bool ConfirmCancel(IObject bo, Form owner)
 {
     return(!((bo != null) && (bo.IsNew || bo.HasChanges) && !WinUtils.ConfirmCancel(owner)));
 }
Exemplo n.º 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="action"></param>
        /// <param name="externalParams"> </param>
        internal virtual void RunAction(ActionMetaItem action, List <object> externalParams)
        {
            WaitDialogType waitType;

            switch (action.ActionType)
            {
            //case ActionTypes.Create:
            //case ActionTypes.Edit:
            //case ActionTypes.View:
            //    waitType = WaitDialogType.FormLoading;
            //    break;
            default:
                waitType = WaitDialogType.None;
                break;
            }
            if (!m_ActionLocker.Lock(waitType))
            {
                return;
            }

            try
            {
                var needCancel = false;
                if (OnBeforeActionExecuting != null)
                {
                    /*
                     * IObject bo;
                     * if (BaseGridPanel != null && BaseGridPanel.FocusedItem != null)
                     *  bo = BaseGridPanel.FocusedItem;
                     * else
                     *  bo = BusinessObject;
                     */
                    OnBeforeActionExecuting(ParentLayout != null ? ParentLayout.ParentBasePanel : null
                                            , action
                                            , BusinessObject
                                            , ref needCancel);
                }
                if (needCancel)
                {
                    return;
                }

                //определим набор параметров, которые могут быть переданы от родительской панели
                //сначала получаем указатель на панель, которую обслуживает эта панель
                var parentBasePanel = ParentLayout != null ? ParentLayout.ParentBasePanel.ParentBasePanel : null;
                var parameters      = externalParams;
                if (parentBasePanel != null && externalParams == null)
                {
                    parameters = parentBasePanel.GetParamsAction(BusinessObject);
                }

                #region Выполнение действий

                var currentBo = BusinessObject;

                switch (action.ActionType)
                {
                case ActionTypes.Action:
                    // For Grid panels only we should pass Key of Selected Item  as parameter
                    using (var manager = CreateDbManagerProxy())
                    {
                        bool bSuccess;
                        if (externalParams != null)
                        {
                            bSuccess = action.RunAction(manager, BusinessObject, externalParams).result;
                        }
                        else if ((BaseGridPanel != null))
                        {
                            BaseGridPanel.RefreshFocusedItem();
                            currentBo = BaseGridPanel.FocusedItem;

                            var prs = CreatePanelGridParameters(BaseGridPanel);
                            prs.AddRange(action.Parameters);
                            bSuccess = action.RunAction(manager, currentBo, prs).result;
                        }
                        else
                        {
                            bSuccess = action.RunAction(manager, BusinessObject).result;
                        }
                        if (bSuccess)
                        {
                            if (action.IsNeedClose)
                            {
                                ActionCloseForm(action.Name == "OK" ? DialogResult.OK : DialogResult.Cancel);
                            }
                            if (!String.IsNullOrEmpty(action.RelatedLists))
                            {
                                var names = action.RelatedLists.Split(',');
                                foreach (var name in names)
                                {
                                    BaseFormManager.RefreshList(name);
                                }
                            }
                        }
                    }
                    break;

                case ActionTypes.Create:
                    if (BaseGridPanel != null)
                    {
                        BaseGridPanel.Edit(null, parameters, action.ActionType, false);
                        currentBo = BaseGridPanel.FocusedItem;
                    }
                    else if ((ParentLayout != null) && (ParentLayout.ParentBasePanel != null))
                    {
                        //TODO необходимо проверить этот код
                        var saveAction =
                            m_AllActions.SingleOrDefault(c => c.ActionType == ActionTypes.Save) ??
                            m_AllActions.SingleOrDefault(c => c.ActionType == ActionTypes.Ok);
                        if (saveAction != null)
                        {
                            if (ActionSave(saveAction, true))
                            {
                                using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                                {
                                    var bo = action.RunAction(manager, null as IObject, parameters).obj;
                                    if (bo != null)
                                    {
                                        currentBo = bo;
                                        ParentLayout.ParentBasePanel.BusinessObject = bo;
                                        ParentLayout.BusinessObject = bo;
                                        BusinessObject = bo;
                                    }
                                }
                            }
                        }
                    }
                    break;

                case ActionTypes.Ok:
                    //проверить наличие изменений + сохранить + закрыть форму
                    var success = true;
                    if (!BusinessObject.ReadOnly)
                    {
                        success = ActionSave(action, false);
                    }
                    if (success)
                    {
                        ActionCloseForm(DialogResult.OK);
                    }
                    break;

                case ActionTypes.Cancel:
                    //проверить наличие изменений + не сохранять + закрыть форму
                    if (ActionCanCancel())
                    {
                        ActionCloseForm();
                    }
                    break;

                case ActionTypes.Close:
                    //закрыть форму
                    var successClose = true;
                    if (BusinessObject != null)
                    {
                        using (var manager = CreateDbManagerProxy())
                        {
                            successClose = action.RunAction(manager, BusinessObject).result;
                        }
                    }
                    if (successClose)
                    {
                        ActionCloseForm();
                    }
                    break;

                case ActionTypes.Delete:
                    //применяется только для списочных форм
                    //проверить наличие активного элемента + сохранить + обновление
                    if ((BaseGridPanel != null) &&
                        (BaseGridPanel.FocusedItem != null) &&
                        (ParentLayout != null))
                    {
                        #region Для списочных форм

                        /*if (BaseGridPanel.FocusedItem.HasChanges && !BaseGridPanel.FocusedItem.IsNew)
                         * {
                         *  ErrorForm.ShowWarning("msgCantDelete", "Can't delete object");
                         * }
                         * else*/
                        if (WinUtils.ConfirmDelete())
                        {
                            BaseGridPanel.RefreshFocusedItem();
                            var itemsToDelete = BaseGridPanel.SelectedItems.Count > 0
                                                        ? BaseGridPanel.SelectedItems
                                                        : new List <IObject> {
                                BaseGridPanel.FocusedItem
                            };
                            currentBo = BaseGridPanel.FocusedItem;
                            try
                            {
                                var appForm = (parentBasePanel ?? ParentLayout.ParentBasePanel) as IApplicationForm;
                                if (
                                    BaseFormManager.FindFormByID(appForm, currentBo.Key) != null)
                                {
                                    ErrorForm.ShowWarning("msgCantDelete", "Can't delete object");
                                    break;
                                }

                                using (var manager = CreateDbManagerProxy())
                                {
                                    foreach (var item in itemsToDelete)
                                    {
                                        item.Validation += GridPanelItem_DeleteValidation;
                                        if (action.RunAction(manager, item).result)
                                        {
                                            if (!(BaseGridPanel is IChildListPanel))
                                            {
                                                BaseFormManager.RefreshList(BusinessObject.GetType().Name);
                                                //BaseGridPanel.Delete(item.Key);
                                            }
                                            else
                                            {
                                                BaseGridPanel.Grid.GridView.BeginDataUpdate();
                                                var filter =
                                                    BaseGridPanel.Grid.GridView.ActiveFilter.NonColumnFilter;
                                                BaseGridPanel.Grid.GridView.ActiveFilter.NonColumnFilter =
                                                    String.Empty;
                                                BaseGridPanel.Grid.GridView.ActiveFilter.NonColumnFilter = filter;
                                                BaseGridPanel.Grid.GridView.EndDataUpdate();
                                            }
                                            if (!string.IsNullOrEmpty(action.RelatedLists))
                                            {
                                                var names = action.RelatedLists.Split(',');
                                                foreach (var name in names)
                                                {
                                                    if (name != BusinessObject.GetType().Name)
                                                    {
                                                        BaseFormManager.RefreshList(name);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            finally
                            {
                                foreach (var item in itemsToDelete)
                                {
                                    item.Validation -= GridPanelItem_DeleteValidation;
                                }
                            }
                        }

                        #endregion
                    }
                    else if
                    (
                        (ParentLayout is LayoutSimple) &&
                        (BusinessObject != null)
                    )
                    {
                        if (!BusinessObject.IsNew && BusinessObject.HasChanges)
                        {
                            ErrorForm.ShowWarning("msgCantDelete", "Can't delete object");
                        }
                        else if (WinUtils.ConfirmDelete())
                        {
                            currentBo = BusinessObject;
                            //if (
                            //    BaseFormManager.FindFormByID(ParentLayout.ParentBasePanel as IApplicationForm,
                            //                                 currentBo.Key) != null)
                            //{
                            //    ErrorForm.ShowWarning("msgCantDelete", "Can't delete object");
                            //    break;
                            //}

                            using (var manager = CreateDbManagerProxy())
                            {
                                if (action.RunAction(manager, BusinessObject).result)
                                {
                                    ActionCloseForm();
                                }
                            }
                        }
                    }

                    break;

                case ActionTypes.Refresh:

                    //применяется только для списочных форм
                    //получить данные из БД
                    if (BaseGridPanel != null)
                    {
                        BaseGridPanel.Refresh();
                    }
                    break;

                case ActionTypes.View:
                case ActionTypes.Edit:

                    //применяется только для списочных форм
                    //проверить наличие активного элемента + открыть форму редактирования (сохранения внутри неё) + обновить
                    if (BaseGridPanel != null)
                    {
                        var readOnly    = action.ActionType == ActionTypes.View || action.IsReadOnly(BusinessObject, Permissions);
                        var focusedItem = BaseGridPanel.FocusedItem;
                        if (BaseGridPanel.EnableMultiEdit && BaseGridPanel.SelectedItems.Count > 1)
                        {
                            var keys = BaseGridPanel.SelectedItems.Select(bo => bo.Key).ToList();
                            BaseGridPanel.Edit(keys, CreatePanelGridParameters(BaseGridPanel), action.ActionType, readOnly);
                        }
                        else if ((focusedItem != null) && (focusedItem.Key != null))
                        {
                            currentBo = focusedItem;
                            BaseGridPanel.Edit(focusedItem.Key, CreatePanelGridParameters(BaseGridPanel), action.ActionType, readOnly);
                        }
                    }
                    break;

                case ActionTypes.Save:
                    //проверить наличие изменений + сохранить
                    ActionSave(action, true);
                    break;

                case ActionTypes.Report:

                    if ((ParentLayout != null) && (ParentLayout.ParentBasePanel != null))
                    {
                        ParentLayout.ParentBasePanel.ShowReport();
                    }
                    break;

                case ActionTypes.Select:
                    if ((BaseGridPanel != null) && (BaseGridPanel.FocusedItem != null))
                    {
                        ActionCloseForm(DialogResult.OK);
                    }
                    break;

                case ActionTypes.SelectAll:
                    if (BaseGridPanel != null)
                    {
                        BaseGridPanel.SelectAll();
                        if (BaseGridPanel.SelectedItems != null && BaseGridPanel.SelectedItems.Count > 0)
                        {
                            ActionCloseForm(DialogResult.OK);
                        }
                    }
                    break;
                }

                #endregion

                if (OnLastExecutedActionChanged != null)
                {
                    OnLastExecutedActionChanged(action);
                }

                RaiseAfterActionExecuted(action, currentBo);
            }
            catch (PermissionException exc)
            {
                ErrorForm.ShowWarning("msgNoExecutePermission");
                Dbg.Debug("Permission exception for {0}.{1}, exeption:{2}", exc.ObjectName, exc.ActionName, exc);
            }
            catch (ParamsCountException exc)
            {
                ErrorForm.ShowError(StandardError.ParamsCountError, exc);
            }
            catch (DbModelTimeoutException)
            {
                ErrorForm.ShowWarning("msgTimeoutList", "Cannot retrieve records from database because of the timeout. Please change search criteria and try again");
            }
            catch (DbModelRaiserrorException ex2)
            {
                if (string.IsNullOrEmpty(ex2.MessageId))
                {
                    ErrorForm.ShowError(ex2.Message, ex2);
                }
                else
                {
                    var args = ex2.MessageId.Split(new[] { ' ' });
                    if (args.Count() > 1)
                    {
                        var pars = new object[args.Count() - 1];
                        for (int i = 1; i < args.Count(); i++)
                        {
                            pars[i - 1] = args[i];
                        }
                        ErrorForm.ShowError(args[0], args[0], pars);
                    }
                    else
                    {
                        ErrorForm.ShowError(ex2.MessageId, ex2.Message, ex2);
                    }
                }
            }
            catch (DbModelException ex1)
            {
                if (string.IsNullOrEmpty(ex1.MessageId))
                {
                    ErrorForm.ShowError(ex1.Message, ex1);
                }
                else
                {
                    ErrorForm.ShowError(ex1.MessageId, ex1.Message, ex1);
                }
            }
            catch (BvModelException exc)
            {
                ErrorForm.ShowError(StandardError.UnprocessedError, exc.InnerException ?? exc);
            }
            catch (Exception exc)
            {
                ErrorForm.ShowError(StandardError.UnprocessedError, exc);
            }
            finally
            {
                m_ActionLocker.Unlock();
            }
        }
Exemplo n.º 28
0
        public void ResetLanguage(string langID)
        {
            if (Localizer.SupportedLanguages.ContainsKey(langID) == false)
            {
                langID = Localizer.lngEn;
            }
            if (m_LangageInitialized && ModelUserContext.CurrentLanguage == langID)
            {
                return;
            }
            if (!BaseFormManager.CloseNonListForms(true))
            {
                return;
            }
            //if (BaseForm.SaveAllOpenedForms == false)
            //{
            //    return;
            //}
            Cursor = Cursors.WaitCursor;
            try
            {
                Enabled = false;
                //BaseForm.SetEnabled(false);
                SuspendLayout();
                ModelUserContext.CurrentLanguage = langID;
                //Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName
                if (LookupCache.Language != langID)
                {
                    LookupCache.Reload();
                }

                langID = CustomCultureHelper.GetCustomCultureName(langID);
                var cultureInfo = new CultureInfo(langID);
                EidssSiteContext.Instance.UpdateDateTimeFormat(cultureInfo);

                //EidssSiteContext.Instance.Clear();
                if (m_LangageInitialized)
                {
                    EidssEventLog.Instance.CreateEvent(EventType.ClientUILanguageChanged, null, null);
                }
                m_LangageInitialized = true;

                Thread.CurrentThread.CurrentUICulture = cultureInfo;
                Thread.CurrentThread.CurrentCulture   = cultureInfo;
                WinClientContext.InitFont();
                CommonResourcesCache.Reset();
                ToolTipController.InitTooltipController();
                DefaultBarAndDockingController1.InitBarAppearance();
                tbToolbar.Appearance.InitAppearance();
                tbMenu.Appearance.InitAppearance();
                tbStatusbar.Appearance.InitAppearance();
                Appearance.InitAppearance();
                WinClientContext.ApplicationCaption = EidssMessages.Get("EIDSS_Caption",
                                                                        "Electronic Integrated Disease Surveillance System");
                Text = GetCaption(WinClientContext.ApplicationCaption);

                barManager1.RightToLeft = (Localizer.IsRtl) ? DefaultBoolean.True : DefaultBoolean.False;
                RightToLeft             = (Localizer.IsRtl) ? RightToLeft.Yes : RightToLeft.No;
                RightToLeftLayout       = Localizer.IsRtl;

                sbiUser.Caption         = EidssUserContext.User.FullName;
                sbiOrganization.Caption = EidssSiteContext.Instance.OrganizationName;
                sbiSite.Caption         = (EidssSiteContext.Instance.SiteType + @"-" + EidssSiteContext.Instance.SiteCode);
                sbiCountry.Caption      = EidssSiteContext.Instance.CountryName;
                var resources = new ResourceManager(typeof(MainForm));
                sbiCountryLabel.Caption          = resources.GetString("sbiCountryLabel.Caption");
                sbiCountryLabel.Description      = resources.GetString("sbiCountryLabel.Description");
                sbiCountryLabel.Hint             = resources.GetString("sbiCountryLabel.Hint");
                sbiSiteLable.Caption             = resources.GetString("sbiSiteLable.Caption");
                sbiSiteLable.Description         = resources.GetString("sbiSiteLable.Description");
                sbiSiteLable.Hint                = resources.GetString("sbiSiteLable.Hint");
                sbiOrganizationLable.Caption     = resources.GetString("sbiOrganizationLable.Caption");
                sbiOrganizationLable.Description = resources.GetString("sbiOrganizationLable.Description");
                sbiOrganizationLable.Hint        = resources.GetString("sbiOrganizationLable.Hint");
                sbiUserLabel.Caption             = resources.GetString("sbiUserLabel.Caption");
                sbiUserLabel.Description         = resources.GetString("sbiUserLabel.Description");
                sbiUserLabel.Hint                = resources.GetString("sbiUserLabel.Hint");

                DesignControlManager.Create(this);
                RegisterActions();
                BaseFormManager.ResetLanguage();
                EidssSiteContext.ReportFactory.ResetLanguage();
                WinUtils.SwitchInputLanguage();
                BasicSyndromicSurveillanceListItem.Init();
            }
            catch (Exception ex)
            {
                Dbg.Debug(ex.ToString());
            }
            finally
            {
                if (m_LanguageMenu.ToolbarItem != null && m_LanguageMenu.MenuItem != null)
                {
                    if (IsLangMenuWithoutFlags)
                    {
                        m_LanguageMenu.ToolbarItem.Caption = Localizer.GetMenuLanguageName(ModelUserContext.CurrentLanguage);
                    }
                    else
                    {
                        if (ModelUserContext.CurrentLanguage == Localizer.lngEn)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.English;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.English;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngRu)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Russian;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Russian;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngAzLat)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Azery;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Azery;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngGe)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Georgian;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Georgian;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngKz)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Kazakhstan;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Kazakhstan;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngAr)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Armenian;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Armenian;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngUk)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Ukrainian;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Ukrainian;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngIraq)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Iraq;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Iraq;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngLaos)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = -1;
                            m_LanguageMenu.MenuItem.ImageIndex         = -1;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngVietnam)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = -1;
                            m_LanguageMenu.MenuItem.ImageIndex         = -1;
                        }
                        else if (ModelUserContext.CurrentLanguage == Localizer.lngThai)
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.Thailand;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.Thailand;
                        }
                        else
                        {
                            m_LanguageMenu.ToolbarItem.LargeImageIndex = (int)MenuIcons.English;
                            m_LanguageMenu.MenuItem.ImageIndex         = (int)MenuIconsSmall.English;
                        }
                    }
                    m_LanguageMenu.ToolbarItem.Hint = Localizer.GetLanguageName(ModelUserContext.CurrentLanguage);
                }
                Enabled = true;
                //BaseForm.SetEnabled(true);
                Cursor = Cursors.Default;
                ResumeLayout();
                BringToFront();
                Activate();
            }
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState( ).IsKeyDown(Keys.Escape))
            {
                Exit( );
            }

            MouseState    MouseState    = Mouse.GetState( );
            KeyboardState KeyboardState = Keyboard.GetState( );

            MousePreviousPosition = MousePosition;
            MousePosition         = MouseState.Position;
            if (MouseState.RightButton == ButtonState.Pressed)
            {
                Cam.Position = Cam.Position + (MousePreviousPosition - MousePosition).Vector2( ) / Cam.Scale;
            }

            Vector2 MouseWorldPosition = MousePosition.Vector2( ) / Cam.Scale + Cam.Position;

            SelectedMap   = MouseWorldPosition.FloorToPoint( ) / MAP_SIZE;
            SelectedPoint = MouseWorldPosition.FloorToPoint( ).Mod(MAP_SIZE);
            if (MouseWorldPosition.X < 0)
            {
                SelectedMap.X  -= 1;
                SelectedPoint.X = MAP_SIZE.X + SelectedPoint.X;
            }
            if (MouseWorldPosition.Y < 0)
            {
                SelectedMap.Y  -= 1;
                SelectedPoint.Y = MAP_SIZE.Y + SelectedPoint.Y;
            }

            if (KeyboardState.IsKeyDown(Keys.D1))
            {
                CurrentValue = Map.WALL;
            }
            else if (KeyboardState.IsKeyDown(Keys.D2))
            {
                CurrentValue = Map.LEFT_SHELF;
            }
            else if (KeyboardState.IsKeyDown(Keys.D3))
            {
                CurrentValue = Map.RIGHT_SHELF;
            }
            else if (KeyboardState.IsKeyDown(Keys.Tab))
            {
                CurrentValue = Map.EMPTY;
            }

            if (MouseState.LeftButton == ButtonState.Pressed)
            {
                { // TODO: Refactor and optimize this code-block later
                    while (SelectedMap.X < 0)
                    {
                        Map[][] newMaps = SimpleUtils.Create2DArray <Map>((uint)Maps.Length + 1, (uint)Maps[0].Length, null);
                        for (uint i = 0; i < Maps.Length; i++)
                        {
                            for (uint j = 0; j < Maps[0].Length; j++)
                            {
                                newMaps[i + 1][j] = Maps[i][j];
                            }
                        }
                        for (uint y = 0; y < newMaps[0].Length; y++)
                        {
                            newMaps[0][y] = new Map(MAP_SIZE);
                        }
                        Maps              = newMaps;
                        Cam.Position     += new Vector2(MAP_SIZE.X, 0f);
                        SelectedMap.X    += 1;
                        PlayerPosition.X += MAP_SIZE.X;
                    }
                    while (SelectedMap.Y < 0)
                    {
                        Map[][] newMaps = SimpleUtils.Create2DArray <Map>((uint)Maps.Length, (uint)Maps[0].Length + 1, null);
                        for (uint i = 0; i < Maps.Length; i++)
                        {
                            for (uint j = 0; j < Maps[0].Length; j++)
                            {
                                newMaps[i][j + 1] = Maps[i][j];
                            }
                        }
                        for (uint x = 0; x < newMaps.Length; x++)
                        {
                            newMaps[x][0] = new Map(MAP_SIZE);
                        }
                        Maps              = newMaps;
                        Cam.Position     += new Vector2(0f, MAP_SIZE.Y);
                        SelectedMap.Y    += 1;
                        PlayerPosition.Y += MAP_SIZE.X;
                    }
                    while (SelectedMap.X >= Maps.Length)
                    {
                        Map[][] newMaps = SimpleUtils.Create2DArray <Map>((uint)Maps.Length + 1, (uint)Maps[0].Length, null);
                        for (uint i = 0; i < Maps.Length; i++)
                        {
                            for (uint j = 0; j < Maps[0].Length; j++)
                            {
                                newMaps[i][j] = Maps[i][j];
                            }
                        }
                        for (uint y = 0; y < newMaps[0].Length; y++)
                        {
                            newMaps[Maps.Length][y] = new Map(MAP_SIZE);
                        }
                        Maps = newMaps;
                    }
                    while (SelectedMap.Y >= Maps[0].Length)
                    {
                        Map[][] newMaps = SimpleUtils.Create2DArray <Map>((uint)Maps.Length, (uint)Maps[0].Length + 1, null);
                        for (uint i = 0; i < Maps.Length; i++)
                        {
                            for (uint j = 0; j < Maps[0].Length; j++)
                            {
                                newMaps[i][j] = Maps[i][j];
                            }
                        }
                        for (uint x = 0; x < newMaps.Length; x++)
                        {
                            newMaps[x][Maps[0].Length] = new Map(MAP_SIZE);
                        }
                        Maps = newMaps;
                    }
                }
                Point pos = SelectedMap * MAP_SIZE + SelectedPoint;
                if (!pos.Equals(PlayerPosition) &&
                    !pos.Equals(PlayerPosition + new Point(0, 1)))
                {
                    Maps[SelectedMap.X][SelectedMap.Y][(uint)SelectedPoint.X, (uint)SelectedPoint.Y] = CurrentValue;
                }
            }

            if (KeyboardState.IsKeyDown(Keys.S) && !PreviousKeyboardState.IsKeyDown(Keys.S))
            {
                Map mapToSave = Map.ConvertToBig(Maps);
                WinUtils.Save(mapToSave, PlayerPosition);
            }

            if (KeyboardState.IsKeyDown(Keys.O) && !PreviousKeyboardState.IsKeyDown(Keys.O))
            {
                Tuple <Map, Point> mapToLoad = WinUtils.LoadMap( );
                Maps           = Map.ConvertFromBig(mapToLoad.Item1, MAP_SIZE);
                PlayerPosition = mapToLoad.Item2;
                Cam.Position   = PlayerPosition.ToVector2( ) - new Vector2(
                    Graphics.PreferredBackBufferWidth / Cam.Scale.X / 2,
                    Graphics.PreferredBackBufferHeight / Cam.Scale.Y / 2);
            }

            PreviousKeyboardState = KeyboardState;

            base.Update(gameTime);
        }
Exemplo n.º 30
0
        private void BtnConnect_Click(object sender, EventArgs e)
        {
            // Change the shown button to the "connecting" one
            btnConnect.Visible     = false;
            pctrConnecting.Visible = true;
            Application.DoEvents();

            // Check if the user is holding ctrl to quick start osu
            bool pressingCtrl = System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.LeftCtrl) || System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.RightCtrl);

            // Save the osu executable path for the reopen feature later
            string osuExecutablePath = "";

            // Only close osu if the feature is enabled
            if (m_settings["closeOsuBeforeSwitching"] == "true")
            {
                // Find the osu process and, if found, save the executable path and kill it
                Process osu = Process.GetProcessesByName("osu!").FirstOrDefault();
                if (osu != null)
                {
                    osuExecutablePath = osu.MainModule.FileName;
                    osu.Kill();
                    // Wait till osu is completely closed
                    osu.WaitForExit();
                }
            }

            // Try to switch the server to the currently selected one
            // if failed the method handles outputting the error
            if (Switcher.SwitchServer(m_currentSelectedServer))
            {
                // Check if the server is available (server that has been switched to is reachable)
                if (!Switcher.CheckServerAvailability())
                {
                    // If not, show a warning
                    MessageBox.Show("The connection test failed. Please restart the switcher and try again.\r\n\r\nIf it's still not working the server either didn't update their mirror yet or their server is currently not running (for example due to maintenance).\nIn this case, please visit our Discord server.", "Ultimate Osu Server Switcher", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                // Start osu if the reopen feature is enabled and an osu instance was found before switching
                // osuExecutablePath can only be != "" if close before switching feature is enabled
                // so a check for the closeOsuBeforeSwitching setting is not necessary
                if (m_settings["reopenOsuAfterSwitching"] == "true" && osuExecutablePath != "")
                {
                    WinUtils.StartProcessUnelevated(osuExecutablePath);
                }
                else if (pressingCtrl) // Start osu if ctrl was pressed when clicking on connect and it has not started already ue to the reopen feature
                {
                    // If we dont have the exe path yet because osu was not killed before get it from the registry
                    if (osuExecutablePath == "")
                    {
                        // Check if the osu path could be found
                        string osuDir = Paths.OsuFolder;
                        if (osuDir == null)
                        {
                            MessageBox.Show("The path to the osu!.exe file could not be found.\n\nPlease make sure you installed osu correctly by starting it as an admin.\n\nIf this issue persists, please visit our Discord server.", "Ultimate Osu Server Switcher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else // build the path
                        {
                            osuExecutablePath = Path.Combine(osuDir, "osu!.exe");
                        }
                    }

                    // Run osu if a path has been found
                    if (osuExecutablePath != "")
                    {
                        WinUtils.StartProcessUnelevated(osuExecutablePath);
                    }
                }
            }

            // Hide the "connecting" button and update the UI (update UI will show the already connected (or connect if switching failed) button then)
            pctrConnecting.Visible = false;
            UpdateUI();
        }