示例#1
0
        internal Rect GetRect(RowView rowView, RowBinding rowBinding)
        {
            var position = GetPosition(rowView, rowBinding);
            var size     = GetSize(rowView, rowBinding);

            return(new Rect(position, size));
        }
示例#2
0
 private void SetCurrentRowFromView()
 {
     Debug.Assert(_focusTo != null);
     UpdateCurrentContainerView(_focusTo);
     CurrentRow = _focusTo.RowPresenter;
     _focusTo   = null;
 }
        private static void VerifyRowBindingRect(LayoutManager layoutManager, RowView rowView, int rowBindingIndex, Rect expectedRect)
        {
            var rowBindings = rowView.RowBindings;
            var rect        = layoutManager.GetRect(rowView, rowBindings[rowBindingIndex]);

            Assert.AreEqual(expectedRect, rect);
        }
示例#4
0
        private void Swap(RowView oldValue, RowView newValue)
        {
            var oldRowPresenter = oldValue.RowPresenter;
            var newRowPresenter = newValue.RowPresenter;
            var oldBlockView    = oldValue.GetBlockView();
            var newBlockView    = newValue.GetBlockView();

            var oldCollection = GetPosition(oldValue, out int oldIndex);
            var newCollection = GetPosition(newValue, out int newIndex);

            if (oldCollection == newCollection && oldIndex < newIndex)
            {
                newCollection.RemoveAt(newIndex);
                oldCollection.RemoveAt(oldIndex);
            }
            else
            {
                oldCollection.RemoveAt(oldIndex);
                newCollection.RemoveAt(newIndex);
            }
            oldValue.Reload(newRowPresenter);
            newValue.Reload(oldRowPresenter);
            newValue.SetBlockView(oldBlockView);
            oldValue.SetBlockView(newBlockView);
            if (oldCollection == newCollection && newIndex < oldIndex)
            {
                newCollection.Insert(newIndex, oldValue);
                oldCollection.Insert(oldIndex, newValue);
            }
            else
            {
                oldCollection.Insert(oldIndex, newValue);
                newCollection.Insert(newIndex, oldValue);
            }
        }
示例#5
0
 private IElementCollection GetPosition(RowView rowView, out int index)
 {
     if (Template.ContainerKind == ContainerKind.Row)
     {
         var placement = GetContainerViewPlacement(rowView.RowPresenter);
         if (placement == CurrentContainerViewPlacement.WithinList)
         {
             index = ContainerViewListStartIndex + GetContainerView(rowView).ContainerOrdinal - ContainerViewList.First.ContainerOrdinal;
         }
         else if (placement == CurrentContainerViewPlacement.BeforeList)
         {
             index = HeadScalarElementsCount;
         }
         else
         {
             Debug.Assert(placement == CurrentContainerViewPlacement.AfterList);
             index = ContainerViewListStartIndex + ContainerViewList.Count;
         }
         return(ElementCollection);
     }
     else
     {
         var blockView = rowView.GetBlockView();
         index = blockView.BlockBindingsSplit + (rowView.RowPresenter.Index % FlowRepeatCount);
         return(blockView.ElementCollection);
     }
 }
示例#6
0
        private void BeginEdit(object sender, ExecutedRoutedEventArgs e)
        {
            var rowView      = RowView.GetCurrent((InPlaceEditor)sender);
            var rowPresenter = rowView.RowPresenter;

            rowPresenter.BeginEdit();
        }
