コード例 #1
0
        private async Task InputManager_AsyncValidators_faulted_Async()
        {
            var dataSet = DataSet <ProductCategory> .Create();

            var _ = dataSet._;

            dataSet.Add(new DataRow());

            RowBinding <TextBox> textBox = null;
            var inputManager             = dataSet.CreateInputManager(builder =>
            {
                textBox = _.Name.BindToTextBox();

                builder.GridColumns("100").GridRows("100")
                .AddBinding(0, 0, textBox).WithRowValidationMode(ValidationMode.Implicit);

                builder.AddAsyncValidator(textBox.Input, dataRow => ValidateFaultedAsync(dataRow));
            });

            var currentRow     = inputManager.CurrentRow;
            var asyncValidator = inputManager.RowValidation.AsyncValidators[0];

            textBox[currentRow].Text = "Anything";
            Assert.AreEqual(AsyncValidatorStatus.Running, asyncValidator.Status);

            await asyncValidator.LastRunTask;

            Assert.AreEqual(AsyncValidatorStatus.Faulted, asyncValidator.Status);
            Assert.AreEqual(typeof(InvalidOperationException), asyncValidator.Exception.GetType());
        }
コード例 #2
0
ファイル: LayoutManager.cs プロジェクト: xydoublez/RDO.Net
        internal Rect GetRect(RowView rowView, RowBinding rowBinding)
        {
            var position = GetPosition(rowView, rowBinding);
            var size     = GetSize(rowView, rowBinding);

            return(new Rect(position, size));
        }
コード例 #3
0
        public void InputManager_AsyncValidators_Reset()
        {
            var dataSet = DataSet <ProductCategory> .Create();

            var _ = dataSet._;

            dataSet.Add(new DataRow());

            RowBinding <TextBox> textBox = null;
            var inputManager             = dataSet.CreateInputManager(builder =>
            {
                textBox = _.Name.BindToTextBox();

                builder.GridColumns("100").GridRows("100")
                .AddBinding(0, 0, textBox).WithRowValidationMode(ValidationMode.Implicit);

                builder.AddAsyncValidator(textBox.Input, dataRow => ValidateFaultedAsync(dataRow));
            });

            var currentRow     = inputManager.CurrentRow;
            var asyncValidator = inputManager.RowValidation.AsyncValidators[0];

            textBox[currentRow].Text = "Anything";
            Assert.AreEqual(AsyncValidatorStatus.Running, asyncValidator.Status);

            asyncValidator.Reset();
            inputManager.InvalidateView();
            Assert.AreEqual(AsyncValidatorStatus.Inactive, asyncValidator.Status);
            Assert.IsNull(asyncValidator.Exception);
        }
コード例 #4
0
        public void ElementManager_RefreshElements_IsEditing()
        {
            var dataSet = DataSetMock.ProductCategories(8, false);
            var _       = dataSet._;
            RowBinding <TextBlock> textBlock = null;
            var elementManager = dataSet.CreateElementManager((builder) =>
            {
                textBlock = _.Name.BindToTextBlock();
                builder.GridColumns("100").GridRows("100")
                .AddBinding(0, 0, textBlock);
            });

            var template = elementManager.Template;
            var rows     = elementManager.Rows;

            Assert.IsFalse(rows[0].IsEditing);

            {
                var elements = elementManager.Elements;
                Assert.AreEqual(1, elements.Count);
                var rowView = (RowView)elements[0];
                Assert.AreEqual(1, rowView.Elements.Count);
                Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
            }

            rows[0].BeginEdit();
            Assert.IsTrue(rows[0].IsEditing);
        }
コード例 #5
0
        public void InputManager_Validate_Implicit()
        {
            var dataSet = DataSet <ProductCategory> .Create();

            var _ = dataSet._;

            dataSet.Add(new DataRow());

            RowBinding <TextBox> textBox = null;
            var inputManager             = dataSet.CreateInputManager(builder =>
            {
                textBox = _.Name.BindToTextBox();
                builder.GridColumns("100").GridRows("100").AddBinding(0, 0, textBox).WithRowValidationMode(ValidationMode.Implicit);
            });

            var currentRow = inputManager.CurrentRow;

            Assert.IsNull(_.Name[0]);
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(1, errors.Count);
                var error = (DataValidationError)errors[0].ErrorContent;
                Assert.AreEqual(_.Name, error.Source);
            }

            textBox[currentRow].Text = "some name";
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(0, errors.Count);
            }
        }
コード例 #6
0
ファイル: InPlaceEditor.cs プロジェクト: xydoublez/RDO.Net
        internal static RowBinding <InPlaceEditor> AddToInPlaceEditor <TEditing, TInert>(RowInput <TEditing> editingInput, RowBinding <TInert> inertBinding)
            where TEditing : UIElement, new()
            where TInert : UIElement, new()
        {
            var result = new RowBinding <InPlaceEditor>(null);

            result.Input = new ProxyRowInput <TEditing, TInert>(result, editingInput, inertBinding);
            return(result);
        }
