Example #1
0
        public void CloseTab(ColumnViewModel column, TabViewModel tab)
        {
            var ci = _columns.IndexOf(column);
            var ti = column.Tabs.IndexOf(tab);

            TabManager.CloseTab(ci, ti);
        }
Example #2
0
        public IActionResult AddColumn(NewSchemaViewModel schemaModel)
        {
            ModelState.Clear();
            schemaModel.Columns.RemoveAll(c => c.IsDeleted == "deleted");
            var columnsList = schemaModel.Columns;
            var newColumn   = new ColumnViewModel
            {
                ColumnName = schemaModel.AppendColumnName,
                Type       = schemaModel.AppendColumnType,
                Order      = schemaModel.AppendColumnOrder,
                LowerLimit = schemaModel.AppendColumnLowerLimit,
                UpperLimit = schemaModel.AppendColumnUpperLimit,
            };

            if (newColumn.Order <= columnsList.Count)
            {
                newColumn.Order = columnsList.Count + 1;
                var maxOrder = columnsList.Max(c => c.Order);
                if (newColumn.Order <= maxOrder)
                {
                    newColumn.Order = maxOrder + 1;
                }
            }

            columnsList.Add(newColumn);
            schemaModel.AppendColumnName       = null;
            schemaModel.AppendColumnType       = ColumnType.FullName;
            schemaModel.AppendColumnOrder      = 1;
            schemaModel.AppendColumnUpperLimit = null;
            schemaModel.AppendColumnLowerLimit = null;

            return(PartialView("Partial/_SchemaColumn", schemaModel));
        }
 private void MoveDown(ColumnViewModel item)
 {
     var index = Columns.IndexOf(item);
     Columns.Move(index, index + 1);
     MoveUpCommand.RaiseCanExecuteChanged();
     MoveDownCommand.RaiseCanExecuteChanged();
 }
Example #4
0
        public void Required()
        {
            var model = new ColumnViewModel();

            var result = model.Validate();

            Assert.True(result.Any());

            Assert.Equal("Description", result.ElementAtOrDefault(0).MemberNames.FirstOrDefault());
            Assert.Equal("The Description field is required.", result.ElementAtOrDefault(0).ErrorMessage);

            Assert.Equal("TableName", result.ElementAtOrDefault(1).MemberNames.FirstOrDefault());
            Assert.Equal("The Table Name field is required.", result.ElementAtOrDefault(1).ErrorMessage);

            Assert.Equal("Name", result.ElementAtOrDefault(2).MemberNames.FirstOrDefault());
            Assert.Equal("The Name field is required.", result.ElementAtOrDefault(2).ErrorMessage);

            Assert.Equal("Type", result.ElementAtOrDefault(3).MemberNames.FirstOrDefault());
            Assert.Equal("The Type field is required.", result.ElementAtOrDefault(3).ErrorMessage);

            Assert.Equal("IsNull", result.ElementAtOrDefault(4).MemberNames.FirstOrDefault());
            Assert.Equal("The Is Null? field is required.", result.ElementAtOrDefault(4).ErrorMessage);

            Assert.Equal("IsIdentity", result.ElementAtOrDefault(5).MemberNames.FirstOrDefault());
            Assert.Equal("The Is Identity? field is required.", result.ElementAtOrDefault(5).ErrorMessage);
        }
Example #5
0
        public void FromEntity()
        {
            var entity = new ColumnEntity()
            {
                Default     = "Test",
                Description = "Test",
                Id          = 1,
                IsIdentity  = 'N',
                IsNull      = 'Y',
                Length      = 1,
                Name        = "Test",
                Number      = 1,
                TableName   = "Test",
                Type        = "Test"
            };
            var model = new ColumnViewModel(entity);

            var result = model.Validate();

            Assert.False(result.Any());

            Assert.Equal(entity.Default, model.Default);
            Assert.Equal(entity.Description, model.Description);
            Assert.Equal(entity.Id, model.Id);
            Assert.Equal(entity.IsIdentity, model.IsIdentity.First());
            Assert.Equal(entity.IsNull, model.IsNull.First());
            Assert.Equal(entity.Length, model.Length);
            Assert.Equal(entity.Name, model.Name);
            Assert.Equal(entity.Number, model.Number);
            Assert.Equal(entity.TableName, model.TableName);
            Assert.Equal(entity.Type, model.Type);
        }
Example #6
0
        public List <ColumnViewModel> Columns(Guid Id, ApiCall call)
        {
            var sitedb = call.WebSite.SiteDb();

            var columns = sitedb.ProductType.GetColumns(Id);
            List <ColumnViewModel> result = new List <ColumnViewModel>();

            foreach (var item in columns)
            {
                if (item.Name.ToLower() != "online")
                {
                    ColumnViewModel model = new ColumnViewModel();
                    model.Name        = item.Name;
                    model.DisplayName = item.DisplayName;
                    model.DataType    = item.DataType;
                    result.Add(model);
                }
            }

            var lastmodified = result.Find(o => o.Name == SystemFields.LastModified.Name);

            if (lastmodified == null)
            {
                ColumnViewModel model = new ColumnViewModel();
                model.Name        = SystemFields.LastModified.Name;
                model.DisplayName = SystemFields.LastModified.DisplayName;
                model.DataType    = SystemFields.LastModified.DataType;
                result.Insert(0, model);
            }

            return(result);
        }
