当前位置: 首页>>代码示例>>C#>>正文


C# InputBox.AskUser方法代码示例

本文整理汇总了C#中InputBox.AskUser方法的典型用法代码示例。如果您正苦于以下问题:C# InputBox.AskUser方法的具体用法?C# InputBox.AskUser怎么用?C# InputBox.AskUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InputBox的用法示例。


在下文中一共展示了InputBox.AskUser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: menuComment_Click

 private void menuComment_Click(object sender, EventArgs e)
 {
     GetSelected();
     if (iSelectedSet >= 0)
     {   //If something selected
         InputBox uBox = new InputBox();//Use input box
         if (uBox.AskUser(uList.uLevelSets[iSelectedSet].sComment, "LevelSet comment", "Your comment:") == DialogResult.OK) //Ask user about new comment
         {   //If new comment confirmed
             uList.uLevelSets[iSelectedSet].sComment = uBox.GetResult();//Update comment
             uList.UpdateDisplayed(iSelectedSet);//Update displayed text (as comment changed)
             Enlist();//Update listbox
         }
     }
     return;
 }
开发者ID:OverQuantum,项目名称:SokobanCompact,代码行数:15,代码来源:ChooseLevelSet.cs

示例2: menuAddDelimiter_Click

 private void menuAddDelimiter_Click(object sender, EventArgs e)
 {
     GetSelected();
     InputBox uBox = new InputBox();//Use input box
     if (uBox.AskUser("-", "Delimiter text", "Your text:") == DialogResult.OK) //Ask user about text
     {
         uList.AddDelimiter(uBox.GetResult(), iSelectedSet);
         Enlist();//Update listbox
     }
 }
开发者ID:OverQuantum,项目名称:SokobanCompact,代码行数:10,代码来源:ChooseLevelSet.cs

示例3: ActionSetBackColor

 ///<summary>User want to change background color</summary>
 private void ActionSetBackColor()
 {
     InputBox uRecName = new InputBox();
     LogSimpleLine(ActionID.ShowForm, "Ask; Background color");
     if (uRecName.AskUser(uSetting.iBackgroundColor.ToString("X").PadLeft(6, '0'), "Background Color", "Please specify background color in RRGGBB hexadecimal format:") != DialogResult.OK) //Promt user to write color in RRGGBB
         return;
     uSetting.iBackgroundColor = OQConvertTools.hex2int(uRecName.GetResult());
     uSetting.sBackgroundImageFile = "";//Clean image from settings to not use it
     if (uSetting.iBackgroundColor == -1)
         uSetting.iBackgroundColor = 0;//OQConvertTools.hex2int return -1 on errors
     LogSimpleLine(ActionID.ChangedBackground, "Set background color; " + uRecName.GetResult());
     UpdateBackground();//Recreate background according to settings
     RedrawAllScreen();
 }
开发者ID:OverQuantum,项目名称:SokobanCompact,代码行数:15,代码来源:FormMain.cs

