Пример #1
0
        /// <summary>
        /// Returns the currently stored set of Api Keys
        /// </summary>
        /// <returns></returns>
        public ObservableConcurrentDictionary <string, string> GetKeys()
        {
            //Deserialize the ApiKeys
            this.ApiKeys = JsonConvert.DeserializeObject <ObservableConcurrentDictionary <string, string> >(this.Keys);

            return(this.ApiKeys);
        }
Пример #2
0
        private NeighborProtocol()
        {
            Neighbors   = new ObservableConcurrentDictionary <string, Neighbor>();
            settings    = Settings.GetInstance;
            senderEvent = new ManualResetEvent(settings.Online);
            address     = App.CheckInterfaces();

            listener = new Thread(Listen)
            {
                Name         = "listener",
                IsBackground = true
            };
            listener.Start();
            sender = new Thread(SendMe)
            {
                Name         = "sender",
                IsBackground = true
            };
            sender.Start();
            cleanT = new Thread(CleanMap)
            {
                Name         = "cleaner",
                IsBackground = true
            };
            cleanT.Start();
            waitForImage = new Thread(WaitForImageRequest)
            {
                Name         = "waitImage",
                IsBackground = true
            };
            waitForImage.Start();
        }
        private static ObservableConcurrentDictionary <string, string> PerformObservableDictionarySetup(
            ICollection <KeyValuePair <string, string> > items)
        {
            var setupLatch = new CountdownEvent(4 * items.Count);

            void SetupCollectionHandler(object sender, NotifyCollectionChangedEventArgs args)
            {
                setupLatch.Signal();
            }

            void SetupPropertyHandler(object sender, PropertyChangedEventArgs args)
            {
                setupLatch.Signal();
            }

            var observableDictionary =
                new ObservableConcurrentDictionary <string, string>(SetupCollectionHandler,
                                                                    SetupPropertyHandler);

            foreach (var item in items)
            {
                observableDictionary.Add(item);
            }

            setupLatch.Wait();

            observableDictionary.CollectionChanged -= SetupCollectionHandler;
            observableDictionary.PropertyChanged   -= SetupPropertyHandler;

            return(observableDictionary);
        }
Пример #4
0
 public ServerSpecificConfig()
 {
     ListOfSelfAssignableRoles = new ObservableCollection <ulong>();
     ObservingStreams          = new ObservableCollection <StreamNotificationConfig>();
     GenerateCurrencyChannels  = new ObservableConcurrentDictionary <ulong, int>();
     VoiceChannelLog           = new ObservableConcurrentDictionary <ulong, ulong>();
     LogserverIgnoreChannels   = new ObservableCollection <ulong>();
 }
Пример #5
0
 private TreeTaskManager()
 {
     this._schedulingLock   = new object();
     this._runningTasksLock = new object();
     this._treeControl      = null;
     this.ProgressManager   = null;
     this._nodeCounter      = null;
     this.RunningTasks      = new ObservableConcurrentDictionary <long, TreeTask>();
 }
Пример #6
0
		private TreeTaskManager()
		{
			this._schedulingLock   = new object();
			this._runningTasksLock = new object();
			this._treeControl      = null;
			this.ProgressManager   = null;
			this._nodeCounter      = null;
			this.RunningTasks      = new ObservableConcurrentDictionary<long, TreeTask>();
		}
Пример #7
0
        public bool ReadDatabase()
        {
            bool success = true;

            try
            {
                if (File.Exists(m_databaseFilename))
                {
                    m_editsDictionary = new ObservableConcurrentDictionary <double, ObservableCollection <FrameEdit> >();

                    using (BinaryReader br = new BinaryReader(new FileStream(m_databaseFilename, FileMode.Open)))
                    {
                        int numFrames = br.ReadInt32(); // read number of frames with edits

                        // iterate each frame with edits
                        for (int i = 0; i < numFrames; i++)
                        {
                            double timestamp     = br.ReadDouble();
                            int    numFrameEdits = br.ReadInt32();

                            ObservableCollection <FrameEdit> feList = new ObservableCollection <FrameEdit>();

                            for (int j = 0; j < numFrameEdits; j++)
                            {
                                FRAME_EDIT_TYPE type = (FRAME_EDIT_TYPE)br.ReadInt32();
                                int             x1   = br.ReadInt32();
                                int             y1   = br.ReadInt32();
                                int             x2   = br.ReadInt32();
                                int             y2   = br.ReadInt32();

                                FrameEdit fe = new FrameEdit(type, new BoundingBox(x1, y1, x2, y2));

                                feList.Add(fe);
                            }

                            m_editsDictionary.Add(timestamp, feList);
                        }
                    }
                }
                else
                {
                    success    = false;
                    m_errorMsg = "File does not exist: " + m_databaseFilename;
                    OnVideoEditsDatabaseEvent(new VideoEditsDatabase_EventArgs(true, m_errorMsg));
                }
            }
            catch (Exception ex)
            {
                m_errorMsg = ex.Message;
                success    = false;
                OnVideoEditsDatabaseEvent(new VideoEditsDatabase_EventArgs(true, m_errorMsg));
            }

            return(success);
        }