Example #7
0
        private void FilterOut(object sender, IEnumerable <Category> categoriesRaw)
        {
            List <Category> categories = categoriesRaw.ToList();

            foreach (Category category in categories)
            {
                category.IsKept = false;
            }

            foreach (Category category in categories)
            {
                ColumnViewModel cvm = category.ColumnViewModel;

                if (cvm.Categories.All(c => c.IsKept))
                {
                    cvm.IsKept = true;
                }
                else if (cvm.Categories.All(c => !c.IsKept))
                {
                    cvm.IsKept = false;
                }
                else
                {
                    cvm.IsKept = null;
                }
            }

            ViewModel.MainPageViewModel.SheetViewModel.UpdateFilter();
            ViewModel.MainPageViewModel.ReflectAll(ReflectReason.RowFiltered);
        }
Example #8
0
 protected SyncEntity(ColumnViewModel viewModel)
 {
     if (viewModel != null)
     {
         TableName = !string.IsNullOrWhiteSpace(viewModel.TableName) ? viewModel.TableName : string.Empty;
     }
 }
        public ActionResult OffersByTopSector()
        {
            var offers = this.Data.JobOffers.All()
                         .Where(o => o.DateCreated >= new DateTime(2017, 1, 1) && o.DateCreated < new DateTime(2018, 1, 1))
                         .GroupBy(o => o.BusinessSectorId)
                         .OrderByDescending(o => o.Count())
                         .Take(5)
                         .ToList();

            var model = new List <ColumnViewModel>();

            foreach (var offer in offers)
            {
                var column = new ColumnViewModel {
                    Name = offer.First().BusinessSector.Name
                };
                var offersByMonth = offer.ToList();

                for (int i = 1; i <= 12; i++)
                {
                    var offersForMonth = offersByMonth.Where(o => o.DateCreated.Month == i).Count();

                    column.Data.Add(offersForMonth);
                }

                model.Add(column);
            }

            return(this.Json(this.ToJson(model)));
        }
Example #10
0
        public List <GroupedRows> Bin(ColumnViewModel selected, List <Row> rows)
        {
            Linear linear = new Linear()
            {
                DomainStart = rows.Select(r => (Double)r.Cells[selected.Index].Content).Min(),
                DomainEnd   = rows.Select(r => (Double)r.Cells[selected.Index].Content).Max(),
            };

            linear.Nice();

            IEnumerable <Bin> bins = HistogramCalculator.Bin(
                linear.DomainStart,
                linear.DomainEnd,
                linear.Step,
                rows,
                selected
                );

            List <GroupedRows> groupedRows = new List <GroupedRows>();

            foreach (Bin bin in bins)
            {
                GroupedRows grs = new GroupedRows();
                grs.Keys[selected] = bin;
                grs.Rows           = bin.Rows.ToList();
                groupedRows.Add(grs);
            }

            return(groupedRows);
        }
Example #11
0
        public RowViewModelComparer(SheetViewModel sheetViewModel, ViewStatus viewStatus, IEnumerable <Row> selectedRows)
        {
            SheetViewModel = sheetViewModel;
            ViewStatus     = viewStatus;
            FilteredRows   = sheetViewModel.FilteredRows;
            SelectedRows   = selectedRows;

            selectedCount          = ViewStatus.SelectedCount;
            sortedColumnViewModels = SheetViewModel.ColumnViewModels.Where(
                cvm => cvm.SortOption != SortOption.None
                ).OrderByDescending(cvm => cvm.SortPriority);
            firstNumerical = ViewStatus.FirstNumerical;

            IEnumerable <ColumnViewModel> nonTailCategoricalColumnViewModels = ViewStatus.SelectedColumnViewModels.Where(
                cvm => cvm.Type == ColumnType.Categorical && cvm != ViewStatus.LastCategorical
                );

            IEnumerable <ColumnViewModel> tailCategoricalOrNumericalColumnViewModels = ViewStatus.SelectedColumnViewModels.Where(
                cvm => cvm.Type == ColumnType.Numerical || cvm == ViewStatus.LastCategorical
                ).OrderByDescending(cvm =>
                                    cvm.SortOption != SortOption.None ? cvm.SortPriority : (cvm.Type == ColumnType.Categorical ? 0 : -1)
                                    );

            sortOrder = nonTailCategoricalColumnViewModels.Concat(tailCategoricalOrNumericalColumnViewModels);
            isN       = viewStatus.IsN;

            foreach (Row row in FilteredRows)
            {
                filteredRowDictionary[row] = true;
            }
        }
