public ActionResult BuscarCatPorID(string CatID) { try { CAT oCat = CatBusiness.Consulta.FirstOrDefault(p => p.UniqueKey.Equals(BuscarCatPorID(CatID))); if (oCat == null) { return(Json(new { resultado = new RetornoJSON() { Alerta = "Cat não encontrado." } })); } else { return(Json(new { data = RenderRazorViewToString("_Detalhes", oCat) })); } } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } }
/// ======================================================================================================= public static string WavPlay(string wav_path, string form_alias = "") { CAT.InteractiveAddNamedOverlay("WAVPLAY", "Preparing for play of " + wav_path); string returnvalue = ""; string path = API.DISK.AutoAddBaseDirectory(API.DISK.AutoAddExt(wav_path, ".wav")); DateTime starttime = DateTime.Now; if (!File.Exists(path)) { string err = "Error: Could not find file '" + path + "'"; CAT.InteractiveUpdateNamedOverlay("WAVPLAY", err, CAT.Status.FAIL); return(err); } string name = "p" + CircularBufer; CircularBufer++; mciSendString("open " + path + " type waveaudio alias " + name, null, 0, 0); mciSendString("play " + name, null, 0, 0); returnvalue += "Load time is " + (DateTime.Now - starttime).TotalMilliseconds + "ms. "; mciSendString("play " + name + " notify", null, 0, 0); StringBuilder sb = new StringBuilder(128); mciSendString("status " + name + " length", sb, 128, 0); string newsb = sb.ToString(); ulong songlength = Convert.ToUInt64(sb.ToString()); CAT.FormAccess(CAT.FormDelegates.SetLength, new object[] { songlength }, form_alias); returnvalue += "Length is " + songlength + "ms. "; ulong position = 0; while (!CAT.AbortAll && !CAT.AbortCurrent && position < songlength) { Thread.Sleep(1); // 1 ms resolution - frees up CPU mciSendString("status " + name + " position", sb, 128, 0); newsb = sb.ToString(); position = Convert.ToUInt64(sb.ToString()); CAT.InteractiveUpdateNamedOverlay("WAVPLAY", "Playing " + path + " " + position + @"/" + songlength + "ms", CAT.Status.BUSY); if (SetPos) { SetPos = false; double pos = (double)CAT.FormAccess(CAT.FormDelegates.GetPosTrackBar, null, form_alias) * songlength; mciSendString("seek " + name + " to " + (int)(pos), null, 0, 0); mciSendString("play " + name + " notify", null, 0, 0); } else { CAT.FormAccess(CAT.FormDelegates.SetPosTrackBar, new object[] { ((double)position / songlength) }, form_alias); } if (Restarter) { Restarter = false; mciSendString("seek " + name + " to start", sb, 128, 0); mciSendString("play " + name + " notify", null, 0, 0); } } mciSendString("close " + name, null, 0, 0); return(returnvalue); }
public PersonTests() { _catWithLinkedCustomer = new CAT("CAT teste com clientes vinculados LTDA", "CAT teste com clientes vinculados", "31933945000190"); _customerWithLinkedAccess = new Customer("Cliente teste com acessos vinculados LTDA", "Cliente teste com acessos vinculados", "26529560000121", _catWithLinkedCustomer.Id); _access = new Access("Acesso teste", "Descrição do acesso", _customerWithLinkedAccess.Id); _customerWithLinkedAccess.AddAccess(_access); _catWithLinkedCustomer.AddCustomer(_customerWithLinkedAccess); _catWithoutLinkedCustomer = new CAT("CAT teste sem clientes vinculados LTDA", "CAT teste sem clientes vinculados", "89017222000120"); _customerWithoutLinkedAccess = new Customer("Cliente teste sem acessos vinculados LTDA", "Cliente teste sem acessos vinculados", "26529560000121", Guid.NewGuid()); }
private void ExtractValues(string elementName, XmlReader reader) { for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); string name = reader.Name; string value = reader.Value; if (SRC.Equals(name)) { this.src = value; } else if (CAT.Equals(name)) { this.category = value; } else if (FILL.Equals(name)) { this.fill.Color = XmlUtils.GetColor(value); } else if (STROKE.Equals(name)) { this.stroke.Color = XmlUtils.GetColor(value); } else if (SYMBOL_HEIGHT.Equals(name)) { this.height = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else if (SYMBOL_PERCENT.Equals(name)) { this.percent = XmlUtils.ParseNonNegativeInteger(name, value); } else if (SYMBOL_SCALING.Equals(name)) { this.scaling = FromValue(value); } else if (SYMBOL_WIDTH.Equals(name)) { this.width = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else if (STROKE_WIDTH.Equals(name)) { this.strokeWidth = XmlUtils.ParseNonNegativeFloat(name, value) * displayModel.ScaleFactor; } else { throw XmlUtils.CreateXmlReaderException(elementName, name, value, i); } } }
private void ExtractValues(string elementName, XmlReader reader) { for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); string name = reader.Name; string value = reader.Value; if (SRC.Equals(name)) { this.src = value; } else if (CAT.Equals(name)) { this.category = value; } else if (DISPLAY.Equals(name)) { this.display = Display.FromString(value); } else if (ID.Equals(name)) { this.id = value; } else if (PRIORITY.Equals(name)) { this.priority = int.Parse(value); } else if (SYMBOL_HEIGHT.Equals(name)) { this.height = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else if (SYMBOL_PERCENT.Equals(name)) { this.percent = XmlUtils.ParseNonNegativeInteger(name, value); } else if (SYMBOL_SCALING.Equals(name)) { this.scaling = FromValue(value); } else if (SYMBOL_WIDTH.Equals(name)) { this.width = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else { throw XmlUtils.CreateXmlReaderException(elementName, name, value, i); } } }
public ActionResult TerminarComRedirect(string IdCat) { try { CAT oCat = CatBusiness.Consulta.FirstOrDefault(p => p.UniqueKey.Equals(IdCat)); if (oCat == null) { return(Json(new { resultado = new RetornoJSON() { Erro = "Não foi possível excluir esta codificação, pois a mesma não foi localizada." } })); } else { oCat.DataExclusao = DateTime.Now; oCat.UsuarioExclusao = "LoginTeste"; CatBusiness.Alterar(oCat); TempData["MensagemSucessoTerminar"] = "A codificação foi foi excluída com sucesso."; return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "EmpProprio") } })); } } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } }
public ActionResult Terminar(string IdCat) { try { CAT oCat = CatBusiness.Consulta.FirstOrDefault(p => p.UniqueKey.Equals(IdCat)); if (oCat == null) { return(Json(new { resultado = new RetornoJSON() { Erro = "Não foi possível excluir a CAT, pois a mesma não foi localizado." } })); } else { oCat.DataExclusao = DateTime.Now; oCat.UsuarioExclusao = "LoginTeste"; CatBusiness.Alterar(oCat); return(Json(new { resultado = new RetornoJSON() { Sucesso = "Esta Cat foi excluído com sucesso." } })); } } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } }
public ICommandResult Handler(CreateCATCommand command) { command.Validate(); if (!command.IsValid) { return(new GenericCommandResult(false, "Ops! Operação não pode ser realizada. Cheque as informações retornadas.", command.Notifications)); } //Validar se cnpj esta vinculado a outro CAT if (_repository.Search(x => x.CNPJ == command.CNPJ).Any()) { return(new GenericCommandResult(false, "Já existe um CAT com este CNPJ", null)); } var cat = new CAT(command.CompanyName, command.FantasyName, command.CNPJ); _repository.Create(cat); return(new GenericCommandResult(true, "CAT cadastrado!", cat)); }
private void ExtractValues(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader) { for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); string name = reader.Name; string value = reader.Value; if (RADIUS.Equals(name) || (XmlUtils.supportOlderRenderThemes && R.Equals(name))) { this.radius = Convert.ToSingle(XmlUtils.ParseNonNegativeFloat(name, value)) * displayModel.ScaleFactor; } else if (SCALE_RADIUS.Equals(name)) { this.scaleRadius = bool.Parse(value); } else if (CAT.Equals(name)) { this.category = value; } else if (FILL.Equals(name)) { this.fill.Color = XmlUtils.GetColor(value); } else if (STROKE.Equals(name)) { this.stroke.Color = XmlUtils.GetColor(value); } else if (STROKE_WIDTH.Equals(name)) { this.strokeWidth = XmlUtils.ParseNonNegativeFloat(name, value) * displayModel.ScaleFactor; } else { throw XmlUtils.CreateXmlReaderException(elementName, name, value, i); } } XmlUtils.CheckMandatoryAttribute(elementName, RADIUS, this.radius); }
// Utilities /// ======================================================================================================= static void WAVInteractivePlay(string input, string folder = "") { foreach (string filename in input.Split(';')) { string updatedfilename = filename; if (!File.Exists(updatedfilename) && !filename.Contains(".wav")) { updatedfilename = filename + ".wav"; } if (!File.Exists(updatedfilename)) { updatedfilename = folder + @"\" + updatedfilename; } bool exists = File.Exists(updatedfilename); CAT.InteractiveAddOverlay(updatedfilename + " exists:" + exists, exists ? API.CAT.Status.PASS : API.CAT.Status.FAIL); if (exists) { new Thread(() => WavPlay(updatedfilename)).Start(); } } }
public void CommandCheck() { Input = Input.ToLower(); if (Input.StartsWith("ls")) { LS.Options(Input); } else if (Input.StartsWith("cat")) { CAT.Options(Input); } else if (Input.StartsWith("os")) { OS.Options(Input); } else if (Input.StartsWith("help")) { new HELP(); } else if (Input.StartsWith("system")) { SYSTEM.Options(Input); } else if (Input.StartsWith("process")) { PROCESSES.Options(Input); } else if (Input.StartsWith("open")) { OPEN.Options(Input); } else if (Input == "exit") { Environment.Exit(0); } else { Console.WriteLine("Non-existent command"); } }
public ActionResult Atualizar(CAT TCat) { if (ModelState.IsValid) { try { CatBusiness.Alterar(TCat); TempData["MensagemSucessoCatAtulizado"] = "A CAT foi atualizado com sucesso."; return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Registro") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
public ActionResult Cadastrar(CAT Cat) { if (ModelState.IsValid) { try { CatBusiness.Inserir(Cat); TempData["MensagemSucessoCat"] = "A codificação da Cat foi cadastrada com sucesso."; return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Registro") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
private void ExtractValues(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader) { FontFamily fontFamily = FontFamily.Default; FontStyle fontStyle = FontStyle.Normal; for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); string name = reader.Name; string value = reader.Value; if (K.Equals(name)) { this.textKey = TextKey.getInstance(value); } else if (POSITION.Equals(name)) { this.position = value.ToPosition(); } else if (CAT.Equals(name)) { this.category = value; } else if (DISPLAY.Equals(name)) { this.display = value.ToDisplay(); } else if (DY.Equals(name)) { this.dy = float.Parse(value) * displayModel.ScaleFactor; } else if (FONT_FAMILY.Equals(name)) { fontFamily = value.ToFontFamily(); } else if (FONT_STYLE.Equals(name)) { fontStyle = value.ToFontStyle(); } else if (FONT_SIZE.Equals(name)) { this.fontSize = XmlUtils.ParseNonNegativeFloat(name, value) * displayModel.ScaleFactor; } else if (FILL.Equals(name)) { this.fill.Color = XmlUtils.GetColor(value); } else if (PRIORITY.Equals(name)) { this.priority = int.Parse(value); } else if (STROKE.Equals(name)) { this.stroke.Color = XmlUtils.GetColor(value); } else if (STROKE_WIDTH.Equals(name)) { this.stroke.StrokeWidth = XmlUtils.ParseNonNegativeFloat(name, value) * displayModel.ScaleFactor; } else if (SYMBOL_ID.Equals(name)) { this.symbolId = value; } else { throw XmlUtils.CreateXmlReaderException(elementName, name, value, i); } } this.fill.SetTypeface(fontFamily, fontStyle); this.stroke.SetTypeface(fontFamily, fontStyle); XmlUtils.CheckMandatoryAttribute(elementName, K, this.textKey); }
private void ExtractValues(string elementName, XmlReader reader) { this.repeatGap = REPEAT_GAP_DEFAULT * displayModel.ScaleFactor; this.repeatStart = REPEAT_START_DEFAULT * displayModel.ScaleFactor; for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); string name = reader.Name; string value = reader.Value; if (SRC.Equals(name)) { this.src = value; } else if (DISPLAY.Equals(name)) { this.display = Display.FromString(value); } else if (DY.Equals(name)) { this.dy = float.Parse(value) * displayModel.ScaleFactor; } else if (ALIGN_CENTER.Equals(name)) { this.alignCenter = bool.Parse(value); } else if (CAT.Equals(name)) { this.category = value; } else if (PRIORITY.Equals(name)) { this.priority = int.Parse(value); } else if (REPEAT.Equals(name)) { this.repeat = bool.Parse(value); } else if (REPEAT_GAP.Equals(name)) { this.repeatGap = float.Parse(value) * displayModel.ScaleFactor; } else if (REPEAT_START.Equals(name)) { this.repeatStart = float.Parse(value) * displayModel.ScaleFactor; } else if (ROTATE.Equals(name)) { this.rotate = bool.Parse(value); } else if (SYMBOL_HEIGHT.Equals(name)) { this.height = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else if (SYMBOL_PERCENT.Equals(name)) { this.percent = XmlUtils.ParseNonNegativeInteger(name, value); } else if (SYMBOL_SCALING.Equals(name)) { this.scaling = FromValue(value); } else if (SYMBOL_WIDTH.Equals(name)) { this.width = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else { throw XmlUtils.CreateXmlReaderException(elementName, name, value, i); } } }
/// ======================================================================================================= public static Return BUILD(string source_path, string timebase_ms, string resolution, string output_folder) { CAT.InteractiveAddNamedOverlay("WAVBUILD", "Preparing for build of " + source_path); string sourcepath = DISK.AutoAddExt(source_path, ".txt"); string[] sourcelines = File.ReadAllLines(DISK.AutoAddBaseDirectory(sourcepath)); DateTime starttime = DateTime.Now; WAVFormat masterfmt = new WAVFormat(2, 96000, 3); // Ideal format double timebase = string.IsNullOrWhiteSpace(timebase_ms) ? 250 : Convert.ToDouble(timebase_ms); int res = string.IsNullOrWhiteSpace(resolution) ? 32 : Convert.ToInt16(resolution); int totaltimems = res == 1 ? Convert.ToInt32(timebase * res) : Convert.ToInt32(timebase * res) + 5000; // 5 seconds decay uint masterdatasize = ConvertMsToNumberOfBytes(Convert.ToUInt32(totaltimems), masterfmt); byte[] masteralldata = CreateBlankWave(Convert.ToUInt32(totaltimems), masterfmt); int masterstartofdata = GetStartOfDataIndex(masteralldata); uint masterlocation = 0; int rowcount = 0; int rowmax = sourcelines.Length / 2; CAT.InteractiveUpdateNamedOverlay("WAVBUILD", "Starting build of " + source_path); for (int linenumber = 0; linenumber < sourcelines.Length - 1; linenumber += 2) { rowcount++; string files; byte[] newalldata; double volumeleft = 1.0; double volumeright = 1.0; if (sourcelines[linenumber].Contains("\t")) { files = sourcelines[linenumber].Split('\t')[0]; try { string volstring = sourcelines[linenumber].Split('\t')[1]; if (volstring.Contains(";")) { volumeleft = Convert.ToDouble(volstring.Split(';')[0]); volumeright = Convert.ToDouble(volstring.Split(';')[1]); } else if (volstring.Contains(":")) { volumeleft = Convert.ToDouble(volstring.Split(':')[0]); volumeright = Convert.ToDouble(volstring.Split(':')[1]); } else { volumeleft = Convert.ToDouble(volstring); volumeright = Convert.ToDouble(volstring); } } catch { /* use default */ } } else { files = sourcelines[linenumber]; } int filecount = 0; foreach (string filename in files.Split(';')) { filecount++; string updatedfilename = filename; if (!filename.Contains(".wav")) { updatedfilename = filename + ".wav"; } // Auto add extension if (!File.Exists(updatedfilename)) { updatedfilename = output_folder + @"\" + updatedfilename; } // auto add output folder if (File.Exists(updatedfilename)) { newalldata = File.ReadAllBytes(updatedfilename); WAVFormat newfmt = ReadFormat(newalldata); int newstartofdata = GetStartOfDataIndex(newalldata); int newdatasize = newalldata.Length - newstartofdata; byte[] newdata = new byte[newdatasize]; Array.Copy(newalldata, newstartofdata, newdata, 0, newdatasize); // copy data - only data is used from new file (header is discarded) string argument = sourcelines[linenumber + 1]; if (!string.IsNullOrWhiteSpace(argument)) { string[] arguments = argument.Split(','); int locationcount = 0; foreach (string location in arguments) { locationcount++; uint locationtouse = Convert.ToUInt32(Convert.ToDouble(location)); if (location.Contains("+")) { masterlocation += locationtouse; } else { masterlocation = locationtouse; } string currentbuilditem = " (row:" + rowcount + @"/" + rowmax + " file:" + filecount + @"/" + files.Split(';').Length + " location:" + locationcount + @"/" + arguments.Length + ")"; CAT.InteractiveUpdateNamedOverlay("WAVBUILD", source_path + ": Adding " + updatedfilename + " at " + masterlocation + currentbuilditem, API.CAT.Status.PASS); uint masteroffset = ConvertMsToNumberOfBytes(masterlocation, masterfmt); bool isleft = true; // Scroll through each of the new data indeces for (int newindex = 0; newindex < newdatasize - (int)newfmt.ByteDepth; newindex += (int)(newfmt.NumberOfChannels * newfmt.ByteDepth)) { double masterkhz = ((ulong)masterfmt.ByteDepth * (ulong)masterfmt.NumberOfChannels * (ulong)masterfmt.SampleRate) / 1000.0; double newkhz = ((ulong)newfmt.ByteDepth * (ulong)newfmt.NumberOfChannels * (ulong)newfmt.SampleRate) / 1000.0; double ratio = masterkhz / newkhz; int masterindex = (int)(newindex * ratio); if (masterindex + masteroffset < masterdatasize) { // Scroll to (left channel) sample start byte while ((masterindex + masteroffset) % (masterfmt.NumberOfChannels * masterfmt.ByteDepth) != 0) { masterindex--; } for (int i = 0; i < newfmt.NumberOfChannels; i++) { for (int j = 0; j < (int)Math.Ceiling((double)(masterfmt.SampleRate / newfmt.SampleRate)); j++) // Fill in gaps { int mastersamplelocation = masterstartofdata + (int)masteroffset + masterindex + i * (int)masterfmt.ByteDepth + j * ((int)masterfmt.NumberOfChannels * (int)masterfmt.ByteDepth); int mastersample = Deserialise(masteralldata, mastersamplelocation, (int)masterfmt.ByteDepth); int newsample = Deserialise(newdata, newindex + i * (int)newfmt.ByteDepth, (int)newfmt.ByteDepth); double masternorm = Normalise(mastersample, (int)masterfmt.ByteDepth); double volume = isleft ? volumeleft : volumeright; isleft = !isleft; double combined = (masternorm + volume * Normalise(newsample, (int)newfmt.ByteDepth)); // Limiting proved highly effective if (combined > 0.499999) { combined = 0.499999; // returndata += "Clip (positive) detected at " + ConvertNumberOfBytesToMs((uint)j, newfmt); } if (combined < -0.499999) { combined = -0.499999; // returndata += "Clip (negative) detected at " + ConvertNumberOfBytesToMs((uint)j, newfmt); } Serialise(ref masteralldata, mastersamplelocation, Denormalise(combined, (int)masterfmt.ByteDepth), (int)masterfmt.ByteDepth); // Copy to both channels if (newfmt.NumberOfChannels == 1) { Serialise(ref masteralldata, masterstartofdata + (int)masteroffset + masterindex + (int)masterfmt.ByteDepth, Denormalise(combined, (int)masterfmt.ByteDepth), (int)masterfmt.ByteDepth); } } } } } } } else { CAT.InteractiveAddOverlay(updatedfilename + " ignored - no times specified", API.CAT.Status.WARN); } } else { CAT.InteractiveAddOverlay(updatedfilename + " does not exist... continued", API.CAT.Status.FAIL); } } } if (!Directory.Exists(output_folder)) { Directory.CreateDirectory(output_folder); CAT.InteractiveAddOverlay("Created " + output_folder + " directory", API.CAT.Status.WARN); } try { string outputfilename = output_folder + "\\" + Path.GetFileNameWithoutExtension(sourcepath) + ".wav"; File.WriteAllBytes(outputfilename, masteralldata); CAT.InteractiveAddOverlay("Built " + outputfilename, API.CAT.Status.PASS); CAT.InteractiveAddOverlay("Build time " + (DateTime.Now - starttime).TotalMilliseconds + "ms", API.CAT.Status.INFO); } catch (Exception e) { CAT.InteractiveAddOverlay("Failed build:\r\n" + API.CAT.ErrorMsg(e), API.CAT.Status.FAIL); } return(new Return("Done")); }
public static API.Return WAV_GRAPH(string path, string start_ms, string end_ms, string timebase_ms) { int reduction = 10; // Note this is adequate for reporting and fourier transforms path = API.DISK.AutoAddExt(path, ".wav"); List <CATMessage> cm = new List <CATMessage>(); if (File.Exists(path)) { byte[] alldata = File.ReadAllBytes(path); WAVFormat fmt = ReadFormat(alldata); int startofdata = GetStartOfDataIndex(alldata); uint start = 0; uint end = fmt.Length; uint timebasems = 1000; try { start = string.IsNullOrWhiteSpace(start_ms) ? 0 : ConvertMsToNumberOfBytes(Convert.ToUInt32(start_ms), fmt); } catch (Exception e) { cm.Add(new CATMessage(CAT.ErrorMsg(e), CAT.Status.FAIL)); } try { end = string.IsNullOrWhiteSpace(end_ms) ? fmt.Length : ConvertMsToNumberOfBytes((Convert.ToUInt32(end_ms)), fmt); } catch (Exception e) { cm.Add(new CATMessage(CAT.ErrorMsg(e), CAT.Status.FAIL)); } try { timebasems = string.IsNullOrWhiteSpace(timebase_ms) ? 1000 : Convert.ToUInt32(Convert.ToDouble(timebase_ms)); } catch (Exception e) { cm.Add(new CATMessage(CAT.ErrorMsg(e), CAT.Status.FAIL)); } cm.Add(new CATMessage("Start:" + ConvertNumberOfBytesToMs(start, fmt) + "ms End:" + ConvertNumberOfBytesToMs(end, fmt) + "ms Timebase:" + timebasems, CAT.Status.INFO)); byte[] newdata = new byte[end - start]; Array.Copy(alldata, startofdata + start, newdata, 0, end - start); List <List <API.Xy> > timewaves = BytesToWave(newdata, fmt, reduction); List <API.ChartData> allcharts = new List <API.ChartData> { new API.ChartData(timewaves, new API.TimeData(timebasems), path) }; return(new API.Return(allcharts, cm)); } return(new Return(new CATMessage(path + " does not exist or has issues"))); }
/// ======================================================================================================= public static Control COMPOSE(string source_path, string timebase_ms, string resolution, string output_folder) { int numlines = 1; string[] sourcelines = null; string sourcepath = API.DISK.AutoAddExt(source_path, ".txt"); // Auto add format extension if (File.Exists(sourcepath)) { sourcelines = File.ReadAllLines(sourcepath); int num = sourcelines.Length; while (num % 2 != 0) { num++; } numlines = (int)Math.Round(num / 2.0); // Rounds } else { // Build Example to use File.WriteAllText(sourcepath, "Example1.wav\t1\r\n0," + timebase_ms + "\r\n" + output_folder + @"\Example2" + "\r\n0"); Thread.Sleep(1000); sourcelines = File.ReadAllLines(sourcepath); API.CAT.AddOverlay(API.CAT.InteractiveControlsFormName, "File did not exist so created example for " + sourcepath); } double timebasems = string.IsNullOrWhiteSpace(timebase_ms) ? 250 : Convert.ToDouble(timebase_ms); int res = string.IsNullOrWhiteSpace(resolution) ? 32 : Convert.ToInt16(resolution); string outputpath = output_folder + (output_folder.Last() == '\\' ? "" : @"\") + Path.GetFileNameWithoutExtension(sourcepath) + ".wav"; // Load data API.CAT.Status status = File.Exists(outputpath) ? API.CAT.Status.PASS : API.CAT.Status.FAIL; GroupBox gb = API.CAT.GetGroupBox("Source:" + sourcepath + " Timebase:" + timebasems + "ms Resolution:" + res + " Output:" + outputpath, status); // Main Menu int menuleft = 0; Label startpos = API.CAT.GetLabel("1", status, "StartPos", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(startpos); menuleft += MENU_ITEM_WIDTH; TrackBar starttb = CAT.GetTrackBar("1", 1, 1, res, "StartTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; starttb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("Start position updated", API.CAT.Status.WARN); startpos.Text = starttb.Value.ToString(); }); gb.Controls.Add(starttb); Label endpos = API.CAT.GetLabel(res.ToString(), status, "EndPos", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(endpos); menuleft += MENU_ITEM_WIDTH; TrackBar endtb = CAT.GetTrackBar(res.ToString(), 1, res, res, "EndTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; endtb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("End position updated", API.CAT.Status.WARN); endpos.Text = endtb.Value.ToString(); }); gb.Controls.Add(endtb); Label timebaser = API.CAT.GetLabel("1", status, "Timebaser", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(timebaser); menuleft += MENU_ITEM_WIDTH; TrackBar timebasertb = CAT.GetTrackBar("1", 1, 32, 64, "TimebaserTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; timebasertb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("Timebase updated", API.CAT.Status.WARN); double value = timebasertb.Value < 32 ? ((double)(1.0 / (32.0 - timebasertb.Value + 1))) : (timebasertb.Value - 32.0 + 1.0); timebaser.Text = value.ToString(); }); gb.Controls.Add(timebasertb); Label scaler = API.CAT.GetLabel("1", status, "Scaler", DockStyle.None, menuleft, MENU_TOP, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, autosize: false); gb.Controls.Add(scaler); menuleft += MENU_ITEM_WIDTH; TrackBar scalertb = CAT.GetTrackBar("1", 1, 32, 64, "ScalarTrackBar", Orientation.Horizontal, CAT.Status.BUSY, DockStyle.None, menuleft, MENU_TOP, MENU_TRACKBAR_WIDTH, MENU_ITEM_HEIGHT); menuleft += MENU_TRACKBAR_WIDTH; scalertb.ValueChanged += new EventHandler((object o, EventArgs e) => { CAT.InteractiveAddOverlay("Vertical scale updated", API.CAT.Status.WARN); double value = scalertb.Value < 32 ? ((double)(1.0 / (32.0 - scalertb.Value + 1))) : (scalertb.Value - 32.0 + 1.0); scaler.Text = value.ToString(); }); gb.Controls.Add(scalertb); AddItem(ref gb, "♫", () => WAVInteractivePlay(outputpath), status, ref menuleft); AddItem(ref gb, "۞", () => { BUILD(source_path, timebase_ms, resolution, output_folder); GroupBox newgb = (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder); CAT.InteractiveUpdate(gb.Name, newgb); }, status, ref menuleft); AddItem(ref gb, "<", () => Save(sourcepath, res, timebasems, gb, numlines), status, ref menuleft, true); AddItem(ref gb, "+", () => { Save(sourcepath, res, timebasems, gb, numlines + 1); GroupBox newgb = (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder); CAT.InteractiveUpdate(gb.Name, newgb); }, status, ref menuleft); AddItem(ref gb, "$", () => CAT.InteractiveShowReport(() => GraphItem(outputpath, "", (timebasems * Convert.ToDouble(timebaser.Text)).ToString(), (timebasems * Convert.ToDouble(timebaser.Text) * (Convert.ToInt16(startpos.Text) - 1)).ToString(), (timebasems * Convert.ToDouble(timebaser.Text) * Convert.ToInt16(endpos.Text)).ToString()), Convert.ToDouble(scaler.Text)), status, ref menuleft, true); AddItem(ref gb, "h", () => CAT.InteractiveShowReport(() => GraphItems(sourcepath, output_folder, (timebasems * Convert.ToDouble(timebaser.Text)).ToString()), Convert.ToDouble(scaler.Text)), status, ref menuleft, true); // Rows int row = 0; for (int line = 0; line < numlines * 2 - 1; line += 2) { Color rowcolor = LightColorMap[row % LightColorMap.Length]; row++; int rowtop = (row - 1) * ROW_HEIGHT + MENU_ITEM_HEIGHT + MENU_TOP + 2; int colpos = 0; string filestouse = sourcelines[line].Split('\t')[0]; string pathname = PathName(row); /*Play*/ AddRowButton(ref gb, "♪", "Play" + row, () => WAVInteractivePlay(((TextBox)gb.Controls.Find(pathname, true)[0]).Text, output_folder), rowcolor, ROW_PLAY_WIDTH, colpos, rowtop, false); colpos += ROW_PLAY_WIDTH; /*Path*/ gb.Controls.Add(API.CAT.GetTextBox(filestouse, PathName(row), rowcolor, height: ROW_HEIGHT, width: ROW_PATH_WIDTH, autosize: false, left: colpos, top: rowtop)); colpos += ROW_PATH_WIDTH; /*Vol*/ gb.Controls.Add(API.CAT.GetTextBox(sourcelines[line].Contains("\t") ? sourcelines[line].Split('\t')[1] : "", VolName(row), rowcolor, height: ROW_HEIGHT, width: ROW_VOL_WIDTH, autosize: false, left: colpos, top: rowtop)); colpos += ROW_VOL_WIDTH; // Row Delete Row Button btndelete = API.CAT.GetButton("3", "Delete" + row, forecolor: rowcolor, height: ROW_HEIGHT, width: ROW_DELETE_WIDTH, left: colpos, top: rowtop, symbol: true); btndelete.Click += new EventHandler((object o, EventArgs e) => { new Thread(() => { Save(sourcepath, res, timebasems, gb, numlines, Convert.ToUInt16(btndelete.Name.Substring(6))); CAT.InteractiveUpdate(gb.Name, (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder)); }).Start(); }); gb.Controls.Add(btndelete); colpos += ROW_DELETE_WIDTH; // Row Move Up Button btnup = API.CAT.GetButton("▲", "Up" + row, forecolor: rowcolor, height: ROW_HEIGHT, width: ROW_UP_WIDTH, left: colpos, top: rowtop); btnup.Click += new EventHandler((object o, EventArgs e) => { new Thread(() => { Save(sourcepath, res, timebasems, gb, numlines, Convert.ToUInt16(btnup.Name.Substring(2)), true); CAT.InteractiveUpdate(gb.Name, (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder)); }).Start(); }); gb.Controls.Add(btnup); colpos += ROW_UP_WIDTH; // Row Move Down Button btndown = API.CAT.GetButton("▼", "Down" + row, forecolor: rowcolor, height: ROW_HEIGHT, width: ROW_DOWN_WIDTH, left: colpos, top: rowtop); btndown.Click += new EventHandler((object o, EventArgs e) => { new Thread(() => { Save(sourcepath, res, timebasems, gb, numlines, Convert.ToUInt16(btndown.Name.Substring(4)), false); CAT.InteractiveUpdate(gb.Name, (GroupBox)COMPOSE(source_path, timebase_ms, resolution, output_folder)); }).Start(); }); gb.Controls.Add(btndown); colpos += ROW_DOWN_WIDTH; /*Row Graph*/ AddRowButton(ref gb, "h", "Graph" + row, () => CAT.InteractiveShowReport(() => GraphItem(((TextBox)gb.Controls.Find(pathname, true)[0]).Text, output_folder, (timebasems * Convert.ToDouble(timebaser.Text)).ToString(), (timebasems * (Convert.ToInt16(startpos.Text) - 1)).ToString(), (timebasems * Convert.ToInt16(endpos.Text)).ToString()), Convert.ToDouble(scaler.Text)), rowcolor, ROW_GRAPH_WIDTH, colpos, rowtop, true); colpos += ROW_GRAPH_WIDTH; /*Row Checkboxes*/ for (int col = 1; col <= res; col++) { gb.Controls.Add(API.CAT.GetCheckBox(rowcolor, col.ToString("00"), CheckBoxName(row, col), CheckState(sourcelines, line, col, timebasems, res), height: ROW_HEIGHT, width: ROW_CHECKBOX_WIDTH, autosize: false, left: colpos + 1, top: rowtop)); colpos += ROW_CHECKBOX_WIDTH + 2; } } return(gb); }
// Utilities /// ======================================================================================================= static string Save(string source_path, int res, double timebase, GroupBox gb, int rowcount, int?excluded_row = null, bool?up_down = null) { CAT.InteractiveAddOverlay("Saving " + source_path, API.CAT.Status.WARN); WriteModes mode = WriteModes.Normal; if (excluded_row != null && up_down != null && excluded_row != rowcount && !(bool)up_down) { mode = WriteModes.Down; } if (excluded_row != null && up_down != null && excluded_row != 1 && (bool)up_down) { mode = WriteModes.Up; } if (excluded_row != null && up_down == null) { mode = WriteModes.Exclude; } string newtext = ""; for (int row = 1; row <= rowcount; row++) { switch (mode) { case WriteModes.Normal: newtext += RowString(gb, row, res, timebase); break; case WriteModes.Exclude: if (row != excluded_row) { newtext += RowString(gb, row, res, timebase); } break; case WriteModes.Up: if (row == excluded_row - 1) { newtext += RowString(gb, row + 1, res, timebase); newtext += RowString(gb, row, res, timebase); row++; } else { newtext += RowString(gb, row, res, timebase); } break; case WriteModes.Down: if (row == excluded_row) { newtext += RowString(gb, row + 1, res, timebase); newtext += RowString(gb, row, res, timebase); row++; } else { newtext += RowString(gb, row, res, timebase); } break; } } try { if (!string.IsNullOrWhiteSpace(newtext)) { newtext = newtext.Remove(newtext.Length - 1, 1); File.WriteAllText(source_path, newtext); CAT.InteractiveAddOverlay("Saved " + source_path + " with data:\r\n" + newtext, API.CAT.Status.PASS); } } catch (Exception e) { CAT.InteractiveAddOverlay("Saving failed:\r\n" + API.CAT.ErrorMsg(e), API.CAT.Status.FAIL); } return(source_path); }
private void ExtractValues(IGraphicFactory graphicFactory, DisplayModel displayModel, string elementName, XmlReader reader, string relativePathPrefix) { for (int i = 0; i < reader.AttributeCount; ++i) { reader.MoveToAttribute(i); string name = reader.Name; string value = reader.Value; if (SRC.Equals(name)) { this.src = value; } else if (CAT.Equals(name)) { this.category = value; } else if (DY.Equals(name)) { this.dy = float.Parse(value) * displayModel.ScaleFactor; } else if (STROKE.Equals(name)) { this.stroke.Color = (Color)XmlUtils.GetColor(graphicFactory, value); } else if (STROKE_WIDTH.Equals(name)) { this.strokeWidth = XmlUtils.ParseNonNegativeFloat(name, value) * displayModel.ScaleFactor; } else if (STROKE_DASHARRAY.Equals(name)) { float[] floatArray = ParseFloatArray(name, value); for (int f = 0; f < floatArray.Length; ++f) { floatArray[f] = floatArray[f] * displayModel.ScaleFactor; } this.stroke.DashPathEffect = floatArray; } else if (STROKE_LINECAP.Equals(name)) { this.stroke.StrokeCap = Cap.FromString(value); } else if (STROKE_LINEJOIN.Equals(name)) { this.stroke.StrokeJoin = Join.FromString(value); } else if (SYMBOL_HEIGHT.Equals(name)) { this.height = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else if (SYMBOL_PERCENT.Equals(name)) { this.percent = XmlUtils.ParseNonNegativeInteger(name, value); } else if (SYMBOL_SCALING.Equals(name)) { this.scaling = FromValue(value); } else if (SYMBOL_WIDTH.Equals(name)) { this.width = XmlUtils.ParseNonNegativeInteger(name, value) * displayModel.ScaleFactor; } else { throw XmlUtils.CreateXmlReaderException(elementName, name, value, i); } } }
void Start() { book = true; CAT = GameObject.Find("CAT"); DOG = GameObject.Find("DOG"); OWL = GameObject.Find("OWL"); BEAR = GameObject.Find("BEAR"); MONKEY = GameObject.Find("MONKEY"); HELLO = GameObject.Find("HELLO"); DOOR = GameObject.Find("DOOR"); MAY = GameObject.Find("MAY"); EVA = GameObject.Find("EVA"); RED = GameObject.Find("RED"); BLUE = GameObject.Find("BLUE"); GREEN = GameObject.Find("GREEN"); YELLOW = GameObject.Find("YELLOW"); if (!Progress.cat) { CAT.SetActive(false); } if (!Progress.dog) { DOG.SetActive(false); } if (!Progress.bear) { BEAR.SetActive(false); } if (!Progress.monkey) { MONKEY.SetActive(false); } if (!Progress.owl) { OWL.SetActive(false); } if (!Progress.door) { DOOR.SetActive(false); } if (!Progress.red) { RED.SetActive(false); } if (!Progress.blue) { BLUE.SetActive(false); } if (!Progress.green) { GREEN.SetActive(false); } if (!Progress.yellow) { YELLOW.SetActive(false); } if (!Progress.hello) { HELLO.SetActive(false); } if (!Progress.may) { MAY.SetActive(false); } if (!Progress.eva) { EVA.SetActive(false); } a = GameObject.Find("a"); a.SetActive(false); b = GameObject.Find("b"); b.SetActive(false); c = GameObject.Find("c"); c.SetActive(false); d = GameObject.Find("d"); d.SetActive(false); e = GameObject.Find("e"); e.SetActive(false); f = GameObject.Find("f"); f.SetActive(false); g = GameObject.Find("g"); g.SetActive(false); h = GameObject.Find("h"); h.SetActive(false); i = GameObject.Find("i"); i.SetActive(false); j = GameObject.Find("j"); j.SetActive(false); k = GameObject.Find("k"); k.SetActive(false); l = GameObject.Find("l"); l.SetActive(false); m = GameObject.Find("m"); m.SetActive(false); n = GameObject.Find("n"); n.SetActive(false); o = GameObject.Find("o"); o.SetActive(false); p = GameObject.Find("p"); p.SetActive(false); q = GameObject.Find("q"); q.SetActive(false); r = GameObject.Find("r"); r.SetActive(false); s = GameObject.Find("s"); s.SetActive(false); t = GameObject.Find("t"); t.SetActive(false); u = GameObject.Find("u"); u.SetActive(false); v = GameObject.Find("v"); v.SetActive(false); w = GameObject.Find("w"); w.SetActive(false); x = GameObject.Find("x"); x.SetActive(false); y = GameObject.Find("y"); y.SetActive(false); z = GameObject.Find("z"); z.SetActive(false); }