Beispiel #1
0
        private static bool export2Template(string filePath, List <object> rowTags, DetailExportTemplateAction action, int startIndex)
        {
            CSharpExcel excel = new CSharpExcel();

            try
            {
                excel.Open(filePath);

                if (!excel.ActivateSheet("Template"))
                {
                    return(false);
                }

                //设置单元格格式,防止科学计数
                excel.SetWriteDataFormat(3, 1, rowTags.Count + 3, 46);

                if (rowTags.Count > 0)
                {
                    for (int i = 0; i < rowTags.Count; i++)
                    {
                        action(rowTags[i], excel, i + startIndex);
                        //excel.WriteData(devInfo.strAssetCode, i + start, 0);
                    }
                }

                if (false == excel.SaveAs(filePath, true))
                {
                    SimpleMessageBox.ShowMessageBox("文件保存失败, 请确认文件未被占用 !");
                    return(false);
                }

                excel.Close();
                return(true);
            }
            catch (Exception ex)
            {
                Log.Write.Error(ex.Message);
            }
            return(false);
        }
Beispiel #2
0
 public MessageBoxTestHelper()
 {
     MessageBoxInstance = new SimpleMessageBox();
 }
Beispiel #3
0
 /// <summary>
 /// Draws a discovery dialogue box
 /// </summary>
 /// <param name="discovery">The discovery text</param>
 public void DrawDiscovery(string discovery)
 {
     SimpleMessageBox.Show("You made a discovery!", discovery, Window.GetWindow(this));
 }
Beispiel #4
0
 /// <summary>
 /// Displays the results of the event based on the option chosen
 /// </summary>
 /// <param name="optionResult">The Main option result</param>
 /// <param name="results">The text from the effects of the result</param>
 public void DrawEventResult(String optionResult, List <String> results)
 {
     SimpleMessageBox.Show(string.Empty, optionResult, MessageBoxButton.OK, Window.GetWindow(this));
 }
Beispiel #5
0
        /// <summary>
        /// Creates a dialogue box for the event and displays it
        /// </summary>
        /// <param name="eventText">The main text for the event</param>
        /// <param name="options">The text for each option</param>
        /// <returns>The selected option</returns>
        public int DrawEvent(String eventText, List <String> options)
        {
            List <String> buttonText = new List <string>()
            {
                "Option 1", "Option 2", "Option 3", "Option 4"
            };

            string optionsText = "";

            for (int i = 1; i <= options.Count; i++)
            {
                optionsText += i + ". " + options[i - 1] + "\n";
            }

            MessageBoxResult result = MessageBoxResult.None;

            switch (options.Count)
            {
            case 1:
                SimpleMessageBox.Show("Event!", eventText + "\n\n" + optionsText, MessageBoxButton.OK, Window.GetWindow(this));
                result = MessageBoxResult.Yes;
                break;

            case 2:
                result = SimpleMessageBox.Show("Event!", eventText + "\n\n" + optionsText, MessageBoxButton.YesNo, buttonText, Window.GetWindow(this));
                break;

            case 3:
                result = SimpleMessageBox.Show("Event!", eventText + "\n\n" + optionsText, MessageBoxButton.YesNoCancel, buttonText, Window.GetWindow(this));
                break;

            case 4:
                result = SimpleMessageBox.Show("Event!", eventText + "\n\n" + optionsText, MessageBoxButton.OKCancel, buttonText, Window.GetWindow(this));
                break;
            }

            int selected = 1;

            switch (result)
            {
            case MessageBoxResult.Yes:
                selected = 1;
                break;

            case MessageBoxResult.No:
                selected = 2;
                break;

            case MessageBoxResult.OK:
                selected = 4;
                break;

            case MessageBoxResult.Cancel:
                if (options.Count == 3)
                {
                    selected = 3;
                }
                else
                {
                    selected = 4;
                }
                break;
            }
            return(selected);
        }
Beispiel #6
0
 /// <summary>
 /// Draws a simple dialogue box with the text supplied
 /// </summary>
 /// <param name="text">The text to display</param>
 public void DrawDialogueBox(String text)
 {
     SimpleMessageBox.Show(string.Empty, text, MessageBoxButton.OK, Window.GetWindow(this));
 }
Beispiel #7
0
 /// <summary>
 /// Draws the victory dialogue
 /// </summary>
 public void DrawVictory()
 {
     SimpleMessageBox.Show("Congradulations", "You made it home.", Window.GetWindow(this));
 }
Beispiel #8
0
 /// <summary>
 /// Draws the game over dialogue
 /// </summary>
 public void DrawGameOver()
 {
     SimpleMessageBox.Show("Game Over", "I'm sorry you did not manage to make your way home.", Window.GetWindow(this));
 }