Example #12
0
        public void ScrollToColumnViewModel(ColumnViewModel columnViewModel)
        {
            Double offset = ActivatedScrollViewer.HorizontalOffset,
                   width  = ViewModel.SheetViewWidth,
                   x1     = columnViewModel.X,
                   x2     = columnViewModel.X + columnViewModel.Width;

            Double?to = null;

            if (x1 < offset)
            {
                to = x1 - 20;
            }
            else if (offset + width < x2)
            {
                to = x2 - width + 20;
            }

            if (to < 0)
            {
                to = 0;
            }

            ActivatedScrollViewer.ChangeView(to, null, null);

            if (to == null)
            {
                ViewModel.ScrollLeft = ActivatedScrollViewer.HorizontalOffset;
            }
            else
            {
                ViewModel.ScrollLeft = (Double)to;
            }
        }
        public IActionResult Edit(ColumnViewModel vmodel)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                var entity = _dbContext.Column.FirstOrDefault(x => x.ColumnUuid == vmodel.ColumnUuid);
                if (entity.ColumnTitle != vmodel.ColumnTitle)
                {
                    if (_dbContext.Column.Any(x => x.ColumnTitle == vmodel.ColumnTitle && x.IsDeleted == 0))
                    {
                        response.SetFailed("已存在该名称的栏目");
                        return(Ok(response));
                    }
                }
                entity.ColumnTitle   = vmodel.ColumnTitle;
                entity.SuperiorUuid  = vmodel.SuperiorUuid;
                entity.SuperiorMenu  = vmodel.SuperiorUuid == null ? 0 : 1;
                entity.ColumnModel   = vmodel.ColumnModel;
                entity.ColumnContent = vmodel.ColumnContent;
                entity.SortId        = vmodel.SortId;
                entity.IsStick       = vmodel.IsStick;
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("编辑", "成功:编辑:栏目列表信息一条数据", _dbContext);
                }
                response = ResponseModelFactory.CreateInstance;
                return(Ok(response));
            }
        }
Example #14
0
        public void ToEntity()
        {
            var model = new ColumnViewModel()
            {
                Default     = "Test",
                Description = "Test",
                Id          = 1,
                IsIdentity  = "N",
                IsNull      = "Y",
                Length      = 1,
                Name        = "Test",
                Number      = 1,
                TableName   = "Test",
                Type        = "Test"
            };

            var result = model.Validate();

            Assert.False(result.Any());

            var entity = model.GetEntity();

            Assert.Equal(model.Default, entity.Default);
            Assert.Equal(model.Description, entity.Description);
            Assert.Equal(model.Id, entity.Id);
            Assert.Equal(model.IsIdentity.First(), entity.IsIdentity);
            Assert.Equal(model.IsNull.First(), entity.IsNull);
            Assert.Equal(model.Length, entity.Length);
            Assert.Equal(model.Name.ToUpper(CultureInfo.InvariantCulture), entity.Name);
            Assert.Equal(model.Number, entity.Number);
            Assert.Equal(model.TableName.ToUpper(CultureInfo.InvariantCulture), entity.TableName);
            Assert.Equal(model.Type, entity.Type);
        }
Example #15
0
        public void Feed(IEnumerable <Row> rows, ColumnViewModel numerical)
        {
            DescriptiveStatisticsViewModel result = DescriptiveStatistics.Analyze(
                DataContext as MainPageViewModel,
                rows.Select(r => (Double)r.Cells[numerical.Index].Content)
                );

            HistogramElement.VerticalAxisTitle = Const.Loader.GetString("Frequency");
            HistogramElement.Width             = this.Width - 20; // (Double)App.Current.Resources["ParagraphWidth"] - 20;
            HistogramElement.Height            = this.Height - 70;
            BoxPlotElement.Width         = this.Width - 90;       // (Double)App.Current.Resources["ParagraphWidth"] - 90;
            BoxPlotElement.Min           = result.Min;
            BoxPlotElement.Max           = result.Max;
            BoxPlotElement.FirstQuartile = result.FirstQuartile;
            BoxPlotElement.Median        = result.Median;
            BoxPlotElement.ThirdQuartile = result.ThirdQuartile;
            BoxPlotElement.Mean          = result.Mean;

            BoxPlotElement.Update();

            d3.Scale.Linear linear = new d3.Scale.Linear()
            {
                DomainStart = result.Min,
                DomainEnd   = result.Max,
                RangeStart  = 0,
                RangeEnd    = 1
            };

            linear.Nice();

            List <Bin> bins = HistogramCalculator.Bin(
                linear.DomainStart,
                linear.DomainEnd,
                linear.Step,
                rows,
                numerical
                ).ToList();

            if (numerical.SortOption == SortOption.Descending)
            {
                bins = bins.OrderByDescending(b => b.Min).ToList();
            }
            else
            {
                bins = bins.OrderBy(b => b.Min).ToList();
            }

            HistogramElement.Data =
                bins
                .Select(d => new BarChartDatum()
            {
                Key             = $"~{Formatter.Auto(d.Max)}",
                ColumnViewModel = numerical,
                Value           = d.Rows.Count(),
                EnvelopeValue   = d.Rows.Count(),
                Rows            = null,
                EnvelopeRows    = d.Rows
            }).ToList();
        }