コード例 #7
0
ファイル: InPlaceEditor.cs プロジェクト: xydoublez/RDO.Net
        private static UIElement GenerateElement(RowBinding binding, RowPresenter p)
        {
            binding.BeginSetup(null);
            var result = binding.Setup(p);

            binding.EndSetup();
            binding.Refresh(result);
            return(result);
        }
コード例 #8
0
ファイル: LayoutManager.cs プロジェクト: xydoublez/RDO.Net
        protected virtual Size GetAvailableAutoSize(RowBinding rowBinding, RowPresenter rowPresenter, out IReadOnlyList <GridColumn> autoWidthColumns, out double measuredWidth,
                                                    out IReadOnlyList <GridRow> autoHeightGridRows, out double measuredHeight)
        {
            autoWidthColumns   = rowBinding.AutoWidthGridColumns;
            autoHeightGridRows = rowBinding.AutoHeightGridRows;
            var gridRange = rowBinding.GridRange;

            measuredWidth  = gridRange.GetMeasuredWidth(x => !x.IsAutoLength);
            measuredHeight = gridRange.GetMeasuredHeight(x => !x.IsAutoLength);
            return(rowBinding.AvailableAutoSize);
        }
コード例 #9
0
ファイル: InPlaceEditor.cs プロジェクト: xydoublez/RDO.Net
 public ProxyRowInput(RowBinding <InPlaceEditor> binding, RowInput <TEditor> editorInput, RowBinding <TInert> inertBinding)
     : base(binding, new ExplicitTrigger <InPlaceEditor>(), null)
 {
     Debug.Assert(editorInput != null);
     Debug.Assert(inertBinding != null);
     _editorInput  = editorInput;
     _inertBinding = inertBinding;
     _editorInput.InjectRowValidation(this);
     InertBinding.Seal(binding, 0);
     EditorBinding.Seal(binding, 1);
 }
コード例 #10
0
            protected override void BuildTemplate(TemplateBuilder builder)
            {
                _subFormBinding = _.SalesOrderDetails.BindToDataView(() => new DetailPresenter(_ownerWindow)).WithStyle(Styles.DataSheet);
                var lineCountValidation = _.LineCount.BindToValidationPlaceholder(_subFormBinding);

                builder.GridRows("Auto", "*", "Auto")
                .GridColumns("580")
                .AddBinding(0, 0, _.BindToSalesOrderHeaderBox(IsNew, out _shipToAddressBinding, out _billToAddressBinding))
                .AddBinding(0, 1, lineCountValidation)
                .AddBinding(0, 1, _subFormBinding)
                .AddBinding(0, 2, _.BindToSalesOrderFooterBox());
            }
コード例 #11
0
        public void InputManager_ScalarInput()
        {
            var            dataSet = DataSetMock.ProductCategories(3, false);
            var            _       = dataSet._;
            Scalar <Int32> scalar  = ScalarContainerMock.New().CreateNew <int>().AddValidator(x =>
            {
                return(x > 5 ? "Value cannot be greater than 5." : null);
            });
            ScalarBinding <TextBox> textBox   = null;
            RowBinding <TextBlock>  textBlock = null;
            var inputManager = dataSet.CreateInputManager((builder) =>
            {
                textBox   = scalar.BindToTextBox();
                textBlock = _.Name.BindToTextBlock(); // to avoid empty RowRange
                builder.GridColumns("100").GridRows("100", "100").AddBinding(0, 0, textBox).AddBinding(0, 1, textBlock);
            }).WithScalars(new Scalar[] { scalar });

            Assert.AreEqual("0", textBox[0].Text);
            Assert.IsNull(inputManager.ScalarValidation.GetFlushingError(textBox[0]));
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[0]);
                Assert.AreEqual(0, errors.Count);
            }

            textBox[0].Text = "A";
            Assert.IsNotNull(inputManager.ScalarValidation.GetFlushingError(textBox[0]));
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[0]);
                Assert.AreEqual(1, errors.Count);
                Assert.AreEqual(inputManager.ScalarValidation.GetFlushingError(textBox[0]), errors[0].ErrorContent);
            }

            textBox[0].Text = "4";
            Assert.IsNull(inputManager.ScalarValidation.GetFlushingError(textBox[0]));
            Assert.AreEqual(4, scalar.GetValue());
            Assert.IsNull(inputManager.ScalarValidation.GetFlushingError(textBox[0]));
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[0]);
                Assert.AreEqual(0, errors.Count);
            }

            inputManager.ScalarValidation.UpdateProgress(textBox.Input, true, true);
            textBox[0].Text = "6";
            Assert.AreEqual("6", textBox[0].Text);
            Assert.AreEqual(1, inputManager.ScalarValidation.Errors.Count);
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[0]);
                Assert.AreEqual(1, errors.Count);
                Assert.AreEqual(inputManager.ScalarValidation.Errors, errors[0].ErrorContent);
            }
        }
