/// <summary>
        ///   Partially removes a given interval from an object range, so only the non intersecting part remains.
        /// </summary>
        /// <param name = "objectRange">The range of which to remove and split a given interval.</param>
        /// <param name = "interval">The interval to remove from the range.</param>
        void SplitRemoveIntersection(IntervalValues objectRange, Interval <TMath> interval)
        {
            // Remove original range.
            _rangedObjects.Remove(objectRange);

            // Add non intersection parts.
            foreach (var remaining in objectRange.Interval.Subtract(interval))
            {
                _rangedObjects.Add(new IntervalValues(objectRange.Values, remaining));
            }
        }
Ejemplo n.º 2
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            // Initialize UI components
            // Repository address
            this.AddressLabel.StringValue = Properties_Resources.WebAddress + ":";
            this.AddressText.StringValue  = Controller.saved_address.ToString();
            this.AddressText.Enabled      = false;

            // User
            this.UserLabel.StringValue = Properties_Resources.User + ":";
            this.UserText.StringValue  = Controller.saved_user;
            this.UserText.Enabled      = false;

            // Password
            this.PasswordLabel.StringValue = Properties_Resources.Password + ":";

            // SyncAtStartup option
            this.StartupCheckbox.Title = Properties_Resources.SyncAtStartup;
            this.StartupCheckbox.State = Controller.saved_syncatstartup ? NSCellStateValue.On : NSCellStateValue.Off;

            // Synchronize interval
            this.SliderLabel.StringValue      = Properties_Resources.SyncInterval + ":";
            this.SliderValueLabel.StringValue = FormattedIntervalString(Controller.saved_sync_interval);
            this.SliderValueLabel.Alignment   = NSTextAlignment.Right;

            this.Slider.TickMarkPosition         = NSTickMarkPosition.Below;
            this.Slider.TickMarksCount           = IntervalValues.Count();
            this.Slider.AllowsTickMarkValuesOnly = true;
            this.Slider.MinValue     = 0;
            this.Slider.MaxValue     = IntervalValues.Count() - 1;
            this.Slider.IntegerValue = PollingIntervalToSliderIndex(Controller.saved_sync_interval);
            this.Slider.Activated   += (object sender, EventArgs e) =>
            {
                SliderValueLabel.StringValue = FormattedIntervalString(SliderIndexToPollingInterval(Slider.IntValue));
            };

            this.SliderMinLabel.StringValue = FormattedIntervalString(IntervalValues[0]);
            this.SliderMaxLabel.StringValue = FormattedIntervalString(IntervalValues[IntervalValues.Count() - 1]);
            this.SliderMaxLabel.Alignment   = NSTextAlignment.Right;

            // CancelButton
            this.CancelButton.Title = Properties_Resources.Cancel;

            // SaveButton
            this.SaveButton.Title = Properties_Resources.Save;

            InsertEvent();
        }
 /// <summary>
 ///   Check whether the given interval with containing objects lies in this collection.
 /// </summary>
 /// <param name = "item">The interval with its objects to check whether its contained in the collection.</param>
 /// <returns>True when the interval and its objects lie in the collection, false otherwise.</returns>
 public bool Contains(IntervalValues item)
 {
     return(_rangedObjects.Contains(item));
 }
 /// <summary>
 ///   Remove an entire interval and its objects.
 /// </summary>
 /// <param name = "objectRange">The interval with its objects to remove.</param>
 /// <returns>True when successful, false otherwise.</returns>
 public bool Remove(IntervalValues objectRange)
 {
     return(_rangedObjects.Remove(objectRange));
 }
Ejemplo n.º 5
0
        // return inverval values (each representing one displayed pixel column)
        private IntervalValues[] CalcIntervalParams(int[] xBordersIndexes, Settings settings, bool calculateNeighborDistances)
        {
            IntervalValues[] yParams = new IntervalValues[settings.dataSize.Width];
            for (int i = 0; i < settings.dataSize.Width; i++)
            {
                if (xBordersIndexes[i] == xBordersIndexes[i + 1])
                {
                    yParams[i] = null;
                    continue;
                }

                double min = ys[xBordersIndexes[i]];
                double max = ys[xBordersIndexes[i]];
                for (int j = xBordersIndexes[i]; j < xBordersIndexes[i + 1]; j++)
                {
                    if (ys[j] < min)
                    {
                        min = ys[j];
                    }
                    if (ys[j] > max)
                    {
                        max = ys[j];
                    }
                }

                yParams[i] = new IntervalValues()
                {
                    yStart      = ys[xBordersIndexes[i]],
                    yEnd        = ys[xBordersIndexes[i + 1] - 1],
                    yMin        = min,
                    yMax        = max,
                    pointsCount = xBordersIndexes[i + 1] - xBordersIndexes[i],
                    pixelIndex  = i,
                };
            }

            if (calculateNeighborDistances)
            {
                const int distanceOnEdges = 100; // using Int.Max can produce overflow

                int Counter = distanceOnEdges;
                for (int i = 0; i < yParams.Length; i++)
                {
                    if (yParams[i] == null)
                    {
                        Counter++;
                    }
                    else
                    {
                        yParams[i].distanceToLeftNeighbor = Counter;
                        Counter = 1;
                    }
                }
                Counter = distanceOnEdges;
                for (int i = yParams.Length - 1; i > 0; i--)
                {
                    if (yParams[i] == null)
                    {
                        Counter++;
                    }
                    else
                    {
                        yParams[i].distanceToRightNeighbor = Counter;
                        Counter = 1;
                    }
                }
            }

            return(yParams);
        }