Example #16
0
        public void Update(ColumnViewModel coloredColumnViewModel,
                           ColumnViewModel firstColoredColumnViewModel,
                           ColumnViewModel secondColoredColumnViewModel,
                           ColumnViewModel thirdColoredColumnViewModel,
                           Boolean updateText)
        {
            if (cellPresenters.Count == 0)
            {
                Style style = Const.CellStyle;

                foreach (Cell cell in RowViewModel.Cells)
                {
                    TextBlock cellPresenter = new TextBlock()
                    {
                        Text  = cell.RawContent,
                        Width = cell.ColumnViewModel.Width,
                        Style = style
                    };

                    CellCanvas.Children.Add(cellPresenter);
                    cellPresenters.Add(cellPresenter);
                }
            }

            Int32 index = 0;

            foreach (Cell cell in RowViewModel.Cells)
            {
                if (updateText)
                {
                    cellPresenters[index].Text = cell.Content.ToString();
                }
                //cellPresenters[index].Width = cell.ColumnViewModel.Width;

                if (cell.ColumnViewModel == coloredColumnViewModel)
                {
                    cellPresenters[index].Foreground = new SolidColorBrush(RowViewModel.Color);
                }
                else if (cell.ColumnViewModel == firstColoredColumnViewModel)
                {
                    cellPresenters[index].Foreground = ViewStatus.Category10FirstSolidColorBrush;
                }
                else if (cell.ColumnViewModel == secondColoredColumnViewModel)
                {
                    cellPresenters[index].Foreground = ViewStatus.Category10SecondSolidColorBrush;
                }
                else if (cell.ColumnViewModel == thirdColoredColumnViewModel)
                {
                    cellPresenters[index].Foreground = ViewStatus.Category10ThirdSolidColorBrush;
                }
                else
                {
                    cellPresenters[index].Foreground = ViewStatus.DefaultRowHeaderSolidColorBrush;
                }

                Canvas.SetLeft(cellPresenters[index], cell.ColumnViewModel.X);
                index++;
            }
        }
Example #17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     vm = new ColumnViewModel(GetMetaLoader(), conn_id, schema_id, tableview_id, column_id);
     if (!IsPostBack)
     {
         reload();
     }
 }
Example #18
0
 public ColumnEntity(ColumnViewModel viewModel) : base(viewModel)
 {
     if (viewModel != null)
     {
         Id          = viewModel.Id;
         Description = viewModel.Description;
     }
 }
Example #19
0
        public async Task <bool> UpdateColumnAsync(ColumnViewModel model)
        {
            var column = _mapper.Map <Column>(model);

            _columnRepository.Update(column);
            await _unitOfWork.SaveAsync();

            return(true);
        }
Example #20
0
        private void RemoveColumnViewModel(object sender, string title)
        {
            ColumnViewModel columnViewModel = ViewModel.MainPageViewModel.SheetViewModel.ColumnViewModels.Where(cvm => cvm.Column.Name == title).FirstOrDefault();

            if (columnViewModel != null)
            {
                ViewModel.RemoveColumnViewModel(columnViewModel);
            }
        }
        public void OnMapColumnSelectionChangedEventRAGeoTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();

            ColumnViewModel columnView = new ColumnViewModel();

            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns        = new ObservableCollection <Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection <ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.sizeColumnList = new ObservableCollection <System.Collections.Generic.KeyValuePair <int, string> >();
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(0, "LAT"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(1, "MAG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(2, "LONG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(3, "DEPTH"));

            target.hoverTextColumnList = new ObservableCollection <System.Collections.Generic.KeyValuePair <int, string> >();
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(0, "LAT"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(1, "MAG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(2, "LONG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair <int, string>(3, "DEPTH"));

            Layer layer = new Layer();

            layer.Name      = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);

            localLayerMap.MapType          = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            target.currentLayer            = localLayerMap;

            EventArgs e = null;

            target.OnMapColumnSelectionChanged(columnView, e);

            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(true, target.IsRAUnitVisible);
            Assert.AreEqual(AngleUnit.Hours, target.selectedRAUnit.Key);

            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.Geo).FirstOrDefault();

            target.ColumnsView = new ObservableCollection <ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.OnMapColumnSelectionChanged(columnView, e);
            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(false, target.IsRAUnitVisible);
        }
Example #22
0
    public override object Copy(IDictionary <object, object>?shared)
    {
        var copy = new ColumnViewModel(ServiceProvider)
        {
            Name      = Name,
            IsVisible = IsVisible
        };

        return(copy);
    }
