/// <summary>
        /// Converts the supplied arguments to an array of parameters describing the column.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments.</param>
        /// <returns>An array of cell info objects.</returns>
        public object Convert(object sender, object e)
        {
            if (e is MouseButtonEventArgs args)
            {
                if (args.ChangedButton != MouseButton.Left)
                {
                    return(null);
                }

                var tableView        = (TableView)sender;
                var tableViewHitInfo = tableView.CalcHitInfo((DependencyObject)args.OriginalSource);

                int?row = null;
                if (tableViewHitInfo.RowHandle != int.MinValue)
                {
                    row = tableViewHitInfo.RowHandle;
                }

                var matrixAddress = new MatrixAddress
                {
                    Row    = row,
                    Column = tableViewHitInfo.Column != null ? tableViewHitInfo.Column.FieldName : string.Empty
                };

                return(matrixAddress);
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Sets properties when the selected item changes
        /// </summary>
        /// <param name="matrixAddress">
        /// the address of the selected cell
        /// </param>
        private void SetRowAndColumnPropertiesOnSelectedItemChanged(MatrixAddress matrixAddress)
        {
            if (matrixAddress == null)
            {
                this.SelectedColumnDetails = string.Empty;
                this.SelectedRowDetails    = string.Empty;

                return;
            }

            var columnDefinition = this.Columns.SingleOrDefault(c => c.FieldName == matrixAddress.Column);

            this.SelectedColumnDetails = columnDefinition?.ToolTip;

            if (matrixAddress.Row != null)
            {
                var row = this.Records[matrixAddress.Row.Value];

                var firstColumn = row.FirstOrDefault();
                this.SelectedRowDetails = firstColumn
                                          .Value?
                                          .Tooltip ??
                                          string.Empty;
            }
            else
            {
                // column only selected
                this.SelectedRowDetails  = string.Empty;
                this.SelectedCellDetails = string.Empty;
            }
        }
예제 #3
0
 /// <summary>
 /// Executes the <see cref="MouseDownCommand" />
 /// </summary>
 /// <param name="matrixAddress">
 /// the address of the selected cell
 /// </param>
 private void MouseDownCommandExecute(MatrixAddress matrixAddress)
 {
     //Only if row is null, otherwise SelectedCell PropertyChanged handles setting properties
     if (matrixAddress.Row is null)
     {
         this.SetRowAndColumnPropertiesOnSelectedItemChanged(matrixAddress);
     }
 }
 public override void Setup()
 {
     base.Setup();
     this.vm            = new MatrixViewModel(this.session.Object, this.iteration, null);
     this.matrixAdress1 = new MatrixAddress();
     this.matrixAdress2 = new MatrixAddress()
     {
         Column = "column", Row = 1
     };
 }
예제 #5
0
        /// <summary>
        /// Sets the info detail properties
        /// </summary>
        /// <param name="vm"><see cref="MatrixCellViewModel"/> that represents the currently selected grid cell</param>
        private void SetPropertiesOnSelectedItemChanged(MatrixCellViewModel vm)
        {
            this.SelectedCellDetails = string.Empty;

            if (vm == null)
            {
                return;
            }

            var selectedRow = this.Records.FirstOrDefault(x => x.SingleOrDefault(y => y.Value == vm).Key != null);

            if (selectedRow != null)
            {
                var thing = vm.SourceX as DefinedThing;

                var matrixAddress = new MatrixAddress
                {
                    Column = thing?.ShortName ?? string.Empty,
                    Row    = this.Records.IndexOf(selectedRow)
                };

                this.SetRowAndColumnPropertiesOnSelectedItemChanged(matrixAddress);
            }

            var toolTip = new StringBuilder();

            foreach (var relationship in vm.Relationships)
            {
                if (toolTip.Length > 0)
                {
                    toolTip.AppendLine("");
                    toolTip.AppendLine("");
                }

                toolTip.AppendLine(relationship.Source.Equals(vm.SourceY) ? "------------->>>" : "<<<-------------");
                toolTip.Append(relationship.Tooltip());
            }

            this.SelectedCellDetails = toolTip.ToString();
        }