示例#7
0
        internal ValidationInfo GetInfo(RowView rowView)
        {
            Debug.Assert(rowView != null);

            var rowPresenter = rowView.RowPresenter;

            for (int i = 0; i < Inputs.Count; i++)
            {
                if (HasError(rowPresenter, Inputs[i], true) || IsValidatingStatus(rowPresenter, Inputs[i], true))
                {
                    return(ValidationInfo.Empty);
                }
            }

            var errors = GetErrors(ValidationErrors.Empty, rowPresenter, null, false);

            errors = GetErrors(errors, rowPresenter, null, true);
            if (errors.Count > 0)
            {
                return(ValidationInfo.Error(errors.Seal()));
            }

            foreach (var asyncValidator in AsyncValidators)
            {
                if (asyncValidator.Status == AsyncValidatorStatus.Running)
                {
                    return(ValidationInfo.Validating);
                }
            }

            return(ValidationInfo.Empty);
        }
        public static Dictionary <int, double> Czebyszew(RowView newRow, List <RowView> allRows)
        {
            double max = 0;
            double mod = 0;
            Dictionary <int, double> results = new Dictionary <int, double>();
            //List<double> results = new List<double>();
            double value;
            double newValue;
            int    rowId = 0;

            foreach (var row in allRows)
            {
                for (int i = 0; i < newRow.Value.Count - 1; i++)
                {
                    value    = Convert.ToDouble(row.Value[i]);
                    newValue = Convert.ToDouble(newRow.Value[i]);
                    mod      = value - newValue;
                    mod      = Math.Abs(mod);
                    max      = Math.Max(max, mod);
                }
                results.Add(rowId, max);
                max = 0;
                mod = 0;
                //results.Add(sum);
                rowId++;
            }
            return(results);
        }
        public static Dictionary <int, double> Euklides(RowView newRow, List <RowView> allRows)
        {
            double sum = 0;
            double pow = 0;
            Dictionary <int, double> results = new Dictionary <int, double>();
            //List<double> results = new List<double>();
            double value;
            double newValue;
            int    rowId = 0;

            foreach (var row in allRows)
            {
                for (int i = 0; i < newRow.Value.Count - 1; i++)
                {
                    value    = Convert.ToDouble(row.Value[i]);
                    newValue = Convert.ToDouble(newRow.Value[i]);
                    pow      = value - newValue;
                    pow      = Math.Pow(pow, 2);
                    sum     += pow;
                }
                sum = Math.Sqrt(sum);
                results.Add(rowId, sum);
                sum = 0;
                pow = 0;
                //results.Add(sum);
                rowId++;
            }
            return(results);
        }
示例#10
0
        /// <inheritdoc/>
        protected internal override void Refresh(RowView rowView)
        {
            if (_backgroudnBrushes.Length == 0)
            {
                return;
            }

            rowView.Background = _backgroudnBrushes[rowView.RowPresenter.Index % AlternationCount];
        }
示例#11
0
            IEnumerable <CommandEntry> RowView.ICommandService.GetCommandEntries(RowView rowView)
            {
                var baseService = this.GetRegisteredService <RowView.ICommandService>();

                foreach (var entry in baseService.GetCommandEntries(rowView))
                {
                    yield return(entry);
                }
                yield return(Commands.SelectCurrent.Bind(new KeyGesture(System.Windows.Input.Key.Enter), new MouseGesture(MouseAction.LeftDoubleClick)));
            }
示例#12
0
            IEnumerable <CommandEntry> RowView.ICommandService.GetCommandEntries(RowView rowView)
            {
                var baseService = ServiceManager.GetRegisteredService <RowView.ICommandService>(this);

                foreach (var entry in baseService.GetCommandEntries(rowView))
                {
                    yield return(entry);
                }
                yield return(GotoSourceCommand.Bind(new KeyGesture(Key.Enter), new MouseGesture(MouseAction.LeftDoubleClick)));
            }
示例#13
0
        private void CanBeginEdit(object sender, CanExecuteRoutedEventArgs e)
        {
            var rowView      = RowView.GetCurrent((InPlaceEditor)sender);
            var rowPresenter = rowView.RowPresenter;

            e.CanExecute = rowPresenter.IsCurrent && !rowPresenter.IsEditing;
            if (!e.CanExecute)
            {
                e.ContinueRouting = true;
            }
        }
示例#14
0
        private void PreventCurrentRowViewFromLosingFocus(RowView newFocusedRowView)
        {
            // Focus management is tricky, we choose not to manage focus at all:
            // instead of setting focus back to current RowView, we reload CurrentRow
            // to the newly focused RowView.
            var oldValue = newFocusedRowView.RowPresenter;

            UpdateCurrentContainerView(newFocusedRowView);
            ContainerViewList.VirtualizeAll();
            CurrentContainerView.ReloadCurrentRow(oldValue);
        }
示例#15
0
 private ContainerView GetContainerView(RowView rowView)
 {
     if (Template.ContainerKind == ContainerKind.Row)
     {
         return(rowView);
     }
     else
     {
         return(rowView.GetBlockView());
     }
 }