Example #23
0
        public void AddColumnAfterConnect_WillCreateColumnInRepo()
        {
            _repo.Setup(x => x.CreateOrUpdateColumn(It.IsAny<Column>())).Returns<Column>(Task.FromResult);
            _box.Connect(_repo.Object);

            var column = new ColumnViewModel {Id = 1};
            _box.Columns.Add(column);

            _repo.Verify(x => x.CreateOrUpdateColumn(It.Is<Column>(b => b.Id == column.Id)), Times.Once);
        }
Example #24
0
        public async Task <IActionResult> Update(ColumnViewModel columnViewModel)
        {
            var isSuccess = await _columnService.UpdateColumnAsync(columnViewModel);

            if (!isSuccess)
            {
                return(this.BadRequestResult("更新失败!"));
            }
            return(Ok());
        }
Example #25
0
        public ActionResult Edit(ColumnViewModel vm)
        {
            Command.Execute(new EditColumnCommand
            {
                Id   = vm.Id ?? 0,
                Name = vm.Name
            });

            return(RedirectToAction("Index"));
        }
Example #26
0
        internal void AddColumn(DataTable dataTable, ColumnViewModel columnViewModel)
        {
            var sdDataTable = _efContext.SDDataTables.Single(c => c.Name == dataTable.TableName);
            var column      = new SDTextBoxColumn(Guid.NewGuid().ToString(), columnViewModel.Name, columnViewModel.DataType, true, sdDataTable.Id);

            _dbTableRepository.AddColumn(dataTable.TableName, column);
            _efContext.SDColumns.Add(column);
            _efContext.SaveChanges();

            _dbTableRepository.UpdateDataTable(sdDataTable, dataTable);
        }
Example #27
0
        void StrokeAdding(Rect boundingRect)
        {
            Double centerX = boundingRect.X + boundingRect.Width / 2 -
                             Const.RowHeaderWidth + ActivatedScrollViewer.HorizontalOffset;

            Double screenHeight       = this.ViewModel.MainPageViewModel.Bounds.Height;
            Double columnHeaderHeight = Const.ColumnHeaderHeight;

            ColumnViewModel selectedColumnViewModel = null;

            foreach (ColumnViewModel columnViewModel in ViewModel.SheetViewModel.ColumnViewModels) // 현재 그 아래에 있는 컬럼을 찾고
            {
                if (columnViewModel.X <= centerX && centerX < columnViewModel.X + columnViewModel.Width)
                {
                    selectedColumnViewModel = columnViewModel;
                    break;
                }
            }

            if (selectedColumnViewModel == null)
            {
                return;
            }

            if (
                boundingRect.Y + boundingRect.Height < columnHeaderHeight * 1.2 ||
                screenHeight - columnHeaderHeight * 1.2 < boundingRect.Y
                ) // 컬럼 헤더에서 스트로크가 쓰여졌을때에는 다음 글자가 쓰여질때까지 기다린다
            {
            }
            else // 아니면 테이블 프리뷰
            {
                if (boundingRect.Height <= VerticalStrokeMinHeight) // 세로 스트로크인지 원인지 모르겠으면 대기
                {
                }
                else if (boundingRect.Width < VerticalStrokeMaxWidth && boundingRect.Height > VerticalStrokeMinHeight) // 세로 스트로크면 소팅하라는 것임 따라서 무시
                {
                    /*if(isSelectionPreviewing)
                     * {
                     *  ReflectState(ViewModel.MainPageViewModel.ExplorationViewModel.ViewStatus);
                     *  isSelectionPreviewing = false;
                     * }*/
                }
                else // 아니면 선택하라는 것임
                {
                    Double startY = boundingRect.Y + ActivatedScrollViewer.VerticalOffset - columnHeaderHeight,
                           endY   = boundingRect.Y + boundingRect.Height + ActivatedScrollViewer.VerticalOffset - columnHeaderHeight;

                    PreviewSelectionByRange(startY, endY);
                    //isSelectionPreviewing = true;
                }
            }
        }
