//��ѡɾ�� protected void btnDelete_Click(object sender, DirectEventArgs e) { User bll = new User(); string values = e.ExtraParams["Values"].ToString(); XmlUtils xml = new XmlUtils(values); string id = xml.GetXmlNodeValue("$KeyName$"); if (string.IsNullOrEmpty(id)) return; if (int.Parse(id) < 0) this.GridPanel1.DeleteSelected(); else { bool blFlag = bll.Delete(id); if (blFlag) { this.GridPanel1.Reload(); ShowNotification("ɾ���ɹ�"); } } }
/// <summary> /// This should be loaded from the database query.I ma just adding a template to help your development /// </summary> public string OrdersReadByParameters(DateTime startDate, DateTime endDate, int page) { try { Orders rootOrder = new Orders(); rootOrder.pages = 50; OrdersOrder order = new OrdersOrder { OrderID = "123456", OrderNumber = "abcd", OrderTotal = 12.56F, OrderDate = DateTime.Now.ToShortDateString(), OrderStatus = "Open", LastModified = DateTime.Now.AddDays(3).ToShortDateString(), ShippingMethod = "USPS-Ground", PaymentMethod = "Credit Card", TaxAmount = 3.45F, ShippingAmount = 5.99F, CustomerNotes = "Adding a note on an order really sucks !!!!", InternalNotes = "This also sucks too !!", Customer = new OrdersOrderCustomer { BillTo = new OrdersOrderCustomerBillTo { Name = "Rennish Joseph", Email = "*****@*****.**", Company = "Kerala Tate Buds", Phone = "9075671234" }, CustomerCode = "010", ShipTo = new OrdersOrderCustomerShipTo { Address1 = "123 Mainstareet", City = "Jacksonville", State = "Florida", Phone = "123456", PostalCode = "32226" } }, Items = new OrdersOrderItem[] { new OrdersOrderItem { SKU = "SKU-12345", Name = "RV part", ImageUrl = "http://asp.net/image.png", Weight = 3.89f, Options = new OrdersOrderItemOption[] { new OrdersOrderItemOption { Name = "XL", Value = "LX", Weight = 6.78f, WeightSpecified = true }, new OrdersOrderItemOption { Name = "Medium", Value = "MD", Weight = 6.78f, WeightSpecified = true } } } } }; rootOrder.Order = new OrdersOrder[] { order }; //use the xml serializer to convert the object into an xml string string xmlString = new XmlUtils().XmlStringSerialize(rootOrder); return xmlString; } catch (Exception ex) { //Log errors throw; } }
public static bool TryGetOnlineTemplates(out List <Dictionary <string, string> > list) { list = new List <Dictionary <string, string> >(); try { var content = WebClientUtils.GetRemoteFileSource(UrlTemplatesXml, ECharset.utf_8); var document = XmlUtils.GetXmlDocument(content); var rootNode = XmlUtils.GetXmlNode(document, "//siteTemplates"); if (rootNode.ChildNodes.Count > 0) { foreach (XmlNode node in rootNode.ChildNodes) { var ie = node.ChildNodes.GetEnumerator(); var title = string.Empty; var description = string.Empty; var author = string.Empty; var source = string.Empty; var lastEditDate = string.Empty; while (ie.MoveNext()) { var childNode = (XmlNode)ie.Current; if (childNode == null) { continue; } var nodeName = childNode.Name; if (StringUtils.EqualsIgnoreCase(nodeName, "title")) { title = childNode.InnerText; } else if (StringUtils.EqualsIgnoreCase(nodeName, "description")) { description = childNode.InnerText; } else if (StringUtils.EqualsIgnoreCase(nodeName, "author")) { author = childNode.InnerText; } else if (StringUtils.EqualsIgnoreCase(nodeName, "source")) { source = childNode.InnerText; } else if (StringUtils.EqualsIgnoreCase(nodeName, "lastEditDate")) { lastEditDate = childNode.InnerText; } } if (!string.IsNullOrEmpty(title)) { list.Add(new Dictionary <string, string> { ["title"] = StringUtils.Trim(title), ["description"] = StringUtils.Trim(description), ["author"] = StringUtils.Trim(author), ["source"] = StringUtils.Trim(source), ["lastEditDate"] = StringUtils.Trim(lastEditDate) }); } } } return(true); } catch { return(false); } }
public void Awake() { MainContainer = GetComponent <UIPanel>(); MainContainer.autoLayout = true; MainContainer.autoLayoutDirection = LayoutDirection.Vertical; MainContainer.padding = new RectOffset(5, 5, 5, 5); MainContainer.autoLayoutPadding = new RectOffset(0, 0, 3, 3); KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, MainContainer.height - 40)); m_tabSettings = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "TxtSettings"); m_tabSize = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MoveCross), "K45_WTS_TEXT_SIZE_ATTRIBUTES", "TxtSize"); m_tabAppearence = TabCommons.CreateScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_WTS_TEXT_APPEARANCE_ATTRIBUTES", "TxtApp"); m_tabConfig = TabCommons.CreateScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoNameIcon), "K45_WTS_TEXT_CONFIGURATION_ATTRIBUTES", "TxtCnf"); var helperSettings = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical); var helperSize = new UIHelperExtension(m_tabSize, LayoutDirection.Vertical); var helperAppearance = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical); var helperConfig = new UIHelperExtension(m_tabConfig, LayoutDirection.Vertical); AddTextField(Locale.Get("K45_WTS_TEXT_TAB_TITLE"), out m_tabName, helperSettings, OnTabNameChanged); AddVector3Field(Locale.Get("K45_WTS_RELATIVE_POS"), out m_arrayCoord, helperSize, OnPositionChange); AddVector3Field(Locale.Get("K45_WTS_RELATIVE_ROT"), out m_arrayRotation, helperSize, OnRotationChange); AddFloatField(Locale.Get("K45_WTS_TEXT_SCALE"), out m_textScale, helperSize, OnScaleSubmit, false); AddFloatField(Locale.Get("K45_WTS_MAX_WIDTH_METERS"), out m_maxWidth, helperSize, OnMaxWidthChange, false); AddCheckboxLocale("K45_WTS_RESIZE_Y_TEXT_OVERFLOW", out m_applyScaleOnY, helperSize, OnChangeApplyRescaleOnY); AddCheckboxLocale("K45_WTS_CREATE_CLONE_180DEG", out m_create180degSimmetricClone, helperSize, OnChangeCreateSimmetricClone); AddCheckboxLocale("K45_WTS_CLONE_180DEG_INVERT_TEXT_HOR_ALIGN", out m_invertTextHorizontalAlignClone, helperSize, OnChangeInvertCloneTextHorizontalAlignment); // AddCheckboxLocale("K45_WTS_MIRRORED", out m_mirrored, helperSize, OnChangeMirrored); AddDropdown(Locale.Get("K45_WTS_TEXT_ALIGN_HOR"), out m_dropdownTextAlignHorizontal, helperAppearance, ColossalUIExtensions.GetDropdownOptions <UIHorizontalAlignment>("K45_ALIGNMENT"), OnSetTextAlignmentHorizontal); helperAppearance.AddSpace(5); AddCheckboxLocale("K45_WTS_USE_CONTRAST_COLOR", out m_useContrastColor, helperAppearance, OnContrastColorChange); AddColorField(helperAppearance, Locale.Get("K45_WTS_TEXT_COLOR"), out m_textFixedColor, OnFixedColorChanged); AddSlider(Locale.Get("K45_WTS_TEXT_DEPTH"), out m_sliderDepth, helperAppearance, OnChangeDepth, -1, 1, 0.025f, (x) => $"{x.ToString("P1")}"); AddDropdown(Locale.Get("K45_WTS_TEXT_MATERIALTYPE"), out m_dropdownMaterialType, helperAppearance, ColossalUIExtensions.GetDropdownOptions <MaterialType>("K45_WTS_TEXTMATERIALTYPE"), OnSetMaterialType); AddSlider(Locale.Get("K45_WTS_TEXT_ILLUMINATIONSTRENGTH"), out m_sliderIllumination, helperAppearance, OnChangeIlluminationStrength, 0, 10, 0.025f, (x) => $"{x.ToString("P1")}"); AddDropdown(Locale.Get("K45_WTS_TEXT_BLINKTYPE"), out m_dropdownBlinkType, helperAppearance, ColossalUIExtensions.GetDropdownOptions <BlinkType>("K45_WTS_BLINKTYPE"), OnSetBlinkType); AddVector4Field(Locale.Get("K45_WTS_TEXT_CUSTOMBLINKPARAMS"), out m_arrayCustomBlink, helperAppearance, OnCustomBlinkChange); AddEmptyDropdown(Locale.Get("K45_WTS_TEXT_CONTENT"), out m_dropdownTextContent, helperConfig, OnSetTextOwnNameContent); AddTextField(Locale.Get("K45_WTS_CUSTOM_TEXT"), out m_customText, helperConfig, OnSetTextCustom); IEnumerator OnFilter(string x, Wrapper <string[]> result) { yield return(result.Value = OnFilterParamImages(WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite, x)); } AddFilterableInput(Locale.Get("K45_WTS_SPRITE_NAME"), helperConfig, out m_spriteFilter, out UIListBox lb2, OnFilter, OnSpriteNameChanged); lb2.size = new Vector2(MainContainer.width - 20, 220); lb2.processMarkup = true; m_spriteFilter.eventGotFocus += (x, y) => { var text = ((UITextField)x).text; if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE)) { WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim(); } }; lb2.eventItemMouseHover += (x, y) => { if (y >= 0 && y < lb2.items.Length) { WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = lb2.items[y].Split('/').Last().Trim(); } }; lb2.eventVisibilityChanged += (x, y) => WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = y; WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = false; AddDropdown(Locale.Get("K45_WTS_PROPLAYOUT_DESTINATIONREFERENCE"), out m_destinationRef, helperConfig, ColossalUIExtensions.GetDropdownOptions <DestinationReference>("K45_WTS_ONNETTEXT_DESTINATION_DESC"), OnChangeDestinationRef); AddDropdown(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERIDX"), out m_parameterIdx, helperConfig, ColossalUIExtensions.GetDropdownOptionsUnlocalized(new string[BoardInstanceOnNetXml.TEXT_PARAMETERS_COUNT].Select((x, i) => $"#{i}").ToArray()), OnChangeTextParameterIdx); AddTextField(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERNAME"), out m_parameterDisplayName, helperConfig, OnSetParameterDisplayName); IEnumerator OnFilter2(string x, Wrapper <string[]> result) { yield return(result.Value = OnFilterParamImages(WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite, x)); } AddFilterableInput(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERDEFAULTVAL"), helperConfig, out m_defaultParameterValue, out UIListBox lb, OnFilter2, OnChangedDefaultTextParam); lb.processMarkup = true; lb.size = new Vector2(MainContainer.width - 20, 220); m_defaultParameterValue.eventGotFocus += (x, y) => { var text = ((UITextField)x).text; if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE)) { WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim(); } }; lb.eventItemMouseHover += (x, y) => { if (y >= 0 && y < lb.items.Length) { WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = lb.items[y].Split('/').Last().Trim(); } }; lb.eventVisibilityChanged += (x, y) => WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = y; WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = false; AddIntField(Locale.Get("K45_WTS_PROPLAYOUT_ITEMDURATIONFRAMES"), out m_slideDurationFrames, helperConfig, OnSetDurationFrames, false); AddIntField(Locale.Get("K45_WTS_PROPLAYOUT_DESYNCFRAMES"), out m_slideDesync, helperConfig, OnSetDesyncOffset, false); helperConfig.AddSpace(5); AddDropdown(Locale.Get("K45_WTS_CLASS_FONT"), out m_fontClassSelect, helperConfig, ColossalUIExtensions.GetDropdownOptions <FontClass>("K45_WTS_FONTCLASS"), OnSetFontClass); AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_overrideFontSelect, helperConfig, OnSetOverrideFont); AddTextField(Locale.Get("K45_WTS_PREFIX"), out m_textPrefix, helperConfig, OnSetPrefix); AddTextField(Locale.Get("K45_WTS_SUFFIX"), out m_textSuffix, helperConfig, OnSetSuffix); AddCheckboxLocale("K45_WTS_TEXT_ALL_CAPS", out m_allCaps, helperConfig, OnSetAllCaps); AddCheckboxLocale("K45_WTS_TEXT_APPLYABBREVIATIONS", out m_applyAbbreviations, helperConfig, OnSetApplyAbbreviations); AddVector2Field(Locale.Get("K45_WTS_TEXT_ROW_COLUMNS"), out m_arrayRowColumnsCount, helperConfig, OnRowColumnCountChanged, true, true); m_arrayRowColumnsCount.ForEach(x => x.allowNegative = false); AddVector2Field(Locale.Get("K45_WTS_TEXT_ROW_COLUMNS_SPACING"), out m_arrayRowColumnsSpacing, helperConfig, OnRowColumnSpacingChanged); AddDropdown(Locale.Get("K45_WTS_VERTICAL_ALIGNMENT"), out m_verticalAlignDD, helperConfig, ColossalUIExtensions.GetDropdownOptions <UIVerticalAlignment>("K45_VERT_ALIGNMENT"), OnSetVerticalAlign); AddCheckboxLocale("K45_WTS_TEXT_FILLCOLUMNSFIRST", out m_checkboxVerticalFirst, helperConfig, OnColumnsFirstChanged); WTSUtils.ReloadFontsOf(m_overrideFontSelect, null, true, true); WTSPropLayoutEditor.Instance.CurrentTabChanged += (newVal) => { int targetTab = newVal - 1; SafeObtain(OnSetData, targetTab); if (WTSPropLayoutEditor.Instance.EditingInstance?.m_configurationSource == ConfigurationSource.CITY) { m_tabContainer.Enable(); } else { m_tabContainer.Disable(); } }; m_isEditing = false; AddLibBox <WTSLibPropTextItem, BoardTextDescriptorGeneralXml>(helperSettings, out UIButton m_copyButtonText, DoCopyText, out m_pasteButtonText, DoPasteText, out UIButton m_deleteButtonText, DoDeleteText, (loadedItem) => SafeObtain((ref BoardTextDescriptorGeneralXml x) => { string name = x.SaveName; x = XmlUtils.DefaultXmlDeserialize <BoardTextDescriptorGeneralXml>(loadedItem); x.SaveName = name; OnSetData(ref x); x.SaveName = name; }), () => XmlUtils.DefaultXmlSerialize(WTSPropLayoutEditor.Instance.EditingInstance.TextDescriptors[Math.Max(0, TabToEdit)])); }
private void DoCopyText() => SafeObtain((ref BoardTextDescriptorGeneralXml x) => { m_clipboard = XmlUtils.DefaultXmlSerialize(x); m_pasteButtonText.isVisible = true; });
protected override void SetInfoBarText() { if (m_informationBar == null) { return; } string titleStr = ""; // See if we have an AlternativeTitle string table id for an alternate title. string titleId = XmlUtils.GetAttributeValue(m_configurationParameters, "altTitleId"); if (titleId != null) { XmlViewsUtils.TryFindString(StringTbl, "AlternativeTitles", titleId, out titleStr); // if they specified an altTitleId, but it wasn't found, they need to do something, // so just return *titleId* if (Clerk.OwningObject != null && titleId.StartsWith("Reversal") && XmlUtils.GetBooleanAttributeValue(m_configurationParameters, "ShowOwnerShortname")) { // Originally this option was added to enable Bulk Edit Reversal Entries title bar to show // which reversal index was being shown. If the 'titleId.StartsWith("Reversal")' in the 'if' // above is removed then the Word List Concordance shows the word being concorded in the // right pane title bar. titleStr = string.Format(xWorksStrings.ksXReversalIndex, Clerk.OwningObject.ShortName, titleStr); } } else if (Clerk.OwningObject != null) { if (XmlUtils.GetBooleanAttributeValue(m_configurationParameters, "ShowOwnerShortname")) { titleStr = Clerk.OwningObject.ShortName; } } if (String.IsNullOrEmpty(titleStr)) { XmlViewsUtils.TryFindPluralFormFromFlid(Clerk.VirtualListPublisher.MetaDataCache, StringTbl, Clerk.OwningFlid, out titleStr); } bool fBaseCalled = false; if (String.IsNullOrEmpty(titleStr)) { base.SetInfoBarText(); fBaseCalled = true; // titleStr = ((IPaneBar)m_informationBar).Text; // can't get to work. // (EricP) For some reason I can't provide an IPaneBar get-accessor to return // the new Text value. If it's desirable to allow TitleFormat to apply to // Clerk.CurrentObject, then we either have to duplicate what the // base.SetInfoBarText() does here, or get the string set by the base. // for now, let's just return. if (string.IsNullOrEmpty(titleStr)) { return; } } // If we have a format attribute, format the title accordingly. string sFmt = XmlUtils.GetAttributeValue(m_configurationParameters, "TitleFormat"); if (sFmt != null) { titleStr = String.Format(sFmt, titleStr); } // if we haven't already set the text through the base, // or if we had some formatting to do, then set the infoBar text. if (!fBaseCalled || sFmt != null) { ((IPaneBar)m_informationBar).Text = titleStr; } }
protected override void SetupDataContext() { base.SetupDataContext(); // Make sure our persisted sorter/filters are up to date so browse viewer // has the latest set for configuring/activating the filterBar bool fNeedReload = Clerk.UpdateFiltersAndSortersIfNeeded(); // This is mainly to handle the possibility that one of our objects in a virtual // property has been deleted, either by some other tool, or by another client altogether. // Enhance: it would be very nice not to do this any time we can be sure it isn't needed. // The second 'true' here is to make it skip the sort. The sort has to be skipped at this // point because our VC has been disposed, and we haven't made a new one yet. The sort // will happen later in the sequence of Init when InitSorter is called int hvo = 0; if (Clerk.OwningObject != null) { hvo = Clerk.OwningObject.Hvo; } // We must update the list if needed BEFORE we create the actual view, otherwise, if it is trying // to display an out-of-date list containing deleted objects, all kinds of things may go wrong. if (XmlUtils.GetOptionalBooleanAttributeValue(m_configurationParameters, "forceReloadListOnInitOrChangeRoot", false)) { m_mediator.PropertyTable.SetProperty(Clerk.Id + "_AlwaysRecomputeVirtualOnReloadList", true); // (EricP) when called by RecordView.InitBase() in the context of ListUpdateHelper.ClearBrowseListUntilReload // the list does not get reloaded until ListUpdateHelper is disposed, but the views property // will get cleared to prevent these views from accessing invalid objects. Clerk.UpdateList(false, true); } m_browseViewer = CreateBrowseViewer(m_configurationParameters, hvo, m_fakeFlid, Cache, m_mediator, Clerk.SortItemProvider, Clerk.VirtualListPublisher); m_browseViewer.SortersCompatible += Clerk.AreSortersCompatible; // If possible make it use the style sheet appropriate for its main window. m_browseViewer.SuspendLayout(); SetStyleSheet(); m_browseViewer.Dock = DockStyle.Fill; RecordFilter linkFilter = m_browseViewer.FilterFromLink(); SetupLinkScripture(); if (linkFilter != null) { Clerk.OnChangeFilter(new FilterChangeEventArgs(linkFilter, Clerk.Filter)); } if (Clerk.Filter != null && !Clerk.Filter.IsValid) { Clerk.ResetFilterToDefault(); } m_browseViewer.UpdateFilterBar(Clerk.Filter); bool fSortChanged = m_browseViewer.InitSorter(Clerk.Sorter); // true if we had to change sorter // Do this AFTER we init the sorter and filter, so if any changes are made to the // sorter or filter as we install, we still get the right load. if (fSortChanged) { HandleSortChange(); // Keep the current index -- see LT-8755. } else { List <int> sortedCols = m_browseViewer.SortedColumns; Clerk.IsDefaultSort = sortedCols.Count > 0 && sortedCols[0] == m_browseViewer.DefaultSortColumn; // This won't actually load if in the context of UpdateListHelper() Clerk.UpdateList(true, fNeedReload); } // Do this very late, it can't display properly until its record list has been built and sorted. Controls.Add(m_browseViewer); m_browseViewer.BringToFront(); m_browseViewer.ResumeLayout(); }
void Init(string xmlSource, ref int i, bool useHashesForNames) { _xmlSource = xmlSource; UseHashesForNames = useHashesForNames; XmlUtils.SkipWhitespace(xmlSource, ref i); if (useHashesForNames) { Name = null; NameHash = XmlUtils.GetHashedValue(xmlSource, ref i, '>', '/', true); } else { Name = XmlUtils.GetValue(xmlSource, ref i, '>', '/', true); NameHash = 0; } XmlUtils.ParseAttributes(xmlSource, ref i, _attributes, '>', '/', useHashesForNames); // skip '/>'. if (xmlSource[i] == '/') { i += 2; return; } i++; var tempIt = i; XmlUtils.SkipWhitespace(xmlSource, ref tempIt); if (xmlSource[tempIt] == '<') { i = tempIt; // parse children. while (xmlSource[i + 1] != '/') { i++; Children.Add(Get(xmlSource, ref i, useHashesForNames)); XmlUtils.SkipWhitespace(xmlSource, ref i); if (i >= xmlSource.Length) { return; } if (xmlSource[i] != '<') { throw new Exception("Invalid token"); } } i++; } else { _valueStart = i; _valueLength = XmlUtils.SkipValue(xmlSource, ref i, '<', '\0', false); i++; if (xmlSource[i] != '/') { throw new Exception("Invalid ending tag at " + i); } } i++; XmlUtils.SkipWhitespace(xmlSource, ref i); var isValid = useHashesForNames ? XmlUtils.GetHashedValue(xmlSource, ref i, '>', '\0', true) == NameHash : XmlUtils.GetValue(xmlSource, ref i, '>', '\0', true) == Name; if (!isValid) { throw new Exception("Start/end tag name mismatch at " + i); } XmlUtils.SkipWhitespace(xmlSource, ref i); if (xmlSource[i] != '>') { throw new Exception("Invalid ending tag at " + i); } i++; }