コード例 #12
0
        //private void comboBoxMeasureGroups_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (Dimension.SelectedIndex > -1)
        //    {
        //        using (Server S = new Server())
        //        {
        //            string connectionString;
        //            connectionString = "DataSource=" + ServerName.Text;
        //            S.Connect(connectionString);


        //            MeasureGroup MG = S.Databases.GetByName(ASDatabase.SelectedItem.ToString()).Cubes.GetByName(Cube.SelectedItem.ToString()).MeasureGroups.GetByName(Dimension.SelectedItem.ToString());
        //            MeasureCollection MC = MG.Measures;

        //            DataTable MA = getMeasureAttributes(MC);
        //            dataGridView1.DataSource = MA;
        //        }
        //    }
        //}

        public DataTable getMeasureAttributes(MeasureCollection MC)
        {
            DataTable MA = new DataTable();

            MA.Columns.Add("Measure Name");
            MA.Columns.Add("Source Table");
            MA.Columns.Add("Source Column");
            MA.Columns.Add("Aggregate User");

            foreach (Measure M in MC)
            {
                DataSourceView DS = M.ParentCube.DataSourceView;
                DataSet        d  = new DataSet();
                d = DS.Schema;

                DataItem  DI = M.Source;
                DataTable DT;
                string    MeasureName = M.Name;
                string    Aggregate   = M.AggregateFunction.ToString();
                string    MeasureSourceColumn;

                if (M.Visible == true)
                {
                    if (DI.Source.GetType().ToString() == "Microsoft.AnalysisServices.ColumnBinding")
                    {
                        ColumnBinding CB = (ColumnBinding)DI.Source;
                        DT = d.Tables[CB.TableID];
                        MeasureSourceColumn = CB.ColumnID;
                    }
                    else
                    {
                        RowBinding RB = (RowBinding)DI.Source;
                        DT = d.Tables[RB.TableID];
                        MeasureSourceColumn = "Rows";
                    }

                    string MeasureSourceTable = DT.ExtendedProperties["DbTableName"].ToString();

                    //MessageBox.Show(MeasureSourceTable);
                    //MessageBox.Show(MeasureSourceColumn);
                    //MessageBox.Show(Aggregate);

                    MA.Rows.Add(MeasureName, MeasureSourceTable, MeasureSourceColumn, Aggregate);
                }
            }

            return(MA);
        }
コード例 #13
0
        public void InputManager_Validate_Progress()
        {
            var dataSet = DataSet <ProductCategory> .Create();

            var _ = dataSet._;

            dataSet.Add(new DataRow());

            RowBinding <TextBox> textBox = null;
            var inputManager             = dataSet.CreateInputManager(builder =>
            {
                textBox = _.Name.BindToTextBox();
                builder.GridColumns("100").GridRows("100").AddBinding(0, 0, textBox);
            });

            var currentRow = inputManager.CurrentRow;

            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(0, errors.Count);
            }

            textBox[currentRow].Text = "some name";
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(0, errors.Count);
            }

            inputManager.RowValidation.UpdateProgress(textBox.Input, true, true);

            textBox[currentRow].Text = null;
            Assert.AreEqual(string.Empty, textBox[currentRow].Text);
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(1, errors.Count);
                var error = (DataValidationError)errors[0].ErrorContent;
                Assert.AreEqual(_.Name, error.Source);
            }

            textBox[currentRow].Text = "some other name";
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(0, errors.Count);
            }
        }