Example #28
0
        public void RemoveColumnAfterConnect_WillRemoveColumnFromRepo()
        {
            var column = new ColumnViewModel {Id = 1};
            _box.Columns.Add(column);
            _repo.Setup(x => x.CreateOrUpdateColumn(It.Is<Column>(b => b.Id == column.Id)))
                .Returns(Task.FromResult(new Column { Id = column.Id }));
            _box.Connect(_repo.Object);

            _box.Columns.Remove(column);

            _repo.Verify(x => x.DeleteColumn(It.Is<int>(id => id == column.Id)), Times.Once);
        }
        public IActionResult Create(ColumnViewModel vmodel)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                if (_dbContext.Content.Any(x => x.ColumnTitle == vmodel.ColumnTitle && x.IsDeleted == 0))
                {
                    response.SetFailed("已存在该名称的栏目");
                    return(Ok(response));
                }

                var query = _dbContext.Column.FirstOrDefault(x => x.ColumnUuid == vmodel.SuperiorUuid);
                if (query == null)
                {
                    response.SetFailed("请填写上级栏目");
                    return(Ok(response));
                }
                if (vmodel.IssueTime == "")
                {
                    response.SetFailed("请选择发布时间");
                    return(Ok(response));
                }
                var entity = new Content();
                entity.ColumnUuid  = Guid.NewGuid();
                entity.IsDeleted   = 0;
                entity.ColumnTitle = vmodel.ColumnTitle;
                entity.AddTime     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                entity.AddPeople   = AuthContextService.CurrentUser.LoginName;

                entity.SuperiorUuid    = vmodel.SuperiorUuid;
                entity.SuperiorMenu    = query.SuperiorMenu + 1;
                entity.ColumnTitleText = query.ColumnTitle;
                entity.ColumnModel     = "列表栏目";
                entity.ColumnContent   = vmodel.ColumnContent;
                entity.Staue           = vmodel.Staue;
                entity.SortId          = vmodel.SortId;
                entity.IsStick         = vmodel.IsStick;
                if (!string.IsNullOrEmpty(vmodel.IssueTime))
                {
                    entity.IssueTime = Convert.ToDateTime(vmodel.IssueTime).ToString("yyyy-MM-dd");
                }
                _dbContext.Content.Add(entity);
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("添加", "成功:添加:内容管理信息一条数据", _dbContext);
                }
                response.SetSuccess();
                return(Ok(response));
            }
        }
Example #30
0
        protected ColumnViewModel ToViewModel(TableColumnDetail column)
        {
            ColumnViewModel vm = new ColumnViewModel
            {
                Id            = column.Column.Id,
                Name          = column.Column.Name,
                Type          = column.Column.Type,
                IsDeleted     = column.Column.IsDeleted,
                TableColumnId = column.TableColumn.Id
            };

            return(vm);
        }
 /// <summary>
 /// Validates the mappings for XYZ column.
 /// Only one of X or ReverseX / Y or ReverseY/ Z or ReverseZ can be mapped at a time.
 /// </summary>
 /// <param name="columnViewModel">Selected column</param>
 private void ValidateXYZMapping(ColumnViewModel columnViewModel)
 {
     // If the selected column in the mapped columns is X/Y/Z
     if (columnViewModel.SelectedWWTColumn.IsXYZColumn())
     {
         ColumnViewModel xyzSelectedColumn = null;
         switch (columnViewModel.SelectedWWTColumn.ColType)
         {
             case ColumnType.X:
                 xyzSelectedColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.ReverseX).FirstOrDefault();
                 break;
             case ColumnType.Y:
                 xyzSelectedColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.ReverseY).FirstOrDefault();
                 break;
             case ColumnType.Z:
                 xyzSelectedColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.ReverseZ).FirstOrDefault();
                 break;
             case ColumnType.ReverseX:
                 xyzSelectedColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.X).FirstOrDefault();
                 break;
             case ColumnType.ReverseY:
                 xyzSelectedColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.Y).FirstOrDefault();
                 break;
             case ColumnType.ReverseZ:
                 xyzSelectedColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.Z).FirstOrDefault();
                 break;
             default:
                 break;
         }
         if (xyzSelectedColumn != null)
         {
             xyzSelectedColumn.SelectedWWTColumn = xyzSelectedColumn.WWTColumns[0];
         }
     }
 }
 /// <summary>
 /// Validates if depth column is mapped and xyz columns are also mapped,
 /// If depth/alt is selected xyz columns will be set to "Select One" else if XYZ is selected
 /// depth/alt column is set to "Select One"
 /// </summary>
 /// <param name="columnViewModel">Selected column in mapping</param>
 private void ValidateDepthXYZColumns(ColumnViewModel columnViewModel)
 {
     // If the selected column is depth column and there is already xyz column mapped then
     // all the xyz selection would be changed to "Select One"
     if (columnViewModel.SelectedWWTColumn.IsDepthColumn() && !this.currentLayer.IsXYZLayer())
     {
         ColumnViewModel xyzColumn = null;
         xyzColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.ReverseX || columnValue.SelectedWWTColumn.ColType == ColumnType.X).FirstOrDefault();
         if (xyzColumn != null)
         {
             xyzColumn.SelectedWWTColumn = xyzColumn.WWTColumns[0];
         }
         xyzColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.ReverseY || columnValue.SelectedWWTColumn.ColType == ColumnType.Y).FirstOrDefault();
         if (xyzColumn != null)
         {
             xyzColumn.SelectedWWTColumn = xyzColumn.WWTColumns[0];
         }
         xyzColumn = this.ColumnsView.Where(columnValue => columnValue.SelectedWWTColumn.ColType == ColumnType.ReverseZ || columnValue.SelectedWWTColumn.ColType == ColumnType.Z).FirstOrDefault();
         if (xyzColumn != null)
         {
             xyzColumn.SelectedWWTColumn = xyzColumn.WWTColumns[0];
         }
     }
     else if (columnViewModel.SelectedWWTColumn.IsXYZColumn() && this.ColumnsView.Where(colVal => colVal.SelectedWWTColumn.IsDepthColumn()).Any())
     {
         // If selected column is xyz column and depth column was already mapped , the depth column
         // would be set to "Select One"
         ColumnViewModel depthCol = this.ColumnsView.Where(colVal => colVal.SelectedWWTColumn.IsDepthColumn()).FirstOrDefault();
         if (depthCol != null)
         {
             depthCol.SelectedWWTColumn = depthCol.WWTColumns[0];
         }
     }
 }
        /// <summary>
        /// Populates columns with the view model column 
        /// property and rebinds the columns
        /// </summary>
        /// <param name="selectedLayerMap">Selected layer map</param>
        /// <param name="columns">Collection of columns</param>
        internal void PopulateColumns(LayerMap selectedLayerMap, Collection<Column> columns)
        {
            this.ColumnsView = new ObservableCollection<ColumnViewModel>();
            int index = 0;

            foreach (string headerData in selectedLayerMap.HeaderRowData)
            {
                ColumnViewModel columnViewModel = new ColumnViewModel();
                columnViewModel.ExcelHeaderColumn = headerData;
                columnViewModel.WWTColumns = new ObservableCollection<Column>();
                columns.ToList().ForEach(col => columnViewModel.WWTColumns.Add(col));
                columnViewModel.SelectedWWTColumn = columns.Where(column => column.ColType == selectedLayerMap.MappedColumnType[index]).FirstOrDefault() ?? columns.Where(column => column.ColType == ColumnType.None).FirstOrDefault();
                this.ColumnsView.Add(columnViewModel);
                index++;
            }
            SetRAUnitVisibility();
        }
