Пример #1
0
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Multiselect = true;//该值确定是否可以选择多个文件
            dialog.Title       = "请选择文件";
            dialog.Filter      = "所有文件(*.*)|*.*";
            string fileName = "";

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fileName = dialog.FileName;
                string url = "{0}/ppttools/pptdata/save?token={1}";
                url = String.Format(url, Rigel.ServerUrl, Rigel.UserToken);
                ProgressWidget pro = new ProgressWidget();
                pro.Show();
                pro.SetInfoText("正在上传,请稍后···");
                pro.Show();
                string resultStr = Request.UploadFilesToRemoteUrl(url, fileName);
                pro.Hide();
                JObject jObject = JObject.Parse(resultStr);

                if (jObject.Value <String>("code").Equals("200"))
                {
                    PromptBox.Prompt("数据上传成功!");
                }
                else
                {
                    PromptBox.Error("上传失败:" + jObject.Value <String>("msg"));
                }
            }
        }
Пример #2
0
        public override void Play()
        {
            string[] dialogContent =
            {
                "Hey Toi !",
                "Je ne t'ai jamais vu ici. . .",
                "Tu es un aventurier ??",
                "Dis moi, quel-est ton nom ?"
            };

            Point dialogPoint  = new Point((int)(Console.WindowWidth * 0.4), (int)(Console.WindowHeight * 0.5));
            Point dialogPoint2 = new Point((int)(Console.WindowWidth * 0.6), (int)(Console.WindowHeight * 0.7));

            Dialog dialog = new Dialog(dialogPoint, dialogPoint2);

            dialog.AddSentences(dialogContent);
            dialog.Display();

            // Here prompting the player name
            Point     promptPoint = new Point((int)(Console.WindowWidth * 0.6), (int)(Console.WindowHeight * 0.5));
            PromptBox namePrompt  = new PromptBox(12, promptPoint, ':');
            string    playerName;

            bool sure = false;

            do
            {
                playerName = namePrompt.Prompt();
                namePrompt.Clear();
                dialog = new Dialog(dialogPoint, dialogPoint2);
                dialog.AddSentence(playerName + ", c'est vraiment ton nom ?");
                dialog.Display();

                TwoChoicesPromptBox nameChoiceSure = new TwoChoicesPromptBox(promptPoint);
                sure = nameChoiceSure.Prompt();
            } while (!sure);

            // Here the player name is definitely chosen
            Stats.Player.Name = playerName;

            dialog = new Dialog(dialogPoint, dialogPoint2);

            dialog.AddSentence("Eh bien " + playerName + " ravi de te rencontrer !");

            string secondSentence = (playerName.ToLower() == "tyrex")
                ? "Figure-toi que c'est mon nom aussi :)"
                : "Moi c'est Tyrex, mais je n'aime pas spécialement parler . . .";

            dialog.AddSentence(secondSentence);

            dialog.AddSentence("Mais laisse-moi te montrer un endroit génial !");
            dialog.Display();

            Stats.Player.ProgressLevel++;
        }
Пример #3
0
        private void button_option_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                UpdateWidget updateWidget = new UpdateWidget();
                updateWidget.setVersion(Rigel.PluginVersion, VSTOUpdater.ServerVersion);
                VSTOUpdater.UpdateLog.TryGetValue("slogan", out string slogan);
                VSTOUpdater.UpdateLog.TryGetValue("content", out string content);
                VSTOUpdater.UpdateLog.TryGetValue("sjhs", out string sjhs);
                List <string> lists = new List <string>();
                if (sjhs != null)
                {
                    lists = sjhs.Split(',').ToList <string>();
                }
                updateWidget.setInfo(slogan, content);

                Int32.TryParse(Rigel.PluginVersion.Replace(".", ""), out int local);
                Int32.TryParse(VSTOUpdater.ServerVersion.Replace(".", ""), out int server);
                if ((lists.Contains(Rigel.UserID) || lists.Contains("all")) && local < server)
                {
                    VSTOUpdater.NeedUpdate = true;
                }
                else
                {
                    updateWidget.setVersion(Rigel.PluginVersion, Rigel.PluginVersion);
                    VSTOUpdater.NeedUpdate = false;
                }

                updateWidget.setNeedUpdate(VSTOUpdater.NeedUpdate);



                if (VSTOUpdater.NeedUpdate)
                {
                    Logger.LogInfo("需要更新版本:" + VSTOUpdater.ServerVersion);
                }
                Logger.LogInfo("开始更新从:" + Rigel.PluginVersion + "升级到:" + VSTOUpdater.ServerVersion);

                DialogResult result = ThisAddIn.FormShower.ShowDialog(updateWidget);
                if (result == DialogResult.OK && VSTOUpdater.Update())
                {
                    PromptBox.Prompt("更新完成,需要重新启动软件。");
                    return;
                }
            }
            catch (Exception ex)
            {
                PromptBox.Prompt("非常抱歉更新失败,请联系工作人员!");
                Logger.LogError(ex.ToString());
            }
        }