示例#16
0
        protected virtual void CoerceCurrentRowView(RowView oldValue)
        {
            Debug.Assert(ContainerViewList.Count > 0);
            Debug.Assert(oldValue != null);
            Debug.Assert(CurrentContainerView == GetContainerView(oldValue));

            var oldPlacement = CurrentContainerViewPlacement;
            var newPlacement = GetContainerViewPlacement(CurrentRow);

            if (IsIsolated(oldPlacement))
            {
                if (IsIsolated(newPlacement))
                {
                    CurrentContainerView.ReloadCurrentRow(oldValue.RowPresenter);
                    if (oldPlacement != newPlacement)
                    {
                        ContainerViewList.VirtualizeAll();
                        newPlacement = CurrentContainerViewPlacement.Alone;
                    }
                }
                else
                {
                    var newValue = CurrentRow.View;
                    Swap(oldValue, newValue);
                    var removalIndex = HeadScalarElementsCount;
                    if (CurrentContainerViewPlacement == CurrentContainerViewPlacement.AfterList)
                    {
                        removalIndex += ContainerViewList.Count;
                    }
                    Cleanup((ContainerView)Elements[removalIndex]);
                    ElementCollection.RemoveAt(removalIndex);
                }
            }
            else
            {
                if (IsIsolated(newPlacement))
                {
                    Debug.Assert(CurrentRow.View == null);
                    var containerView = Setup(CurrentRow);
                    Debug.Assert(CurrentRow.View != null);
                    var insertIndex = HeadScalarElementsCount;
                    if (newPlacement == CurrentContainerViewPlacement.AfterList)
                    {
                        insertIndex += ContainerViewList.Count;
                    }
                    ElementCollection.Insert(insertIndex, containerView);
                }
                Swap(oldValue, CurrentRow.View);
            }

            CurrentContainerView          = GetContainerView(CurrentRow.View);
            CurrentContainerViewPlacement = newPlacement;
        }
        public void ReadFileFromPath(string path, bool firstRowHeader)
        {
            AllRows.ClearFullFile();
            AllRows allColumns = AllRows.GetInstance();

            char[] delimiters = new[] { ' ', ';', '\t' };
            string line;

            string[]     splitLine;
            bool         firstRow = true;
            StreamReader file     = new StreamReader(path);

            while ((line = file.ReadLine()) != null)
            {
                splitLine = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                if (splitLine.Length > 0)
                {
                    if (splitLine[0].FirstOrDefault() != '#')
                    {
                        if (firstRowHeader && firstRow)
                        {
                            allColumns.HeaderName = new List <string>();
                            for (int i = 0; i < splitLine.Length; i++)
                            {
                                allColumns.HeaderName.Add(splitLine[i]);
                            }
                            firstRow = false;
                        }
                        else if (!firstRowHeader && firstRow)
                        {
                            RowView column = new RowView();
                            allColumns.HeaderName = new List <string>();
                            for (int i = 0; i < splitLine.Length; i++)
                            {
                                column.Value.Add(splitLine[i]);
                                allColumns.HeaderName.Add("Kolumna__" + (i + 1));
                            }
                            allColumns.FullFile.Add(column);
                        }
                        else
                        {
                            RowView column = new RowView();
                            for (int i = 0; i < splitLine.Length; i++)
                            {
                                //List<string> column = new List<string>();
                                column.Value.Add(splitLine[i]);
                            }
                            allColumns.FullFile.Add(column);
                        }
                    }
                }
            }
        }
    private RowView CreateRow(KeyBinding binding)
    {
        RowView row = CreateEmptyRow();

        row.Command = binding.CommandName;
        row.Key     = binding.DisplayKey;
        if (isAllowedToRebind)
        {
            row.keyButton.onClick.AddListener(
                () => App.controller.menu.keyBindings.StartListeningForKeyAndRebind(binding));
        }
        return(row);
    }
示例#19
0
 internal Size Measure(RowView rowView, Size constraintSize)
 {
     Debug.Assert(IsMeasuring);
     if (IsPreparingMeasure)
     {
         PrepareMeasure(rowView);
     }
     else
     {
         FinalizeMeasure(rowView);
     }
     return(constraintSize);
 }
示例#20
0
        internal void ArrangeChildren(RowView rowView)
        {
            var rowBindings = rowView.RowBindings;

            if (rowBindings.Count == 0)
            {
                return;
            }

            foreach (var rowBinding in rowBindings)
            {
                var element = rowView.Elements[rowBinding.Ordinal];
                var rect    = GetRect(rowView, rowBinding);
                var clip    = GetFrozenClip(rowView, rowBinding);
                Arrange(element, rowBinding, rect, clip);
            }
        }
