public void ObservableDictionaryExtensions_Any_ReturnsFalseIfObservableDictionaryDoesNotContainItems()
        {
            var dictionary = new ObservableDictionary<Int32, String>();

            var result = dictionary.Any();

            TheResultingValue(result).ShouldBe(false);
        }
        public void ObservableDictionaryExtensions_Any_ReturnsFalseIfObservableDictionaryDoesNotContainItems()
        {
            var dictionary = new ObservableDictionary <Int32, String>();

            var result = dictionary.Any();

            TheResultingValue(result).ShouldBe(false);
        }
        public void ObservableDictionaryExtensions_Any_ReturnsTrueIfObservableDictionaryContainsItems()
        {
            var dictionary = new ObservableDictionary <Int32, String>()
            {
                { 1, "A" },
            };

            var result = dictionary.Any();

            TheResultingValue(result).ShouldBe(true);
        }
        public void ObservableDictionaryExtensions_Any_ReturnsTrueIfObservableDictionaryContainsItems()
        {
            var dictionary = new ObservableDictionary<Int32, String>()
            {
                { 1, "A" },
            };

            var result = dictionary.Any();

            TheResultingValue(result).ShouldBe(true);
        }
        public void ObservableDictionaryExtensions_AnyWithPredicate_ReturnsFalseIfObservableDictionaryDoesNotContainMatchingItems()
        {
            var dictionary = new ObservableDictionary <Int32, String>()
            {
                { 1, "A" },
                { 3, "C" },
            };

            var result = dictionary.Any(x => x.Key % 2 == 0);

            TheResultingValue(result).ShouldBe(false);
        }
        public void ObservableDictionaryExtensions_AnyWithPredicate_ReturnsFalseIfObservableDictionaryDoesNotContainMatchingItems()
        {
            var dictionary = new ObservableDictionary<Int32, String>()
            {
                { 1, "A" },
                { 3, "C" },
            };

            var result = dictionary.Any(x => x.Key % 2 == 0);

            TheResultingValue(result).ShouldBe(false);
        }
Exemplo n.º 7
0
        void SetSources(bool forcePopulatePresetMapItemsSource = false)
        {
            CompileProcessesListBox.ItemsSource = CompileProcessesSubList.Any() && CompileProcessesSubList.Keys.Any(x => x == ConfigurationManager.CurrentPresetMap) ? CompileProcessesSubList[ConfigurationManager.CurrentPresetMap] : new ObservableCollection <CompileProcess>();

            // ran during first time setup to populate PresetMapConfigListBox.ItemsSource
            if (PresetMapConfigListBox.ItemsSource == null || forcePopulatePresetMapItemsSource)
            {
                var presetMapItemSources = new ObservableCollection <PresetMapCheckbox>();
                foreach (var presetMap in ConfigurationManager.KnownPresetsMaps)
                {
                    if (string.IsNullOrWhiteSpace(presetMap))
                    {
                        continue;
                    }

                    if (!CompilingManager.MapFiles.Any() || !CompilingManager.MapFiles.Keys.Any(x => x == presetMap))
                    {
                        CompilingManager.MapFiles.Add(presetMap, null);
                    }

                    var map       = CompilingManager.MapFiles[presetMap];
                    var file      = map == null ? string.Empty : map.File;
                    var compile   = map != null && map.Compile;
                    var processes = (map == null || map.Processes == null || map.Processes.Count() == 0) ? new Dictionary <string, MapProcess>() : map.Processes;
                    presetMapItemSources.Add(new PresetMapCheckbox(presetMap, file, compile, processes));
                }

                PresetMapConfigListBox.ItemsSource = presetMapItemSources;
            }

            MapListBox.ItemsSource = (!CompilingManager.MapFiles.Any() || !CompilingManager.MapFiles.Keys.Any(x => x == ConfigurationManager.CurrentPresetMap) || CompilingManager.MapFiles[ConfigurationManager.CurrentPresetMap] == null || CompilingManager.MapFiles[ConfigurationManager.CurrentPresetMap].File == null)
                                        ? new ObservableCollection <Map>()
                                        : new ObservableCollection <Map>()
            {
                CompilingManager.MapFiles[ConfigurationManager.CurrentPresetMap]
            };

            OrderManager.Init();

            if (!string.IsNullOrWhiteSpace(ConfigurationManager.CurrentPresetMap) && ConfigurationManager.CompileProcesses != null && ConfigurationManager.CompileProcesses.Any())
            {
                OrderManager.UpdateOrder();
            }


            //BindingOperations.EnableCollectionSynchronization(CurrentOrder, lockObj);
        }