コード例 #14
0
            protected override void BuildTemplate(TemplateBuilder builder)
            {
                var userName = _.UserName.BindToTextBox();
                var emailAddress = _.EmailAddress.BindToTextBox();
                var password = _.Password.BindToPasswordBox();
                var confirmPassword = _.PasswordConfirmation.BindToPasswordBox();
                var passwordMismatch = new RowBinding[] { password, confirmPassword }.BindToValidationPlaceholder();
                var interests1 = _.Interests.BindToCheckBox(Interests.Books);
                var interests2 = _.Interests.BindToCheckBox(Interests.Comics);
                var interests3 = _.Interests.BindToCheckBox(Interests.Hunting);
                var interests4 = _.Interests.BindToCheckBox(Interests.Movies);
                var interests5 = _.Interests.BindToCheckBox(Interests.Music);
                var interests6 = _.Interests.BindToCheckBox(Interests.Physics);
                var interests7 = _.Interests.BindToCheckBox(Interests.Shopping);
                var interests8 = _.Interests.BindToCheckBox(Interests.Sports);
                var interestsValidation = new RowBinding[] { interests1, interests2, interests3, interests4, interests5, interests6, interests7, interests8 }.BindToValidationPlaceholder();

                builder
                .GridColumns("Auto", "*", "*")
                .GridRows("Auto", "Auto", "Auto", "Auto", "Auto", "Auto", "Auto", "Auto", "Auto")
                .AddBinding(1, 2, 2, 3, passwordMismatch)
                .AddBinding(1, 4, 2, 7, interestsValidation)
                .AddBinding(0, 0, _.UserName.BindToLabel(userName, LABEL_FORMAT))
                .AddBinding(0, 1, _.EmailAddress.BindToLabel(emailAddress, LABEL_FORMAT))
                .AddBinding(0, 2, _.Password.BindToLabel(password, LABEL_FORMAT))
                .AddBinding(0, 3, _.PasswordConfirmation.BindToLabel(confirmPassword, LABEL_FORMAT))
                .AddBinding(0, 4, 0, 7, _.Interests.BindToLabel(interests1, LABEL_FORMAT))
                .AddBinding(1, 0, 2, 0, userName)
                .AddBinding(1, 1, 2, 1, emailAddress)
                .AddBinding(1, 2, 2, 2, password)
                .AddBinding(1, 3, 2, 3, confirmPassword)
                .AddBinding(1, 4, interests1)
                .AddBinding(2, 4, interests2)
                .AddBinding(1, 5, interests3)
                .AddBinding(2, 5, interests4)
                .AddBinding(1, 6, interests5)
                .AddBinding(2, 6, interests6)
                .AddBinding(1, 7, interests7)
                .AddBinding(2, 7, interests8)
                .AddBinding(0, 8, 2, 8, _.BindToValidationErrorsControl().WithAutoSizeWaiver(AutoSizeWaiver.Width))
                .AddAsyncValidator(userName.Input, ValidateUserNameFunc);
            }
コード例 #15
0
        public void ElementManager_RefreshElements()
        {
            var dataSet = DataSetMock.ProductCategories(8, false);
            var _       = dataSet._;
            RowBinding <TextBlock> textBlock = null;
            var elementManager = dataSet.CreateElementManager((builder) =>
            {
                textBlock = _.Name.BindToTextBlock();
                builder.GridColumns("100").GridRows("100").AddBinding(0, 0, textBlock);
            });

            {
                var template = elementManager.Template;
                var rows     = elementManager.Rows;

                elementManager.ContainerViewList.RealizeFirst(1);
                dataSet._.Name[1] = "CHANGED NAME";
                Assert.AreEqual(dataSet._.Name[1], textBlock[rows[1]].Text);
            }
        }
コード例 #16
0
ファイル: TableView.cs プロジェクト: sableferret/TableData
        public TableView(ITableQuery query, string name, IEnumerable<IColumn> columns, int throttleTime, IConstituentRowRepository currentRows)
        {
            #region Guards
            if (query == null) throw new ArgumentNullException("query", "query cannot be null");
            if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "name cannot be null or empty");
            #endregion

            TableQuery = query;
            Name = name;
            this.throttleTime = throttleTime;

            Columns = new ObservableCollection<IColumn>();
            ((ObservableCollection<IColumn>)Columns).CollectionChanged += OnColumnsChanged;

            if (columns != null)
                foreach (var column in columns)
                    Columns.Add(column);

            Data = new RowBinding(Columns, currentRows.AttachView(this));
        }
コード例 #17
0
ファイル: InputManager.cs プロジェクト: xydoublez/RDO.Net
        private bool TryFocus(RowBinding rowBinding, RowPresenter row)
        {
            if (rowBinding[row] == null)
            {
                if (IsEditing)
                {
                    CurrentRow.EndEdit();
                }
                CurrentRow = row;
            }

            var element = rowBinding[row];

            Debug.Assert(element != null);
            if (element.IsKeyboardFocusWithin)
            {
                return(true);
            }
            return(element.Focus());
        }
コード例 #18
0
        public void InputManager_SetAsyncErrors()
        {
            var dataSet = DataSet <ProductCategory> .Create();

            var _ = dataSet._;

            dataSet.Add(new DataRow());

            RowBinding <TextBox> textBox = null;
            var inputManager             = dataSet.CreateInputManager(builder =>
            {
                textBox = _.Name.BindToTextBox();
                builder.GridColumns("100").GridRows("100").AddBinding(0, 0, textBox).WithRowValidationMode(ValidationMode.Implicit);
            });

            var currentRow = inputManager.CurrentRow;

            Assert.IsNull(_.Name[0]);
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(1, errors.Count);
                var errorMessage = (DataValidationError)errors[0].ErrorContent;
                Assert.AreEqual(_.Name, errorMessage.Source);
            }

            var error   = new DataValidationError("Result Error", _.Name);
            var results = DataValidationResults.Empty.Add(new DataValidationResult(currentRow.DataRow, error));

            inputManager.RowValidation.SetAsyncErrors(results);
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(2, errors.Count);
                Assert.AreEqual(error, errors[1].ErrorContent);
            }

            textBox[currentRow].Text = "any value";
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[currentRow]);
                Assert.AreEqual(0, errors.Count);
            }
        }
