Exemple #1
0
        /// <summary>
        /// Removes all values of a property from all projects
        /// (for a given configuration/platform)
        /// </summary>
        /// <param name="name"></param>
        /// <param name="val"></param>
        public void Move(string name, string val)
        {
            Parallel.ForEach(_allProjects, proj =>
            {
                ProjectProperty p = proj.GetProperty(name);
                if (p != null &&
                    !p.IsEnvironmentProperty &&
                    !p.IsGlobalProperty &&
                    !p.IsImported &&
                    !p.IsReservedProperty)
                {
                    proj.RemoveProperty(p);
                }
            });

            if (_allFoundProperties.ContainsKey(name))
            {
                ReferencedProperty refp = _allFoundProperties[name];
                refp.RemoveProjects(_allProjects);
                if (refp.UsedCount == 0)
                {
                    bool removed = _allFoundProperties.Remove(name);
                    Debug.Assert(removed, "Property was not removed from the list");
                }
            }

            UpdatePropertySheet(name, val);
        }
Exemple #2
0
 public void RegisterPlugin(string key, IExceptionlessPlugin plugin)
 {
     if (_plugins.ContainsKey(key))
     {
         _plugins[key] = plugin;
     }
     else
     {
         _plugins.Add(key, plugin);
     }
 }
        public void GetPropertyValues()
        {
            foreach (MSBProject project in this.Projects)
            {
                ProjectProperty itemprop = project.GetProperty(this.Name);
                if (itemprop != null)
                {
                    string key = itemprop.EvaluatedValue;
                    if (String.Compare(this.Name, "OutputPath", true) == 0)
                    {
                        key = project.OutputPath;
                    }

                    if (_PropertyValues.ContainsKey(key))
                    {
                        _PropertyValues[key].AddProject(project);
                    }
                    else
                    {
                        _PropertyValues[key] = new ReferencedValues(project)
                        {
                            EvaluatedValue = key, Owner = this
                        };
                    }
                }
            }
        }
Exemple #4
0
        public SeasonalItemsViewModel()
        {
            Title                = "What's in Season?";
            Items                = new ObservableConcurrentDictionary <int, SeasonalItem>();
            DocsChangeIndexes    = new HashSet <int>();
            LoadItemsCommand     = new Command(() => ExecuteLoadItemsCommand());
            SaveDocumentsCommand = new Command(async() => await ExecuteSaveDocumentsCommand());

            //tag::LoadData[]
            var q = QueryBuilder.Select(SelectResult.All())
                    .From(DataSource.Database(_db))
                    .Where(Meta.ID.EqualTo(Expression.String(CoreApp.DocId)))
                    .AddChangeListener((sender, args) =>
            {
                var allResult = args.Results.AllResults();
                var result    = allResult[0];
                var dict      = result[CoreApp.DB.Name].Dictionary;
                var arr       = dict.GetArray(CoreApp.ArrKey);

                if (arr.Count < Items.Count)
                {
                    Items = new ObservableConcurrentDictionary <int, SeasonalItem>();
                }

                Parallel.For(0, arr.Count, i =>
                {
                    var item  = arr[i].Dictionary;
                    var name  = item.GetString("key");
                    var cnt   = item.GetInt("value");
                    var image = item.GetBlob("image");

                    if (_items.ContainsKey(i))
                    {
                        _items[i].Name           = name;
                        _items[i].Quantity       = cnt;
                        _items[i].ImageByteArray = image?.Content;
                    }
                    else
                    {
                        var seasonalItem = new SeasonalItem {
                            Index          = i,
                            Name           = name,
                            Quantity       = cnt,
                            ImageByteArray = image?.Content
                        };

                        _items.Add(i, seasonalItem);
                    }
                });
            });
            //end::LoadData[]
        }