Пример #8
0
        public DataGridViewModel(IComponentContext container, IKeyService service, IEventAggregator eventAggregator, ILoggerFactory loggerfac)
        {
            this.ea        = eventAggregator;
            this.container = container;
            this.logger    = loggerfac.Create <DataGridViewModel>();
            var req = new AvailableRequests();

            this.Requests              = new ObservableCollection <RequestObject>(req.GetRequests());
            this.service               = service;
            this.ApiKeys               = new ObservableConcurrentDictionary <string, string>();
            this.ConnStrings           = new ObservableConcurrentDictionary <string, string>();
            this.ApiKeys               = service.GetKeys();
            this.ConnStrings           = service.GetConnections();
            this.UpdateServicesCommand = new DelegateCommand(UpdateServices);
            this.AddKeyToPluginCommand = new DelegateCommand(AddKeyToPlugin);
            this.PingDatabaseCommand   = new DelegateCommand(CheckConnection);
            this.aTimer             = new Timer();
            this.SelectedItemKey    = Properties.Settings.Default.CurrentKey;
            this.SelectedConnString = Properties.Settings.Default.CurrentConnString;
            this.Validity           = false;

            this.dictionary        = new ResourceDictionary();
            this.dictionary.Source = new Uri("/XModule;component/Resources/ResourceDictionary.xaml", UriKind.RelativeOrAbsolute);
            var value = this.dictionary["idatabackup50"].ToString();

            this.ImagePath = this.dictionary["idatabackup50"].ToString();

            this.ea.GetEvent <ConnectionImageChanged>().Subscribe((oc) =>
            {
                if (oc)
                {
                    this.ImagePath = this.dictionary["idatabaseview50"].ToString();
                }
                else
                {
                    this.ImagePath = this.dictionary["ideletedatabase50"].ToString();
                }
            });

            //subsccribes to the add keepa key event
            this.ea.GetEvent <AddKeepaKeyEvent>().Subscribe((oc) =>
            {
                AddKeyToPlugin();
            });

            //subscribes to the add keepa conn event
            this.ea.GetEvent <AddKeepaConnEvent>().Subscribe((oc) =>
            {
                AddConnToPlugin();
            });

            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 500;
            aTimer.Enabled  = true;
        }
Пример #9
0
        public LibraryItem(ISBN isbn, string title, Category category)
        {
            Validate(new KeyValuePair <string, object>("Title", title));

            _isbn     = isbn;
            _title    = title;
            _category = category;
            _copies   = new ObservableConcurrentDictionary <uint, ItemCopy>();
            _copies.CollectionChanged += _copies_CollectionChanged;
            AddCopy();
        }