コード例 #19
0
        private async Task InputManager_AsyncValidators_input_error_to_invalid_to_valid_Async()
        {
            var dataSet = DataSet <ProductCategory> .Create();

            var _ = dataSet._;

            dataSet.Add(new DataRow());

            RowBinding <TextBox> textBox = null;
            var inputManager             = dataSet.CreateInputManager(builder =>
            {
                textBox = _.Name.BindToTextBox();

                builder.GridColumns("100").GridRows("100")
                .AddBinding(0, 0, textBox).WithRowValidationMode(ValidationMode.Implicit);

                builder.AddAsyncValidator(textBox.Input, dataRow => ValidateBadNameAsync(_.Name, dataRow));
            });

            var currentRow     = inputManager.CurrentRow;
            var asyncValidator = inputManager.RowValidation.AsyncValidators[0];

            Assert.AreEqual(AsyncValidatorStatus.Inactive, asyncValidator.Status);

            textBox[currentRow].Text = BAD_NAME;
            Assert.AreEqual(AsyncValidatorStatus.Running, asyncValidator.Status);

            await asyncValidator.LastRunTask;

            Assert.AreEqual(AsyncValidatorStatus.Error, asyncValidator.Status);

            textBox[currentRow].Text = "Good Name";
            Assert.AreEqual(AsyncValidatorStatus.Running, asyncValidator.Status);

            await asyncValidator.LastRunTask;

            Assert.AreEqual(AsyncValidatorStatus.Validated, asyncValidator.Status);
        }
コード例 #20
0
        public void InputManager_RowInput()
        {
            var dataSet = DataSetMock.ProductCategories(3, false);
            var _       = dataSet._;
            RowBinding <TextBox> textBox = null;
            var inputManager             = dataSet.CreateInputManager((builder) =>
            {
                textBox = _.ParentProductCategoryID.BindToTextBox();
                builder.GridColumns("100").GridRows("100").AddBinding(0, 0, textBox);
            });

            var element = textBox[inputManager.CurrentRow];

            Assert.IsTrue(string.IsNullOrEmpty(element.Text));
            Assert.IsNull(inputManager.RowValidation.GetFlushingError(element));
            {
                var errors = System.Windows.Controls.Validation.GetErrors(element);
                Assert.AreEqual(0, errors.Count);
            }

            element.Text = "A";
            Assert.IsNotNull(inputManager.RowValidation.GetFlushingError(element));
            {
                var errors = System.Windows.Controls.Validation.GetErrors(textBox[inputManager.CurrentRow]);
                Assert.AreEqual(1, errors.Count);
                Assert.AreEqual(inputManager.RowValidation.GetFlushingError(element), errors[0].ErrorContent);
            }

            element.Text = "100";
            Assert.IsNull(inputManager.RowValidation.GetFlushingError(element));
            Assert.AreEqual(100, dataSet._.ParentProductCategoryID[inputManager.CurrentRow.DataRow]);
            {
                var errors = System.Windows.Controls.Validation.GetErrors(element);
                Assert.AreEqual(0, errors.Count);
            }
        }
コード例 #21
0
 internal override Thickness GetFrozenClip(RowView rowView, RowBinding rowBinding)
 {
     return(new Thickness());
 }
コード例 #22
0
 protected override Size GetSize(RowView rowView, RowBinding rowBinding)
 {
     return(rowBinding.GridRange.MeasuredSize);
 }
コード例 #23
0
 protected override Point GetPosition(RowView rowView, RowBinding rowBinding)
 {
     return(Template.RowRange.GetRelativePosition(rowBinding.GridRange));
 }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of <see cref="ValueChangedTrigger{T}"/> class.
 /// </summary>
 /// <param name="columns">The columns.</param>
 /// <param name="rowBinding">The row binding.</param>
 public ValueChangedTrigger(IColumns columns, RowBinding <T> rowBinding)
 {
     _columns    = columns.VerifyNotNull(nameof(columns));
     _rowBinding = rowBinding.VerifyNotNull(nameof(rowBinding));
 }
