Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idx">boundary index</param>
        /// <param name="level"></param>
        public void MoveBoundary(int idx, double level)
        {
            var copy = Boundaries.ToArray();

            copy[idx]  = new LayerBoundary(level, copy[idx].Rank);
            Boundaries = copy;
        }
Example #2
0
 /// <param name="wpfHeight">The column height in WPF units</param>
 public LayerBoundaryEditorVM(double wpfHeight, int maxRank, AnnotationDirection annotationDirection)
 {
     Boundaries = new LayerBoundary[] {
         new LayerBoundary(0.0, maxRank),
         new LayerBoundary(wpfHeight, maxRank)
     };
     AnnotationDirection = annotationDirection;
 }
Example #3
0
        public void ChangeRank(Guid boundaryID, int rank)
        {
            LayerBoundary        toUpdate = boundaries.Single(b => b.ID == boundaryID);
            List <LayerBoundary> newVal   = new List <LayerBoundary>(boundaries.Where(b => b.ID != boundaryID));

            newVal.Add(new LayerBoundary(toUpdate.Level, rank));
            Boundaries = newVal.ToArray();
        }
        private void LayerLabel_MouseDown(object sender, MouseButtonEventArgs e)
        {
            LayerBoundary vm = DataContext as LayerBoundary;

            if (vm != null)
            {
                if (vm.DragStarted != null)
                {
                    DragStartEventArgs dsea = new DragStartEventArgs();
                    dsea.FrameworkElement = sender as FrameworkElement;
                    dsea.GetEventPoint    = (elem => e.GetPosition(elem));
                    vm.DragStarted.Execute(dsea);
                    e.Handled = true;
                }
            }
        }
Example #5
0
        /// <summary>
        /// Fills in Number array of each boundary with respect to the annotation direction
        /// </summary>
        /// <param name="boundaries">Including outer boundaries of the first and last layer</param>
        /// <returns></returns>
        public static void RecalcBoundaryNumbers(LayerBoundary[] boundaries, AnnotationDirection direction)
        {
            if (boundaries.Length == 0)
            {
                return;
            }

            //asserting conditions
            int maxRank = boundaries.Select(b => b.Rank).Max();

            if (boundaries[0].Rank != maxRank)
            {
                new ArgumentException("the first boundary must be outer boundaries having the max rank");
            }
            if (boundaries[boundaries.Length - 1].Rank != maxRank)
            {
                new ArgumentException("the last boundary must be outer boundaries having the max rank");
            }

            int N = boundaries.Length;

            int[] recentNumbers = Enumerable.Repeat(0, maxRank + 1).ToArray();

            switch (direction)
            {
            case AnnotationDirection.UpToBottom:
                for (int i = 0; i < N; i++)
                {
                    LayerBoundary lb = boundaries[i];
                    int           maxIdxToAccount = lb.Rank;

                    //updating recent numbers
                    recentNumbers[maxIdxToAccount]++;     //highest rank number increases
                    for (int j = 0; j < maxIdxToAccount; j++)
                    {
                        recentNumbers[j] = 1;     //lower numbers reset ot 1
                    }
                    //now copying the part of the recentNumbers to the lb.Number
                    lb.Numbers = recentNumbers.Take(maxIdxToAccount + 1).ToArray();
                }
                break;

            case AnnotationDirection.BottomToUp:

                for (int i = N - 1; i >= 0; i--)
                {
                    LayerBoundary lb = boundaries[i];

                    if (i == N - 1)
                    {
                        //lower boundary always contains all zeros, thus skipping it
                        lb.Numbers = recentNumbers.ToArray();
                        continue;
                    }

                    int maxIdxToAccount = lb.Rank;

                    //updating recent numbers
                    for (int j = 0; j <= maxIdxToAccount; j++)
                    {
                        recentNumbers[j]++;
                    }

                    //coping updated recent to the boundary
                    lb.Numbers = recentNumbers.Take(maxIdxToAccount + 1).ToArray();

                    //reseting lower rank recent numbers
                    for (int j = 0; j < maxIdxToAccount; j++)
                    {
                        recentNumbers[j] = 0;
                    }
                }

                break;

            default:
                throw new NotSupportedException();
                break;
            }

            return;
        }