Example #34
0
 public ColumnSetting(ColumnViewModel col)
 {
     this.Name = col.PropertyName;
     this.Title = col.Title;
 }
Example #35
0
        public List<ColumnViewModel> GetColumns(ViewModelConfig viewModelConfig)
        {
            var cache = GetCache();

            if (cache.ContainsKey(viewModelConfig.Mnemonic))
                return cache[viewModelConfig.Mnemonic];

            lock (CacheLock)
            {
                if (!cache.ContainsKey(viewModelConfig.Mnemonic))
                {
                    var type = viewModelConfig.TypeEntity;

                    var columns = new List<ColumnViewModel>();

                    foreach (
                        var prop in
                            type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                                .Where(p => !p.IsDefined(typeof (JsonIgnoreAttribute), false)))
                    {
                        var listViewAttr = prop.GetCustomAttribute<ListViewAttribute>();
                        var detailViewAttr = prop.GetCustomAttribute<DetailViewAttribute>();

                        var systemPropertyAttr = prop.GetCustomAttribute<SystemPropertyAttribute>();

                        if (listViewAttr == null && systemPropertyAttr != null)
                        {
                            listViewAttr = new ListViewAttribute()
                            {
                                Name = prop.Name,
                                Hidden = true
                            };
                        }

                        if (listViewAttr != null)
                        {
                            var column = new ColumnViewModel()
                            {
                                Mnemonic = detailViewAttr.With(x => x.Mnemonic),
                                PropertyName = prop.Name,
                                PropertyInfo = prop,
                                Hidden = listViewAttr.Hidden,
                                Order = listViewAttr.Order,
                                Filterable = listViewAttr.Filterable,
                                Sortable = listViewAttr.Sortable,
                                Width = listViewAttr.Width != 0 ? (int?) listViewAttr.Width : null,
                                Height = listViewAttr.Height != 0 ? (int?) listViewAttr.Height : null,
                                IsSystemPropery = systemPropertyAttr != null,
                                Groupable = listViewAttr.Groupable,
                            };

                            var maxLengthAttr = prop.GetCustomAttribute<MaxLengthAttribute>();

                            if (maxLengthAttr != null)
                            {
                                column.MaxLength = maxLengthAttr.Length;
                            }

                            column.ColumnType = column.PropertyType.IsBaseCollection()
                                ? column.PropertyType.GetGenericType().GenericTypeArguments[0]
                                : column.PropertyType;

                            column.Title = listViewAttr.Name;

                            if (String.IsNullOrEmpty(column.Title))
                            {
                                if (detailViewAttr != null)
                                {
                                    column.Title = detailViewAttr.Name;
                                }

                                if (String.IsNullOrEmpty(column.Title))
                                {
                                    column.Title = prop.Name;
                                }
                            }

                            if (column.Order < 0 && detailViewAttr != null)
                            {
                                column.Order = detailViewAttr.Order;
                            }

                            var configColumn =
                                viewModelConfig.ListView.Columns.FirstOrDefault(
                                    m => m.PropertyName == column.PropertyName);

                            if (configColumn != null)
                            {
                                if (configColumn.Mnemonic != null)
                                    column.Mnemonic = configColumn.Mnemonic;

                                if (configColumn.Title != null)
                                    column.Title = configColumn.Title;

                                if (configColumn.Hidden.HasValue)
                                    column.Hidden = configColumn.Hidden.Value;

                                if (configColumn.Filterable.HasValue)
                                    column.Filterable = configColumn.Filterable.Value;

                                if (configColumn.Order.HasValue)
                                    column.Order = configColumn.Order.Value;

                                if (configColumn.Locked.HasValue)
                                    column.Locked = configColumn.Locked.Value;

                                if (configColumn.Lockable.HasValue)
                                    column.Lockable = configColumn.Lockable.Value;
                            }

                            column.ViewModelConfig = _viewModelConfigService.Get(column.Mnemonic) ??
                                                     _viewModelConfigService.Get(column.ColumnType);

                            if (column.ViewModelConfig == null && prop.PropertyType.IsAssignableFromBase())
                                throw new Exception(
                                    String.Format("The configuration file is not configured for type \"{0}\"",
                                        column.ColumnType.Name));

                            if (String.IsNullOrEmpty(column.Mnemonic))
                                column.Mnemonic = type.GetTypeName();

                            columns.Add(column);
                        }
                    }

                    cache.Add(viewModelConfig.Mnemonic, columns.OrderBy(m => m.Order).ToList());
                }
            }

            return cache[viewModelConfig.Mnemonic];
        }