コード例 #25
0
        /// <summary>
        /// Add measure into a measure group
        /// </summary>
        /// <param name="measureGroup"></param>
        /// <param name="tableID"></param>
        /// <param name="columnID"></param>
        /// <param name="measureName"></param>
        /// <param name="measureID"></param>
        /// <param name="displayFolder"></param>
        /// <param name="formatStr"></param>
        /// <param name="aggregationFunction"></param>
        /// <param name="visible"></param>
        /// <param name="sourceColDataType"></param>
        /// <param name="measureDataType"></param>
        internal static void ADD_MEASURE_TO_MEASURE_GROUP(
            DB_SQLHELPER_BASE sqlHelper
            , MeasureGroup measureGroup
            , String tableID
            , String columnID
            , String measureName
            , String measureID
            , String displayFolder
            , String formatStr
            , String aggregationFunction
            , bool visible             = true
            , String sourceColDataType = "double"
            , String measureDataType   = "double")
        {
            Microsoft.AnalysisServices.DataItem source = new Microsoft.AnalysisServices.DataItem();
            source.NullProcessing = NullProcessing.Preserve;
            Measure measure = new Measure(measureName, measureID);
            String  aggType = aggregationFunction.ToLower();

            measure.DataType = AS_API_HELPER.GET_SSAS_MEASURE_DATA_TYPE_BY_NAME(measureDataType);
            if (aggType == "count*")
            {
                RowBinding rowBind = new RowBinding();
                rowBind.TableID           = tableID;
                measure.AggregateFunction = AggregationFunction.Count;
                source.Source             = rowBind;
                measure.Source            = source;
                measure.DataType          = MeasureDataType.Integer;
                //source.DataType = AS_API_HELPER.GET_SSAS_OLEDB_TYPE_BY_NAME(sourceColDataType);
            }
            else
            {
                ColumnBinding colBind = new ColumnBinding();
                colBind.TableID           = tableID;
                colBind.ColumnID          = columnID;
                source.DataType           = AS_API_HELPER.GET_SSAS_OLEDB_TYPE_BY_NAME(sourceColDataType);
                source.Source             = colBind;
                measure.AggregateFunction = AS_API_HELPER.GET_SSAS_AGGREGATION_FUNCTION_BY_NAME(aggType.ToLower());
                if (aggType.ToLower() == "distinctcount")
                {
                    source.NullProcessing = NullProcessing.Automatic;
                    source.DataType       = AS_API_HELPER.GET_SSAS_OLEDB_TYPE_BY_NAME("integer");
                    measure.DataType      = MeasureDataType.Integer;
                }
                measure.Source = source;
            }
            String dataType = sourceColDataType.ToLower();

            measure.DisplayFolder = displayFolder;
            //measure.FormatString = formatStr
            measure.Visible = visible;
            Measure measureEx = measureGroup.Measures.Find(measureID);

            if (measureEx != null)
            {
                sqlHelper.ADD_MESSAGE_LOG(

                    String.Format("measure {0} exists", measureName),
                    MESSAGE_TYPE.MEASURES, MESSAGE_RESULT_TYPE.Warning);
                measureEx.Name = measure.Name;
                measureEx.AggregateFunction = measure.AggregateFunction;
                measureEx.DataType          = AS_API_HELPER.GET_SSAS_MEASURE_DATA_TYPE_BY_NAME(measureDataType);
                measureEx.DisplayFolder     = measure.DisplayFolder;
                measureEx.Visible           = measure.Visible;
                measureEx.FormatString      = measure.FormatString;
                measureEx.Source            = source.Clone();
            }
            else
            {
                sqlHelper.ADD_MESSAGE_LOG(
                    String.Format("Added measure {0} into measure group {1}", measureName, measureGroup.Name),
                    MESSAGE_TYPE.MEASURES, MESSAGE_RESULT_TYPE.Succeed);
                measureGroup.Measures.Add(measure);
            }
        }
コード例 #26
0
 internal void AddBinding(GridRange gridRange, RowBinding rowBinding)
 {
     Debug.Assert(IsValid(gridRange));
     rowBinding.Seal(this, gridRange, InternalRowBindings.Count);
     InternalRowBindings.Add(gridRange, rowBinding);
 }
コード例 #27
0
ファイル: LayoutManager.cs プロジェクト: xydoublez/RDO.Net
 protected abstract Point GetPosition(RowView rowView, RowBinding rowBinding);
コード例 #28
0
ファイル: LayoutManager.cs プロジェクト: xydoublez/RDO.Net
 protected abstract Size GetSize(RowView rowView, RowBinding rowBinding);