Пример #10
0
 public Robot()
 {
     Controllers            = new ObservableConcurrentDictionary <uint, Controller>();
     Motors                 = new ObservableCollection <Motor>();
     SerialMotors           = new ObservableCollection <Motor>();
     SerialControllers      = new ObservableConcurrentDictionary <uint, Controller>();
     setpointTimer          = new System.Timers.Timer(19);
     setpointTimer.Elapsed += setpointTimer_Elapsed;
     //setpointTimer.Start();
     //StartUpdates();
 }
        public Calculation CreateEmptyCalculation()
        {
            ObservableConcurrentDictionary <string, Parameter> p_in = new ObservableConcurrentDictionary <string, Parameter>();

            p_in.Add("x", null);
            ObservableConcurrentDictionary <string, Parameter> p_out = new ObservableConcurrentDictionary <string, Parameter>();

            p_out.Add("out01", null);
            this.calc_candidate = new Calculation(CALC_CANDIDATE_EXPR, CALC_CANDIDATE_NAME, p_in, p_out);
            this.calc_record.Add(this.calc_candidate);
            return(this.calc_candidate);
        }
        /// <summary>
        /// Creates a named calculation that takes a lambda expression, input and output Parameter instances.
        /// </summary>
        /// <param name="_name"></param>
        /// <param name="_expr">a mathematical expression with named parameters (e.g. (x + y/2)*3.5)</param>
        /// <param name="_parameters_in">List of input parameters</param>
        /// <param name="_parameters_out">List of output parameters (each receives the same value)</param>
        /// <returns></returns>
        internal Calculation CreateCalculation(string _name, string _expr, Dictionary <string, Parameter> _parameters_in,
                                               Dictionary <string, Parameter> _parameters_out)
        {
            if (string.IsNullOrEmpty(_name) || string.IsNullOrEmpty(_expr) ||
                _parameters_in == null || _parameters_in.Count < 1 ||
                _parameters_out == null || _parameters_out.Count < 1)
            {
                return(null);
            }

            ObservableConcurrentDictionary <string, Parameter> p_IN = new ObservableConcurrentDictionary <string, Parameter>();

            foreach (var entry in _parameters_in)
            {
                p_IN.Add(entry.Key, entry.Value);
            }
            ObservableConcurrentDictionary <string, Parameter> p_OUT = new ObservableConcurrentDictionary <string, Parameter>();

            foreach (var entry in _parameters_out)
            {
                p_OUT.Add(entry.Key, entry.Value);
            }

            try
            {
                Dictionary <string, double> params_in_value = new Dictionary <string, double>();
                foreach (var entry in p_IN)
                {
                    if (entry.Value == null)
                    {
                        continue;
                    }
                    params_in_value.Add(entry.Key, entry.Value.ValueCurrent);
                }
                // try to parse the expression(SPACES and UNDERLINES cause Exceptions!!!)
                Func <double> func = CalculationFactory.CALCULATOR.ParseExpression(_expr, params_in_value).Compile();
                if (func == null)
                {
                    return(null);
                }
                // create the Calculation instance ONLY if parsing was successful
                Calculation c = new Calculation(_expr, _name, p_IN, p_OUT);
                this.calc_record.Add(c);
                return(c);
            }
            catch (Exception e)
            {
                string debug = e.Message;
                MessageBox.Show(debug, "Eingabefehler Gleichung", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
        }
Пример #13
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[]
        }
        private void InitializeHelix()
        {
            _items.Clear();
            _controllerObjects = new ObservableConcurrentDictionary <MotionControllerModel, SphereVisual3D>();

            _items.Add(new SunLight());
            _items.Add(new GridLinesVisual3D
            {
                Width  = 500,
                Length = 500
            });

            CubeVisual3D camera = new CubeVisual3D
            {
                SideLength = 10,
                Fill       = new SolidColorBrush(Colors.Blue),
                Center     = new Point3D(_camera.Calibration.TranslationToWorld[0, 0],
                                         _camera.Calibration.TranslationToWorld[2, 0],
                                         _camera.Calibration.TranslationToWorld[1, 0])
            };

            _items.Add(camera);

            ArrowVisual3D axis = new ArrowVisual3D
            {
                Origin    = new Point3D(0, 0, 0),
                Direction = new Vector3D(100, 0, 0),
                Diameter  = 2,
                Fill      = new SolidColorBrush(Colors.Red)
            };

            _items.Add(axis);

            axis = new ArrowVisual3D
            {
                Origin    = new Point3D(0, 0, 0),
                Direction = new Vector3D(0, 100, 0),
                Diameter  = 2,
                Fill      = new SolidColorBrush(Colors.Green)
            };
            _items.Add(axis);

            axis = new ArrowVisual3D
            {
                Origin    = new Point3D(0, 0, 0),
                Direction = new Vector3D(0, 0, 100),
                Diameter  = 2,
                Fill      = new SolidColorBrush(Colors.Blue)
            };
            _items.Add(axis);
        }
Пример #15
0
        public void SetDataRange(Enum key, uint value, ObservableConcurrentDictionary <Enum, DataBlock> dataMap)
        {
            byte[] bytes = BitConverter.GetBytes(value);
            Array.Reverse(bytes);

            using (var dataEntryEnumarator = dataMap[key].GetDataEntries())
            {
                int i = 0;
                while (dataEntryEnumarator.MoveNext() && i < bytes.Length)
                {
                    dataMap[key].UpdateData(dataEntryEnumarator.Current.Key, bytes[i++]);
                }
            }
        }
        public void TestTryAdd()
        {
            var latch = new CountdownEvent(4);

            var collectionChangedActions = new List <NotifyCollectionChangedAction>();
            var propertiesChanged        = new List <string>();

            void CollectionChangedHandler(object sender, NotifyCollectionChangedEventArgs args)
            {
                collectionChangedActions.Add(args.Action);
                latch?.Signal();
            }

            void PropertyChangedHandler(object sender, PropertyChangedEventArgs args)
            {
                propertiesChanged.Add(args.PropertyName);
                latch?.Signal();
            }

            var observableDictionary =
                new ObservableConcurrentDictionary <string, string>(CollectionChangedHandler, PropertyChangedHandler);

            var success = observableDictionary.TryAdd("1", "value");

            latch.Wait();

            Assert.True(success);

            Assert.Single(observableDictionary);

            var keys = new string[1];

            observableDictionary.Keys.CopyTo(keys, 0);
            Assert.Equal("1", keys[0]);

            var values = new string[1];

            observableDictionary.Values.CopyTo(values, 0);
            Assert.Equal("value", values[0]);

            Assert.Single(collectionChangedActions);
            Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedActions[0]);

            Assert.Equal(3, propertiesChanged.Count);
            Assert.Contains("Count", propertiesChanged);
            Assert.Contains("Keys", propertiesChanged);
            Assert.Contains("Values", propertiesChanged);

            latch.Dispose();
        }