Exemple #5
0
        public static void AddDrop(string drop)
        {
            var formattedDrop = drop.Replace("a ", "").Replace("an ", "");

            if (_drops.ContainsKey(formattedDrop))
            {
                _drops[formattedDrop] += 1;
            }
            else
            {
                _drops[formattedDrop] = 1;
            }
            NotifyPropertyChanged("Drops");
        }
 public void AddFrameEdit(double timestamp, FRAME_EDIT_TYPE type, BoundingBox bbox)
 {
     if (bbox.x2 - bbox.x1 > m_minimumRedactionSize && bbox.y2 - bbox.y1 > m_minimumRedactionSize) // make sure bounding box is big enough
     {
         if (m_editsDictionary.ContainsKey(timestamp))
         {
             ObservableCollection <FrameEdit> list = m_editsDictionary[timestamp];
             list.Add(new FrameEdit(type, bbox));
         }
         else
         {
             ObservableCollection <FrameEdit> list = new ObservableCollection <FrameEdit>();
             list.Add(new FrameEdit(type, bbox));
             m_editsDictionary.Add(timestamp, list);
         }
     }
 }
        private async void StartUpdateTask()
        {
            if (_updateTask != null && _updateTask.Status == TaskStatus.Running)
            {
                return;
            }

            _ctsUpdate = new CancellationTokenSource();
            try
            {
                _updateTask = Task.Factory.StartNew(() =>
                {
                    Stopwatch sw = new Stopwatch();
                    while (!_ctsUpdate.Token.IsCancellationRequested)
                    {
                        sw.Restart();
                        foreach (MotionControllerModel mc in _camera.Controllers)
                        {
                            var mc1 = mc;
                            // update if the controller is selected for tracking
                            if (mc.Tracking.ContainsKey(_camera) && mc.Tracking[_camera])
                            {
                                // add if missing
                                if (!_controllerObjects.ContainsKey(mc))
                                {
                                    DispatcherHelper.UIDispatcher.Invoke(() =>
                                    {
                                        // convert color
                                        byte r      = (byte)(mc1.Color.r * 255 + 0.5);
                                        byte g      = (byte)(mc1.Color.g * 255 + 0.5);
                                        byte b      = (byte)(mc1.Color.b * 255 + 0.5);
                                        Color color = Color.FromRgb(r, g, b);

                                        SphereVisual3D sphere = new SphereVisual3D
                                        {
                                            Center = new Point3D(mc1.WorldPosition[_camera].x,
                                                                 mc1.WorldPosition[_camera].z,
                                                                 mc1.WorldPosition[_camera].y),
                                            Radius = ((int)((14.0 / Math.PI) * 100)) / 200.0,
                                            Fill   = new SolidColorBrush(color)
                                        };
                                        _controllerObjects.Add(mc1, sphere);
                                        _items.Add(sphere);
                                    });
                                }
                                // update position
                                if (mc.WorldPosition.ContainsKey(_camera))
                                {
                                    DispatcherHelper.UIDispatcher.Invoke((Action)(() => _controllerObjects[mc1].Center = new Point3D(
                                                                                      mc1.WorldPosition[_camera].x,
                                                                                      mc1.WorldPosition[_camera].z,
                                                                                      mc1.WorldPosition[_camera].y)));
                                }
                            }
                            // remove objects corresponding to unselected controllers
                            else
                            {
                                if (_controllerObjects.ContainsKey(mc))
                                {
                                    DispatcherHelper.UIDispatcher.Invoke((Action)(() => _items.Remove(_controllerObjects[mc1])));
                                    _controllerObjects.Remove(mc);
                                }
                            }
                        } // foreach
                        sw.Stop();
                        // taking the processing time of the task itself into account, pause the thread to approximately reach the given FPS
                        Thread.Sleep((int)(Math.Max((1000.0 / _camera.FPS) - sw.ElapsedMilliseconds, 0) + 0.5));
                    } // while
                }, _ctsUpdate.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
                await _updateTask;
            }
            catch (OperationCanceledException ex)
            {
                Console.WriteLine(ex.StackTrace);
                Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                Stop();
            }
        }
Exemple #8
0
    private void OnSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        void Add(TKey key, TValue value)
        {
            _view[key] = _selector(value);
            if (value is INotifyPropertyChanged o)
            {
                o.PropertyChanged -= OnSourceItemPropertyChanged;
                o.PropertyChanged += OnSourceItemPropertyChanged;
            }
        }

        void AddRange(IEnumerable enumerable)
        {
            foreach (var(key, value) in enumerable.OfType <KeyValuePair <TKey, TValue> >())
            {
                Add(key, value);
            }
        }

        void Remove(TKey key, TValue value)
        {
            if (_view.ContainsKey(key))
            {
                _view.Remove(key);
            }

            if (value is INotifyPropertyChanged o)
            {
                o.PropertyChanged -= OnSourceItemPropertyChanged;
            }
        }

        void RemoveRange(IEnumerable enumerable)
        {
            foreach (var(key, value) in enumerable.OfType <KeyValuePair <TKey, TValue> >())
            {
                Remove(key, value);
            }
        }

        if (e.Action == NotifyCollectionChangedAction.Add)
        {
            AddRange(e.NewItems);
        }
        else if (e.Action == NotifyCollectionChangedAction.Remove)
        {
            RemoveRange(e.OldItems);
        }
        else if (e.Action == NotifyCollectionChangedAction.Replace)
        {
            RemoveRange(e.OldItems);
            AddRange(e.NewItems);
        }
        else if (e.Action == NotifyCollectionChangedAction.Reset)
        {
            foreach (var(key, value) in _dictionary)
            {
                Remove(key, _dictionary[key]);
            }

            _view.Clear();
        }
        else if (e.Action == NotifyCollectionChangedAction.Move)
        {
        }
    }
Exemple #9
0
 public bool ContainsKey(TKey key) => _dictionary.ContainsKey(key);