private void Copy() { FileStream fs = new FileStream(sourceFileName, FileMode.Open); //открытие для чтения FileStream fs2 = new FileStream(destFileName, FileMode.Create); //открытие для записи var size = fs.Length; //длина byte[] buf = new byte[1024]; while (fs.Position < fs.Length) { int readed = fs.Read(buf, 0, 1024); //чтение из файла (возвращает кол-во фактически прочитанных байт) ShowProgress sp = () => { progressBar1.Value = (int)(fs.Position / (float)fs.Length * 100); }; progressBar1.Invoke(sp); //fs2.Write(buf, 0, 10); //запись в файл fs2.Write(buf, 0, readed); Thread.Sleep(1000); } fs.Close(); fs2.Close(); EventWaitHandle testEvent = new EventWaitHandle(true, EventResetMode.AutoReset, "testEvent"); testEvent.Set(); progressBar1.Value = 100; }
public void StoreValues(Data data, string path) { AttachmentPage.StoreValues(data, path + @"AttachmentPage\"); AutoSave.StoreValues(data, path + @"AutoSave\"); BackgroundPage.StoreValues(data, path + @"BackgroundPage\"); CoverPage.StoreValues(data, path + @"CoverPage\"); EmailClient.StoreValues(data, path + @"EmailClient\"); EmailSmtp.StoreValues(data, path + @"EmailSmtp\"); Ftp.StoreValues(data, path + @"Ftp\"); Ghostscript.StoreValues(data, path + @"Ghostscript\"); JpegSettings.StoreValues(data, path + @"JpegSettings\"); PdfSettings.StoreValues(data, path + @"PdfSettings\"); PngSettings.StoreValues(data, path + @"PngSettings\"); Printing.StoreValues(data, path + @"Printing\"); Properties.StoreValues(data, path + @"Properties\"); SaveDialog.StoreValues(data, path + @"SaveDialog\"); Scripting.StoreValues(data, path + @"Scripting\"); Stamping.StoreValues(data, path + @"Stamping\"); TiffSettings.StoreValues(data, path + @"TiffSettings\"); data.SetValue(@"" + path + @"AuthorTemplate", Data.EscapeString(AuthorTemplate)); data.SetValue(@"" + path + @"FileNameTemplate", Data.EscapeString(FileNameTemplate)); data.SetValue(@"" + path + @"Guid", Data.EscapeString(Guid)); data.SetValue(@"" + path + @"Name", Data.EscapeString(Name)); data.SetValue(@"" + path + @"OpenViewer", OpenViewer.ToString()); data.SetValue(@"" + path + @"OutputFormat", OutputFormat.ToString()); data.SetValue(@"" + path + @"ShowProgress", ShowProgress.ToString()); data.SetValue(@"" + path + @"SkipPrintDialog", SkipPrintDialog.ToString()); data.SetValue(@"" + path + @"TitleTemplate", Data.EscapeString(TitleTemplate)); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine("[AttachmentPage]"); sb.AppendLine(AttachmentPage.ToString()); sb.AppendLine("[AutoSave]"); sb.AppendLine(AutoSave.ToString()); sb.AppendLine("[BackgroundPage]"); sb.AppendLine(BackgroundPage.ToString()); sb.AppendLine("[CoverPage]"); sb.AppendLine(CoverPage.ToString()); sb.AppendLine("[DropboxSettings]"); sb.AppendLine(DropboxSettings.ToString()); sb.AppendLine("[EmailClientSettings]"); sb.AppendLine(EmailClientSettings.ToString()); sb.AppendLine("[EmailSmtpSettings]"); sb.AppendLine(EmailSmtpSettings.ToString()); sb.AppendLine("[Ftp]"); sb.AppendLine(Ftp.ToString()); sb.AppendLine("[Ghostscript]"); sb.AppendLine(Ghostscript.ToString()); sb.AppendLine("[JpegSettings]"); sb.AppendLine(JpegSettings.ToString()); sb.AppendLine("[PdfSettings]"); sb.AppendLine(PdfSettings.ToString()); sb.AppendLine("[PngSettings]"); sb.AppendLine(PngSettings.ToString()); sb.AppendLine("[Printing]"); sb.AppendLine(Printing.ToString()); sb.AppendLine("[Properties]"); sb.AppendLine(Properties.ToString()); sb.AppendLine("[SaveDialog]"); sb.AppendLine(SaveDialog.ToString()); sb.AppendLine("[Scripting]"); sb.AppendLine(Scripting.ToString()); sb.AppendLine("[Stamping]"); sb.AppendLine(Stamping.ToString()); sb.AppendLine("[TextSettings]"); sb.AppendLine(TextSettings.ToString()); sb.AppendLine("[TiffSettings]"); sb.AppendLine(TiffSettings.ToString()); sb.AppendLine("[UserTokens]"); sb.AppendLine(UserTokens.ToString()); sb.AppendLine("AuthorTemplate=" + AuthorTemplate.ToString()); sb.AppendLine("FileNameTemplate=" + FileNameTemplate.ToString()); sb.AppendLine("Guid=" + Guid.ToString()); sb.AppendLine("KeywordTemplate=" + KeywordTemplate.ToString()); sb.AppendLine("Name=" + Name.ToString()); sb.AppendLine("OpenViewer=" + OpenViewer.ToString()); sb.AppendLine("OpenWithPdfArchitect=" + OpenWithPdfArchitect.ToString()); sb.AppendLine("OutputFormat=" + OutputFormat.ToString()); sb.AppendLine("ShowProgress=" + ShowProgress.ToString()); sb.AppendLine("SkipPrintDialog=" + SkipPrintDialog.ToString()); sb.AppendLine("SubjectTemplate=" + SubjectTemplate.ToString()); sb.AppendLine("TitleTemplate=" + TitleTemplate.ToString()); return(sb.ToString()); }
public EndSectionTransition(Vector2 startCoordinates) { _content = ResourceLoader.InstantiatePrefabAtPosition(Constants.Resources.SectionTransition, new Vector2(startCoordinates.x - _placementOffsetx, startCoordinates.y), null); _manager = _content.GetComponent <EvaluationManager>(); _progressbar = _content.GetComponentInChildren <ShowProgress>(); _activityTransition = new EndActivityTransition(_content, _manager); SetEdges(); InitializeTriggers(); }
private void SearchSubDirectoriesRecursive(string subFolder, List <string> dirs) //recrusive func to loop on al sub-folders that were sent to it { try { ShowProgress?.Invoke(""); //invoke progress event foreach (string folder in Directory.GetDirectories(subFolder, "*", SearchOption.TopDirectoryOnly).ToArray()) //loop on all top directoires { dirs.Add(folder); // add this folder to the dirs list SearchSubDirectoriesRecursive(folder, dirs); //send each directory to the search recursive func again - recursive } } catch { } }
public void StoreValues(Data data, string path) { AttachmentPage.StoreValues(data, path + @"AttachmentPage\"); AutoSave.StoreValues(data, path + @"AutoSave\"); BackgroundPage.StoreValues(data, path + @"BackgroundPage\"); CoverPage.StoreValues(data, path + @"CoverPage\"); CustomScript.StoreValues(data, path + @"CustomScript\"); DropboxSettings.StoreValues(data, path + @"DropboxSettings\"); EmailClientSettings.StoreValues(data, path + @"EmailClientSettings\"); EmailSmtpSettings.StoreValues(data, path + @"EmailSmtpSettings\"); ForwardToFurtherProfile.StoreValues(data, path + @"ForwardToFurtherProfile\"); Ftp.StoreValues(data, path + @"Ftp\"); Ghostscript.StoreValues(data, path + @"Ghostscript\"); HttpSettings.StoreValues(data, path + @"HttpSettings\"); JpegSettings.StoreValues(data, path + @"JpegSettings\"); PdfSettings.StoreValues(data, path + @"PdfSettings\"); PngSettings.StoreValues(data, path + @"PngSettings\"); Printing.StoreValues(data, path + @"Printing\"); Properties.StoreValues(data, path + @"Properties\"); Scripting.StoreValues(data, path + @"Scripting\"); Stamping.StoreValues(data, path + @"Stamping\"); TextSettings.StoreValues(data, path + @"TextSettings\"); TiffSettings.StoreValues(data, path + @"TiffSettings\"); UserTokens.StoreValues(data, path + @"UserTokens\"); Watermark.StoreValues(data, path + @"Watermark\"); for (int i = 0; i < ActionOrder.Count; i++) { data.SetValue(path + @"ActionOrder\" + i + @"\ActionOrder", Data.EscapeString(ActionOrder[i])); } data.SetValue(path + @"ActionOrder\numClasses", ActionOrder.Count.ToString()); data.SetValue(@"" + path + @"AuthorTemplate", Data.EscapeString(AuthorTemplate)); data.SetValue(@"" + path + @"EnableWorkflowEditor", EnableWorkflowEditor.ToString()); data.SetValue(@"" + path + @"FileNameTemplate", Data.EscapeString(FileNameTemplate)); data.SetValue(@"" + path + @"Guid", Data.EscapeString(Guid)); data.SetValue(@"" + path + @"KeywordTemplate", Data.EscapeString(KeywordTemplate)); data.SetValue(@"" + path + @"Name", Data.EscapeString(Name)); data.SetValue(@"" + path + @"OpenViewer", OpenViewer.ToString()); data.SetValue(@"" + path + @"OpenWithPdfArchitect", OpenWithPdfArchitect.ToString()); data.SetValue(@"" + path + @"OutputFormat", OutputFormat.ToString()); data.SetValue(@"" + path + @"SaveFileTemporary", SaveFileTemporary.ToString()); data.SetValue(@"" + path + @"ShowAllNotifications", ShowAllNotifications.ToString()); data.SetValue(@"" + path + @"ShowOnlyErrorNotifications", ShowOnlyErrorNotifications.ToString()); data.SetValue(@"" + path + @"ShowProgress", ShowProgress.ToString()); data.SetValue(@"" + path + @"ShowQuickActions", ShowQuickActions.ToString()); data.SetValue(@"" + path + @"SkipPrintDialog", SkipPrintDialog.ToString()); data.SetValue(@"" + path + @"SubjectTemplate", Data.EscapeString(SubjectTemplate)); data.SetValue(@"" + path + @"TargetDirectory", Data.EscapeString(TargetDirectory)); data.SetValue(@"" + path + @"TitleTemplate", Data.EscapeString(TitleTemplate)); }
public SplashVm(int miliSecondsToInit) { ProductVersion = String.Format("Versión: " + CurrentVersion); ShowProgress = ReactiveCommand.CreateAsyncObservable(_ => Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(miliSecondsToInit / 100.0)) .Take(miliSecondsToInit / 10) .Scan(0, (acc, x) => acc + 1)); ShowProgress.Subscribe(x => { Progress = x; }); }
public void Import() { var count = RowCount; ShowProgress?.SetMaxValue(count); var cells = Excel.Workbook.Worksheets[SheetNumber].Cells; Print?.PrintLog("Start importing data from excel"); var startRow = IncludeHeader ? 2 : 1; for (var i = startRow; i < count + 1; i++) { ImportRow(cells, i); Print?.PrintLog($"Rows {i} has imported."); ShowProgress?.SetCurrentValue(i); ShowPercentage?.Invoke((double)i / count * 100.00); } try { Print?.PrintLog("Start saving to database."); if (!IgnoreSaveData) { Context.Database.Log = s => { Log.Info(s); Print?.PrintLog(s); }; } } catch (Exception e) { var errors = e.Message; if (e.InnerException != null) { errors += "Internal Exception:\r" + e.InnerException.Message; } Print?.PrintLog(errors); throw new Exception("Could not save data." + errors); } finally { ShowProgress?.Done(); } }
public void Save() { try { if (IsOneView) { ViewSettingsParser.Modify(_configLocation.FileName, new ViewSettings { URL = URL, ProjectNameRegEx = ProjectNameRegEx, CategoryRegEx = CategoryRegEx, ServerNameRegEx = ServerNameRegEx, SkinName = SkinName, ViewName = ViewName, ShowOnlyBroken = ShowOnlyBroken, ShowServerName = ShowServerName, ShowOutOfDate = ShowOutOfDate, OutOfDateDifferenceInMinutes = OutOfDateDifferenceInMinutes }); } var config = OpenExeConfiguration(); config.AppSettings.Settings[PollFrequencyKey].Value = PollFrequency.ToString(); config.AppSettings.Settings[ShowCountdownKey].Value = ShowCountdown.ToString(); config.AppSettings.Settings[ShowProgressKey].Value = ShowProgress.ToString(); config.AppSettings.Settings[PlaySoundsKey].Value = PlaySounds.ToString(); config.AppSettings.Settings[PlaySpeechKey].Value = PlaySpeech.ToString(); config.AppSettings.Settings[BrokenBuildSoundKey].Value = BrokenBuildSound; config.AppSettings.Settings[FixedBuildSoundKey].Value = FixedBuildSound; config.AppSettings.Settings[BrokenBuildTextKey].Value = BrokenBuildText; config.AppSettings.Settings[FixedBuildTextKey].Value = FixedBuildText; config.AppSettings.Settings[SpeechVoiceNameKey].Value = SpeechVoiceName; config.AppSettings.Settings[BreakerGuiltStrategyKey].Value = _breakerGuiltStrategy; config.Save(ConfigurationSaveMode.Minimal); } catch (Exception ex) { // config may be edited in the file (manually) - we cannot show an error dialog here // because it's entirely reasonable that the user doesn't have access to the machine running // the exe, in order to close a dialog _log.Error(ex.Message, ex); } }
void InitData() { progress = GameObject.Find("LoadingCanvas_pc").transform.GetComponent <ShowProgress>(); if (GameObject.Find("ModelParent") == null) { //模型管理父物体 PublicClass.Transform_parent = new GameObject("ModelParent").transform; // PublicClass.Model_A = Transform_parent.gameObject; PublicClass.Transform_parent.position = Vector3.zero; } if (GameObject.Find("ModelParent_temp") == null) { //模型管理父物体 PublicClass.Transform_temp = new GameObject("ModelParent_temp").transform; // PublicClass.Model_A = Transform_parent.gameObject; PublicClass.Transform_temp.position = Vector3.zero; } DontDestroyOnLoad(PublicClass.Transform_parent.gameObject); DontDestroyOnLoad(PublicClass.Transform_temp.gameObject); }
public void StoreValues(Data data, string path) { AttachmentPage.StoreValues(data, path + @"AttachmentPage\"); AutoSave.StoreValues(data, path + @"AutoSave\"); BackgroundPage.StoreValues(data, path + @"BackgroundPage\"); CoverPage.StoreValues(data, path + @"CoverPage\"); CustomScript.StoreValues(data, path + @"CustomScript\"); DropboxSettings.StoreValues(data, path + @"DropboxSettings\"); EmailClientSettings.StoreValues(data, path + @"EmailClientSettings\"); EmailSmtpSettings.StoreValues(data, path + @"EmailSmtpSettings\"); Ftp.StoreValues(data, path + @"Ftp\"); Ghostscript.StoreValues(data, path + @"Ghostscript\"); HttpSettings.StoreValues(data, path + @"HttpSettings\"); JpegSettings.StoreValues(data, path + @"JpegSettings\"); PdfSettings.StoreValues(data, path + @"PdfSettings\"); PngSettings.StoreValues(data, path + @"PngSettings\"); Printing.StoreValues(data, path + @"Printing\"); Properties.StoreValues(data, path + @"Properties\"); Scripting.StoreValues(data, path + @"Scripting\"); Stamping.StoreValues(data, path + @"Stamping\"); TextSettings.StoreValues(data, path + @"TextSettings\"); TiffSettings.StoreValues(data, path + @"TiffSettings\"); UserTokens.StoreValues(data, path + @"UserTokens\"); data.SetValue(@"" + path + @"AuthorTemplate", Data.EscapeString(AuthorTemplate)); data.SetValue(@"" + path + @"FileNameTemplate", Data.EscapeString(FileNameTemplate)); data.SetValue(@"" + path + @"Guid", Data.EscapeString(Guid)); data.SetValue(@"" + path + @"KeywordTemplate", Data.EscapeString(KeywordTemplate)); data.SetValue(@"" + path + @"Name", Data.EscapeString(Name)); data.SetValue(@"" + path + @"OpenViewer", OpenViewer.ToString()); data.SetValue(@"" + path + @"OpenWithPdfArchitect", OpenWithPdfArchitect.ToString()); data.SetValue(@"" + path + @"OutputFormat", OutputFormat.ToString()); data.SetValue(@"" + path + @"ShowAllNotifications", ShowAllNotifications.ToString()); data.SetValue(@"" + path + @"ShowOnlyErrorNotifications", ShowOnlyErrorNotifications.ToString()); data.SetValue(@"" + path + @"ShowProgress", ShowProgress.ToString()); data.SetValue(@"" + path + @"ShowQuickActions", ShowQuickActions.ToString()); data.SetValue(@"" + path + @"SkipPrintDialog", SkipPrintDialog.ToString()); data.SetValue(@"" + path + @"SubjectTemplate", Data.EscapeString(SubjectTemplate)); data.SetValue(@"" + path + @"TargetDirectory", Data.EscapeString(TargetDirectory)); data.SetValue(@"" + path + @"TitleTemplate", Data.EscapeString(TitleTemplate)); }
public XmlNode GenerateXML() { // Create XML Node and Attributes XmlDocument d = new XmlDocument(); XmlNode output = d.CreateNode("element", "Action", null); XmlAttribute type = d.CreateAttribute("Type"); XmlAttribute showProgress = d.CreateAttribute("ShowProgress"); XmlAttribute valueTypes = d.CreateAttribute("ValueTypes"); XmlAttribute condition = d.CreateAttribute("Condition"); // Assign attribute values type.Value = "DefaultValues"; showProgress.Value = ShowProgress.ToString(); valueTypes.Value = GenerateValueTypes(); condition.Value = Condition; // Append Attributes output.Attributes.Append(type); if (null != ShowProgress) { output.Attributes.Append(showProgress); } output.Attributes.Append(valueTypes); if (!string.IsNullOrEmpty(Condition)) { output.Attributes.Append(condition); } // Append Children foreach (IChildElement input in SubChildren) { XmlNode importNode = d.ImportNode(input.GenerateXML(), true); output.AppendChild(importNode); } return(output); }
public void ProcessOnEncode(byte[] inBuffer, Stream outStream, int level = 16, ShowProgress progress = null) { long perc, perc0 = 0; if (progress != null) { progress(0); } for (int iin = 0; iin < inBuffer.Length; iin++) { perc = 100 * iin / inBuffer.Length; if (perc > perc0) { perc0 = perc; if (progress != null) { progress(perc); } } WriteByte(outStream, inBuffer[iin]); } if (progress != null) { progress(100); } }
public static List <AzureIoTHub> GetIotHubList( ShowProgress progressCallback, ShowError errorCallback, RunPSCommand PSCallback) { List <AzureIoTHub> hubList = new List <AzureIoTHub>(); try { if (MSAHelper.Subscriptions.Count == 0) { // no subscritions means no IoT Hubs return(hubList); } double progressPerSubscription = 85.0f / MSAHelper.Subscriptions.Count; for (int k = 0; k < MSAHelper.Subscriptions.Count; k++) { List <Task> tasks = new List <Task>(); string subscriptionName = MSAHelper.Subscriptions[k]; PSCallback?.Invoke("az account set --subscription '" + subscriptionName + "'"); Collection <string> hubListResults = PSCallback?.Invoke("az iot hub list"); if (hubListResults != null && hubListResults.Count != 0) { for (int i = 0; i < hubListResults.Count; i++) { string hubName = hubListResults[i]; if (hubName.Contains("\"name\"")) { hubName = hubName.Substring(hubName.IndexOf(":")); hubName = hubName.Substring(hubName.IndexOf("\"") + 1); hubName = hubName.Substring(0, hubName.IndexOf("\"")); // filter if (hubName == "$fallback" || hubName == "S1" || hubName == "F1" || hubName == "B1") { continue; } tasks.Add(Task.Run(() => { Collection <string> results2 = PSCallback("az iot hub show-connection-string --name '" + hubName + "'"); if (results2 != null && results2.Count != 0) { for (int j = 0; j < results2.Count; j++) { string connectionString = results2[j]; if (connectionString.Contains("\"connectionString\"")) { // we have access lock (hubListLock) { hubList.Add(new AzureIoTHub(hubName, subscriptionName)); } } } } })); } } } Task.WhenAll(tasks).Wait(); tasks.Clear(); progressCallback?.Invoke(progressPerSubscription, false); } } catch (Exception ex) { errorCallback?.Invoke(ex.Message); } return(hubList); }
void Start() { OperaStatus = AppOperState.Init; DebugLog.DebugLogInfo("-------------------------------进入场景分发器---------------------------------------"); //创建资源文件夹 Create_assets_path(); if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.PPTPlayer) { SceneManager.LoadScene("WeiKePlayer"); return; } show_progress = Unity_Tools.Get_scene_instance <ShowProgress>("LoadingCanvas_pc"); #if UNITY_EDITOR if (firstTest) { //StartCoroutine(App_tool.testMethod("游戏", "2", "game", "GA0101001", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001// // StartCoroutine(App_tool.testMethod("经络穴位", "24", "acu", "AA0100012N", Get_app)); //StartCoroutine(App_tool.testMethod_acu("acu", "AA0100000N", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801001", Get_app)); //Get_app(App_tool.testMethod()); //StartCoroutine(App_tool.testMethod_wk_lz("微课课程", "13", "microlesson", "WK0000001", Get_app)); //StartCoroutine(App_tool.testMethod("肌肉动画", "29", "equip_drill", "MAO10001", Get_app)); //StartCoroutine(App_tool.testMethod("测验练习", "exam", "qa001", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0A01001", Get_app));//SA0201007//SA0202010 // StartCoroutine(App_tool.testMethod("人体构造", "2", "animation", "DA0100039", Get_app)); // StartCoroutine(App_tool.testMethod("微课课程", "2", "microlesson", "HMFWK001", Get_app));//HMFWK002 // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801001", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "2", "sign_ssp", "SA0C01007", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001 // StartCoroutine(App_tool.testMethod("经络穴位", "24", "sign_acu", "AA0100002", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001// //StartCoroutine(App_tool.testMethod("人体构造", "2", "sign", "SA0604002", Get_app));//SA0903001//SA0903005//SA0903006//SA0903007 Get_app(App_tool.testMethod_signnew("sign_new", "SA090C003", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001//SA0C02000//SA0C04002// //StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0000000", Get_app));//SA0101047//SA0000000//RA0100001//SA0801002 firstTest = false; } else { firstTest = true; // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801004", Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0801003", Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "model", "SA0101047", Get_app));//SA0101047//SA0000000//RA0100001 //StartCoroutine(App_tool.testMethod("经络穴位", "24", "sign_acu", "AA0100000", Get_app));//SA0101047//SA0000000//RA0100001//SA0C02001// // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0000000", Get_app)); // StartCoroutine(App_tool.testMethod("微课课程", "2", "microlesson", "HMFWK001", Get_app));//HMFWK002 // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0101047", Get_app));//SA0103043 // StartCoroutine(App_tool.testMethod("人体构造", "2", "model", "SA0101047", Get_app)); //StartCoroutine(App_tool.testMethod("人体构造", "2", "animation", "DA0100050", Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", get_id_list(), Get_app)); // StartCoroutine(App_tool.testMethod("人体构造", "44", "medical", "RA0801001", Get_app)); // StartCoroutine(App_tool.testMethod("测验练习", "2", "exam", "qa001", Get_app)); // StartCoroutine(App_tool.testMethod("经络穴位", "24", "sign_acu", "AA0100005", Get_app)); //StartCoroutine(App_tool.testMethod("经络穴位", "24", "acu", "AA0100009N", Get_app)); } #elif UNITY_ANDROID show_progress = Unity_Tools.Get_scene_instance <ShowProgress>("LoadingCanvas"); #elif UNITY_STANDALONE_WIN show_progress = Unity_Tools.Get_scene_instance <ShowProgress>("LoadingCanvas_pc"); if (PPTGlobal.PPTEnv == PPTGlobal.PPTEnvironment.plugin) { if (PublicClass.app != null) { Get_app(PublicClass.app); } } else { if (!PublicClass.is_enter_server_control) { InternalSocketMananger.instance.HideUnityWidows(); DebugLog.DebugLogInfo("HideUnityWidows"); } } #endif if (PublicClass.app == null) { SetOperaToLoop(); } }
/// <summary> /// 通过命令序列导出schmeatic /// </summary> /// <param name="commandLine">命令序列</param> /// <param name="SettingParam">导出设置</param> /// <param name="ExportPath">导出路径</param> public void ExportSchematic(CommandLine commandLine, ExportSetting SettingParam, string ExportPath = "C:\\MyAudioRiptide.schematic", ShowProgress showProgress = null) { try { var Schematic = Serialize(commandLine, SettingParam, showProgress); //Export Schematic if (SettingParam.Type == ExportSetting.ExportType.Universal) { new NbtFile(Schematic).SaveToFile(ExportPath, NbtCompression.None); } else if (SettingParam.Type == ExportSetting.ExportType.WorldEdit || SettingParam.Type == ExportSetting.ExportType.WorldEdit_113) { new NbtFile(Schematic).SaveToFile(ExportPath, NbtCompression.GZip); } } catch { } }
private BlockInfo CommandLine2SchematicInfo(CommandLine commandLine, ExportSetting SettingParam, string mode, ShowProgress showProgress = null) { //Setblock Command var redstone_block = "minecraft:redstone_block 0"; if (mode == "1.13") { redstone_block = "minecraft:redstone_block"; } try { var blockInfo = new BlockInfo(); var count = commandLine.Keyframe.Count + 4; /* Set Total Progress */ this.totalProgress = count * 2; /* Define the region size */ var n = SettingParam.Width; var l = (count % n == 0) ? count / n : count / n + 1; var h = 0; /* Define a block position , data */ var x = 0; var y = 0; var z = 0; var r = 0;//0: down, 1: up, 2: north, 3: south, 4: west, 5: east, #region General & End (impulse) var general = new Command(); var end = new Command(); var dot = new Command(); dot.Commands = new List <string>(); //general general.Commands = commandLine.Start; commandLine.Keyframe.Insert(0, general); commandLine.Keyframe.Insert(1, dot); //end end.Commands = commandLine.End; commandLine.Keyframe.Add(dot); commandLine.Keyframe.Add(end); #endregion #region KeyFrames (line) /* Get Y_max */ for (int i = 0; i < count; i++) { if (SettingParam.AutoTeleport && commandLine.Keyframe[i].Commands.Count > 0) //Add AutoTp { var tpdir = new List <double[]>() { new double[] { (double)1 / SettingParam.Width, 0 }, new double[] { (double)-1 / SettingParam.Width, 0 }, new double[] { 0, (double)1 / SettingParam.Width }, new double[] { 0, (double)-1 / SettingParam.Width }, }; commandLine.Keyframe[i].Commands.Add("tp @p ~" + tpdir[SettingParam.Direction][0].ToString("0.0000") + " ~ ~" + tpdir[SettingParam.Direction][1].ToString("0.0000")); } if (commandLine.Keyframe[i].Commands.Count > h) { h = commandLine.Keyframe[i].Commands.Count; } /* Update Current Progress */ this.currentProgress++; if (showProgress != null && this.totalProgress > 0) { showProgress((double)this.currentProgress / this.totalProgress); } } /* Create Arrays for block storing */ var blocks = new byte[0]; var datas = new byte[0]; if (SettingParam.Direction == 0 || SettingParam.Direction == 1) { blockInfo.Height.Value = (short)h; blockInfo.Length.Value = (short)n; blockInfo.Width.Value = (short)l; //blocks = new byte[((h - 1) * l + (n - 1)) * n + (l - 1) + 1]; datas = new byte[((h - 1) * l + (n - 1)) * n + (l - 1) + 1]; } if (SettingParam.Direction == 2 || SettingParam.Direction == 3) { blockInfo.Height.Value = (short)h; blockInfo.Length.Value = (short)l; blockInfo.Width.Value = (short)n; //blocks = new byte[((h - 1) * n + (l - 1)) * l + (n - 1) + 1]; datas = new byte[((h - 1) * n + (l - 1)) * l + (n - 1) + 1]; } blocks = new byte[h * n * l]; datas = new byte[h * n * l]; /* Write in position */ for (int i = 0; i < count; i++) { #region get (X & Z & Rotation) -> x y r //X+ if (SettingParam.Direction == 0) { x = i / n; z = i % n; if (x % 2 == 0) { if (z == n - 1) { r = 5; } /*x++*/ else { r = 3; } /*z++*/ } else { z = n - z - 1; if (z == 0) { r = 5; } /*x++*/ else { r = 2; } /*z--*/ } } //X- if (SettingParam.Direction == 1) { x = i / n; z = i % n; if (x % 2 == 0) { if (z == n - 1) { r = 4; } /*x--*/ else { r = 3; } /*z++*/ } else { z = n - z - 1; if (z == 0) { r = 4; } /*x--*/ else { r = 2; } /*z--*/ } x = l - x - 1; } //Z+ if (SettingParam.Direction == 2) { x = i % n; z = i / n; if (z % 2 == 0) { if (x == n - 1) { r = 3; } /*z++*/ else { r = 5; } /*x++*/ } else { x = n - x - 1; if (x == 0) { r = 3; } /*z++*/ else { r = 4; } /*x--*/ } } //Z- if (SettingParam.Direction == 3) { x = i % n; z = i / n; if (z % 2 == 0) { if (x == n - 1) { r = 2; } /*z--*/ else { r = 5; } /*x++*/ } else { x = n - x - 1; if (x == 0) { r = 2; } /*z--*/ else { r = 4; } /*x--*/ } z = l - z - 1; } #endregion var vector2 = new int[] { 0, 0 }; #region Rotation switch (r) { case 2: vector2[0] = 0; vector2[1] = -1; break; case 3: vector2[0] = 0; vector2[1] = 1; break; case 4: vector2[0] = -1; vector2[1] = 0; break; case 5: vector2[0] = 1; vector2[1] = 0; break; } #endregion //Options about command if (!SettingParam.AlwaysActive) { commandLine.Keyframe[i].Commands.Remove("setworldspawn ~ ~ ~"); } if (!SettingParam.AlwaysLoadEntities) { commandLine.Keyframe[i].Commands.Remove("tp @e[tag=Tracks] @p"); } //WriteIn Commands for (y = 0; y < commandLine.Keyframe[i].Commands.Count; y++) { //X+ X- if (SettingParam.Direction == 0 || SettingParam.Direction == 1) { var index = (y * n + z) * l + x; if (y == 0) { blocks[index] = 137; datas[index] = 1; if (commandLine.Keyframe[i].Commands[0] == "$setblock") { blockInfo.TileEntities.Add(AddCommand("setblock ~" + vector2[0].ToString() + " ~-1 ~" + vector2[1].ToString() + " " + redstone_block + " keep", x, y, z, false, mode)); } else { blockInfo.TileEntities.Add(AddCommand(commandLine.Keyframe[i].Commands[y], x, y, z, false, mode)); } } else { blocks[index] = 211; datas[index] = 1; blockInfo.TileEntities.Add(AddCommand(commandLine.Keyframe[i].Commands[y], x, y, z, true, mode)); } } //Z+ Z- else if (SettingParam.Direction == 2 || SettingParam.Direction == 3) { var index = (y * l + z) * n + x; if (y == 0 && commandLine.Keyframe[i].Commands[0] == "$setblock") { blocks[index] = 137; datas[index] = 1; if (commandLine.Keyframe[i].Commands[0] == "$setblock") { blockInfo.TileEntities.Add(AddCommand("setblock ~" + vector2[0].ToString() + " ~-1 ~" + vector2[1].ToString() + " " + redstone_block + " 0 keep", x, y, z, false, mode)); } else { blockInfo.TileEntities.Add(AddCommand(commandLine.Keyframe[i].Commands[y], x, y, z, false, mode)); } } else { blocks[index] = 211; datas[index] = 1; blockInfo.TileEntities.Add(AddCommand(commandLine.Keyframe[i].Commands[y], x, y, z, true, mode)); } } } /* Update Current Progress */ this.currentProgress++; if (showProgress != null && this.totalProgress > 0) { showProgress((double)this.currentProgress / this.totalProgress); } } blockInfo.Blocks.Value = blocks; blockInfo.Data.Value = datas; #endregion return(blockInfo); } catch { return(null); } }
public override void ProcessOnEncode(byte[] inBuffer, Stream outStream, int level = 16, ShowProgress progress = null) { }
/// <summary> /// 序列化Schematic序列 /// </summary> /// <param name="commandLine"></param> /// <param name="SettingParam"></param> /// <returns></returns> public NbtCompound Serialize(CommandLine commandLine, ExportSetting SettingParam, ShowProgress showProgress = null) { try { var Schematic = new NbtCompound("Schematic"); //CommandLine -> BlockInfo var blockInfo = CommandLine2SchematicInfo(commandLine, SettingParam, (SettingParam.Type == ExportSetting.ExportType.WorldEdit_113) ? "1.13" : "", showProgress); //BlockInfo -> Schematic Schematic.Add(blockInfo.Height); Schematic.Add(blockInfo.Length); Schematic.Add(blockInfo.Width); Schematic.Add(new NbtList("Entities", NbtTagType.Compound)); Schematic.Add(blockInfo.Data); Schematic.Add(blockInfo.Blocks); Schematic.Add(blockInfo.TileEntities); if (SettingParam.Type == ExportSetting.ExportType.WorldEdit) { var weInfo = BlockInfo2WorldEditBlockInfo(blockInfo, SettingParam.Direction); Schematic.Remove("Entities"); Schematic.Add(weInfo.Materials); Schematic.Add(weInfo.WEOriginX); Schematic.Add(weInfo.WEOriginY); Schematic.Add(weInfo.WEOriginZ); Schematic.Add(weInfo.WEOffsetX); Schematic.Add(weInfo.WEOffsetY); Schematic.Add(weInfo.WEOffsetZ); } else if (SettingParam.Type == ExportSetting.ExportType.WorldEdit_113) //1.13 { var schem = BlockInfo2Schema113Info(blockInfo, SettingParam.Direction); Schematic.Remove(blockInfo.Data); Schematic.Remove(blockInfo.Blocks); Schematic.Remove("Entities"); Schematic.Add(schem.Metadata); Schematic.Add(schem.Palette); Schematic.Add(schem.PaletteMax); Schematic.Add(schem.Version); Schematic.Add(schem.BlockData); Schematic.Add(schem.Offset); } return(Schematic); } catch { return(null); } }
public virtual void ProcessOnEncode(byte[] inBuffer, Stream outStream, int level = 1000, ShowProgress progress = null) { long perc, perc0 = 0; long percbord = 0; if (progress != null) { progress(0); } m_shiftIndex = 8; m_itowrite = 0; m_outstream = outStream; m_inp = inBuffer; m_level = level < 6 ? 6 : level > 280 ? 280 : level; m_maxdist = level < 50 ? 50 : level > 0x1fff ? 0x1fff : level; perc0 = percbord; if (progress != null) { progress(percbord); } m_ind = 0; while (m_ind < inBuffer.Length) { perc = percbord + (100 - percbord) * (Int64)m_ind / inBuffer.Length; if (perc > perc0) { perc0 = perc; if (progress != null) { progress(perc); } } uint ofs; int len = FindRep(m_ind, out ofs); //Debug.WriteLine("ind={0:x} len={1:x} ofs={2:x}",m_ind, len, ofs); if (len == 0) { SetFlag(0); m_towrite[m_itowrite++] = inBuffer[m_ind]; m_ind++; } else { SetFlag(1); if (len <= 6 && ofs <= 0xff) { SetFlag(0); SetFlagsL((byte)((len - 3)), 2); m_towrite[m_itowrite++] = (byte)ofs; m_ind += len; } else { SetFlag(1); UInt16 u16 = (UInt16)ofs; byte hi, lo; if (len <= 9) { u16 |= (UInt16)((len - 2) << 13); } hi = (byte)(u16 >> 8); lo = (byte)(u16 & 0xff); m_towrite[m_itowrite++] = hi; m_towrite[m_itowrite++] = lo; m_ind += len; if (len > 9) { if (len <= 25) { SetFlag(0); SetFlagsL((byte)((len - 10)), 4); } else { SetFlag(1); m_towrite[m_itowrite++] = (byte)(len - 0x1a); } } } } } flushflag(true); //Debug.WriteLine("Done"); if (progress != null) { progress(100); } }
public override bool Equals(object o) { if (!(o is ConversionProfile)) { return(false); } ConversionProfile v = o as ConversionProfile; if (!AttachmentPage.Equals(v.AttachmentPage)) { return(false); } if (!AutoSave.Equals(v.AutoSave)) { return(false); } if (!BackgroundPage.Equals(v.BackgroundPage)) { return(false); } if (!CoverPage.Equals(v.CoverPage)) { return(false); } if (!CustomScript.Equals(v.CustomScript)) { return(false); } if (!DropboxSettings.Equals(v.DropboxSettings)) { return(false); } if (!EmailClientSettings.Equals(v.EmailClientSettings)) { return(false); } if (!EmailSmtpSettings.Equals(v.EmailSmtpSettings)) { return(false); } if (!ForwardToFurtherProfile.Equals(v.ForwardToFurtherProfile)) { return(false); } if (!Ftp.Equals(v.Ftp)) { return(false); } if (!Ghostscript.Equals(v.Ghostscript)) { return(false); } if (!HttpSettings.Equals(v.HttpSettings)) { return(false); } if (!JpegSettings.Equals(v.JpegSettings)) { return(false); } if (!PdfSettings.Equals(v.PdfSettings)) { return(false); } if (!PngSettings.Equals(v.PngSettings)) { return(false); } if (!Printing.Equals(v.Printing)) { return(false); } if (!Properties.Equals(v.Properties)) { return(false); } if (!Scripting.Equals(v.Scripting)) { return(false); } if (!Stamping.Equals(v.Stamping)) { return(false); } if (!TextSettings.Equals(v.TextSettings)) { return(false); } if (!TiffSettings.Equals(v.TiffSettings)) { return(false); } if (!UserTokens.Equals(v.UserTokens)) { return(false); } if (!Watermark.Equals(v.Watermark)) { return(false); } if (!ActionOrder.SequenceEqual(v.ActionOrder)) { return(false); } if (!AuthorTemplate.Equals(v.AuthorTemplate)) { return(false); } if (!EnableWorkflowEditor.Equals(v.EnableWorkflowEditor)) { return(false); } if (!FileNameTemplate.Equals(v.FileNameTemplate)) { return(false); } if (!Guid.Equals(v.Guid)) { return(false); } if (!KeywordTemplate.Equals(v.KeywordTemplate)) { return(false); } if (!Name.Equals(v.Name)) { return(false); } if (!OpenViewer.Equals(v.OpenViewer)) { return(false); } if (!OpenWithPdfArchitect.Equals(v.OpenWithPdfArchitect)) { return(false); } if (!OutputFormat.Equals(v.OutputFormat)) { return(false); } if (!SaveFileTemporary.Equals(v.SaveFileTemporary)) { return(false); } if (!ShowAllNotifications.Equals(v.ShowAllNotifications)) { return(false); } if (!ShowOnlyErrorNotifications.Equals(v.ShowOnlyErrorNotifications)) { return(false); } if (!ShowProgress.Equals(v.ShowProgress)) { return(false); } if (!ShowQuickActions.Equals(v.ShowQuickActions)) { return(false); } if (!SkipPrintDialog.Equals(v.SkipPrintDialog)) { return(false); } if (!SubjectTemplate.Equals(v.SubjectTemplate)) { return(false); } if (!TargetDirectory.Equals(v.TargetDirectory)) { return(false); } if (!TitleTemplate.Equals(v.TitleTemplate)) { return(false); } return(true); }
/// <summary> /// 通过时间序列生成指定音轨/乐器的命令序列 /// </summary> /// <param name="timeLine">时间序列</param> /// <param name="trackName">音轨名(默认null)</param> /// <param name="instrumentName">乐器名(默认null)</param> /// <param name="version">游戏版本</param> /// <returns></returns> public CommandLine SerializeSpecified(TimeLine timeLine, string trackName = null, string instrumentName = null, bool waveLeft = true, bool waveRight = true, string version = "1.12", ShowProgress showProgress = null) { try { var commandLine = new CommandLine(); //List of Scoreboards var scoreboards = new List <string>(); //List of Entities var entities = new Dictionary <string, DescribeEntity>(); #region Head of TimeLine entities.Add("GenParam", new DescribeEntity() { Feature = "GenParam", Count = 1 }); bool hasGenParam = timeLine.OutPutTick || timeLine.OutPutBPM; scoreboards = Param2ScoreboardsList(timeLine.Param, scoreboards); foreach (string param in timeLine.Param.Keys) { if (timeLine.Param[param].Enable == true) { hasGenParam = true; commandLine.Start.Add(setCommand("GenParam", timeLine.Param[param].Name, timeLine.Param[param].Value, version)); } } if (timeLine.OutPutTick) { scoreboards.Add("CurrentTick"); } if (timeLine.OutPutBPM) { scoreboards.Add("CurrentBPM"); } #endregion #region Keyframes /* Set Total Progress */ this.totalProgress = timeLine.TickNodes.Count; //Command: var cmdExecute = "execute "; var cmdRelative = ""; var isrun = false; if (version == "1.13") { cmdExecute = "execute as "; cmdRelative = " at @s positioned"; isrun = true; } //Create Keyframes for (int c = 0; c < timeLine.TickNodes.Count; c++) { commandLine.Keyframe.Add(new Command()); } //Foreach Tick for (int i = 0; i < timeLine.TickNodes.Count; i++) { var tickNode = timeLine.TickNodes[i]; var midiNodes = tickNode.MidiTracks; var waveNodesL = tickNode.WaveNodesLeft; var waveNodesR = tickNode.WaveNodesRight; if (timeLine.OutPutTick) { commandLine.Keyframe[i].Commands.Add(setCommand("GenParam", "CurrentTick", i, version)); } #region Midi if (midiNodes.Count > 0 && !(trackName == null && instrumentName == null)) { foreach (string track in midiNodes.Keys) { if (trackName != track && trackName != null) { continue; } foreach (string instrument in midiNodes[track].Keys) { if (instrumentName != track && instrumentName != null) { continue; } var nodes = midiNodes[track][instrument]; for (int j = 0; j < nodes.Count; j++) { var node = nodes[j]; if (node.IsEvent == true) { if (timeLine.OutPutBPM) { commandLine.Keyframe[i].Commands.Add(setCommand("GenParam", "CurrentBPM", node.Param["BeatPerMinute"].Value, version)); } continue; } //Set Midi Tag var regex = new Regex("[^a-z^A-Z^0-9_]"); var TrackName = regex.Replace(node.TrackName, "_"); var Instrument = regex.Replace(node.Instrument, "_"); var _track = "t_" + TrackName; var _instrument = "i_" + Instrument; var feature = ((TrackName.Length > 5) ? TrackName.Substring(0, 5) : TrackName) + "_" + ((Instrument.Length > 5) ? Instrument.Substring(0, 5) : Instrument); //Add Command foreach (string k in node.Param.Keys) { if (node.Param[k].Enable) { //Update ScoreboardsList & EntitiesList if (entities.Keys.Contains(feature)) { if (j >= entities[feature].Count) { entities[feature].Count = j + 1; } } else { entities.Add(feature, new DescribeEntity() { Feature = feature, Instrument = _instrument, Track = _track, Count = 1 }); } scoreboards = Param2ScoreboardsList(node.Param, scoreboards); var f = feature + "_" + j; commandLine.Keyframe[i].Commands.Add(setCommand(f, node.Param[k].Name, node.Param[k].Value, version)); } } #region Playsound & Stopsound if (node.PlaySound.Enable && node.PlaySound.PlaySource != "" && node.PlaySound.PlaySource != null)//Enable Playsound { //PlaySound var playsound = node.PlaySound; //Set Expression var subName = InheritExpression.Expression(playsound.InheritExpression, node.Param["Pitch"].Value, node.Param["MinecraftTickDuration"].Value, node.Param["Velocity"].Value, node.Param["BarIndex"].Value, node.Param["BeatDuration"].Value, node.Param["Channel"].Value); var rxp = (playsound.SoundName != "" && subName != "") ? "." : ""; if (playsound.StopSound)//Enable Stopsound { var endtick = node.Param["MinecraftTickStart"].Value + node.Param["MinecraftTickDuration"].Value + node.PlaySound.ExtraDelay; if (endtick >= timeLine.TickNodes.Count) { var nowCount = commandLine.Keyframe.Count; for (int m = 0; m < endtick - nowCount + 1; m++) { commandLine.Keyframe.Add(new Command()); } } var command1 = cmdExecute + playsound.ExecuteTarget + cmdRelative + " ~ ~ ~ " + ((isrun) ? "run " : "") + "stopsound " + playsound.PlayTarget + " " + playsound.PlaySource + " " + playsound.SoundName + rxp + subName; for (int _t = node.Param["MinecraftTickStart"].Value + 1; _t < endtick; _t++)//Avoid Stopping Ahead { if (commandLine.Keyframe[_t].Commands.Contains(command1)) { commandLine.Keyframe[_t].Commands.Remove(command1); } } commandLine.Keyframe[endtick].Commands.Add(command1); } //Set Cood string cood = "~" + ((playsound.ExecuteCood[0] == 0) ? "" : playsound.ExecuteCood[0].ToString()) + " ~" + ((playsound.ExecuteCood[1] == 0) ? "" : playsound.ExecuteCood[1].ToString()) + " ~" + ((playsound.ExecuteCood[2] == 0) ? "" : playsound.ExecuteCood[2].ToString()); //Set Volume double vp = ((playsound.PercVolume < 0) ? (double)100 : (double)playsound.PercVolume) / 100; double manda_vol = (playsound.MandaVolume < 0) ? 1 : (double)playsound.MandaVolume / 100; var volume = (node.Param["Velocity"].Value * manda_vol * vp / 100 > 2) ? 2 : (node.Param["Velocity"].Value * manda_vol * vp / 100 < 0) ? 0 : (double)node.Param["Velocity"].Value * vp * manda_vol / 100; var command = cmdExecute + playsound.ExecuteTarget + cmdRelative + " ~ ~ ~ " + ((isrun) ? "run " : "") + "playsound " + playsound.SoundName + rxp + subName + " " + playsound.PlaySource + " " + playsound.PlayTarget + " " + cood + " " + volume + ((node.PlaySound.PitchPlayable) ? (" " + setPlaysoundPitch(node.Param["Pitch"].Value)) : ""); commandLine.Keyframe[i].Commands.Add(command); } #endregion } } } } #endregion #region Wave //Wave Left if (waveNodesL.Count > 0 && waveLeft == true) { for (int j = 0; j < waveNodesL.Count; j++) { var node = waveNodesL[j]; //Set Wave Tag var feature = "wave" + j.ToString() + "_l"; var param = node.Param; foreach (string k in node.Param.Keys) { for (int n = 0; n < node.Param[k].Count; n++) { if (node.Param[k][n].Enable) { //Update ScoreboardsList & EntitiesList if (!entities.Keys.Contains(feature)) { entities.Add(feature, new DescribeEntity() { Feature = feature, Count = node.Param[k].Count }); } if (param[k][n].Enable && !scoreboards.Contains(param[k][n].Name)) { scoreboards.Add(param[k][n].Name); } commandLine.Keyframe[i].Commands.Add(setCommand(feature + "_" + n, param[k][n].Name, param[k][n].Value, version)); } } } } } //Wave Right if (waveNodesR.Count > 0 && waveRight == true) { for (int j = 0; j < waveNodesR.Count; j++) { var node = waveNodesR[j]; //Set Wave Tag var feature = "wave" + j.ToString() + "_r"; var param = node.Param; foreach (string k in node.Param.Keys) { for (int n = 0; n < node.Param[k].Count; n++) { if (node.Param[k][n].Enable) { //Update ScoreboardsList & EntitiesList if (!entities.Keys.Contains(feature)) { entities.Add(feature, new DescribeEntity() { Feature = feature, Count = node.Param[k].Count }); } if (param[k][n].Enable && !scoreboards.Contains(param[k][n].Name)) { scoreboards.Add(param[k][n].Name); } commandLine.Keyframe[i].Commands.Add(setCommand(feature + "_" + n, param[k][n].Name, param[k][n].Value, version)); } } } } } #endregion /* Update Current Progress */ this.currentProgress++; if (showProgress != null && this.totalProgress > 0) { showProgress((double)this.currentProgress / this.totalProgress); } } #endregion #region End of Timeline foreach (var feature in entities.Keys) { var entity = entities[feature]; for (int m = 0; m < entity.Count; m++) { if (entity.Feature == "GenParam" && !hasGenParam) { continue; // No General Param } var tags = (entity.Feature == "GenParam") ? "GenParam" : entity.Feature + "_" + m + "," + entity.Track + "," + entity.Instrument; if (version == "1.12") { commandLine.Start.Insert(0, "summon area_effect_cloud ~ ~ ~ {Tags:[" + tags + ",AudioRiptideNode],Duration:" + (commandLine.Keyframe.Count * 10).ToString() + "}"); } else { commandLine.End.Add("scoreboard players reset " + entity.Feature + "_" + m); } } } foreach (var scoreboard in scoreboards) { commandLine.Start.Insert(0, "scoreboard objectives add " + scoreboard + " dummy"); commandLine.End.Add("scoreboard objectives remove " + scoreboard); } commandLine.End.Add("kill @e[tag=AudioRiptideNode]"); #endregion return(commandLine); } catch { return(null); } }
public static bool SignIn( ShowProgress progressCallback, ShowError errorCallback, RunPSCommand PSCallback) { if (CurrentState == SigninStates.SignedIn) { return(true); } try { Collection <string> results = PSCallback?.Invoke("az"); if (results == null || results.Count == 0) { errorCallback?.Invoke(Strings.AzureCLI); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Process.Start(new ProcessStartInfo("https://aka.ms/installazurecliwindows")); } else if (Environment.OSVersion.Platform == PlatformID.Unix) { "sudo apt-get update".Bash(); "sudo apt --assume-yes install curl".Bash(); "curl -sL -N https://aka.ms/InstallAzureCLIDeb | sudo bash".Bash(); } else { errorCallback?.Invoke(Strings.OSNotSupported); } return(false); } progressCallback?.Invoke(5, true); results = PSCallback?.Invoke("az login"); if (results == null || results.Count == 0) { errorCallback?.Invoke(Strings.LoginFailedAlertMessage); return(false); } // enumerate subscriptions Subscriptions.Clear(); for (int i = 0; i < results.Count; i++) { string json = results[i].ToString(); if (json.Contains("\"name\"")) { json = json.Substring(json.IndexOf(":")); json = json.Substring(json.IndexOf("\"") + 1); json = json.Substring(0, json.IndexOf("\"")); if (!json.Contains("@")) { Subscriptions.Add(json); } } } progressCallback?.Invoke(10, true); // install iot extension, if required PSCallback?.Invoke("az extension add --name azure-cli-iot-ext"); progressCallback?.Invoke(15, true); CurrentState = SigninStates.SignedIn; return(true); } catch (Exception ex) { errorCallback?.Invoke(Strings.LoginFailedAlertMessage + ": " + ex.Message); return(false); } }
public override void ProcessOnEncode(byte[] inBuffer, Stream outStream, int level = 16, ShowProgress progress = null) { FillTable(); BinaryWriter br = new BinaryWriter(outStream); br.Write(m_hfTableLen); for (int i = 0; i < m_hfTableLen; i++) { br.Write(m_hfTable[i]); } base.ProcessOnEncode(inBuffer, outStream, level, progress); FlushWrite(outStream); }
/// <summary> /// 通过Midi生成时间序列 /// </summary> /// <param name="fileName">Midi文件路径</param> /// <param name="timeLine">时间序列</param> /// <param name="rate">播放速率(New BPM = BPM * rate)</param> /// <returns>时间序列</returns> public TimeLine SerializeByRate(string fileName, TimeLine timeLine, double rate = -1, ShowProgress showProgress = null) { return(Serialize(fileName, timeLine, rate, -1, showProgress)); }
public override bool Equals(object o) { if (!(o is ConversionProfile)) { return(false); } var v = o as ConversionProfile; if (!AttachmentPage.Equals(v.AttachmentPage)) { return(false); } if (!AutoSave.Equals(v.AutoSave)) { return(false); } if (!BackgroundPage.Equals(v.BackgroundPage)) { return(false); } if (!CoverPage.Equals(v.CoverPage)) { return(false); } if (!EmailClient.Equals(v.EmailClient)) { return(false); } if (!EmailSmtp.Equals(v.EmailSmtp)) { return(false); } if (!Ftp.Equals(v.Ftp)) { return(false); } if (!Ghostscript.Equals(v.Ghostscript)) { return(false); } if (!JpegSettings.Equals(v.JpegSettings)) { return(false); } if (!PdfSettings.Equals(v.PdfSettings)) { return(false); } if (!PngSettings.Equals(v.PngSettings)) { return(false); } if (!Printing.Equals(v.Printing)) { return(false); } if (!Properties.Equals(v.Properties)) { return(false); } if (!SaveDialog.Equals(v.SaveDialog)) { return(false); } if (!Scripting.Equals(v.Scripting)) { return(false); } if (!Stamping.Equals(v.Stamping)) { return(false); } if (!TiffSettings.Equals(v.TiffSettings)) { return(false); } if (!AuthorTemplate.Equals(v.AuthorTemplate)) { return(false); } if (!FileNameTemplate.Equals(v.FileNameTemplate)) { return(false); } if (!Guid.Equals(v.Guid)) { return(false); } if (!Name.Equals(v.Name)) { return(false); } if (!OpenViewer.Equals(v.OpenViewer)) { return(false); } if (!OutputFormat.Equals(v.OutputFormat)) { return(false); } if (!ShowProgress.Equals(v.ShowProgress)) { return(false); } if (!SkipPrintDialog.Equals(v.SkipPrintDialog)) { return(false); } if (!TitleTemplate.Equals(v.TitleTemplate)) { return(false); } return(true); }
/// <summary> /// 通过Midi生成时间序列 /// </summary> /// <param name="fileName">Midi文件路径</param> /// <param name="timeLine">时间序列</param> /// <param name="rate">播放速率(New BPM = BPM * rate)</param> /// <param name="synchroTick">节奏间隔(MidiTick),设置此项后将忽略播放速率</param> /// <returns>时间序列</returns> public TimeLine Serialize(string fileName, TimeLine timeLine, double rate = -1, int synchroTick = -1, ShowProgress showProgress = null) { try { if (timeLine == null) { timeLine = new TimeLine(); } var midiFile = new MidiFile(fileName, false); #region HeadParam timeLine.Param["MidiFileFormat"].Value = midiFile.FileFormat; timeLine.Param["MidiTracksCount"].Value = midiFile.Tracks; timeLine.Param["MidiDeltaTicksPerQuarterNote"].Value = midiFile.DeltaTicksPerQuarterNote; #endregion #region Nodes //Public Event var timeSignature = midiFile.Events[0].OfType <TimeSignatureEvent>().FirstOrDefault(); double bpm = 0; timeLine.BeatsPerBar = timeSignature == null ? 4 : timeSignature.Numerator; timeLine.TicksPerBar = timeSignature == null ? midiFile.DeltaTicksPerQuarterNote * 4 : (timeSignature.Numerator * midiFile.DeltaTicksPerQuarterNote * 4) / (1 << timeSignature.Denominator); timeLine.TicksPerBeat = timeLine.TicksPerBar / timeLine.BeatsPerBar; #region MidiFile -> MidiNodes(Unordered) List <MidiNode> MidiNodes = new List <MidiNode>(); //Foreach Events in MidiFile for (int i = 0; i < midiFile.Tracks; i++) { //Track Events var track = ""; var instrument = ""; var vol = -1; var pan = -1; foreach (MidiEvent midiEvent in midiFile.Events[i]) { //Event BPM if (new Regex("(?<=SetTempo )\\d+(?=bpm \\(\\d+\\))").Match(midiEvent.ToString()).Success) { bpm = Int32.Parse(new Regex("(?<=SetTempo )\\d+(?=bpm \\(\\d+\\))").Match(midiEvent.ToString()).Value); if (rate > 0) { bpm *= rate; } MidiNodes.Add(new MidiNode() { IsEvent = true, Param = new Dictionary <string, _Node_INT>() { { "BeatPerMinute", new _Node_INT() { Value = (int)bpm } }, { "DeltaTickStart", new _Node_INT() { Value = midiEvent.DeltaTime } }, { "MinecraftTickStart", new _Node_INT() { Value = 0 } } } }); } //Event Track Name if (new Regex("(?<=SequenceTrackName ).+(?=$)").Match(midiEvent.ToString()).Success) { track = new Regex("(?<=SequenceTrackName ).+(?=$)").Match(midiEvent.ToString()).Value; } //Event Instrument Name if (new Regex("(?<=PatchChange Ch: \\d+ ).+(?=$)").Match(midiEvent.ToString()).Success) { instrument = new Regex("(?<=PatchChange Ch: \\d+ ).+(?=$)").Match(midiEvent.ToString()).Value; } //Event Track Volume if (new Regex("(?<=MainVolume Value )\\d*(?=$)").Match(midiEvent.ToString()).Success) { Int32.TryParse(new Regex("(?<=MainVolume Value )\\d*(?=$)").Match(midiEvent.ToString()).Value, out vol); } //Event Track Pan if (new Regex("(?<=Pan Value )\\d*(?=$)").Match(midiEvent.ToString()).Success) { Int32.TryParse(new Regex("(?<=Pan Value )\\d*(?=$)").Match(midiEvent.ToString()).Value, out pan); } if (!MidiEvent.IsNoteOff(midiEvent)) { //Get Param var MBT = GetMBT(midiEvent.AbsoluteTime, midiFile.DeltaTicksPerQuarterNote, timeSignature); var EventAnalysis = AnalysisEvent(midiEvent, instrument); //Write into MidiNodes if (EventAnalysis != null) { var MidiNode = new MidiNode(); #region Param //Time-related MidiNode.Param["DeltaTickStart"].Value = (int)EventAnalysis.StartTick; //MidiNode Starts Needs more Calculation MidiNode.Param["DeltaTickDuration"].Value = (int)EventAnalysis.Length; MidiNode.Param["MinecraftTickDuration"].Value = (int)MinecraftTickDuration(EventAnalysis.Length, midiFile.DeltaTicksPerQuarterNote, timeSignature, (int)bpm); MidiNode.Param["BeatPerMinute"].Value = (int)bpm; //Bar-related MidiNode.Param["BarIndex"].Value = (int)MBT[0]; MidiNode.Param["BeatDuration"].Value = (int)MBT[1]; //Note-related MidiNode.Param["Channel"].Value = (int)EventAnalysis.Channel; MidiNode.Param["Pitch"].Value = (int)EventAnalysis.Pitch; MidiNode.Param["Velocity"].Value = (int)EventAnalysis.Velocity; MidiNode.Param["Panning"].Value = pan; //Track-related MidiNode.Instrument = EventAnalysis.Instrument; MidiNode.TrackName = track; //PlaySound-related MidiNode.PlaySound = new PlaySoundInfo(); MidiNode.PlaySound.MandaVolume = (vol < 0) ? 100 : vol; MidiNode.PlaySound.SetPan(pan); //Generate Track & Instrument List var currentTrack = timeLine.TrackList.AsEnumerable().FirstOrDefault(t => t.Name == track); if (currentTrack == null) { currentTrack = new TimeLine.MidiSettingInspector { Name = track, Type = TimeLine.MidiSettingType.Track, Enable = true }; timeLine.TrackList.Add(currentTrack); } //Add new Track var currentInstrument = timeLine.InstrumentList.AsEnumerable().FirstOrDefault(ins => ins.Name == EventAnalysis.Instrument); if (currentInstrument == null) { currentInstrument = new TimeLine.MidiSettingInspector { Name = EventAnalysis.Instrument, Type = TimeLine.MidiSettingType.Instrument, Enable = true }; timeLine.InstrumentList.Add(currentInstrument); } //Add new Instrument if (!currentTrack.Instruments.Any(ins => ins.Name == EventAnalysis.Instrument)) { currentTrack.Instruments.Add(currentInstrument); currentTrack.InstrumentsUid.Add(currentInstrument.Uid); }//Line Track if (!currentInstrument.Tracks.Any(t => t.Name == track)) { currentInstrument.Tracks.Add(currentTrack); currentInstrument.TracksUid.Add(currentTrack.Uid); } #endregion MidiNodes.Add(MidiNode); } } } } #endregion #region MidiNodes in Order /* Set Total Progress */ timeLine.totalProgress = MidiNodes.Count * 2; bpm = 0; long bpm_key_t = 0; //When BPM Changes long bpm_key_mt = 0; MidiNodes = (from n in MidiNodes orderby n.Param["DeltaTickStart"].Value select n).ToList(); //Make Nodes in Order int synchroCount = 0; for (int i = 0; i < MidiNodes.Count; i++) //Calculate Tick Start { var n = MidiNodes[i]; if (n.IsEvent) { if (bpm != 0) { bpm_key_mt = MinecraftTickStart(n.Param["DeltaTickStart"].Value, midiFile.DeltaTicksPerQuarterNote, timeSignature, bpm, bpm_key_t, bpm_key_mt); } bpm = n.Param["BeatPerMinute"].Value; bpm_key_t = n.Param["DeltaTickStart"].Value; } else { n.Param["BeatPerMinute"].Value = (int)bpm; } if (synchroTick <= 0) { n.Param["MinecraftTickStart"].Value = (int)MinecraftTickStart(n.Param["DeltaTickStart"].Value, midiFile.DeltaTicksPerQuarterNote, timeSignature, bpm, bpm_key_t, bpm_key_mt); } else { //Using synchroTick n.Param["MinecraftTickStart"].Value = n.Param["DeltaTickStart"].Value / synchroTick; if (n.Param["DeltaTickStart"].Value % synchroTick == 0) { synchroCount++; } } /* Update Current Progress */ timeLine.currentProgress++; if (showProgress != null && timeLine.totalProgress > 0) { showProgress((double)timeLine.currentProgress / timeLine.totalProgress); } } timeLine.SynchronousRate = (double)synchroCount / MidiNodes.Count; #endregion #region MidiNodes -> TickNodes //Creat and Set Lenth of TickNodes if (timeLine.TickNodes == null) { timeLine.TickNodes = new List <TickNode>(); } var maxTick = MidiNodes.Max(n => n.Param["MinecraftTickStart"].Value); if (maxTick >= timeLine.TickNodes.Count) { var nowCount = timeLine.TickNodes.Count; for (int i = 0; i < maxTick - nowCount + 1; i++) { timeLine.TickNodes.Add(new TickNode()); } } //MidiNodes -> TickNodes foreach (MidiNode node in MidiNodes) { var index = node.Param["MinecraftTickStart"].Value; var track = node.TrackName; var instrument = node.Instrument; if (timeLine.TickNodes[index].MidiTracks.ContainsKey(track) == false) { timeLine.TickNodes[index].MidiTracks.Add(track, new Dictionary <string, List <MidiNode> >()); } if (timeLine.TickNodes[index].MidiTracks[track].ContainsKey(instrument) == false) { timeLine.TickNodes[index].MidiTracks[track].Add(instrument, new List <MidiNode>()); } timeLine.TickNodes[index].MidiTracks[track][instrument].Add(node); timeLine.TickNodes[index].BPM = node.Param["BeatPerMinute"].Value; timeLine.TickNodes[index].CurrentTick = index; /* Update Current Progress */ timeLine.currentProgress++; if (showProgress != null && timeLine.totalProgress > 0) { showProgress((double)timeLine.currentProgress / timeLine.totalProgress); } } #endregion timeLine.Param["TotalTicks"].Value = timeLine.TickNodes.Count; return(timeLine); //minecraft tick = AbsoluteTime / (bpm * ticksPerBeat) * 1200 #endregion } catch { return(null); } }
/// <summary> /// 通过Midi生成时间序列 /// </summary> /// <param name="fileName">Midi文件路径</param> /// <param name="timeLine">时间序列</param> /// <param name="synchroTick">节奏间隔(MidiTick)</param> /// <returns>时间序列</returns> public TimeLine SerializeByBeat(string fileName, TimeLine timeLine, int synchroTick = -1, ShowProgress showProgress = null) { return(Serialize(fileName, timeLine, -1, synchroTick, showProgress)); }
/// <summary> /// 通过波形生成时间序列 /// </summary> /// <param name="fileName">波形文件路径</param> /// <param name="timeLine">时间序列</param> /// <param name="fre_count">频率采样数</param> /// <param name="vol_count">振幅采样数</param> /// <param name="tick_cycle">采样周期</param> /// <returns>时间序列</returns> public TimeLine Serialize(string fileName, TimeLine timeLine, int fre_count = 1, int vol_count = 1, int tick_cycle = 1, ShowProgress showProgress = null) { try { //Read Waves var reader = new WaveFileReader(fileName); reader.Position = 0; #region WaveFile -> WaveNodes //Create WaveNodes var waveNodesL = new List <WaveNode>(); var waveNodesR = new List <WaveNode>(); float[] samplesL = new float[reader.Length / reader.BlockAlign]; float[] samplesR = new float[reader.Length / reader.BlockAlign]; //Get Time-related Param var Hz = (int)(samplesL.Length / reader.TotalTime.TotalSeconds); var FperTick = Hz / 20; var SampleCycle = FperTick * tick_cycle; var totalTick = samplesL.Length / FperTick; //Frequency & Peak int[] Fre = new int[] { /* left */ 0, /* right */ 0 }; float[] Peak = new float[] { /* left_min */ 0, /* right_min */ 0, /* left_max */ 0, /* right_max */ 0 }; #region Set Nodes' //Foreach Frequency & Peak in WaveFile int _temp = -1; /* Set Total Progress */ timeLine.totalProgress = samplesL.Length; for (int i = 0; i < samplesL.Length; i++) { //Get Sample float[] sample = reader.ReadNextSampleFrame(); samplesL[i] = sample[0]; //Mono - Right samplesR[i] = sample[1]; //Stereo - Left //Get Frequency & Peak if (i > 0) { //Get Frequency if (samplesL[i] * samplesL[i - 1] < 0) { Fre[0]++; } if (samplesR[i] * samplesR[i - 1] < 0) { Fre[1]++; } //Get Peak if (samplesL[i] < Peak[0]) { Peak[0] = samplesL[i]; } else if (samplesL[i] > Peak[1]) { Peak[1] = samplesL[i]; } if (samplesR[i] < Peak[2]) { Peak[2] = samplesR[i]; } else if (samplesR[i] > Peak[3]) { Peak[3] = samplesR[i]; } //Creat Objects int v = (i - 1) % SampleCycle; int g = (i - 1) % FperTick; int t = (i - 1) / FperTick; if (v == 0) { waveNodesL.Add(new WaveNode() { TickStart = t, IsLeft = true }); waveNodesR.Add(new WaveNode() { TickStart = t, IsLeft = false }); _temp = t; } else if (g == 0) { waveNodesL.Add(new WaveNode() { TickStart = t, IsLeft = true }); waveNodesR.Add(new WaveNode() { TickStart = t, IsLeft = false }); } //Write To Nodes float ft = (float)SampleCycle / fre_count; float vt = (float)SampleCycle / vol_count; if (v % ft < 1) { waveNodesL[_temp].Param["FrequencyPerTick"].Add(new _Node_INT() { Name = "Fre", Value = Fre[0] }); waveNodesR[_temp].Param["FrequencyPerTick"].Add(new _Node_INT() { Name = "Fre", Value = Fre[1] }); Fre[0] = 0; Fre[1] = 0; } if (v % vt < 1) { waveNodesL[_temp].Param["VolumePerTick"].Add(new _Node_INT() { Name = "Vol", Value = (int)((Peak[1] - Peak[0]) * 1000) }); waveNodesR[_temp].Param["VolumePerTick"].Add(new _Node_INT() { Name = "Vol", Value = (int)((Peak[3] - Peak[2]) * 1000) }); Peak[0] = 0; Peak[1] = 0; Peak[2] = 0; Peak[3] = 0; } } /* Update Current Progress */ timeLine.currentProgress++; if (showProgress != null && timeLine.totalProgress > 0) { showProgress((double)timeLine.currentProgress / timeLine.totalProgress); } } #endregion #endregion #region WaveNodes -> TickNodes //Creat and Set Lenth of TickNodes if (timeLine.TickNodes == null) { timeLine.TickNodes = new List <TickNode>(); } if (totalTick >= timeLine.TickNodes.Count) { var nowCount = timeLine.TickNodes.Count; for (int i = 0; i < totalTick - nowCount + 1; i++) { timeLine.TickNodes.Add(new TickNode()); } } //WaveNodes -> TickNodes foreach (WaveNode waveNodeL in waveNodesL) { if (timeLine.TickNodes[waveNodeL.TickStart].WaveNodesLeft == null) { timeLine.TickNodes[waveNodeL.TickStart].WaveNodesLeft = new List <WaveNode>(); } timeLine.TickNodes[waveNodeL.TickStart].WaveNodesLeft.Add(waveNodeL); } foreach (WaveNode waveNodeR in waveNodesR) { if (timeLine.TickNodes[waveNodeR.TickStart].WaveNodesRight == null) { timeLine.TickNodes[waveNodeR.TickStart].WaveNodesRight = new List <WaveNode>(); } timeLine.TickNodes[waveNodeR.TickStart].WaveNodesRight.Add(waveNodeR); } #endregion timeLine.Param["TotalTicks"].Value = timeLine.TickNodes.Count; return(timeLine); } catch { return(null); } }
/// <summary>Upload files from the named path via FTP to the internet.</summary> public static void UploadFiles(string uploadMethod, string uploadSite, string username, string password, string localPath, List <Holder> selected, ShowProgress progress = null) { string url = uploadMethod + "://" + uploadSite; if (url.Last() != '/') { url += '/'; } Cursor.Current = Cursors.WaitCursor; try { using (WebClient client = new WebClient()) { client.Credentials = new NetworkCredential(username.Normalize(), password.Normalize()); UploadFile(client, url, localPath, "index.html"); for (int h = 0; h < selected.Count; h++) { string key = selected[h].Key; DirectoryInfo di = new DirectoryInfo(Path.Combine(localPath, key)); // Create a directory on FTP site: // WebRequest wr = WebRequest.Create(url + key); // wr.Method = WebRequestMethods.Ftp.MakeDirectory; // wr.Credentials = client.Credentials; // wr.GetResponse(); FileInfo[] files = di.GetFiles("*.html"); for (int i = 0; i < files.Count(); i++) { UploadFile(client, url, Path.Combine(localPath, key), files[i].Name); progress?.Invoke((1.0 * i / files.Count() + h) / selected.Count, "Uploaded " + files[i].Name); } } } } catch (WebException we) { MessageBox.Show(we.Message, we.Status.ToString()); } finally { Cursor.Current = Cursors.Default; } }