private void AddNewStringItem_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(NewStringItem)) { return; } if (StringItems?.Contains(NewStringItem) ?? false) { MessageBox.Show($"Item: {NewStringItem} already exists", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (StringItems == null) { StringItems = new ObservableCollection <string>(); } StringItems.Add(NewStringItem); if (AvailableStringItems?.Contains(NewStringItem) ?? false) { AvailableStringItems?.Remove(NewStringItem); } NewStringItem = null; }
private void DeleteStringItemMenuItem_Click(object sender, RoutedEventArgs e) { if (SelectedStringItem == null) { return; } if (AskConfirmationOnDelete) { var result = MessageBox.Show($"Confirm removal for item: {SelectedStringItem}", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result != MessageBoxResult.Yes) { return; } } if (IsEnabledToAddRemovedItemsToAvailable && !(AvailableStringItems?.Contains(SelectedStringItem) ?? false)) { AvailableStringItems?.Add(SelectedStringItem); } StringItems.RemoveAt(StringItemsListBox.SelectedIndex); }
private static string CreateStringItems(string word) { if (word.Length > 0) { var stringObject = new StringItems { OriginalString = word, FirstLetter = word[0].ToString(), LastLetter = word[word.Length - 1].ToString() }; if (word.Length > 2) { stringObject.StringLength = CalculateDistinctCharacters(word); } if (word.Length < 2) { stringObject.StringLength = 0; } return(stringObject.FirstLetter + stringObject.StringLength + stringObject.LastLetter); } return(null); }
private void EditStringItemMenuItem_Click(object sender, RoutedEventArgs e) { if (SelectedStringItem == null) { return; } var index = StringItemsListBox.SelectedIndex; var editDialog = new TextDialog(ItemName, SelectedStringItem); editDialog.Validate = str => !string.IsNullOrEmpty(str) && !StringItems.Contains(str); if (editDialog.ShowDialog() != true) { return; } StringItems[index] = editDialog.Text; }
public void Initialize() { if (myInitialized) { return; } Items = new List <ItemTemplateModel>(); foreach (String str in StringItems.Split(',')) { try { Items.Add(ItemTemplateTable.GetTemplate(int.Parse(str))); } catch (NullReferenceException e) { Logger.Error("Item " + str + " Introuvable dans la panoplie " + ID); } catch (FormatException e) { Logger.Error("Echoue lors de la convertion de l'item " + str); } } Stats = new List <GenericStats>(); foreach (String str in StringBonus.Split(';')) { var stats = new GenericStats(); foreach (String str2 in str.Split(',')) { try { String[] infos = str2.Split(':'); if (infos.Length < 2) { continue; } stats.AddItem((EffectEnum)int.Parse(infos[0], NumberStyles.Number, CultureInfo.InvariantCulture), int.Parse(infos[1], NumberStyles.Number, CultureInfo.InvariantCulture)); } catch (FormatException e) { Logger.Error(str2.Split(':')[0] + "|" + str2.Split(':')[1] + ""); } } Stats.Add(stats); } myInitialized = true; }
internal void FromGroupItems(GroupItems gis) { SetAllNull(); SLMissingItem mi; SLNumberItem ni; SLBooleanItem bi; SLErrorItem ei; SLStringItem si; SLDateTimeItem dti; using (var oxr = OpenXmlReader.Create(gis)) { while (oxr.Read()) { if (oxr.ElementType == typeof(MissingItem)) { mi = new SLMissingItem(); mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Missing, MissingItems.Count)); MissingItems.Add(mi); } else if (oxr.ElementType == typeof(NumberItem)) { ni = new SLNumberItem(); ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Number, NumberItems.Count)); NumberItems.Add(ni); } else if (oxr.ElementType == typeof(BooleanItem)) { bi = new SLBooleanItem(); bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Boolean, BooleanItems.Count)); BooleanItems.Add(bi); } else if (oxr.ElementType == typeof(ErrorItem)) { ei = new SLErrorItem(); ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Error, ErrorItems.Count)); ErrorItems.Add(ei); } else if (oxr.ElementType == typeof(StringItem)) { si = new SLStringItem(); si.FromStringItem((StringItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.String, StringItems.Count)); StringItems.Add(si); } else if (oxr.ElementType == typeof(DateTimeItem)) { dti = new SLDateTimeItem(); dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.DateTime, DateTimeItems.Count)); DateTimeItems.Add(dti); } } } }
internal void FromSharedItems(SharedItems sis) { SetAllNull(); if (sis.ContainsSemiMixedTypes != null) { ContainsSemiMixedTypes = sis.ContainsSemiMixedTypes.Value; } if (sis.ContainsNonDate != null) { ContainsNonDate = sis.ContainsNonDate.Value; } if (sis.ContainsDate != null) { ContainsDate = sis.ContainsDate.Value; } if (sis.ContainsString != null) { ContainsString = sis.ContainsString.Value; } if (sis.ContainsBlank != null) { ContainsBlank = sis.ContainsBlank.Value; } if (sis.ContainsMixedTypes != null) { ContainsMixedTypes = sis.ContainsMixedTypes.Value; } if (sis.ContainsNumber != null) { ContainsNumber = sis.ContainsNumber.Value; } if (sis.ContainsInteger != null) { ContainsInteger = sis.ContainsInteger.Value; } if (sis.MinValue != null) { MinValue = sis.MinValue.Value; } if (sis.MaxValue != null) { MaxValue = sis.MaxValue.Value; } if (sis.MinDate != null) { MinDate = sis.MinDate.Value; } if (sis.MaxDate != null) { MaxDate = sis.MaxDate.Value; } //count if (sis.LongText != null) { LongText = sis.LongText.Value; } SLMissingItem mi; SLNumberItem ni; SLBooleanItem bi; SLErrorItem ei; SLStringItem si; SLDateTimeItem dti; using (var oxr = OpenXmlReader.Create(sis)) { while (oxr.Read()) { if (oxr.ElementType == typeof(MissingItem)) { mi = new SLMissingItem(); mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Missing, MissingItems.Count)); MissingItems.Add(mi); } else if (oxr.ElementType == typeof(NumberItem)) { ni = new SLNumberItem(); ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Number, NumberItems.Count)); NumberItems.Add(ni); } else if (oxr.ElementType == typeof(BooleanItem)) { bi = new SLBooleanItem(); bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Boolean, BooleanItems.Count)); BooleanItems.Add(bi); } else if (oxr.ElementType == typeof(ErrorItem)) { ei = new SLErrorItem(); ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.Error, ErrorItems.Count)); ErrorItems.Add(ei); } else if (oxr.ElementType == typeof(StringItem)) { si = new SLStringItem(); si.FromStringItem((StringItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.String, StringItems.Count)); StringItems.Add(si); } else if (oxr.ElementType == typeof(DateTimeItem)) { dti = new SLDateTimeItem(); dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement()); Items.Add(new SLSharedGroupItemsTypeIndexPair(SLSharedGroupItemsType.DateTime, DateTimeItems.Count)); DateTimeItems.Add(dti); } } } }
internal void FromPivotCacheRecord(PivotCacheRecord pcr) { SetAllNull(); SLMissingItem mi; SLNumberItem ni; SLBooleanItem bi; SLErrorItem ei; SLStringItem si; SLDateTimeItem dti; FieldItem fi; using (var oxr = OpenXmlReader.Create(pcr)) { while (oxr.Read()) { if (oxr.ElementType == typeof(MissingItem)) { mi = new SLMissingItem(); mi.FromMissingItem((MissingItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Missing, MissingItems.Count)); MissingItems.Add(mi); } else if (oxr.ElementType == typeof(NumberItem)) { ni = new SLNumberItem(); ni.FromNumberItem((NumberItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Number, NumberItems.Count)); NumberItems.Add(ni); } else if (oxr.ElementType == typeof(BooleanItem)) { bi = new SLBooleanItem(); bi.FromBooleanItem((BooleanItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Boolean, BooleanItems.Count)); BooleanItems.Add(bi); } else if (oxr.ElementType == typeof(ErrorItem)) { ei = new SLErrorItem(); ei.FromErrorItem((ErrorItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Error, ErrorItems.Count)); ErrorItems.Add(ei); } else if (oxr.ElementType == typeof(StringItem)) { si = new SLStringItem(); si.FromStringItem((StringItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.String, StringItems.Count)); StringItems.Add(si); } else if (oxr.ElementType == typeof(DateTimeItem)) { dti = new SLDateTimeItem(); dti.FromDateTimeItem((DateTimeItem)oxr.LoadCurrentElement()); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.DateTime, DateTimeItems.Count)); DateTimeItems.Add(dti); } else if (oxr.ElementType == typeof(FieldItem)) { fi = (FieldItem)oxr.LoadCurrentElement(); Items.Add(new SLPivotCacheRecordItemsTypeIndexPair(SLPivotCacheRecordItemsType.Field, FieldItems.Count)); FieldItems.Add(fi.Val.Value); } } } }