コード例 #29
0
        public void ElementManager_Elements()
        {
            var dataSet = DataSetMock.ProductCategories(8, false);
            var _       = dataSet._;
            ScalarBinding <TextBlock> columnHeader1 = null;
            BlockBinding <TextBlock>  blockHeader   = null;
            RowBinding <TextBlock>    textBlock     = null;
            ScalarBinding <TextBlock> columnHeader2 = null;
            var elementManager = dataSet.CreateElementManager((builder) =>
            {
                columnHeader1 = _.Name.AsScalarTextBlock();
                blockHeader   = _.AsBlockHeader();
                textBlock     = _.Name.BindToTextBlock();
                columnHeader2 = _.Name.AsScalarTextBlock().RepeatWhenFlow();
                builder.GridColumns("100", "100")
                .GridRows("100", "100", "100")
                .Layout(Orientation.Vertical, 0)
                .AddBinding(1, 0, columnHeader1)
                .AddBinding(0, 1, blockHeader)
                .AddBinding(1, 1, textBlock)
                .AddBinding(1, 2, columnHeader2);
            });

            {
                var template = elementManager.Template;
                var rows     = elementManager.Rows;

                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(3, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    var blockView = (BlockView)elements[1];
                    Assert.AreEqual(2, blockView.Elements.Count);
                    Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                    var rowView = (RowView)blockView.Elements[1];
                    Assert.AreEqual(1, rowView.Elements.Count);
                    Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                    Assert.AreEqual(columnHeader2[0], elements[2]);
                }

                elementManager.FlowRepeatCount = 3;
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(5, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    var blockView = (BlockView)elements[1];
                    Assert.AreEqual(4, blockView.Elements.Count);
                    Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                    {
                        var rowView = (RowView)blockView.Elements[1];
                        Assert.AreEqual(1, rowView.Elements.Count);
                        Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                    }
                    {
                        var rowView = (RowView)blockView.Elements[2];
                        Assert.AreEqual(1, rowView.Elements.Count);
                        Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                    }
                    {
                        var rowView = (RowView)blockView.Elements[3];
                        Assert.AreEqual(1, rowView.Elements.Count);
                        Assert.AreEqual(textBlock[rows[2]], rowView.Elements[0]);
                    }
                    Assert.AreEqual(columnHeader2[0], elements[2]);
                    Assert.AreEqual(columnHeader2[1], elements[3]);
                    Assert.AreEqual(columnHeader2[2], elements[4]);
                    Assert.AreNotEqual(columnHeader2[0], columnHeader2[1]);
                    Assert.AreNotEqual(columnHeader2[0], columnHeader2[2]);
                    Assert.AreNotEqual(columnHeader2[1], columnHeader2[2]);
                }

                elementManager.ContainerViewList.RealizeFirst(1);
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(6, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    {
                        var blockView = (BlockView)elements[1];
                        Assert.AreEqual(4, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[3];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[2]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[2];
                        Assert.AreEqual(4, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[1], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[3]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[4]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[3];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[5]], rowView.Elements[0]);
                        }
                    }
                    Assert.AreEqual(columnHeader2[0], elements[3]);
                    Assert.AreEqual(columnHeader2[1], elements[4]);
                    Assert.AreEqual(columnHeader2[2], elements[5]);
                }

                elementManager.ContainerViewList.RealizePrev();
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(6, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    {
                        var blockView = (BlockView)elements[1];
                        Assert.AreEqual(4, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[3];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[2]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[2];
                        Assert.AreEqual(4, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[1], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[3]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[4]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[3];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[5]], rowView.Elements[0]);
                        }
                    }
                    Assert.AreEqual(columnHeader2[0], elements[3]);
                    Assert.AreEqual(columnHeader2[1], elements[4]);
                    Assert.AreEqual(columnHeader2[2], elements[5]);
                }

                elementManager.ContainerViewList.RealizeNext();
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(7, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    {
                        var blockView = (BlockView)elements[1];
                        Assert.AreEqual(4, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[3];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[2]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[2];
                        Assert.AreEqual(4, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[1], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[3]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[4]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[3];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[5]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[3];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[2], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[6]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[7]], rowView.Elements[0]);
                        }
                    }
                    Assert.AreEqual(columnHeader2[0], elements[4]);
                    Assert.AreEqual(columnHeader2[1], elements[5]);
                    Assert.AreEqual(columnHeader2[2], elements[6]);
                }

                elementManager.FlowRepeatCount = 2;
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(4, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    var blockView = (BlockView)elements[1];
                    Assert.AreEqual(3, blockView.Elements.Count);
                    Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                    {
                        var rowView = (RowView)blockView.Elements[1];
                        Assert.AreEqual(1, rowView.Elements.Count);
                        Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                    }
                    {
                        var rowView = (RowView)blockView.Elements[2];
                        Assert.AreEqual(1, rowView.Elements.Count);
                        Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                    }
                    Assert.AreEqual(columnHeader2[0], elements[2]);
                    Assert.AreEqual(columnHeader2[1], elements[3]);
                    Assert.AreNotEqual(columnHeader2[0], columnHeader2[1]);
                }

                elementManager.ContainerViewList.RealizeFirst(1);
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(5, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    {
                        var blockView = (BlockView)elements[1];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[2];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[1], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[2]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[3]], rowView.Elements[0]);
                        }
                    }
                    Assert.AreEqual(columnHeader2[0], elements[3]);
                    Assert.AreEqual(columnHeader2[1], elements[4]);
                }

                elementManager.ContainerViewList.RealizePrev();
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(5, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    {
                        var blockView = (BlockView)elements[1];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[2];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[1], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[2]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[3]], rowView.Elements[0]);
                        }
                    }
                    Assert.AreEqual(columnHeader2[0], elements[3]);
                    Assert.AreEqual(columnHeader2[1], elements[4]);
                }

                elementManager.ContainerViewList.RealizeNext();
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(6, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    {
                        var blockView = (BlockView)elements[1];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[2];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[1], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[2]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[3]], rowView.Elements[0]);
                        }
                    }
                    {
                        var blockView = (BlockView)elements[3];
                        Assert.AreEqual(3, blockView.Elements.Count);
                        Assert.AreEqual(blockHeader[2], blockView.Elements[0]);
                        {
                            var rowView = (RowView)blockView.Elements[1];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[4]], rowView.Elements[0]);
                        }
                        {
                            var rowView = (RowView)blockView.Elements[2];
                            Assert.AreEqual(1, rowView.Elements.Count);
                            Assert.AreEqual(textBlock[rows[5]], rowView.Elements[0]);
                        }
                    }
                    Assert.AreEqual(columnHeader2[0], elements[4]);
                    Assert.AreEqual(columnHeader2[1], elements[5]);
                }

                elementManager.ContainerViewList.VirtualizeAll();
                {
                    var elements = elementManager.Elements;
                    Assert.AreEqual(4, elements.Count);
                    Assert.AreEqual(columnHeader1[0], elements[0]);
                    var blockView = (BlockView)elements[1];
                    Assert.AreEqual(3, blockView.Elements.Count);
                    Assert.AreEqual(blockHeader[0], blockView.Elements[0]);
                    {
                        var rowView = (RowView)blockView.Elements[1];
                        Assert.AreEqual(1, rowView.Elements.Count);
                        Assert.AreEqual(textBlock[rows[0]], rowView.Elements[0]);
                    }
                    {
                        var rowView = (RowView)blockView.Elements[2];
                        Assert.AreEqual(1, rowView.Elements.Count);
                        Assert.AreEqual(textBlock[rows[1]], rowView.Elements[0]);
                    }
                    Assert.AreEqual(columnHeader2[0], elements[2]);
                    Assert.AreEqual(columnHeader2[1], elements[3]);
                }

                elementManager.ClearElements();
                Assert.IsNull(elementManager.Elements);
            }
        }