示例4: CheckLevelCompletition

        ///<summary>If level completed - display messages and move to the next</summary>
        private void CheckLevelCompletition()
        {
            if (uGame.IsLevelCompleted(false))//Check internal flag of level
            {
                DialogResult uDR;//Object for asking user
                bool bAskRecordName = uSetting.bAskRecordName;//Get option of asking about record name
                //string sMessage, sTitle;

                LogSimpleLine(ActionID.LevelSolved, "Level solved; " + (uLevelSet.GetCurrentLevel() + 1).ToString() + "; " + uLevelSet.sFileName);
                NonModalMessage("Level " + (uLevelSet.GetCurrentLevel() + 1).ToString() + " completed");//"+1" - to numerate level from 1

                uGame.RecalcStats();//This recalc stats, as not all stats calculated automatically

                //Default name of record: player, stats, data-time
                uGame.uStats.sName = uSetting.sPlayerName + ", " + uGame.uStats.ToString() + ", " + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");

                //Build all message for box
                const string sTitle = "Congratulations";
                string sMessage = "You solve level " + uGame.sTitle + "!\r\n";
                sMessage += "Your solution stats is: ";
                sMessage += uGame.uStats.ToString() + ".\r\n";
                SolutionFlags uFlags = uGame.EstimateNewSolution(uGame);//Check new solution for rectodrs
                if ((uFlags & SolutionFlags.FirstSolution) != 0)
                {
                    //First solution of this level
                    if (!uSetting.bAskSavingFirstSolution)
                    {
                        uDR = DialogResult.Yes;
                        bAskRecordName = false;
                        goto lSilentSave;
                    }
                    sMessage += "This is first solution of this level!\r\n";
                }
                else if (uFlags == SolutionFlags.Nothing)
                {
                    //No records achived
                    sMessage += "- No new records achived.\r\n";
                }
                else
                {
                    //Improved one-two records
                    if ((uFlags & SolutionFlags.BestMoves) != 0)
                        sMessage += "* This is new best-moves solution!\r\n";
                    if ((uFlags & SolutionFlags.BestPushes) != 0)
                        sMessage += "* This is new best-pushes solution!\r\n";
                }
                sMessage += "Do you want to save your solution?";

                LogSimpleLine(ActionID.ShowDialog, "Ask; Save new solution");
                //Ask user
                uDR = MessageBox.Show(sMessage, sTitle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
            lSilentSave:
                switch (uDR)
                {
                    case DialogResult.Yes://User answer "yes" - save solution and advance to next level

                        if (bAskRecordName)//if allowed by settings
                        {//Ask name for new record
                            InputBox uRecName = new InputBox();
                            LogSimpleLine(ActionID.ShowForm, "Ask; Record name; " + uGame.uStats.sName);
                            if (uRecName.AskUser(uGame.uStats.sName, "Save record", "Please set record name:") != DialogResult.OK)
                                break;
                            uGame.uStats.sName = uRecName.GetResult();
                        }
                        if (uLevelSet.SaveNewRecord(uGame) != FunctionResult.OK) //Try to save record
                        {//Some problem with saving record
                            LogSimpleLine(ActionID.ShowDialog, "Info; Record was not saved, keep current level");
                            MessageBox.Show("Record was not saved.\r\nKeep current level...", "ERROR");
                            break;
                        }
                        uLevelSetList.UpdateSolved(uLevelSet.GetNumOfSolved());//Update number of solved levels in current levelset
                        //if (uGame.SavePosition(sSolutionsDirectory + AutoNamePosition() + ".sol", uLevelSet.sFileName, uLevelSet.GetCurrentLevel(), uSetting.sPlayerName) != 0) //Try to save solution
                        if (SavePosition(sSolutionsDirectory + AutoNamePosition() + ".sol") != FunctionResult.OK) //Try to save solution
                        {//Some problem with saving solution
                            LogSimpleLine(ActionID.ShowDialog, "Info; Solution was not saved, keep current level");
                            MessageBox.Show("Solution was not saved.\r\nKeep current level...", "ERROR");
                            break;
                        }
                        //break;
                        goto lNextLevel;
                    case DialogResult.No://User answer "no" - do not save solution but advance to next level
                    lNextLevel:
                        //bHaveUnfinishedPosition = false;//Solution saved or ignored - anyway position in ignored
                        KillAutosavedPosition();//Solution saved or ignored - autosaved position should be killed
                        //ActionNextLevel();
                        ActionNextUnsolved();
                        break;
                    default: //User answer "cancel - keep this level and do not save anything
                        break;
                }
            }
        }
开发者ID:OverQuantum,项目名称:SokobanCompact,代码行数:93,代码来源:FormMain.cs

示例5: ActionSavePosition

        ///<summary>User want to save current position</summary>
        public void ActionSavePosition()
        {
            if (uGame.uStats.iMoves == 0)
            {
                LogSimpleLine(ActionID.ShowDialog, "Info; Position empty, nothing to save");
                MessageBox.Show("You are on level start, nothing to save");
                return;
            }
            InputBox uAskFileName = new InputBox();
            string sFileName = AutoNamePosition();

            //Ask user about position filename
            LogSimpleLine(ActionID.ShowForm, "Ask; File for save position");
            if (uAskFileName.AskUser(sFileName, "Save position", "Please input position filename:") == DialogResult.OK)
            {
                FunctionResult uRV;
                uGame.RecalcStats();//Recalc stats (some of them are not calculated automatically)
                sFileName = uAskFileName.GetResult() + ".pos";
                uGame.uStats.sName = uAskFileName.GetResult();
                //if (uGame.SavePosition(sSolutionsDirectory + sFileName, uLevelSet.sFileName, uLevelSet.GetCurrentLevel(), uSetting.sPlayerName) != 0)//Saving
                uRV = SavePosition(sSolutionsDirectory + sFileName);
                if (uRV != FunctionResult.OK)//Saving
                {
                    LogSimpleLine(ActionID.ShowDialog, "Error; Position was not saved!; " + sFileName + "; " + uRV);
                    MessageBox.Show("Position was not saved! " + uRV.ToString(), "ERROR");
                    return;
                }
                LogSimpleLine(ActionID.SavePosition, "Position saved; " + uGame.uStats.iMoves.ToString() + " moves; " + sFileName);
                NonModalMessage("Position saved");
            }
        }
开发者ID:OverQuantum,项目名称:SokobanCompact,代码行数:32,代码来源:FormMain.cs


注:本文中的InputBox.AskUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。