Exemplo n.º 8
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length < 2)
            {
                return(null);
            }
            if (values[0] == null)
            {
                return(null);
            }

            ObservableDictionary <GraphNodeVM, int> nodes = values[0] as ObservableDictionary <GraphNodeVM, int>;

            if (nodes == null)
            {
                return(null);
            }
            if (values[1] == null)
            {
                return(null);
            }
            GraphNodeVM node = values[1] as GraphNodeVM;

            if (node == null)
            {
                return(null);
            }
            if (!nodes.Any())
            {
                return(null);
            }
            if (!nodes.ContainsKey(node))
            {
                return(null);
            }

            var tmp = nodes[node];

            return(tmp.ToString());
        }
Exemplo n.º 9
0
        public static void AssembleParameters()
        {
            var allPresetMapNames = new List <string>();

            if (!Directory.Exists(PresetsMapsFolder))
            {
                Directory.CreateDirectory(PresetsMapsFolder);
            }

            // get all preset map names, as there is no knowledge of them at this point on startup
            var presetsMaps = Directory.GetDirectories(PresetsMapsFolder);

            foreach (string presetPath in presetsMaps)
            {
                allPresetMapNames.Add(Path.GetFileName(presetPath));
            }


            CompileProcesses.Clear();

            string tempPresetName = "presetMapUsedToFillPresetDictionaryOnly";
            var    presetMapNames = allPresetMapNames.Any() ? allPresetMapNames : new List <string>()
            {
                tempPresetName
            };

            foreach (var presetMap in presetMapNames)
            {
                CompileProcesses.Add(presetMap, new ObservableCollection <CompileProcess>());

                CompileProcesses[presetMap].Add(new BSPPack());
                CompileProcesses[presetMap].Add(new CubemapProcess());
                CompileProcesses[presetMap].Add(new NavProcess());
                CompileProcesses[presetMap].Add(new ShutdownProcess());
                CompileProcesses[presetMap].Add(new UtilityProcess());
                CompileProcesses[presetMap].Add(new CustomProcess());

                //collect new metadatas

                var metadatas = Directory.GetDirectories(ParametersFolder);

                foreach (var metadata in metadatas)
                {
                    string folderName = Path.GetFileName(metadata);

                    if (CompileProcesses[presetMap].Any(c => String.Equals(c.Metadata.Name, folderName, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        continue;
                    }

                    var compileProcess = new CompileExecutable(folderName);

                    CompileProcesses[presetMap].Add(compileProcess);
                }

                //collect legacy metadatas
                var csvMetaDatas = Directory.GetFiles(ParametersFolder + "\\", "*.meta");

                foreach (var metadata in csvMetaDatas)
                {
                    string name = Path.GetFileName(metadata).Replace(".meta", "");

                    if (CompileProcesses[presetMap].Any(c => String.Equals(c.Metadata.Name, name, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        continue;
                    }

                    var compileProcess = new CompileExecutable(name);

                    CompileProcesses[presetMap].Add(compileProcess);
                }

                CompileProcesses[presetMap] = new ObservableCollection <CompileProcess>(CompileProcesses[presetMap].OrderBy(c => c.Metadata.Order));

                AssemblePreset(presetMap);
            }
            AssemblePresetMaps();

            // remove temp preset map name if used
            if (CompileProcesses.Any(x => x.Key == tempPresetName))
            {
                CompileProcesses.Remove(tempPresetName);
            }
        }
Exemplo n.º 10
0
        public int Score(ObservableDictionary<string, object> list, int score)
        {
            if (list.Any())
            {
                return score;
            }

            return 0;
        }