コード例 #30
0
ファイル: LayoutManager.cs プロジェクト: xydoublez/RDO.Net
 internal abstract Thickness GetFrozenClip(RowView rowView, RowBinding rowBinding);
コード例 #31
0
        public static RowCompositeBinding <SalesOrderHeaderBox> BindToSalesOrderHeaderBox(this SalesOrderInfo _, bool isNew,
                                                                                          out RowBinding <ForeignKeyBox> shipToAddressBinding, out RowBinding <ForeignKeyBox> billToAddressBinding)
        {
            var result = new RowCompositeBinding <SalesOrderHeaderBox>()
                         .AddChild(_.FK_Customer.BindToForeignKeyBox(_.Customer, CustomerBox.RefreshAction), v => v._customer)
                         .AddChild(shipToAddressBinding = _.FK_ShipToAddress.BindToForeignKeyBox(_.ShipToAddress, AddressBox.RefreshAction), v => v._shipTo)
                         .AddChild(billToAddressBinding = _.FK_BillToAddress.BindToForeignKeyBox(_.BillToAddress, AddressBox.RefreshAction), v => v._billTo)
                         .AddChild(_.OrderDate.BindToDatePicker(), v => v._orderDate)
                         .AddChild(_.ShipDate.BindToDatePicker(), v => v._shipDate)
                         .AddChild(_.DueDate.BindToDatePicker(), v => v._dueDate)
                         .AddChild(_.PurchaseOrderNumber.BindToTextBox(), v => v._purchaseOrderNumber)
                         .AddChild(_.AccountNumber.BindToTextBox(), v => v._accountNumber)
                         .AddChild(_.ShipMethod.BindToTextBox(), v => v._shipMethod)
                         .AddChild(_.CreditCardApprovalCode.BindToTextBox(), v => v._creditCardApprovalCode)
                         .AddChild(_.Status.BindToComboBox(), v => v._status)
                         .AddChild(_.OnlineOrderFlag.BindToCheckBox(), v => v._onlineOrderFlag)
                         .AddChild(_.Comment.BindToTextBox(), v => v._comment);

            if (!isNew)
            {
                result.AddChild(_.SalesOrderNumber.BindToTextBlock(), v => v._salesOrderNumber);
            }
            return(result);
        }