Beispiel #1
0
        private void EhSwitchToAdvancedView()
        {
            int from = _view.EasyRangeFrom;
            int to   = _view.EasyRangeTo;

            if (!(from < to))
            {
                Current.Gui.ErrorMessageBox("'Range start ('From') should be less than range end ('to')!");
                return;
            }
            _ranges.Clear();
            _ranges.Add(new MyRange {
                From = from, To = to
            });

            _view.SetRangeListSource(_ranges);
            _view.SwitchEasyAdvanced(_isInAdvancedView = true);
        }
Beispiel #2
0
        public void TestRemovingRanges()
        {
            RangeCollection ranges = new RangeCollection();

            ranges.AddRange(0, 4);
            ranges.RemoveRange(1, 2);
            Assert.AreEqual(2, ranges.Count);
            Assert.AreEqual(new Range(0, 0), ranges[0]);
            Assert.AreEqual(new Range(3, 4), ranges[1]);

            ranges.Clear();

            ranges.AddRange(0, 4);
            ranges.RemoveRange(0, 1);
            Assert.AreEqual(1, ranges.Count);
            Assert.AreEqual(new Range(2, 4), ranges[0]);

            ranges.Clear();

            ranges.AddRange(0, 4);
            ranges.RemoveRange(4, 4);
            Assert.AreEqual(1, ranges.Count);
            Assert.AreEqual(new Range(0, 3), ranges[0]);
        }
Beispiel #3
0
        private void Wait()
        {
            try
            {
                lock (_lockObj)
                {
                    _workerThreadIsSetUp.Set(); // once we're here, thread safety is ok. but make everyone wait till we get here.
                    while (true)
                    {
                        Monitor.Wait(_lockObj);                  // release lock and wait for pulse

                        if (_rangePendingCheckin.Count() > 0)
                        {
                            Console.WriteLine("Wait: {0} items to check in. Requesting file.", _rangePendingCheckin.Count());
                            Monitor.Exit(_lockObj);         // release lock while we block for file lock
                            _sharedRangeFile.ObtainLock();  // block until we get a lock on the shared file or sharedFile is disposed (haveLock = false)
                            Monitor.Enter(_lockObj);        // reobtain lock to allow us to finish up the work
                            Console.WriteLine("Wait: Checking in {0} items covering {1}.", _rangePendingCheckin.Count(), _rangePendingCheckin);

                            // note: it is very important that _rangeComplete ONLY be modified under these conditions; namely,
                            // 1) you have the lock on the shared file.
                            // 2) you have the lock on the _rangePendingCheckin. and
                            // 3) you just added items to the file.
                            // Failure to do so may result in multiple jobs thinking they were the last to add items.
                            _rangeCompletedByThisProcess = AsynchronousAddRangeToStream(_rangePendingCheckin, _numberOfItemsToAdd);
                            _rangePendingCheckin.Clear();

                            _sharedRangeFile.ReleaseLock();
                        }

                        Monitor.Pulse(_lockObj);        // let anyone waiting know we're done.
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Failure in SynchronizedRangeCollectionWrapper worker thread: {0}", e.Message);
                Console.WriteLine(e.StackTrace);
                throw;
            }
            finally
            {
                _sharedRangeFile.ReleaseLock(); // no matter what, we MUST release the file or the other processes may hang.
            }
        }
Beispiel #4
0
        protected void AdjustDataBounds(ChartColumnCollection columnSet)
        {
            _Ranges.Clear();
            Range globalRange = new NumberRange(0, 0);

            for (int i = 0; i < columnSet.Count; i++)
            {
                if (columnSet[i].Range.GetType() == typeof(NumberRange))
                {
                    globalRange = globalRange.ExpandTo(columnSet[i].Range);
                }
                // Experimental
                if (_EnableMultipleScales)
                {
                    _Ranges.AppendRange(columnSet[i].Range);
                }
            }
            if (!_EnableMultipleScales)
            {
                _Ranges.AppendRange(globalRange);
            }
        }