Пример #4
0
        private void img2pdf(List <string> ImageName)
        {
            string[] files = ImageName.ToArray();
            iTextSharp.text.Document document = new iTextSharp.text.Document(new iTextSharp.text.Rectangle(100f, 100f, 800f, 500f, 0));
            try
            {
                iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(FileName, FileMode.Create, FileAccess.ReadWrite));
                document.Open();
                iTextSharp.text.Image image;
                for (int i = 0; i < files.Length; i++)
                {
                    if (String.IsNullOrEmpty(files[i]))
                    {
                        break;
                    }
                    image = iTextSharp.text.Image.GetInstance(files[i]);
                    if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
                    {
                        image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
                    }
                    else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
                    {
                        image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
                    }
                    image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
                    document.NewPage();
                    document.Add(image);
                    //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");

                    //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();

                    //p1.Leading = 150;      //行间距

                    //document.Add(p1);
                }

                Console.WriteLine("转换成功!");
            }

            catch (Exception ex)

            {
                Console.WriteLine("转换失败,原因:" + ex.Message);
            }

            document.Close();
            PromptBox.Prompt("导出完成!");
            Console.ReadKey();
        }
Пример #5
0
        private async void button_login_Click(object sender, RibbonControlEventArgs e)
        {
            DialogResult result = DialogResult.None;

            if (String.IsNullOrEmpty(Rigel.UserID))
            {
                LoginWidget loginWidget = new LoginWidget();
                result = loginWidget.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (String.IsNullOrEmpty(Rigel.UserID))
                    {
                        PromptBox.Error("登录失败!");
                        return;
                    }
                    else
                    {
                        Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey,
                                          StrUserName, Rigel.UserName);
                        Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey,
                                          StrUserToken, Rigel.UserToken);
                        button_login.Label = Rigel.UserName;
                        button_login.Image = Properties.Resources.Login;
                        ResetButtonEnable(true);
                    }
                }
            }
            else
            {
                result = PromptBox.Prompt("确认退出登录?");
                if (result == DialogResult.OK)
                {
                    await RequestHandle.Logout(Rigel.UserName);

                    Rigel.UserID    = "";
                    Rigel.UserToken = "";
                    Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey,
                                      StrUserToken, String.Empty);
                    button_login.Label = "登录\r\n";
                    button_login.Image = Properties.Resources.Logout;
                    Globals.ThisAddIn.TaskWidget.Visible = false;
                    ResetButtonEnable(false);
                }
            }
        }
Пример #6
0
		public static bool Update()
		{
			UninstallPlugin();
			String strinstall = Rigel.PluginDir + "Plugins/InstallVSTO.bat";
			try
			{
				if (File.Exists(strinstall))
				{
					ProcessStartInfo startInfo = new ProcessStartInfo(strinstall);
					//设置不在新窗口中启动新的进程
					startInfo.CreateNoWindow = true;
					//不使用操作系统使用的shell启动进程
					startInfo.UseShellExecute = false;
					//将输出信息重定向
					startInfo.RedirectStandardOutput = true;
					Process process = Process.Start(startInfo);

					if (process != null)
					{
						process.WaitForExit();
						return true;
					}
				}
				else
				{
					bool flag = execCmd("i");
					if (!flag)
					{
						PromptBox.Prompt("升级失败");
					}
					return flag;
				}
				
			}
			catch (Exception ex)
			{
				Logger.LogError(ex.ToString());
				PromptBox.Prompt("非常抱歉更新失败,请联系工作人员!");
			}
			return false;
		}