Пример #17
0
    public ObservableConcurrentDictionaryView(ObservableConcurrentDictionary <TKey, TValue> dictionary, Func <TValue, TView> selector, string propertyName)
    {
        _propertyName = propertyName;
        _selector     = selector;

        _view = new ObservableConcurrentDictionary <TKey, TView>();
        _view.PropertyChanged   += (s, e) => PropertyChanged?.Invoke(s, e);
        _view.CollectionChanged += (s, e) => CollectionChanged?.Invoke(s, e);

        _dictionary = dictionary;
        _dictionary.CollectionChanged += OnSourceCollectionChanged;
        _dictionary.PropertyChanged   += OnSourceItemPropertyChanged;

        OnSourceCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, _dictionary.ToList()));
    }
        /// <summary>
        /// Is to be called only by the CalculationFactory, Component, and DXFComponent.
        /// </summary>
        /// <param name="_expr">a mathematical expression with named parameters (e.g. (x + y/2)*3.5)</param>
        /// <param name="_parameters_in">List of input parameters</param>
        /// <param name="_parameters_out">List of output / return parameters (each receives the same value)</param>
        internal Calculation(string _expr, string _name, ObservableConcurrentDictionary <string, Parameter> _parameters_in,
                             ObservableConcurrentDictionary <string, Parameter> _parameters_out)
        {
            this.ID           = (++Calculation.NR_CALCULATIONS);
            this.Name         = _name;
            this.Expression   = _expr;
            this.InputParams  = _parameters_in;
            this.ReturnParams = _parameters_out;
            this.GatherInputParamNames();
            this.GatherReturnParamNames();

            this.IsExpanded      = false;
            this.IsSelected      = false;
            this.OwnerIsSelected = false;
            this.UpToDate        = true;
        }
 public TransmissionLossCalculatorService()
 {
     WorkQueue = new ObservableConcurrentDictionary<Guid, Radial>();
     var calculator = new ActionBlock<Radial>(radial =>
     {
         if (!radial.IsDeleted) Calculate(radial);
         WorkQueue.Remove(radial.Guid);
         _shadeFileProcessorQueue.Post(radial);
     }, new ExecutionDataflowBlockOptions { BoundedCapacity = -1, MaxDegreeOfParallelism = System.Environment.ProcessorCount });
     _calculatorQueue = new BufferBlock<Radial>(new DataflowBlockOptions { BoundedCapacity = -1 });
     _calculatorQueue.LinkTo(calculator);
     var shadeFileProcessor = new ActionBlock<Radial>(r =>
     {
         if (!r.IsDeleted && r.ExtractAxisData()) r.ReleaseAxisData();
     }, new ExecutionDataflowBlockOptions { BoundedCapacity = -1, MaxDegreeOfParallelism = System.Environment.ProcessorCount });
     _shadeFileProcessorQueue = new BufferBlock<Radial>(new DataflowBlockOptions { BoundedCapacity = -1 });
     _shadeFileProcessorQueue.LinkTo(shadeFileProcessor);
 }
Пример #20
0
    protected AbstractOutputTarget(int instanceIndex, IEventAggregator eventAggregator, IDeviceAxisValueProvider valueProvider)
    {
        InstanceIndex   = instanceIndex;
        EventAggregator = eventAggregator;
        _valueProvider  = valueProvider;

        _statusEvent   = new AsyncManualResetEvent();
        Values         = DeviceAxis.All.ToDictionary(a => a, a => a.DefaultValue);
        AxisSettings   = new ObservableConcurrentDictionary <DeviceAxis, DeviceAxisSettings>(DeviceAxis.All.ToDictionary(a => a, _ => new DeviceAxisSettings()));
        UpdateInterval = 10;

        PropertyChanged += (s, e) =>
        {
            if (string.Equals(e.PropertyName, "Status", StringComparison.OrdinalIgnoreCase))
            {
                _statusEvent.Reset();
            }
        };
    }
Пример #21
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values[0] == null || values[1] == null)
            {
                return(false);
            }
            if (values[0] == DependencyProperty.UnsetValue)
            {
                return(false);
            }
            if (values[1] == DependencyProperty.UnsetValue)
            {
                return(false);
            }
            ObservableConcurrentDictionary <CameraModel, bool> dict = (ObservableConcurrentDictionary <CameraModel, bool>)values[0];
            CameraModel camera   = (CameraModel)values[1];
            bool        tracking = dict[camera];

            return(tracking);
        }
        private void SetSelectedItems()
        {
            if (SelectedItems == null)
            {
                SelectedItems = new ObservableConcurrentDictionary <string, object>();
            }
            //else
            //  ((ICollection<KeyValuePair<string, object>>)SelectedItems).Clear();
            foreach (var node in _nodeList.Where(node => node.Title != "All"))
            {
                if (node.IsSelected)
                {
                    SelectedItems.Add(node.Title, ItemsSource[node.Title]);
                }
                else
                {
                    SelectedItems.Remove(node.Title);
                }
            }

            SelectionChanged?.Invoke(this, EventArgs.Empty);
        }