示例#21
0
 private void UpdateCurrentContainerView(RowView rowView)
 {
     if (CurrentContainerViewPlacement != CurrentContainerViewPlacement.WithinList)
     {
         Cleanup(CurrentContainerView);
         if (CurrentContainerViewPlacement == CurrentContainerViewPlacement.BeforeList)
         {
             ElementCollection.RemoveAt(HeadScalarElementsCount);
         }
         else
         {
             Debug.Assert(CurrentContainerViewPlacement == CurrentContainerViewPlacement.AfterList);
             ElementCollection.RemoveAt(HeadScalarElementsCount + ContainerViewList.Count);
         }
         CurrentContainerViewPlacement = CurrentContainerViewPlacement.WithinList;
     }
     CurrentContainerView = GetContainerView(rowView);
 }
示例#22
0
        private void PrepareMeasure(RowView rowView)
        {
            var autoSizeBindings = GetAutoSizeBindings(rowView);

            if (autoSizeBindings.Count == 0)
            {
                return;
            }

            var containerView = this[rowView];

            foreach (var rowBinding in autoSizeBindings)
            {
                var element           = rowView.Elements[rowBinding.Ordinal];
                var availableAutoSize = GetAvailableAutoSize(rowBinding, rowView.RowPresenter, out var autoWidthColumns, out var measuredWidth, out var autoHeightRows, out var measuredHeight);
                element.Measure(availableAutoSize);
                UpdateAutoSize(containerView, autoWidthColumns, measuredWidth, autoHeightRows, measuredHeight, element.DesiredSize);
            }
        }
示例#23
0
 internal void OnFocused(RowView rowView)
 {
     if (rowView.RowPresenter != CurrentRow)
     {
         SuspendInvalidateView();
         _currentRowChangedByInsertSuspended = true;
         _focusTo = rowView;
         if (!CanChangeCurrentRow)
         {
             PreventCurrentRowViewFromLosingFocus(rowView);
         }
         else if (_focusTo != null)  // _focusTo can be null from OnRowsChanged.
         {
             SetCurrentRowFromView();
         }
         _currentRowChangedByInsertSuspended = false;
         ResumeInvalidateView();
     }
 }
示例#24
0
        private void FinalizeMeasure(RowView rowView)
        {
            var rowBindings = rowView.RowBindings;

            if (rowBindings.Count == 0)
            {
                return;
            }

            foreach (var rowBinding in rowBindings)
            {
                // Resizing auto size binding should invalidate measure, the binding should only be measured with infinity length, which was done in previous PrepareMeasure.
                if (IsAutoSize(rowBinding, rowView))
                {
                    continue;
                }

                var element = rowView.Elements[rowBinding.Ordinal];
                element.Measure(GetSize(rowView, rowBinding));
            }
        }
示例#25
0
        public void HeavyMethod()
        {
            AllRows allColumns = AllRows.GetInstance();
            RowView row        = new RowView();

            for (int i = 0; i < allColumns.FullFile[0].Value.Count; i++)
            {
                Binding            binding = new Binding(String.Format("Value[{0}]", i));
                DataGridTextColumn column  = new DataGridTextColumn();
                binding.Mode = BindingMode.TwoWay;
                binding.ValidatesOnDataErrors = true;
                column.Binding     = binding;
                column.CanUserSort = false;
                column.Header      = allColumns.HeaderName[i];
                dataGrid.Columns.Add(column);
                row.Value.Add("");
            }
            NewObjects.Add(row);
            dataGrid.ItemsSource = NewObjects;

            //dataGrid.ItemsSource = allColumns.FullFile;
        }
示例#26
0
 //-------------------------------------------------------------------------------------------
 public DataAccess(RowView view, params String[] roles)
 {
     this.RowViews = view;
        this.AllowedRoles = roles;
 }
示例#27
0
 protected ContainerView this[RowView rowView]
 {
     get { return(this[rowView.ContainerOrdinal]); }
 }
示例#28
0
 /// <summary>
 /// Cleanup the <see cref="RowView"/>.
 /// </summary>
 /// <param name="rowView">The <see cref="RowView"/>.</param>
 protected internal abstract void Cleanup(RowView rowView);
示例#29
0
 protected override Point GetPosition(RowView rowView, RowBinding rowBinding)
 {
     return(Template.RowRange.GetRelativePosition(rowBinding.GridRange));
 }
示例#30
0
 internal override Thickness GetFrozenClip(RowView rowView, RowBinding rowBinding)
 {
     return(new Thickness());
 }
示例#31
0
 protected override Size GetSize(RowView rowView, RowBinding rowBinding)
 {
     return(rowBinding.GridRange.MeasuredSize);
 }