private void NotifyOuterKey(ValueChangedNotificationResult <TKey> keyChange, List <TResult> added, List <TResult> removed) { var value = (TaggedObservableValue <TKey, TOuter>)keyChange.Source; var group = groups[keyChange.OldValue]; group.OuterElements.Remove(value); if (group.InnerKeys.Count != 0) { var result = group.OuterElements[value]; removed.Add(result.Value); result.Successors.Unset(this); } if (!groups.TryGetValue(value.Value, out group)) { group = new KeyGroup(); groups.Add(value.Value, group); } var newResult = resultSelector.InvokeTagged(value.Tag, group.InnerElements, value.Tag); newResult.Successors.Set(this); group.OuterElements.Add(value, newResult); if (group.InnerKeys.Count != 0) { added.Add(newResult.Value); } }
/// <summary> /// Initializes a new instance of the <see cref="Morph"/> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> /// <param name="numVertices">The number vertices.</param> public Morph(NiFile file, BinaryReader reader, uint numVertices) { if (file.Version >= eNifVersion.VER_10_1_0_106) { this.FrameName = new NiString(file, reader); } if (file.Version <= eNifVersion.VER_10_1_0_0) { this.Keys = new KeyGroup<FloatKey>(reader); } if (file.Version >= eNifVersion.VER_10_1_0_106 && file.Version <= eNifVersion.VER_10_2_0_0) { this.UnkownInt = reader.ReadUInt32(); } if (file.Version >= eNifVersion.VER_20_0_0_4 && file.Version <= eNifVersion.VER_20_1_0_3) { this.UnkownInt = reader.ReadUInt32(); } this.Vectors = new Vector3[numVertices]; int num = 0; while ((long)num < (long)((ulong)numVertices)) { this.Vectors[num] = reader.ReadVector3(); num++; } }
private TResult AttachOuter(TOuter item) { var keyValue = outerKeySelector.InvokeTagged(item, item); keyValue.Successors.Set(this); Stack <TaggedObservableValue <TKey, TOuter> > valueStack; if (!outerValues.TryGetValue(item, out valueStack)) { valueStack = new Stack <TaggedObservableValue <TKey, TOuter> >(); outerValues.Add(item, valueStack); } valueStack.Push(keyValue); KeyGroup group; if (!groups.TryGetValue(keyValue.Value, out group)) { group = new KeyGroup(); groups.Add(keyValue.Value, group); } var resultValue = resultSelector.InvokeTagged(item, group.InnerElements, item); resultValue.Successors.Set(this); group.OuterElements.Add(keyValue, resultValue); return(resultValue.Value); }
protected void KeysGroup_Click(object sender, EventArgs e) { AdvAli.Entity.KeyGroup kg = new KeyGroup(); if (groupname.Value.Trim().Length == 0) { Common.MsgBox.Alert("分组名字不能为空!"); return; } if (Common.Util.GetPageParamsAndToInt("siteid") == -100 || Common.Util.GetPageParamsAndToInt("siteid") == 0) { Common.MsgBox.Alert("请选择分组所属网站!"); return; } kg.GroupName = groupname.Value.Trim(); kg.SiteId = Common.Util.GetPageParamsAndToInt("siteid"); kg.UserId = base.GetLoggedMemberId(); if (AdvAli.Keys.KeyManage.KeysGroupAdd(kg)) { Common.MsgBox.Alert("redirect", "关键字分组,添加成功!", "group.aspx"); } else { Common.MsgBox.Alert("alert", "分组名称已经存在!"); } }
private void OnOutputException(KeyGroup grp, Exception exception) { lock (_syncLock) { base.PushException(exception); } }
private void InnerKeyChanged(object sender, ValueChangedEventArgs e) { var value = sender as TaggedObservableValue <TKey, TInner>; var oldKey = (TKey)e.OldValue; var group = groups[oldKey]; group.InnerKeys.Remove(value); group.collectionView.NotifyRemoveItem(value.Tag); var removed = new List <TResult>(); if (group.InnerKeys.Count == 0) { removed.AddRange(group.OuterElements.Values.Select(r => r.Value)); } if (!groups.TryGetValue(value.Value, out group)) { group = new KeyGroup(); groups.Add(value.Value, group); } group.InnerKeys.Add(value); group.collectionView.NotifyAddItem(value.Tag); var added = new List <TResult>(); if (group.InnerKeys.Count == 1) { added.AddRange(group.OuterElements.Values.Select(r => r.Value)); } OnReplaceItems(removed, added); }
private void AttachInner(TInner item, ICollection <TResult> added) { var keyValue = innerKeySelector.InvokeTagged(item, item); Stack <TaggedObservableValue <TKey, TInner> > valueStack; if (!innerValues.TryGetValue(item, out valueStack)) { valueStack = new Stack <TaggedObservableValue <TKey, TInner> >(); innerValues.Add(item, valueStack); } valueStack.Push(keyValue); KeyGroup group; if (!groups.TryGetValue(keyValue.Value, out group)) { group = new KeyGroup(); groups.Add(keyValue.Value, group); } keyValue.ValueChanged += InnerKeyChanged; group.InnerKeys.Add(keyValue); group.collectionView.NotifyAddItem(item); if (group.InnerKeys.Count == 1 && added != null) { foreach (var result in group.OuterElements.Values) { added.Add(result.Value); } } }
/// <summary> /// Initializes a new instance of the <see cref="NiUVData"/> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> public NiUVData(NiFile file, BinaryReader reader) : base(file, reader) { this.UTranslation = new KeyGroup<FloatKey>(reader); this.VTranslation = new KeyGroup<FloatKey>(reader); this.UScalingAndTiling = new KeyGroup<FloatKey>(reader); this.VScalingAndTiling = new KeyGroup<FloatKey>(reader); }
private void OnOutputPushValue(KeyGroup grp, TOut value) { lock (_syncLock) { base.PushValue(value); } }
private void AttachInner(TInner item, ICollection <TResult> added) { var keyValue = innerKeySelector.InvokeTagged(item, item); Stack <TaggedObservableValue <TKey, TInner> > valueStack; if (!innerValues.TryGetValue(item, out valueStack)) { valueStack = new Stack <TaggedObservableValue <TKey, TInner> >(); innerValues.Add(item, valueStack); } valueStack.Push(keyValue); KeyGroup group; if (!groups.TryGetValue(keyValue.Value, out group)) { group = new KeyGroup(); groups.Add(keyValue.Value, group); } keyValue.ValueChanged += InnerKeyChanged; group.InnerKeys.Add(keyValue); if (added == null) { foreach (var outer in group.OuterKeys) { AttachResult(group, outer.Tag, item); } } else { foreach (var outer in group.OuterKeys) { added.Add(AttachResult(group, outer.Tag, item)); } } }
private void InnerKeyChanged(object sender, ValueChangedEventArgs e) { var value = sender as TaggedObservableValue <TKey, TInner>; var oldKey = (TKey)e.OldValue; var group = groups[oldKey]; group.InnerKeys.Remove(value); var removed = new List <TResult>(); foreach (var outer in group.OuterKeys) { removed.Add(DetachResult(group, outer.Tag, value.Tag)); } if (!groups.TryGetValue(value.Value, out group)) { group = new KeyGroup(); groups.Add(value.Value, group); } group.InnerKeys.Add(value); var added = new List <TResult>(); foreach (var outer in group.OuterKeys) { added.Add(AttachResult(group, outer.Tag, value.Tag)); } OnReplaceItems(removed, added); }
private void OnOutputCompleted(KeyGroup grp) { lock (_syncLock) { _outSubscriptions.TryDispose(grp.OutputSubscription); TryComplete(); } }
private void SetupKeyBinding() { KeyGroup keyGroup = new KeyGroup(getIdentifier()); keyGroup.keyGroupName = getName(); ScriptableSingleton <InputManager> .Instance.registerKeyGroup(keyGroup); RegisterKey("AnarchyToggle", KeyCode.None, "Toggle Construction Anarchy", "Used to enable or disable all settings applied by Construction Anarchy"); RegisterKey("AnarchySettings", KeyCode.None, "Open mods settings panel", "Can be used for easy access to Construction Anarchy settings panel"); }
public void KeyGroup_Constructor_CsvParsedCorrectly() { var sut = new KeyGroup("2ABC"); Assert.AreEqual('2', sut.MainDigit); Assert.AreEqual(3, sut.Letters.Length); Assert.AreEqual('A', sut.Letters[0]); Assert.AreEqual('B', sut.Letters[1]); Assert.AreEqual('C', sut.Letters[2]); }
private void SetupKeyBinding() { KeyGroup group = new KeyGroup(getIdentifier()); group.keyGroupName = getName(); InputManager.Instance.registerKeyGroup(group); RegisterKey("openSettings", KeyCode.U, "Toggle More Realism settings window", "Use this key to toggle the settings window for the park you're currently in"); }
public void KeyGroup_ToLinkedSymbols_WithoutLetters_OK() { var sut = new KeyGroup("0"); var symbols = sut.ToLinkedSymbols().ToArray(); Assert.AreEqual(1, symbols.Length); var symbol = symbols[0]; Assert.AreEqual('0', symbol.Value); Assert.AreEqual('0', symbol.MainDigit); Assert.AreEqual(char.MinValue, symbol.Previous); Assert.AreEqual(char.MinValue, symbol.Next); }
private TResult DetachResult(KeyGroup group, TOuter outer, TInner inner) { var match = new Match(outer, inner); var resultStack = group.Results[match]; var result = resultStack.Pop(); var value = result.Value; result.Successors.Unset(this); if (resultStack.Count == 0) { group.Results.Remove(match); } return(value); }
private TResult DetachResult(KeyGroup group, TOuter outer, TInner inner) { var match = new Match(outer, inner); var resultStack = group.Results[match]; var result = resultStack.Pop(); result.ValueChanged -= ResultValueChanged; result.Detach(); if (resultStack.Count == 0) { group.Results.Remove(match); } return(result.Value); }
public static FrameData Read(BinaryReader br) { FrameData ret = new FrameData(); ret.StartFrame = br.ReadUInt32(); ret.EndFrame = br.ReadUInt32(); ret.Offset = br.ReadUInt32(); ret.KeygroupCount = br.ReadUInt32(); ret.KeyGroups = new KeyGroup[ret.KeygroupCount]; for (int i = 0; i < ret.KeygroupCount; i++) { ret.KeyGroups[i] = KeyGroup.Read(br); } return(ret); }
private void SetupKeyBinding() { KeyGroup group = new KeyGroup(getIdentifier()); KeyMapping key = new KeyMapping(getIdentifier() + "/enter", KeyCode.R, KeyCode.None); key.keyGroupIdentifier = getIdentifier(); group.keyGroupName = "CoasterCam"; key.keyName = "Enter attraction"; key.keyDescription = "Use this key on a attraction to enter it"; InputManager.Instance.registerKeyGroup(group); InputManager.Instance.registerKeyMapping(key); }
public void Load(IList <KeyValuePair <string, IList <BookItem> > > recommandBookGroups) { foreach (var bookGroup in recommandBookGroups) { var group = new KeyGroup <string, BookCoverViewModel> { Key = bookGroup.Key }; group.AddRange(bookGroup.Value.Select(x => new BookCoverViewModel(x))); this.Add(group); } NotifyPropertyChanged("IsEmpty"); IsLoaded = true; IsLoading = false; }
private TResult AttachResult(KeyGroup group, TOuter outer, TInner inner) { var match = new Match(outer, inner); Stack <INotifyValue <TResult> > resultStack; if (!group.Results.TryGetValue(match, out resultStack)) { resultStack = new Stack <INotifyValue <TResult> >(); group.Results.Add(match, resultStack); } var result = resultSelector.Observe(outer, inner); result.ValueChanged += ResultValueChanged; resultStack.Push(result); return(result.Value); }
public static KeyGroup GetKeyGroup(int id) { KeyGroup kg = new KeyGroup(); using (DataSet ds = Logic.Consult.GetKeyGroup(id)) { if (Common.Util.CheckDataSet(ds)) { DataRow reader = ds.Tables[0].Rows[0]; kg.Id = Util.ConvertToInt(reader["id"].ToString()); kg.GroupName = reader["groupname"].ToString(); kg.SiteId = Util.ConvertToInt(reader["siteid"].ToString()); kg.UserId = Util.ConvertToInt(reader["userid"].ToString()); return(kg); } } return(null); }
protected override void AttachCore() { outerSource.Attach(); outerSource.CollectionChanged += OuterSourceCollectionChanged; var innerSourceNotifiable = innerSource as INotifyEnumerable <TInner>; if (innerSourceNotifiable != null) { innerSourceNotifiable.Attach(); innerSourceNotifiable.CollectionChanged += InnerSourceCollectionChanged; } else { var notifier = innerSource as INotifyCollectionChanged; if (notifier != null) { notifier.CollectionChanged += InnerSourceCollectionChanged; } } foreach (var item in outerSource) { var keyValue = outerKeySelector.InvokeTagged(item, item); Stack <TaggedObservableValue <TKey, TOuter> > valueStack; if (!outerValues.TryGetValue(item, out valueStack)) { valueStack = new Stack <TaggedObservableValue <TKey, TOuter> >(); outerValues.Add(item, valueStack); } valueStack.Push(keyValue); KeyGroup group; if (!groups.TryGetValue(keyValue.Value, out group)) { group = new KeyGroup(); groups.Add(keyValue.Value, group); } keyValue.ValueChanged += OuterKeyChanged; var resultValue = resultSelector.InvokeTagged(item, group.InnerKeys.Select(t => t.Tag), item); group.OuterElements.Add(keyValue, resultValue); } foreach (var item in innerSource) { AttachInner(item, null); } }
public static void Main() { Console.WriteLine("Interceptor example"); Console.WriteLine("CTRL-J, CTRL-SHIFT-J and CTRL-I all have simple console writeline global hot keys"); var h = new Interceptor(); h.KeyDown += InterceptKeys_KeyDown; h.KeyUp += InterceptKeys_KeyUp; var ctrlKeysGroup = KeyGroup.ControlKeys; var shftKeysGroup = KeyGroup.ShiftKeys; var iKeyGroup = new KeyGroup(Keys.I); var jKeyGroup = new KeyGroup(Keys.J); h.Register(() => Console.WriteLine("Hello from CTRL-J"), Keys.J, ctrlKeysGroup); h.Register(() => Console.WriteLine("Hello from CTRL-SHFT-J"), Keys.J, ctrlKeysGroup, shftKeysGroup); h.Register(() => Console.WriteLine("Hello from CTRL-SHFT-I"), ctrlKeysGroup, shftKeysGroup, iKeyGroup); h.Register(() => Console.WriteLine("Hello from CTRL-SHFT-I-J"), ctrlKeysGroup, shftKeysGroup, iKeyGroup, jKeyGroup); Application.Run(); }
private static KeyGroup[] ReadKeyGroups(EndianBinaryReader reader) { long chunkOffset = FindChunk(reader, "kgrp"); if (chunkOffset == -1) { return(Array.Empty <KeyGroup>()); } else { uint chunkLength = reader.ReadUInt32(chunkOffset + 0xC); var keyGroups = new KeyGroup[chunkLength / 8]; // 8 is the size of a KeyGroup for (int i = 0; i < keyGroups.Length; i++) { keyGroups[i] = reader.ReadObject <KeyGroup>(); } return(keyGroups); } }
public async Task <IDictionary <string, IList <BookItem> > > LoadAsync(bool forceRefresh = false, int maxVolumeCount = 9) { if (!IsLoading && (!IsLoaded || forceRefresh)) { IsLoading = true; try { var recommandBookGroups = await CachedClient.GetRecommandedBookLists(forceRefresh); this.Clear(); foreach (var bookGroup in recommandBookGroups) { var group = new KeyGroup <string, BookCoverViewModel> { Key = bookGroup.Key }; if (bookGroup.Value.Count <= maxVolumeCount) { group.AddRange(bookGroup.Value.Select(x => new BookCoverViewModel(x))); } else { group.AddRange(bookGroup.Value.Take(maxVolumeCount).Select(x => new BookCoverViewModel(x))); } this.Add(group); } IsLoading = false; IsLoaded = true; NotifyPropertyChanged("IsEmpty"); return(recommandBookGroups); } catch (Exception exception) { IsLoading = false; IsLoaded = false; Debug.WriteLine(exception.Message); return(null); } } return(null); }
private void NotifyInnerKey(ValueChangedNotificationResult <TKey> keyChange, List <TResult> replaceAdded, List <TResult> replaceRemoved) { var value = (TaggedObservableValue <TKey, TInner>)keyChange.Source; var group = groups[keyChange.OldValue]; group.InnerKeys.Remove(value); if (group.InnerKeys.Count == 0) { replaceRemoved.AddRange(group.OuterElements.Values.Select(r => r.Value)); } if (!groups.TryGetValue(value.Value, out group)) { group = new KeyGroup(); groups.Add(value.Value, group); } group.InnerKeys.Add(value); if (group.InnerKeys.Count == 1) { replaceAdded.AddRange(group.OuterElements.Values.Select(r => r.Value)); } }
public static KeyGroups GetKeyGroups(int userid, int siteid) { KeyGroups kgs = new KeyGroups(); using (DataSet ds = Logic.Consult.GetKeyGroups(userid, siteid)) { if (Common.Util.CheckDataSet(ds)) { foreach (DataRow reader in ds.Tables[0].Rows) { KeyGroup kg = new KeyGroup(); kg.Id = Util.ConvertToInt(reader["id"].ToString()); kg.GroupName = reader["groupname"].ToString(); kg.SiteId = Util.ConvertToInt(reader["siteid"].ToString()); kg.UserId = Util.ConvertToInt(reader["userid"].ToString()); kgs.Add(kg); } return(kgs); } } return(null); }
private KeyGroup GetOrCreateObservable(TIn value) { TKey key = _getKey(value); KeyGroup grp; if (!_observableDictionary.TryGetValue(key, out grp)) { grp = new KeyGroup { Key = key, PushSubject = new PushSubject <TIn>() }; grp.OutputSubscription = _groupedObservableTransformation(grp.PushSubject).Subscribe( i => OnOutputPushValue(grp, i), () => OnOutputCompleted(grp), e => OnOutputException(grp, e) ); _outSubscriptions.Set(grp.OutputSubscription); _observableDictionary[key] = grp; } return(grp); }
public async Task LoadRecommandDataAsync() { if (IsLoading || IsRecommandLoaded) { return; } LoadingText = "Loading recommand books"; IsLoading = true; try { var recommandBookGroups = await CachedClient.GetRecommandedBookLists(); RecommandBookItems = new List <KeyGroup <string, BookCoverViewModel> >(); foreach (var bookGroup in recommandBookGroups) { var group = new KeyGroup <string, BookCoverViewModel> { Key = bookGroup.Key }; if (bookGroup.Value.Count <= 12) { group.AddRange(bookGroup.Value.Select(x => new BookCoverViewModel(x))); } else { group.AddRange(bookGroup.Value.Take(12).Select(x => new BookCoverViewModel(x))); } RecommandBookItems.Add(group); } IsLoading = false; IsRecommandLoaded = true; } catch (Exception exception) { MessageBox.Show(exception.Message, "Exception when retriving recommanded books", MessageBoxButton.OK); IsLoading = false; } }
private void NotifyInnerKey(ValueChangedNotificationResult <TKey> keyChange, List <TResult> replaceAdded, List <TResult> replaceRemoved) { var value = (TaggedObservableValue <TKey, TInner>)keyChange.Source; var group = groups[keyChange.OldValue]; group.InnerKeys.Remove(value); foreach (var outer in group.OuterKeys) { replaceRemoved.Add(DetachResult(group, outer.Tag, value.Tag)); } if (!groups.TryGetValue(value.Value, out group)) { group = new KeyGroup(); groups.Add(value.Value, group); } group.InnerKeys.Add(value); foreach (var outer in group.OuterKeys) { replaceAdded.Add(AttachResult(group, outer.Tag, value.Tag)); } }
private void AttachOuter(TOuter item, ICollection <TResult> added) { var keyValue = outerKeySelector.InvokeTagged(item, item); keyValue.Successors.Set(this); Stack <TaggedObservableValue <TKey, TOuter> > valueStack; if (!outerValues.TryGetValue(item, out valueStack)) { valueStack = new Stack <TaggedObservableValue <TKey, TOuter> >(); outerValues.Add(item, valueStack); } valueStack.Push(keyValue); KeyGroup group; if (!groups.TryGetValue(keyValue.Value, out group)) { group = new KeyGroup(); groups.Add(keyValue.Value, group); } group.OuterKeys.Add(keyValue); if (added != null) { foreach (var inner in group.InnerKeys) { added.Add(AttachResult(group, item, inner.Tag)); } } else { foreach (var inner in group.InnerKeys) { AttachResult(group, item, inner.Tag); } } }
public async Task LoadRecommandDataAsync() { if (IsLoading || IsRecommandLoaded) return; LoadingText = "Loading recommand books"; IsLoading = true; try { var recommandBookGroups = await CachedClient.GetRecommandedBookLists(); RecommandBookItems = new List<KeyGroup<string, BookCoverViewModel>>(); foreach (var bookGroup in recommandBookGroups) { var group = new KeyGroup<string, BookCoverViewModel> { Key = bookGroup.Key }; if (bookGroup.Value.Count <= 12) group.AddRange(bookGroup.Value.Select(x=>new BookCoverViewModel(x))); else group.AddRange(bookGroup.Value.Take(12).Select(x=>new BookCoverViewModel(x))); RecommandBookItems.Add(group); } IsLoading = false; IsRecommandLoaded = true; } catch (Exception exception) { MessageBox.Show(exception.Message, "Exception when retriving recommanded books", MessageBoxButton.OK); IsLoading = false; } }
/// <summary> /// Initializes a new instance of the <see cref="NiColorData" /> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> public NiColorData(NiFile file, BinaryReader reader) : base(file, reader) { this.Data = new KeyGroup<Color4Key>(reader); }
/// <summary> /// Initializes a new instance of the <see cref="NiFloatData" /> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> public NiFloatData(NiFile file, BinaryReader reader) : base(file, reader) { this.Data = new KeyGroup<FloatKey>(reader); }
/// <summary> /// Initializes a new instance of the <see cref="NiKeyframeData" /> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> public NiKeyframeData(NiFile file, BinaryReader reader) : base(file, reader) { uint num = reader.ReadUInt32(); if (num != 0u) { this.KeyType = (eKeyType)reader.ReadUInt32(); } if (this.KeyType != eKeyType.XYZ_ROTATION_KEY) { this.QuaternionKeys = new QuatKey[num]; int num2 = 0; while ((long)num2 < (long)((ulong)num)) { this.QuaternionKeys[num2] = new QuatKey(reader, this.KeyType); num2++; } } if (base.Version <= eNifVersion.VER_10_1_0_0 && this.KeyType == eKeyType.XYZ_ROTATION_KEY) { this.UnkownFloat = reader.ReadSingle(); } if (this.KeyType == eKeyType.XYZ_ROTATION_KEY) { this.Rotations = new KeyGroup<FloatKey>[3]; for (int i = 0; i < 3; i++) { this.Rotations[i] = new KeyGroup<FloatKey>(reader); } } this.Translations = new KeyGroup<VecKey>(reader); this.Scales = new KeyGroup<FloatKey>(reader); }
/// <summary> /// Initializes a new instance of the <see cref="NiPosData"/> class. /// </summary> /// <param name="file">The file.</param> /// <param name="reader">The reader.</param> public NiPosData(NiFile file, BinaryReader reader) : base(file, reader) { this.Data = new KeyGroup<VecKey>(reader); }