public void CreateEntity_Prop_KeyTextCode_ValTextCode() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); TextCode tcToshiba = core.Editor.CreateTextCode("Toshiba"); // create an ent Entity toshibaCoreI7 = core.Editor.CreateEntity(); // Add a property to an object: key - value Property propName = core.Editor.CreateProperty(toshibaCoreI7, tcName, tcToshiba); // check the property key (type and value) PropertyKeyTextCode propKeyTextCode = propName.Key as PropertyKeyTextCode; Assert.IsNotNull(propKeyTextCode, "the key should be a TextCode"); Assert.AreEqual(tcName.Id, propKeyTextCode.TextCodeId, "the key should be 'Name'"); // check the property value (type and value) ValTextCodeId propValueTextCode = propName.Value as ValTextCodeId; Assert.IsNotNull(propValueTextCode, "the value should be a TextCode"); Assert.AreEqual(tcToshiba.Id, propValueTextCode.TextCodeId, "the key should be 'Toshiba'"); }
/// <summary> /// The property key text can be a string or a textCode. /// If its a textCode, go in the repository to read the textCode by the id. /// </summary> /// <param name="propCritKeyTextWork"></param> /// <param name="propertyKeyBase"></param> /// <returns></returns> private bool GetKeyText(PropertyKeyBase propertyKeyBase, out string keyText) { PropertyKeyString propKeyString = propertyKeyBase as PropertyKeyString; if (propKeyString != null) { keyText = propKeyString.Key; // ok return(true); } keyText = ""; PropertyKeyTextCode propKeyTextCode = propertyKeyBase as PropertyKeyTextCode; if (propKeyTextCode == null) { // error! return(false); } // load the textCode TextCode textCode = _reposit.Finder.FindTextCodeById(propKeyTextCode.TextCodeId); if (textCode == null) { // error! return(false); } keyText = textCode.Code; return(true); }
public static string ReadTextEnd(byte[] frame, int index, TextCode code) { switch (code) { case TextCode.Ascii: { return(ReadASCIIEnd(frame, index)); } case TextCode.Utf16: { return(ReadUTF16End(frame, index)); } case TextCode.Utf16BE: { return(ReadUTF16BEEnd(frame, index)); } case TextCode.Utf8: { return(ReadUTF8End(frame, index)); } default: { throw new InvalidFrameException("Invalid TextCode string type."); } } }
/// <summary> /// Create an entity from a template (basic case). /// Has one property: key and value are string type. /// /// ET: "TemplComputer" /// P: K=Type, V=Computer /// /// After processing the template: /// /// E: /// P: K=Type, V=Computer /// /// </summary> public void EntityTemplate_PropKeyAndValue_TextCode() { EtagairEngine engine = CreateEngine(); Console.WriteLine("Create an entity template."); //====Create an entity template EntityTempl templComputer = engine.EditorTempl.CreateEntityTempl("TemplComputer"); TextCode tcKeyType = engine.Editor.CreateTextCode("Type"); TextCode tcValueType = engine.Editor.CreateTextCode("Computer"); // add property to the template, Key=Type, Value=Computer engine.EditorTempl.CreatePropTempl(templComputer, tcKeyType, tcValueType); //====Instanciate the template, create an entity, under the root folder EntityTemplToInst templToInst = engine.ProcessTempl.CreateEntity(templComputer); // the state should be Success Console.WriteLine("Create entity:"); Console.WriteLine(" State: " + templToInst.State.ToString()); // the nextStep should be: Ends Console.WriteLine(" NextStep: " + templToInst.NextStep.ToString()); // displays the entity id Console.WriteLine("\n-----Created entity id: " + templToInst.Entity.Id); DisplayEntity(engine, templToInst.Entity, 0, false); }
protected TextLocal GenerateTextLocal(TextCode textCode, TextLocalModel textLocalModel, List <string> listParams) { TextLocal textLocal = new TextLocal(); textLocal.TextLocalModelId = textLocalModel.Id; // insert params if (listParams != null) { // check the params count // todo: try { textLocal.Text = string.Format(textLocalModel.Text, listParams.ToArray()); } catch { // error! textLocal.Text = textLocalModel.Text; } } else { textLocal.Text = textLocalModel.Text; } return(textLocal); }
public void ChangeCurrentLang_GetTextLocal_ok() { EtagairCore core = Common.CreateCore(RepositConfig); //----Define languages in the current catalog core.Editor.DefineLanguage(LanguageCode.en); // ->becomes the default language core.Editor.DefineLanguage(LanguageCode.fr); // create textCode and translation TextCode tcName = core.Editor.CreateTextCode("Name"); TextLocalModel tl_en_Name = core.Editor.CreateTextLocalModel(LanguageCode.en, tcName, "Name"); TextLocalModel tl_fr_Name = core.Editor.CreateTextLocalModel(LanguageCode.fr, tcName, "Nom"); // create textCode and translation TextCode tcNameToshiba = core.Editor.CreateTextCode("NameToshiba"); core.Editor.CreateTextLocalModel(LanguageCode.en, tcNameToshiba, "Laptop Toshiba Core i7 RAM 8Go HD 1To Win10"); core.Editor.CreateTextLocalModel(LanguageCode.fr, tcNameToshiba, "Ordinateur portable Toshiba Core i7 RAM 8Go DD 1To Win10"); // change the current language from en to fr core.Searcher.SetCurrentLanguage(LanguageCode.fr); // get localized text TextLocal tlNameFound = core.Editor.GenerateTextLocal(tcName); // should be in french Assert.AreEqual(tl_fr_Name.Id, tlNameFound.TextLocalModelId, "the TextLocal Language should be 'en'"); }
/// <summary> /// Parse the text binary frame. /// </summary> /// <param name="frame">binary frame</param> public override void Parse(byte[] frame) { int index = 0; _textEncoding = (TextCode)frame[index]; index++; _text = TextBuilder.ReadTextEnd(frame, index, _textEncoding); }
public TextCode CreateTextCode(string textCode, int paramsCount) { if (string.IsNullOrWhiteSpace(textCode)) { return(null); } // check the syntax of the code // TODO: définir regles! pas de car spéciaux, ;;; // check if the textCode is not already used if (_reposit.Finder.FindTextCodeByCode(textCode) != null) { return(null); } if (paramsCount < 0) { paramsCount = 0; } TextCode tc = new TextCode(); tc.Code = textCode; tc.ParamsCount = paramsCount; _reposit.Builder.SaveTextCode(tc); return(tc); }
public void AddPayment(long accountNumber, DateTime paymentDate, string ownRef, TextCode textCode, TransferCode transferCode, int amount, string payeeAccNum, string payeeName, string swiftBankAddr, string bankAddress, string bankCode, string bankName, string receivingCountryCode, string payeeAddress, string payeeInvoiceRef, ISOCurrencySymbols currencyInfo, Charges chargesAbroad = Charges.BEN, Charges chargesInNorway = Charges.OUR) { InternationalPaymentOrder order = new InternationalPaymentOrder(); this.PaymentOrders.Add(order); AddTransferRecord(order, accountNumber, paymentDate, ownRef, currencyInfo, chargesAbroad, chargesInNorway); AddPaymentRecord(order, accountNumber, amount, payeeAccNum, payeeName, swiftBankAddr, bankAddress, bankCode, bankName, receivingCountryCode, payeeAddress, payeeInvoiceRef); }
public static string ReadText(byte[] frame, ref int index, TextCode code) { switch (code) { case TextCode.Ascii: { return ReadASCII(frame, ref index); } case TextCode.Utf16: { return ReadUTF16(frame, ref index); } case TextCode.Utf16BE: { return ReadUTF16BE(frame, ref index); } case TextCode.Utf8: { return ReadUTF8(frame, ref index); } default: { throw new InvalidFrameException("Invalid text code string type."); } } }
public TextLocal GenerateTextLocal(TextCode textCode, Language lang, List <string> listParams) { TextLocal textLocal; if (textCode == null) { return(null); } // a textLocal exists for this languageCode? TextLocalModel textLocalModel = _reposit.Finder.FindTextLocal(lang.LanguageCode, textCode.Id); if (textLocalModel != null) { textLocal = GenerateTextLocal(textCode, textLocalModel, listParams); return(textLocal); } // no textLocal found, get the mainLanguageCode of the languageCode MainLanguageCode mainLanguageCode = lang.MainLanguageCode; // convert the mainLanguageCode to a languageCode LanguageCode languageCode = LanguageDef.ToLanguageCode(mainLanguageCode); // load the textLocal textLocalModel = _reposit.Finder.FindTextLocal(languageCode, textCode.Id); textLocal = GenerateTextLocal(textCode, textLocalModel, listParams); return(textLocal); }
/// <summary> /// Parse binary data unsynchronised lyrics/comment frame. /// </summary> /// <param name="frame">binary frame data</param> public override void Parse(byte[] frame) { if (frame == null) { throw new ArgumentNullException("frame"); } int index = 0; _textEncoding = (TextCode)frame[index]; index++; //TODO: Invalid tag, may be legacy. if (frame.Length - index < 3) { return; } _language = UTF8Encoding.UTF8.GetString(frame, index, 3); index += 3; // Three language bytes if (frame.Length - index < 1) { return; } _contents = TextBuilder.ReadText(frame, ref index, _textEncoding); _text = TextBuilder.ReadTextEnd(frame, index, _textEncoding); }
//验证并消费 private void BTVerify_Click(object sender, EventArgs e) { string code = TextCode.Text.Trim(); if (code == "") { BathClass.printErrorMsg("需要输入优惠券代码!"); return; } string errorDesc = ""; var consumeWxCouponResult = WxCouponManagement.consumeCoupon(LogIn.connectionIP, LogIn.options.company_Code, code, out errorDesc); if (consumeWxCouponResult == null) { BathClass.printErrorMsg(errorDesc); TextCode.SelectAll(); TextCode.Focus(); return; } if (!consumeWxCouponResult.success) { BathClass.printErrorMsg(consumeWxCouponResult.errorDesc); TextCode.SelectAll(); TextCode.Focus(); return; } couponValue = consumeWxCouponResult.value; this.DialogResult = DialogResult.OK; this.Close(); }
public static byte[] WriteTextEnd(string text, TextCode code) { switch (code) { case TextCode.Ascii: { return(WriteASCIIEnd(text)); } case TextCode.Utf16: { return(WriteUTF16End(text)); } case TextCode.Utf16BE: { return(WriteUTF16BEEnd(text)); } case TextCode.Utf8: { return(WriteUTF8End(text)); } default: { throw new InvalidFrameException("Invalid TextCode string type."); } } }
/// <summary> /// Create an entity with a property group. /// /// Ent: /// P: tc:tcName= tc:tcNameToshiba /// P: "RAM"= "8" /// PG: "Processor"\ /// P: "Constructor"= "Intel" /// P: "Model"= "i7" /// </summary> public void CreateEntityWithPropGroup() { EtagairEngine engine = CreateEngine(); //----set defined (activate) language codes in the application engine.Editor.DefineLanguage(LanguageCode.en); engine.Editor.DefineLanguage(LanguageCode.fr); // create localized text for main languages managed in the application TextCode tcName = engine.Editor.CreateTextCode("Name"); engine.Editor.CreateTextLocalModel(LanguageCode.en, tcName, "Name"); engine.Editor.CreateTextLocalModel(LanguageCode.fr, tcName, "Nom"); TextCode tcValueToshiba = engine.Editor.CreateTextCode("ValueToshiba"); engine.Editor.CreateTextLocalModel(LanguageCode.en, tcValueToshiba, "Laptop Toshiba Core i7 RAM 8Go HD 1To Win10"); engine.Editor.CreateTextLocalModel(LanguageCode.fr, tcValueToshiba, "Ordinateur portable Toshiba Core i7 RAM 8Go DD 1To Win10"); // create an entity with one property: key and value are TextCode Entity toshibaCoreI7 = engine.Editor.CreateEntity(); // Add a property to an object: key - value, both are textCode (will be displayed translated depending on the language) engine.Editor.CreateProperty(toshibaCoreI7, tcName, tcValueToshiba); // create property: RAM: 8 Go(Gb) engine.Editor.CreateProperty(toshibaCoreI7, "RAM", "8"); // add a properties group (folder inside object) in the object PropertyGroup propGrpProc = engine.Editor.CreatePropertyGroup(toshibaCoreI7, "Processor"); engine.Editor.CreateProperty(toshibaCoreI7, propGrpProc, "Constructor", "Intel"); engine.Editor.CreateProperty(toshibaCoreI7, propGrpProc, "Model", "i7"); }
public Bookmark(TextCode tb, string name, int lineIndex) { this.TB = tb; this.Name = name; this.LineIndex = lineIndex; Color = tb.BookmarkColor; }
public Hints(TextCode tb) { this.tb = tb; tb.TextChanged += OnTextBoxTextChanged; tb.KeyDown += OnTextBoxKeyDown; tb.VisibleRangeChanged += OnTextBoxVisibleRangeChanged; }
/// <summary> /// Occurs when user click on StyleVisualMarker joined to this style /// </summary> public virtual void OnVisualMarkerClick(TextCode tb, VisualMarkerEventArgs args) { if (VisualMarkerClick != null) { VisualMarkerClick(tb, args); } }
public string GetRtf(TextCode tb) { this.tb = tb; Range sel = new Range(tb); sel.SelectAll(); return(GetRtf(sel)); }
public void CreateTextCode() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); Assert.IsNotNull(tcName.Id, "id should be set"); }
async void ButtonCheck_TouchUpInside(object sender, EventArgs e) { TextCode.ResignFirstResponder(); if (CheckFields()) { await _presenter.ButtonCheckTapped(TextCode.Text); } }
public void CreateTextCode_codeNull_Failed() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode(""); Assert.IsNull(tcName, "can't be created"); }
/// <summary> /// Create a property to an object: key - value, /// </summary> /// <param name="entity"></param> /// <param name="tcKey"></param> /// <param name="tcValue"></param> /// <returns></returns> public Property CreateProperty(Entity entity, PropertyGroup propertyParent, TextCode tcKey, double value) { // create the property value ValDouble valDouble = new ValDouble(); valDouble.Value = value; return(CreateProperty(entity, propertyParent, tcKey, valDouble)); }
/// <summary> /// Create a property to an object: key - value, /// </summary> /// <param name="entity"></param> /// <param name="tcKey"></param> /// <param name="tcValue"></param> /// <returns></returns> public Property CreateProperty(Entity entity, PropertyGroup propertyParent, TextCode tcKey, bool value) { // create the property value ValBool valBool = new ValBool(); valBool.Value = value; return(CreateProperty(entity, propertyParent, tcKey, valBool)); }
public FileTextSource(TextCode currentTB) : base(currentTB) { timer.Interval = 10000; timer.Tick += new EventHandler(timer_Tick); timer.Enabled = true; SaveEOL = Environment.NewLine; }
/// <summary> /// Create a property to an object: key - value, /// </summary> /// <param name="entity"></param> /// <param name="tcKey"></param> /// <param name="tcValue"></param> /// <returns></returns> public Property CreateProperty(Entity entity, PropertyGroup propertyParent, TextCode tcKey, int value) { // create the property value ValInt valInt = new ValInt(); valInt.Value = value; return(CreateProperty(entity, propertyParent, tcKey, valInt)); }
/// <summary> /// Create a property to an object: key - value, /// </summary> /// <param name="entity"></param> /// <param name="tcKey"></param> /// <param name="tcValue"></param> /// <returns></returns> public Property CreateProperty(Entity entity, PropertyGroup propertyParent, TextCode tcKey, string value) { // create the property value ValString valString = new ValString(); valString.Value = value; return(CreateProperty(entity, propertyParent, tcKey, valString)); }
/// <summary> /// Create a property to an object: key - value, /// both are textCode (will be displayed translated depending on the language). /// </summary> /// <param name="entity"></param> /// <param name="tcKey"></param> /// <param name="tcValue"></param> /// <returns></returns> public Property CreateProperty(Entity entity, PropertyGroup propertyParent, TextCode tcKey, TextCode tcValue) { // create the property value ValTextCodeId valTextCode = new ValTextCodeId(); valTextCode.TextCodeId = tcValue.Id; return(CreateProperty(entity, propertyParent, tcKey, valTextCode)); }
public bool SaveTextCode(TextCode tc) { // check that the code is not already used // TODO: tc.Id = Guid.NewGuid().ToString(); _sysData.ListTextCode.Add(tc); return(true); }
public void CreateTextLocal_NoLanguageDefined_Failed() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); TextLocalModel tlmName = core.Editor.CreateTextLocalModel(LanguageCode.en, tcName, "Name"); Assert.IsNull(tlmName, "should be null, lang is not defined"); }
public void CreateTextCode_Find_Ok() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); TextCode tcNameFind = core.Searcher.FindTextCodeById(tcName.Id); Assert.AreEqual(tcName.Code, tcNameFind.Code, "Both Code should match"); }
/// <summary> /// Parse the binary frame /// </summary> /// <param name="frame">binary frame</param> public override void Parse(byte[] frame) { //TODO: Handle this invalid tag if (frame.Length < 1) return; int index = 0; _textEncoding = (TextCode)frame[index]; index++; _contents = TextBuilder.ReadText(frame, ref index, _textEncoding); _url = TextBuilder.ReadTextEnd(frame, index, _textEncoding); }
/// <summary> /// Parse binary data unsynchronised lyrics/comment frame. /// </summary> /// <param name="frame">binary frame data</param> public override void Parse(byte[] frame) { int index = 0; _textEncoding = (TextCode)frame[index]; index++; //TODO: Invalid tag, may be legacy. if (frame.Length - index < 3) return; _contents = TextBuilder.ReadText(frame, ref index, _textEncoding); _text = TextBuilder.ReadTextEnd(frame, index, _textEncoding); }
/// <summary> /// Parse binary data unsynchronised lyrics/comment frame. /// </summary> /// <param name="frame">binary frame data</param> public override void Parse(byte[] frame) { if (frame == null) throw new ArgumentNullException("frame"); int index = 0; _textEncoding = (TextCode)frame[index]; index++; //TODO: Invalid tag, may be legacy. if (frame.Length - index < 3) return; _language = UTF8Encoding.UTF8.GetString(frame, index, 3); index += 3; // Three language bytes if (frame.Length - index < 1) return; _contents = TextBuilder.ReadText(frame, ref index, _textEncoding); _text = TextBuilder.ReadTextEnd(frame, index, _textEncoding); }
/// <summary> /// Create a FrameLCText frame. /// </summary> /// <param name="frameId">ID3v2 type of text frame</param> public FrameFullText(string frameId) : base(frameId) { _textEncoding = TextCode.Ascii; }
/// <summary> /// Create a FrameText frame. /// </summary> /// <param name="frameId">ID3v2 type of text frame</param> public FrameText(string frameId) : base(frameId) { _textEncoding = TextCode.Utf8; }
/// <summary> /// Create a FrameLCText frame. /// </summary> /// <param name="frameId">ID3v2 type of text frame</param> public FrameTextUserDef(string frameId) : base(frameId) { _textEncoding = TextCode.Ascii; }
//public Color active = new Color(); void Start() { core = GameObject.FindGameObjectWithTag ("core").GetComponent<CubeAppear>(); cargoTxt = txt.GetComponent<TextCode>(); }
/// <summary> /// Picture Frame /// </summary> public FramePicture(string frameId) : base(frameId) { _textEncoding = TextCode.Ascii; }
/// <summary> /// Load from binary data a picture frame /// </summary> /// <param name="frame">picture binary representation</param> public override void Parse(byte[] frame) { int index = 0; _textEncoding = (TextCode)frame[index]; index++; _mime = TextBuilder.ReadASCII(frame, ref index); _pictureType = (PictureTypeCode)frame[index]; index++; _description = TextBuilder.ReadText(frame, ref index, _textEncoding); _pictureData = Memory.Extract(frame, index, frame.Length - index); }
/// <summary> /// Create a FrameGEOB frame. /// </summary> /// <param name="frameId">ID3v2 GEOB frame</param> public FrameBinary(string frameId) : base(frameId) { _textEncoding = TextCode.Ascii; }
/// <summary> /// Parse the binary GEOB frame /// </summary> /// <param name="frame">binary frame</param> public override void Parse(byte[] frame) { if (frame == null) throw new ArgumentNullException("frame"); int index = 0; _textEncoding = (TextCode)frame[index]; index++; _mime = TextBuilder.ReadASCII(frame, ref index); _fileName = TextBuilder.ReadText(frame, ref index, _textEncoding); _description = TextBuilder.ReadText(frame, ref index, _textEncoding); _objectData = Memory.Extract(frame, index, frame.Length - index); }
public static byte[] WriteTextEnd(string text, TextCode code) { switch (code) { case TextCode.Ascii: { return WriteASCIIEnd(text); } case TextCode.Utf16: { return WriteUTF16End(text); } case TextCode.Utf16BE: { return WriteUTF16BEEnd(text); } case TextCode.Utf8: { return WriteUTF8End(text); } default: { throw new InvalidFrameException("Invalid text code string type."); } } }