Пример #23
0
        /// <summary>
        /// Make all new objects, restarts our stopwatch, starts search
        /// </summary>
        private void ExecuteSearch()
        {
            _numResults = 0;
            RefreshListView();
            progressBar.Maximum = _paraCount = DocumentHelpers.ActiveDocument.Paragraphs.Count;
            _cts = new CancellationTokenSource();
            _observableResults = new ObservableConcurrentDictionary <Word.Range, string>();
            _resultMap         = new Dictionary <int, Word.Range>();
            _hashList          = new HashSet <string>();
            _observableResults.CollectionChanged += AddedNewResult;
            _progressIndicator = new Progress <int>(UpdateStatuses);
            SetProxObject();
            if (DocumentHasChanges && (_prox != null))
            {
                GetParagraphMarkers();
            }

            _stopwatch = new Stopwatch();
            _stopwatch.Start();
            UpdateStatuses(0);
            GetObservableResults();
        }
        public void TestAddOrUpdate_TryRemove()
        {
            var npc = new NotifyPropertyChangedImpl();

            const string testKey = "One";

            var ocd = new ObservableConcurrentDictionary <string, NotifyPropertyChangedImpl>();

            ocd.AddOrUpdate(testKey, npc, (s, impl) => throw new InvalidOperationException());

            // Register without doing, just to make sure we also test the event generation for now
            ocd.CollectionChanged += (sender, args) =>
            {
                Log.Info().WriteLine($"Old location: {args.OldStartingIndex}");
            };

            var isNpcTriggered = false;

            // Subscribe to the PropertyChanged
            using (ocd.OnPropertyChanged().Subscribe(args => isNpcTriggered = true))
            {
                // change a value, a NPC is triggered
                npc.Name = "Robin1";
                // Test trigger
                Assert.True(isNpcTriggered);

                // Reset the trigger test value
                isNpcTriggered = false;

                // Remove the item, this should remove the event registration
                Assert.True(ocd.TryRemove(testKey, out _));

                // change a value, a NPC is triggered
                npc.Name = "Robin2";
                // Make sure we DID NOT get the trigger
                Assert.False(isNpcTriggered);
            }
        }
 public void Expose(ActorExposureRecord exposureRecord)
 {
     if (Filter1 == null) throw new ApplicationException("Filter1 cannot be null");
     if (Filter2 == null) throw new ApplicationException("Filter2 cannot be null");
     var key1 = Filter1(exposureRecord);
     if (!key1.HasValue) return;
     var key2 = Filter2(exposureRecord);
     if (!key2.HasValue) return;
     ObservableConcurrentDictionary<int, ObservableCollection<HistogramBins>> level2;
     if (!Exposures.TryGetValue(key1.Value, out level2))
     {
         level2 = new ObservableConcurrentDictionary<int, ObservableCollection<HistogramBins>>();
         if (!Exposures.TryAdd(key1.Value, level2)) if (!Exposures.TryGetValue(key1.Value, out level2)) throw new ApplicationException("Could not add level two dictionary.");
     }
     ObservableCollection<HistogramBins> bins;
     if (!level2.TryGetValue(key2.Value, out bins))
     {
         bins = new ObservableCollection<HistogramBins> { new HistogramBins(_histogramSource), new HistogramBins(_histogramSource) }; //peakSPL and Energy
         if (!level2.TryAdd(key2.Value, bins)) if (!level2.TryGetValue(key2.Value, out bins)) throw new ApplicationException("Could not add bins.");
     }
     bins[0].Add(exposureRecord.PeakSPL);
     bins[1].Add(exposureRecord.Energy);
 }
Пример #26
0
        public VideoEditsDatabase(string mp4Filename)
        {
            if (File.Exists(mp4Filename))
            {
                m_mp4Filename      = mp4Filename;
                m_databaseFilename = BuildVideoEditsDatabaseFilename(m_mp4Filename);

                m_editsDictionary = new ObservableConcurrentDictionary <double, ObservableCollection <FrameEdit> >();

                if (File.Exists(m_databaseFilename))
                {
                    if (ReadDatabase())
                    {
                        OnVideoEditsDatabaseEvent(new VideoEditsDatabase_EventArgs(false, "Reading Existing Edit Database:\n" +
                                                                                   m_databaseFilename));
                    }
                }
            }
            else
            {
                OnVideoEditsDatabaseEvent(new VideoEditsDatabase_EventArgs(true, "File does not exist:\n" + mp4Filename));
            }
        }