Example #36
0
 public ColumnSetting Init(ColumnViewModel vm)
 {
     _viewModel = vm;
     return this;
 }
        public void OnMapColumnSelectionChangedEventRAGeoTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();

            ColumnViewModel columnView = new ColumnViewModel();
            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns = new ObservableCollection<Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.sizeColumnList = new ObservableCollection<System.Collections.Generic.KeyValuePair<int, string>>();
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(0, "LAT"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(1, "MAG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(2, "LONG"));
            target.sizeColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(3, "DEPTH"));

            target.hoverTextColumnList = new ObservableCollection<System.Collections.Generic.KeyValuePair<int, string>>();
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(0, "LAT"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(1, "MAG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(2, "LONG"));
            target.hoverTextColumnList.Add(new System.Collections.Generic.KeyValuePair<int, string>(3, "DEPTH"));

            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            target.currentLayer = localLayerMap;

            EventArgs e = null;
            target.OnMapColumnSelectionChanged(columnView, e);

            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(true, target.IsRAUnitVisible);
            Assert.AreEqual(AngleUnit.Hours, target.selectedRAUnit.Key);

            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.Geo).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.OnMapColumnSelectionChanged(columnView, e);
            Assert.AreEqual(true, target.isMarkerTabEnabled);
            Assert.AreEqual(false, target.isDistanceVisible);
            Assert.AreEqual(false, target.IsRAUnitVisible);
        }
        public void OnGroupSelectionChangedTest()
        {
            LayerDetailsViewModel_Accessor target = new LayerDetailsViewModel_Accessor();
            Group group = new Group("Sun", GroupType.ReferenceFrame, null);
            Group skyGroup = new Group("Sky", GroupType.ReferenceFrame, null);
            Layer layer = new Layer();
            layer.Name = "Layer1";
            layer.StartTime = DateTime.Now;

            LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
            localLayerMap.MapType = LayerMapType.Local;
            localLayerMap.RangeDisplayName = "Sheet_1";
            localLayerMap.HeaderRowData = new Collection<string>();
            localLayerMap.HeaderRowData.Add("Lat");

            localLayerMap.MappedColumnType = new Collection<ColumnType>();
            localLayerMap.MappedColumnType.Add(ColumnType.RA);
            target.currentLayer = localLayerMap;

            ColumnViewModel columnView = new ColumnViewModel();
            columnView.ExcelHeaderColumn = "RA";
            columnView.WWTColumns = new ObservableCollection<Column>();
            ColumnExtensions.PopulateColumnList().ToList().ForEach(col => columnView.WWTColumns.Add(col));
            columnView.SelectedWWTColumn = columnView.WWTColumns.Where(column => column.ColType == ColumnType.RA).FirstOrDefault();

            target.ColumnsView = new ObservableCollection<ColumnViewModel>();
            target.ColumnsView.Add(columnView);

            target.selectedScaleType = new System.Collections.Generic.KeyValuePair<ScaleType, string>(ScaleType.StellarMagnitude, "StellarMagnitude");

            object sender = group;
            EventArgs e = null;
            target.OnGroupSelectionChanged(sender, e);

            Assert.AreEqual(false, target.isRAUnitVisible);
            Assert.AreEqual("Sun", target.selectedGroupText);
            Assert.AreEqual(ScaleType.Power, target.selectedScaleType.Key);

            sender = skyGroup;
            target.OnGroupSelectionChanged(sender, e);
            Assert.AreEqual(ScaleType.StellarMagnitude, target.selectedScaleType.Key);
        }