示例#1
0
        /// <summary>
        /// Refreshes the list of elements that can be set as current selection.
        /// </summary>
        private void RefreshSelectableElements()
        {
            selectableElements.Clear();

            var worldPosition = Controller.GetMousePositionInUI();
            var elements      = GetElementsAtPosition(ref worldPosition);

            if (elements != null)
            {
                selectableElements.AddRange(elements);
            }
        }
示例#2
0
 /// <summary>
 /// Activates the given plugin.
 /// </summary>
 /// <param name="p_lstPlugins">The list of plugin to activate.</param>
 public void ActivatePlugins(IList <Plugin> p_lstPlugins)
 {
     m_ostActivePlugins.AddRange(p_lstPlugins);
     if (CurrentTransaction == null)
     {
         Commit();
     }
     else
     {
         Enlist();
     }
 }
示例#3
0
        private void AddLibrary(UILibraryViewModel library)
        {
            // Don't add itself as a library or if already referenced
            if (library == Asset || factories.Any(l => l.Category == library.Url))
            {
                return;
            }

            var asset = library.Asset;
            var list  = asset.PublicUIElements.Select(x => new UIElementFromLibrary(ServiceProvider, library, x.Key)).OrderBy(x => x.Name);

            factories.AddRange(list);

            if (!library.IsEditable)
            {
                return;
            }

            var node = NodeContainer.GetOrCreateNode(asset)[nameof(UILibraryAsset.PublicUIElements)].Target;

            node.ItemChanged += LibraryContentChanged;
        }
 private void LoadFromSettings()
 {
     lock (SyncRoot)
     {
         // We load a copy of the profile in case concurrent Game Studio instances are running.
         var profileCopy = loadLatestProfile.Invoke();
         var loadedList  = settingsKey.GetValue(profileCopy, true);
         // Sort by descending timestamp
         loadedList.Sort((x, y) => - x.Timestamp.CompareTo(y.Timestamp));
         mruList.Clear();
         mruList.AddRange(loadedList.Where(IsDataValid));
     }
 }
示例#5
0
        public void TestAddRange()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.Equal(set.Count, list.Count);
            bool propertyChangedInvoked   = false;
            bool collectionChangedInvoked = false;

            set.PropertyChanged += (sender, e) =>
            {
                Assert.Equal(nameof(ObservableSet <string> .Count), e.PropertyName);
                propertyChangedInvoked = true;
            };
            set.CollectionChanged += (sender, e) =>
            {
                Assert.Equal(NotifyCollectionChangedAction.Add, e.Action);
                Assert.Equal(3, e.NewStartingIndex);
                Assert.NotNull(e.NewItems);
                Assert.Equal(2, e.NewItems.Count);
                Assert.Equal("ddd", e.NewItems[0]);
                Assert.Equal("eee", e.NewItems[1]);
                collectionChangedInvoked = true;
            };
            set.AddRange(new[] { "ddd", "eee" });
            Assert.Equal(5, set.Count);
            Assert.Equal("aaa", set[0]);
            Assert.Equal("bbb", set[1]);
            Assert.Equal("ccc", set[2]);
            Assert.Equal("ddd", set[3]);
            Assert.Equal("eee", set[4]);
            Assert.True(propertyChangedInvoked);
            Assert.True(collectionChangedInvoked);
        }
示例#6
0
        public void TestAddRange()
        {
            var list = new List <string> {
                "aaa", "bbb", "ccc"
            };
            var set = new ObservableSet <string>(list);

            Assert.Equal(set.Count, list.Count);
            bool propertyChangedInvoked   = false;
            bool collectionChangedInvoked = false;

            set.PropertyChanged += (sender, e) =>
            {
                Assert.Equal(e.PropertyName, nameof(ObservableSet <string> .Count));
                propertyChangedInvoked = true;
            };
            set.CollectionChanged += (sender, e) =>
            {
                Assert.Equal(e.Action, NotifyCollectionChangedAction.Add);
                Assert.Equal(e.NewStartingIndex, 3);
                Assert.NotNull(e.NewItems);
                Assert.Equal(e.NewItems.Count, 2);
                Assert.Equal(e.NewItems[0], "ddd");
                Assert.Equal(e.NewItems[1], "eee");
                collectionChangedInvoked = true;
            };
            set.AddRange(new[] { "ddd", "eee" });
            Assert.Equal(set.Count, 5);
            Assert.Equal(set[0], "aaa");
            Assert.Equal(set[1], "bbb");
            Assert.Equal(set[2], "ccc");
            Assert.Equal(set[3], "ddd");
            Assert.Equal(set[4], "eee");
            Assert.True(propertyChangedInvoked);
            Assert.True(collectionChangedInvoked);
        }
示例#7
0
 public void TestAddRange()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableSet<string>(list);
     Assert.AreEqual(set.Count, list.Count);
     bool propertyChangedInvoked = false;
     bool collectionChangedInvoked = false;
     set.PropertyChanged += (sender, e) =>
     {
         Assert.AreEqual(e.PropertyName, nameof(ObservableSet<string>.Count));
         propertyChangedInvoked = true;
     };
     set.CollectionChanged += (sender, e) =>
     {
         Assert.AreEqual(e.Action, NotifyCollectionChangedAction.Add);
         Assert.AreEqual(e.NewStartingIndex, 3);
         Assert.NotNull(e.NewItems);
         Assert.AreEqual(e.NewItems.Count, 2);
         Assert.AreEqual(e.NewItems[0], "ddd");
         Assert.AreEqual(e.NewItems[1], "eee");
         collectionChangedInvoked = true;
     };
     set.AddRange(new[] { "ddd", "eee" });
     Assert.AreEqual(set.Count, 5);
     Assert.AreEqual(set[0], "aaa");
     Assert.AreEqual(set[1], "bbb");
     Assert.AreEqual(set[2], "ccc");
     Assert.AreEqual(set[3], "ddd");
     Assert.AreEqual(set[4], "eee");
     Assert.True(propertyChangedInvoked);
     Assert.True(collectionChangedInvoked);
 }