Пример #27
0
        /// <summary>Set all values</summary>
        public static void setStandardValues(ref dynamic vaProxy)
        {
            // Update our primary objects only if they don't match the state of the EDDI instance.
            try
            {
                if (EDDI.Instance.CurrentStarSystem != CurrentStarSystem)
                {
                    setStarSystemValues(EDDI.Instance.CurrentStarSystem, "System", ref vaProxy);
                    CurrentStarSystem = EDDI.Instance.CurrentStarSystem;
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set current system", ex);
            }

            try
            {
                if (EDDI.Instance.LastStarSystem != LastStarSystem)
                {
                    setStarSystemValues(EDDI.Instance.LastStarSystem, "Last system", ref vaProxy);
                    LastStarSystem = EDDI.Instance.LastStarSystem;
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set last system", ex);
            }

            try
            {
                if (EDDI.Instance.CurrentStellarBody != CurrentStellarBody)
                {
                    setDetailedBodyValues(EDDI.Instance.CurrentStellarBody, "Body", ref vaProxy);
                    CurrentStellarBody = EDDI.Instance.CurrentStellarBody;
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set stellar body", ex);
            }

            try
            {
                if (EDDI.Instance.CurrentStation != CurrentStation)
                {
                    setStationValues(EDDI.Instance.CurrentStation, "Last station", ref vaProxy);
                    CurrentStation = EDDI.Instance.CurrentStation;
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set last station", ex);
            }

            try
            {
                ShipMonitor shipMonitor = ((ShipMonitor)EDDI.Instance.ObtainMonitor("Ship monitor"));

                try
                {
                    if (shipMonitor?.GetCurrentShip() != Ship)
                    {
                        setShipValues(shipMonitor?.GetCurrentShip(), "Ship", ref vaProxy);
                        Ship = shipMonitor.GetCurrentShip();
                    }
                }
                catch (Exception ex)
                {
                    Logging.Error("Failed to set current ship values", ex);
                }

                try
                {
                    if (shipMonitor?.shipyard != Shipyard)
                    {
                        List <Ship> shipyard = new List <Ship>(shipMonitor?.shipyard);
                        if (shipyard != null)
                        {
                            int currentStoredShip = 1;
                            foreach (Ship StoredShip in shipyard)
                            {
                                setShipValues(StoredShip, "Stored ship " + currentStoredShip, ref vaProxy);
                                currentStoredShip++;
                            }
                            vaProxy.SetInt("Stored ship entries", shipMonitor?.shipyard.Count);
                        }
                        Shipyard = shipMonitor.shipyard;
                    }
                }
                catch (Exception ex)
                {
                    Logging.Error("Failed to set shipyard", ex);
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to obtain ship monitor & set VoiceAttack values", ex);
            }

            try
            {
                if (EDDI.Instance.HomeStarSystem != HomeStarSystem)
                {
                    setStarSystemValues(EDDI.Instance.HomeStarSystem, "Home system", ref vaProxy);
                    HomeStarSystem = EDDI.Instance.HomeStarSystem;

                    // Backwards-compatibility with 1.x
                    try
                    {
                        if (EDDI.Instance.HomeStarSystem != null)
                        {
                            vaProxy.SetText("Home system", EDDI.Instance.HomeStarSystem.name);
                            vaProxy.SetText("Home system (spoken)", Translations.StarSystem(EDDI.Instance.HomeStarSystem.name));
                        }
                        if (EDDI.Instance.HomeStation != null)
                        {
                            vaProxy.SetText("Home station", EDDI.Instance.HomeStation.name);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.Error("Failed to set 1.x home system values", ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set home system", ex);
            }

            try
            {
                Status currentStatus = ((StatusMonitor)EDDI.Instance.ObtainMonitor("Status monitor"))?.GetStatus();
                if (currentStatus != Status)
                {
                    setStatusValues(StatusMonitor.currentStatus, "Status", ref vaProxy);
                    Status = currentStatus;
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set current status", ex);
            }

            try
            {
                // Set SetState values
                if (EDDI.Instance.State != State)
                {
                    setDictionaryValues(EDDI.Instance.State, "state", ref vaProxy);
                    State = EDDI.Instance.State;
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set state", ex);
            }

            try
            {
                if (EDDI.Instance.Cmdr != Commander)
                {
                    setCommanderValues(EDDI.Instance.Cmdr, ref vaProxy);
                    Commander = EDDI.Instance.Cmdr;
                }
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set commander values", ex);
            }

            // On every event...
            // Set miscellaneous values
            try
            {
                vaProxy.SetText("Environment", EDDI.Instance.Environment);
                vaProxy.SetText("Vehicle", EDDI.Instance.Vehicle);
                vaProxy.SetText("EDDI version", Constants.EDDI_VERSION.ToString());
            }
            catch (Exception ex)
            {
                Logging.Error("Failed to set misc values", ex);
            }
        }
Пример #28
0
 public void PurgeThumbCache()
 {
     cache = new ObservableConcurrentDictionary<string, BitmapImage>();
 }
Пример #29
0
 public IODevice()
 {
     DataMapIn  = new ObservableConcurrentDictionary <Enum, DataBlock>();
     DataMapOut = new ObservableConcurrentDictionary <Enum, DataBlock>();
 }
        /*   private List<XMLSimSetupNotification> _simulations = new List<XMLSimSetupNotification>();
        public List<XMLSimSetupNotification> Simulations
        {
            get
            {
                return _simulations;
            }
            set
            {
                _simulations = value;
            }
        }*/
        public MainWindow()
        {
            InitializeComponent();

            //necessary for data binding
            this.DataContext = this;
            _setupMessages = new ObservableConcurrentDictionary<string, XMLSimSetupNotification>();
            _participantList = new ObservableConcurrentDictionary<string, SimulationParticipant>();

            LoadApplicationData(); // <---------start
        }
Пример #31
0
 private void OnDeserializing(StreamingContext context)
 {
     _copies = new ObservableConcurrentDictionary <uint, ItemCopy>();
 }
        private void InitializeHelix()
        {
            _items.Clear();
            _controllerObjects = new ObservableConcurrentDictionary<MotionControllerModel, SphereVisual3D>();

            _items.Add(new SunLight());
            _items.Add(new GridLinesVisual3D
            {
                Width = 500,
                Length = 500
            });

            CubeVisual3D camera = new CubeVisual3D
            {
                SideLength = 10,
                Fill = new SolidColorBrush(Colors.Blue),
                Center = new Point3D(_camera.Calibration.TranslationToWorld[0, 0],
                    _camera.Calibration.TranslationToWorld[2, 0],
                    _camera.Calibration.TranslationToWorld[1, 0])
            };
            _items.Add(camera);

            ArrowVisual3D axis = new ArrowVisual3D
            {
                Origin = new Point3D(0, 0, 0),
                Direction = new Vector3D(100, 0, 0),
                Diameter = 2,
                Fill = new SolidColorBrush(Colors.Red)
            };
            _items.Add(axis);

            axis = new ArrowVisual3D
            {
                Origin = new Point3D(0, 0, 0),
                Direction = new Vector3D(0, 100, 0),
                Diameter = 2,
                Fill = new SolidColorBrush(Colors.Green)
            };
            _items.Add(axis);

            axis = new ArrowVisual3D
            {
                Origin = new Point3D(0, 0, 0),
                Direction = new Vector3D(0, 0, 100),
                Diameter = 2,
                Fill = new SolidColorBrush(Colors.Blue)
            };
            _items.Add(axis);
        }
 public HelixCameraVisualizationService()
 {
     _controllerObjects = new ObservableConcurrentDictionary<MotionControllerModel, SphereVisual3D>();
 }
 public BinnedExposureDictionary(IHistogramSource histogramSource)
 {
     Exposures = new ObservableConcurrentDictionary<int, ObservableConcurrentDictionary<int, ObservableCollection<HistogramBins>>>();
     _histogramSource = histogramSource;
 }
Пример #35
0
		public Settings()
		{
			accountsDict = new ObservableConcurrentDictionary<string, UserCredential>();
		}
Пример #36
0
        public static Task FindText(string searchKey,
                                    bool searchKeyCaseSensitive,
                                    ObservableConcurrentDictionary <Word.Range, string> observableResults,
                                    IProgress <int> progress,
                                    CancellationToken cancelToken,
                                    ProxSearchSettings prox = null)
        {
            return(Task.Run(() =>
            {
                var paraVisitedCount = 0;
                var proxIsNull = (prox == null);
                int totalParaCount = DocumentHelpers.ActiveDocument.Paragraphs.Count;
                var pOpts = new ParallelOptions {
                    CancellationToken = cancelToken
                };
                var sKeyRegOpts = searchKeyCaseSensitive ? SysRegex.RegexOptions.None : SysRegex.RegexOptions.IgnoreCase;
                var searchKeyRegex = proxIsNull
                                ? new SysRegex.Regex(searchKey, sKeyRegOpts)
                                : new SysRegex.Regex(searchKey + ".*?" + prox.SearchKey + "|" + prox.SearchKey + ".*?" + searchKey + "|" + searchKey, sKeyRegOpts);

                Parallel.ForEach(DocumentHelpers.GetParagraphsEnumerator(),
                                 pOpts,
                                 (currentParagraph, loopState, index) =>
                {
                    // Catch this cancellation throw in the FindPane to update the pane/results
                    pOpts.CancellationToken.ThrowIfCancellationRequested();
                    var paraRange = ((Word.Paragraph)currentParagraph).Range;

                    // Find all of the single Find matches
                    if (proxIsNull)
                    {
                        FinderHelpers.DoFind(searchKeyRegex.Match(paraRange.Text),
                                             paraRange.Start,
                                             paraRange.End,
                                             observableResults);
                    }

                    #region Proximity Matching
                    // Proximity matching

                    else
                    {
                        // If we are doing interparagraph matching, let's make sure we don't
                        // try to access a paragraph out of bounds
                        if (prox.ParaProximity)
                        {
                            int lookaheadPosition = (int)index + prox.ParaThreshold;
                            int topRange = (lookaheadPosition > totalParaCount)
                                    ? totalParaCount
                                    : lookaheadPosition;
                            //Debug.WriteLine("LAP: " + lookaheadPosition.ToString() +
                            //                "Total: " + totalParaCount.ToString() +
                            //                "topRng: " + topRange.ToString());
                            paraRange.End = prox.ParaEndingRanges[topRange - 1];
                        }

                        IEnumerable <SysRegex.Match> matches = null;
                        if (paraRange.Text != null)
                        {
                            if (!prox.LogicalNot)
                            {
                                searchKeyRegex = new SysRegex.Regex(searchKey + ".*?" + prox.SearchKey, sKeyRegOpts);
                                var proxKeyRegex = new SysRegex.Regex(prox.SearchKey + ".*?" + searchKey, sKeyRegOpts);


                                var skMatches = searchKeyRegex.Matches(paraRange.Text);
                                var pkMatches = proxKeyRegex.Matches(paraRange.Text);
                                matches = skMatches.OfType <SysRegex.Match>()
                                          .Concat(pkMatches.OfType <SysRegex.Match>())
                                          .Where(m => m.Success);
                            }

                            else
                            {
                                // why didn't we do this in the assignment of matches and let the if statement
                                // override its value?  imagine all of the wasted ops this call does
                                // if its not needed!
                                matches = searchKeyRegex.Matches(paraRange.Text).OfType <SysRegex.Match>();
                            }

                            FinderHelpers.DoFindProximity(matches,
                                                          paraRange.Start,
                                                          paraRange.End,
                                                          new SysRegex.Regex(searchKey, sKeyRegOpts),
                                                          prox,
                                                          observableResults);
                        }
                    }
                    #endregion Proximity Matching

                    // Report back our progress
                    progress.Report(++paraVisitedCount);
                });
            }, cancelToken));
        }
Пример #37
0
 public Robot()
 {
     Controllers    = new ObservableConcurrentDictionary <uint, Controller>();
     Motors         = new ObservableCollection <Motor>();
     timer.Elapsed += timer_Elapsed;
 }
Пример #38
0
        public Configuration()
        {
            //First Time Installs
            redist_first_time      = true;
            logitech_first_time    = true;
            corsair_first_time     = true;
            razer_first_time       = true;
            steelseries_first_time = true;
            dualshock_first_time   = true;

            //General Program Settings
            allow_peripheral_devices     = true;
            UseVolumeAsBrightness        = false;
            allow_wrappers_in_background = true;
            allow_all_logitech_bitmaps   = true;
            GlobalBrightness             = 1.0f;
            KeyboardBrightness           = 1.0f;
            PeripheralBrightness         = 1.0f;
            updates_check_on_start_up    = true;
            start_silently              = false;
            close_mode                  = AppExitMode.Ask;
            mouse_orientation           = MouseOrientationType.RightHanded;
            keyboard_brand              = PreferredKeyboard.None;
            keyboard_localization       = PreferredKeyboardLocalization.None;
            mouse_preference            = PreferredMouse.None;
            virtualkeyboard_keycap_type = KeycapType.Default;
            detection_mode              = ApplicationDetectionMode.WindowsEvents;
            excluded_programs           = new HashSet <string>();
            //additional_profiles = new Dictionary<string, GenericApplicationProfileManager>();
            devices_disable_keyboard = false;
            devices_disable_mouse    = false;
            devices_disable_headset  = false;
            devices_disabled         = new HashSet <Type>();
            devices_disabled.Add(typeof(Devices.Dualshock.DualshockDevice));
            devices_disabled.Add(typeof(Devices.AtmoOrbDevice.AtmoOrbDevice));
            devices_disabled.Add(typeof(Devices.NZXT.NZXTDevice));
            OverlaysInPreview = true;

            //Blackout and Night theme
            time_based_dimming_enabled      = false;
            time_based_dimming_affect_games = false;
            time_based_dimming_start_hour   = 21;
            time_based_dimming_start_minute = 0;
            time_based_dimming_end_hour     = 8;
            time_based_dimming_end_minute   = 0;

            nighttime_enabled      = false;
            nighttime_start_hour   = 20;
            nighttime_start_minute = 0;
            nighttime_end_hour     = 7;
            nighttime_end_minute   = 0;

            //// Idle Effects
            idle_type  = IdleEffects.None;
            idle_delay = 5;
            idle_speed = 1.0f;
            idle_effect_primary_color   = Color.FromArgb(0, 255, 0);
            idle_effect_secondary_color = Color.FromArgb(0, 0, 0);
            idle_amount    = 5;
            idle_frequency = 2.5f;

            //Debug
            BitmapDebugTopMost = false;
            HttpDebugTopMost   = false;

            //ProfileOrder = new List<string>(ApplicationProfiles.Keys);

            VarRegistry = new VariableRegistry();

            EvaluatableTemplates = new ObservableConcurrentDictionary <string, IEvaluatable>();
        }
 public HelixCameraVisualizationService()
 {
     _controllerObjects = new ObservableConcurrentDictionary <MotionControllerModel, SphereVisual3D>();
 }
Пример #40
0
 public ServerModel()
 {
     _childSockets = new ObservableConcurrentDictionary<SimpleServerChildTcpSocket, ChildSocketState>();
     _clients = new ObservableConcurrentDictionary<SimpleServerChildTcpSocket, ClientModel>();
     _port = 3000;
 }