public AdministrationCommands(MessageRemoverService responseRemover, StatisticsRepository statisticsRepository, AdvanceImagesRepository advanceImagesRepository, MemoryCache memoryCache) : base(responseRemover) { _statisticsRepository = statisticsRepository; _advanceImagesRepository = advanceImagesRepository; _memoryCache = memoryCache; }
public ActionResult _ajax_GetUserModuleStats(int course, string id, int company, int department, int user) { id = id ?? ""; bool superadmin = SessionManager.inst.IsSuperadmin(); bool admin = SessionManager.inst.IsAdmin(); bool manager = SessionManager.inst.IsManager(); if (!superadmin) { company = company != 0 ? company : SessionManager.inst.Company().Id; } if (manager && !admin) { department = department != 0 ? department : SessionManager.inst.User().DepartmentId; } //var graph = StatisticsRepository.GetUserScoreForCourse(id, course, company, department, user); var graph = StatisticsRepository.GetUsersScoreForCourse(course, id, company, department, user); if (graph != null) { return(Json(graph, JsonRequestBehavior.AllowGet)); } else { return(Json("no_data", JsonRequestBehavior.AllowGet)); }; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var config = new MongoDBConfig(); Configuration.Bind(config); #region Statistics var statisticsContext = new StatisticsContext(config); var statisticsRepository = new StatisticsRepository(statisticsContext); services.AddSingleton <StatisticsRepository>(statisticsRepository); #endregion var statistics = statisticsRepository.GetAll().GetAwaiter().GetResult(); if (statistics.Count() == 0) { this.seedDefaultStatisticsObject(statisticsRepository); } services.AddControllers(); services.AddCors(options => { options.AddPolicy(MyAllowSpecificOrigins, builder => { builder.WithOrigins("http://localhost:4200") .AllowAnyHeader() .AllowAnyMethod(); }); }); }
/// <summary> /// 搜索宿舍预定信息 /// </summary> /// <param name="webModel">列表页视图Model</param> /// <param name="context">数据库连接上下文对象</param> /// <returns></returns> public async Task <DormitoryViewModel> SearchDormitoryAsync(DormitoryViewModel webModel, ApplicationDbContext context) { try { //Source Data List var list = await StatisticsRepository.GetListAsync(webModel, context); //Return Data List var dataList = new List <DormitoryData>(); if (list != null && list.Any()) { dataList.AddRange(list.Select(item => new DormitoryData { Building = item.BuildingName, DateTime = item.DateTime.ToString("yyyy-MM-dd HH:mm:ss"), Dorm = item.DormName, Floor = item.Floor, MajorClass = item.MajorClassName, Name = item.StudentName, StudentId = item.StudentId.ToString() })); } webModel.DormitoryList = dataList; webModel.Total = await StatisticsRepository.GetListCountAsync(webModel, context); } catch (Exception ex) { _logger.LogError("获取宿舍预定列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message); } return(webModel); }
/// <summary> /// 获取服务预定详细信息 /// </summary> /// <param name="id"></param> /// <param name="context"></param> /// <returns></returns> public async Task <BookDetailViewModel> GetBookAsync(long id, ApplicationDbContext context) { var webModel = new BookDetailViewModel(); try { var model = await StatisticsRepository.GetEntityAsync(id, context); webModel.Count = model.Count; webModel.DepartureTime = model.DepartureTime; webModel.Id = model.Id.ToString(); webModel.IsCancel = model.IsCancel; webModel.Name = model.Name; webModel.Place = model.Place; webModel.Remark = model.Remark; webModel.ScheduledTime = model.ScheduledTime; webModel.ServiceName = model.ServiceName; webModel.Tel = model.Tel; } catch (Exception ex) { _logger.LogError("获取服务预定详细信息失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message); } return(webModel); }
/// <summary> /// 搜索新生注册信息 /// </summary> /// <param name="webModel">列表页视图Model</param> /// <param name="context">数据库连接上下文对象</param> /// <returns></returns> public async Task <RegisterViewModel> SearchRegisterAsync(RegisterViewModel webModel, ApplicationDbContext context) { try { //Source Data List var list = await StatisticsRepository.GetListAsync(webModel, context); //Return Data List var dataList = new List <RegisterData>(); if (list != null && list.Any()) { dataList.AddRange(list.Select(item => new RegisterData { Id = item.StudentId.ToString(), Name = item.Name, Address = item.Place, Department = item.Department, MajorClass = item.MajorClass, Way = item.Way, DateTime = item.ArriveTime, Express = item.ExpressId })); } webModel.RegisterList = dataList; webModel.Total = await StatisticsRepository.GetListCountAsync(webModel, context); } catch (Exception ex) { _logger.LogError("获取新生注册列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message); } return(webModel); }
/// <summary> /// 搜索物品选择数据信息 /// </summary> /// <param name="webModel">列表页视图Model</param> /// <param name="context">数据库连接上下文对象</param> /// <returns></returns> public async Task <GoodsViewModel> SearchGoodsAsync(GoodsViewModel webModel, ApplicationDbContext context) { try { //Source Data List var list = await StatisticsRepository.GetListAsync(webModel, context); //Return Data List var dataList = new List <GoodsData>(); if (list != null && list.Any()) { dataList.AddRange(list.Select(item => new GoodsData { Id = item.StudentId.ToString(), Name = item.StudentName, GoodsId = item.GoodsId.ToString(), GoodsName = item.GoodsName, Size = item.Size, DateTime = item.ChosenTime, Remark = item.Remark.Length > 20 ? item.Remark.Substring(0, 20) : item.Remark })); } webModel.GoodsList = dataList; webModel.Total = await StatisticsRepository.GetListCountAsync(webModel, context); } catch (Exception ex) { _logger.LogError("获取物品选择列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message); } return(webModel); }
public ActionResult ListСompanies(int course, int company, int department, int user) { var companys = StatisticsRepository.DropDownLists(course, company, department, user); var json = new JavaScriptSerializer().Serialize(companys); return(Json(json, JsonRequestBehavior.AllowGet)); }
public void GenerateLeaderboard() { using (var ts = new TransactionScope()) { this.BulkInsertTestData(); var repository = new StatisticsRepository(ConnectionString); var count = 5; var leaderboard = repository.GenerateLeaderboard(count); Assert.AreEqual(3, leaderboard.Count()); int idBoard = 0; foreach (var board in leaderboard) { Assert.AreEqual(++idBoard, board.Id); Assert.AreEqual(count, board.Scores.Count()); int idScore = 0; foreach (var score in board.Scores) { Assert.AreEqual(++idScore, score.Id); } } } }
public UnitOfWork(DtsContext context) { _context = context; Drones = new DroneRepository(_context); NavigationPoints = new NavigationRepository(_context); Scales = new ScaleRepository(_context); Street = new StreetRepository(_context); Statistics = new StatisticsRepository(_context); }
public UnitOfWork(/*TakeMyTimeDbContext context*/) { this.context = new TakeMyTimeDbContext(); Projects = new ProjectRepository(context); Entries = new EntryRepository(context); Assignments = new AssignmentRepository(context); ProjectTypes = new ProjectTypeRepository(context); Subtasks = new SubtaskRepository(context); Statistics = new StatisticsRepository(context); }
public ActionResult ChangeDates(int course, int company, int department, int user, string start, string end) { bool rez = StatisticsRepository.ChangeDates(course, company, department, user, start, end); if (rez) { return(Json("Ok", JsonRequestBehavior.AllowGet)); } else { return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public ActionResult _ajax_StatUsers(int course, int company, int department) { var customCourseIds = StatisticsRepository.MasterId2customId(course, company, department, 0).Distinct().ToList(); List <StatUsersModel> stats = new List <StatUsersModel>(); for (var i = 0; i < customCourseIds.Count(); i++) { stats.AddRange(StatisticsRepository.GetStatUsers(course, customCourseIds[i], company, department)); } var json = new JavaScriptSerializer().Serialize(stats.Distinct()); return(Json(json, JsonRequestBehavior.AllowGet)); }
public ActionResult _ajax_GetSparklineStat(int course, int company, int department, string start, string end) { bool superadmin = SessionManager.inst.IsSuperadmin(); bool admin = SessionManager.inst.IsAdmin(); bool manager = SessionManager.inst.IsManager(); if (!superadmin) { company = company != 0 ? company : SessionManager.inst.Company().Id; } if (manager && !admin) { department = department != 0 ? department : SessionManager.inst.User().DepartmentId; } var customCourseId = StatisticsRepository.MasterId2customId(course, company, department, 0).FirstOrDefault(); DateTime?startDateTime = null; DateTime?endDateTime = null; var result = new Dictionary <string, int>(); if (!start.Equals("")) { startDateTime = DateTime.ParseExact(start, dateFormat, CultureInfo.InvariantCulture); } if (!end.Equals("")) { endDateTime = DateTime.ParseExact(end, dateFormat, CultureInfo.InvariantCulture); } var started = 0; var ended = 0; if (customCourseId != 0) { var customCourseIds = StatisticsRepository.masterId2customIds(course); for (var i = 0; i < customCourseIds.Count(); i++) { started += StatisticsRepository.CourseWeekStatistics(customCourseIds[i], company, department, startDateTime, endDateTime, 0); ended += StatisticsRepository.CoursesWeekStatistics(customCourseIds[i], company, department, startDateTime, endDateTime, 0); } } else { started += StatisticsRepository.CourseWeekStatistics(customCourseId, company, department, startDateTime, endDateTime, 0); ended += StatisticsRepository.CoursesWeekStatistics(customCourseId, company, department, startDateTime, endDateTime, 0); } result.Add("started", started); result.Add("ended", ended); var json = new JavaScriptSerializer().Serialize(result); return(Json(json, JsonRequestBehavior.AllowGet)); }
private void GenuriSolicitate_Click(object sender, EventArgs e) { var statistics = new StatisticsRepository(); var ctx = statistics.GetAllRequestedGenres(); string content = "Genurile cele mai solicitate \n"; for (int index = 0; index < ctx.LongCount(); index++) { content += "\tGen " + (index + 1) + ": " + ctx[index] + "\n"; } MessageBox((IntPtr)0, content, "Message Box", 0); }
public StartupManager( ILogFactory logFactory, RiskConstrainsInitializer riskConstrainsInitializer, ICqrsEngine cqrsEngine, StatisticsRepository statisticsRepository, Server grpcServer) { _log = logFactory.CreateLog(this); _riskConstrainsInitializer = riskConstrainsInitializer; _cqrsEngine = cqrsEngine; _statisticsRepository = statisticsRepository; _grpcServer = grpcServer; }
private void AutoriCautati_Click(object sender, EventArgs e) { var statistics = new StatisticsRepository(); var ctx = statistics.GetAllWantedAuthors(); string content = "Autorii cei mai cautati \n"; for (int index = 0; index < ctx.LongCount(); index++) { content += "\tAutor " + (index + 1) + ": " + ctx[index] + "\n"; } MessageBox((IntPtr)0, content, "Message Box", 0); }
public KaTaLyzerWorker(PlatformDependencies platformDependencies) { if (!ConfigurationManager.GetInstance().HasConfiguration()) { throw new InvalidOperationException("Can't start KaTaLyzer without configuration"); } _platformDependencies = platformDependencies; _networkAdaptersStatistics = new List <NetworkAdapterStatistics>(); _runningTasks = new List <Task>(); _adapters = ConfigurationManager.GetInstance().GetNetworkAdapterConfiguration().Select(configuration => { NetworkAdapter adapter = null; adapter = new NetworkAdapter(configuration, platformDependencies); adapter.PacketCaptured += ProcessPacket; adapter.ErrorOccured += AdapterErrorOccured; return(adapter); }).ToList(); ulong uploadedCount = 0; _timer = new Timer { Interval = ConfigurationManager.GetInstance().GetUploadInterval() * 1000 }; _timer.Elapsed += async(sender, eventArgs) => { var statisticsRepository = new StatisticsRepository(); try { await statisticsRepository.PersistStatistics(TakeNetworkAdaptersStatistics()); uploadedCount++; StatisticsPersisted?.Invoke(new StatisticsPersistedEventArgs(_capturingStartedAt, DateTime.Now, uploadedCount)); } catch (Exception e) { await KaTaLyzerLogger.Log(LogLevel.Error, e); Error?.Invoke(this, e); } }; }
private void Review_uriCarte_Click(object sender, EventArgs e) { var statistics = new StatisticsRepository(); var ctx = statistics.GetReviewByBookTitle(boxTitluCarteStatistica.Text.Trim()); string content = "Review-uri pentru o carte \n"; for (int index = 0; index < ctx.LongCount(); index++) { content += "\tReview " + (index + 1) + ": " + ctx[index] + "\n"; } MessageBox((IntPtr)0, content, "Message Box", 0); boxTitluCarteStatistica.Text = ""; }
public StatisticsRepositoryTests() { _repository = new StatisticsRepository(Context.Object); Context.Setup(c => c.ExistsAsync(It.IsAny <Expression <Func <Statistics, bool> > >())) .Returns(() => Task.FromResult(Collection.Any(s => s.Id == _statistics.Id))); Context.Setup(c => c.UpdateIncrementAsync(It.IsAny <Expression <Func <Statistics, bool> > >(), It.IsAny <Expression <Func <Statistics, int> > >(), It.IsAny <int>())) .Callback(() => Collection[0].ViewsAmount += 1) .Returns(Task.CompletedTask); Context.Setup(c => c.GetInAndWhereAsync(It.IsAny <Expression <Func <Statistics, Guid> > >(), It.IsAny <IEnumerable <Guid> >(), It.IsAny <Expression <Func <Statistics, bool> > >())) .Returns(() => Task.FromResult(Collection.Where(s => s.DateTime >= DateTime.Today && s.DateTime <= DateTime.Today))); InitializeData(); }
void seedDefaultStatisticsObject(StatisticsRepository statisticsRepository) { var stat = new Statistics() { Id = "1", DataPlans = new Dictionary <string, int>(), Extensions = new Dictionary <string, int>(), UploadDates = new Dictionary <string, int>(), NumberOfFiles = 0, NumberOfMessages = 0, NumberOfUsers = 0, TotalDataStored = 0, }; statisticsRepository.Create(stat); }
public UnitOfWork(AcaShareDbContext dbContext) { _db = dbContext; Universities = new UniversityRepository(_db.University); Departments = new DepartmentRepository(_db.Department); Semesters = new SemesterRepository(_db.Semester); Subjects = new SubjectRepository(_db.Subject); Lessons = new LessonRepository(_db.Lesson); Users = new UserRepository(_db.User); Materials = new MaterialRepository(_db.Material, _db.File, _db.ChangeReason, _db.DeleteRequest, _db.EditRequest); MaterialStates = new MaterialStatesRepository(_db.MaterialState); SidebarRepository = new SidebarRepository(_db.Comment, _db.Material, _db.Favorites); StatisticsRepository = new StatisticsRepository(_db.DeleteRequest); NotificationRepository = new NotificationRepository(_db.Notification); MainModeratorRepository = new MainModeratorRepository(_db.UniversityMainModerator); }
// Statistici ... private void NrNumeCititori_Click(object sender, EventArgs e) { var statistics = new StatisticsRepository(); DateTime startData = new DateTime(2018, 2, 4); DateTime stopData = new DateTime(2018, 3, 24); var ctx = statistics.GetAllReadersByPeriodTime(startData, stopData); string content = "Nr de Cititor intr-o perioada de timp\n"; content += "Nr Cititor: " + ctx.LongCount() + "\n"; for (int index = 0; index < ctx.LongCount(); index++) { content += "\tNume Cititor " + (index + 1) + ": " + ctx[index] + "\n"; } MessageBox((IntPtr)0, content, "Message Box", 0); }
public void BulkInsertTestData() { var repository = new StatisticsRepository(ConnectionString); var rnd = new Random(); for (int i = 0; i < 100; i++) { var stats = new UserStats() { UserId = "testuser_" + i.ToString(), Victories = rnd.Next(1000), Defeats = rnd.Next(1000), GameCount = rnd.Next(1000) }; repository.Save(stats); } }
private Statistics GetStatistics() { AesEncryption aes = new AesEncryption(); byte[] key = aes.GenerateRandomNumber(32); byte[] iv = aes.GenerateRandomNumber(16); // Gets the statistics encrypted byte[] encryptedData = StatisticsRepository.GetStatistics(key, iv, _carwashId); // Decrypts the data byte[] decryptedData = aes.Decrypt(encryptedData, key, iv); // Makes the byte array into a string string decryptedJson = Encoding.UTF8.GetString(decryptedData); // Deserializes the json string Statistics statistics = JsonHelper.DeserializeJson <Statistics>(decryptedJson); return(statistics); }
public void GenerateLeaderboardFocused() { using (var ts = new TransactionScope()) { this.BulkInsertTestData(); var repository = new StatisticsRepository(ConnectionString); var count = 2; var userFocus = "testuser_50"; var leaderboard = repository.GenerateLeaderboard(userFocus, count); Assert.AreEqual(3, leaderboard.Count()); int idBoard = 0; foreach (var board in leaderboard) { Assert.AreEqual(++idBoard, board.Id); Assert.AreEqual((Math.Floor(count / 2.0) * 2) + 1, board.Scores.Count()); } } }
private static void Generate() { var statisticsRepository = new StatisticsRepository(); var fromDate = DateTime.Now.AddDays(-1); var rnd = new Random(); for (int i = 0; i < 24 * 60 / 5; i++) { var dateStart = fromDate.AddMinutes(i * 5); var value = rnd.Next(150, 250) / 10.0; statisticsRepository.AddStat(new StatisticsDbEntry { TimeStart = dateStart, TimeEnd = dateStart.AddMinutes(5), Domain = "HomeAutomation.BasicThermostat", Address = "1", Parameter = "Sensor.Temperature", AvgValue = value, ModuleName = "Thermostat" }); } }
public void SaveAndRetrieveUserStatistics() { using (var ts = new TransactionScope()) { var repository = new StatisticsRepository(ConnectionString); var stats = new UserStats() { UserId = "testuser", GameCount = 10, Victories = 5, Defeats = 1 }; repository.Save(stats); var result = repository.Retrieve(stats.UserId); Assert.AreEqual(result.UserId, stats.UserId); Assert.AreEqual(result.GameCount, stats.GameCount); Assert.AreEqual(result.Victories, stats.Victories); Assert.AreEqual(result.Defeats, stats.Defeats); } }
public static void Register(IUnityContainer container) { var sessionFactory = container.Resolve <ISessionFactory>(); var playerRepository = new PlayerRepository(sessionFactory); var gameRepository = new GameRepository(sessionFactory); var courseRepository = new CourseRepository(sessionFactory); var statisticsRepository = new StatisticsRepository(sessionFactory); var scoreRepository = new ScoreRepository(sessionFactory); var tourRepository = new TourRepository(sessionFactory); container.RegisterType <IPlayerRepository, PlayerRepository>(); container.RegisterType <IGameRepository, GameRepository>(); container.RegisterType <ICourseRepository, CourseRepository>(); container.RegisterType <IStatisticsRepository, StatisticsRepository>(); container.RegisterType <IScoreRepository, ScoreRepository>(); container.RegisterType <ITourRepository, TourRepository>(); container.RegisterInstance(playerRepository); container.RegisterInstance(gameRepository); container.RegisterInstance(courseRepository); container.RegisterInstance(statisticsRepository); container.RegisterInstance(scoreRepository); container.RegisterInstance(tourRepository); }
/// <summary> /// 搜索迎新服务预定信息 /// </summary> /// <param name="webModel">列表页视图Model</param> /// <param name="context">数据库连接上下文对象</param> /// <returns></returns> public async Task <BookViewModel> SearchBookAsync(BookViewModel webModel, ApplicationDbContext context) { try { //Source Data List var list = await StatisticsRepository.GetListAsync(webModel, context); //Return Data List var dataList = new List <BookData>(); if (list != null && list.Any()) { dataList.AddRange(list.Select(item => new BookData { Id = item.Id.ToString(), Name = item.Name, Tel = item.Tel, Count = item.Count, ScheduledTime = item.ScheduledTime.ToString("yyyy-MM-dd HH:mm"), ServiceName = item.ServiceName, DepartureTime = item.DepartureTime.ToString("yyyy-MM-dd HH:mm"), Place = item.Place, Remark = !string.IsNullOrEmpty(item.Remark) && (item.Remark.Length > 20) ? item.Remark.Substring(0, 20) : item.Remark, IsCancel = item.IsCancel })); } webModel.BookList = dataList; webModel.Total = await StatisticsRepository.GetListCountAsync(webModel, context); } catch (Exception ex) { _logger.LogError("获取迎新服务预定列表失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message); } return(webModel); }
private void SetChartData(List<XYChartData> dataList, StatisticsRepository.LinearRegression.LinearRegressionResults regresResults, NumericDataValue maxValue, NumericDataValue minValue) { List<RegressionChartData> regressionDataList = new List<RegressionChartData>(); if (regresResults.variables != null) { decimal coefficient = Convert.ToDecimal(regresResults.variables[0].coefficient); decimal constant = Convert.ToDecimal(regresResults.variables[1].coefficient); NumericDataValue newMaxValue = new NumericDataValue(); newMaxValue.IndependentValue = maxValue.IndependentValue; newMaxValue.DependentValue = (coefficient * maxValue.IndependentValue) + constant; NumericDataValue newMinValue = new NumericDataValue(); newMinValue.IndependentValue = minValue.IndependentValue; newMinValue.DependentValue = (coefficient * minValue.IndependentValue) + constant; tblockEquation.Text = "Y = (" + Math.Round(coefficient, 4).ToString() + ")X + " + Math.Round(constant, 4).ToString(); List<NumericDataValue> regresValues = new List<NumericDataValue>(); regresValues.Add(newMinValue); regresValues.Add(newMaxValue); RegressionChartData rChartData = new RegressionChartData(); rChartData.X = (double)newMinValue.IndependentValue; rChartData.Z = (double)newMinValue.DependentValue; regressionDataList.Add(rChartData); rChartData = new RegressionChartData(); rChartData.X = (double)newMaxValue.IndependentValue; rChartData.Z = (double)newMaxValue.DependentValue; regressionDataList.Add(rChartData); //bool foundMin = false; //bool foundMax = false; //foreach (XYChartData chartData in dataList) //{ // if ((double)chartData.X == (double)newMaxValue.IndependentValue) // { // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = (double)newMaxValue.IndependentValue; // rChartData.Z = (double)newMaxValue.DependentValue; // regressionDataList.Add(rChartData); // //chartData.Z = (double)newMaxValue.DependentValue; // foundMax = true; // } // if ((double)chartData.X == (double)newMinValue.IndependentValue) // { // //chartData.Z = (double)newMinValue.DependentValue; // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = (double)newMaxValue.IndependentValue; // rChartData.Z = (double)newMinValue.DependentValue; // regressionDataList.Add(rChartData); // foundMin = true; // } //} //if (foundMax == false) //{ // XYChartData data = new XYChartData(); // data.X = (double)newMaxValue.IndependentValue; // //data.Z = (double)newMaxValue.DependentValue; // dataList.Add(data); // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = data.X; // rChartData.Z = (double)newMaxValue.DependentValue; // regressionDataList.Add(rChartData); // xAxis.MaxValue = data.X; //} //if (foundMin == false) //{ // XYChartData data = new XYChartData(); // data.X = (double)newMinValue.IndependentValue; // //data.Z = (double)newMinValue.DependentValue; // dataList.Add(data); // RegressionChartData rChartData = new RegressionChartData(); // rChartData.X = data.X; // rChartData.Z = (double)newMinValue.DependentValue; // regressionDataList.Add(rChartData); // xAxis.MinValue = data.X; //} } //xAxis.UseOnlyVisiblePointsToComputeRange = true; //xyChart.DataSource = dataList; series0.DataSource = dataList; series1.DataSource = regressionDataList; xyChart.Width = double.Parse(txtWidth.Text); xyChart.Height = double.Parse(txtHeight.Text); //xAxis.UseOnlyVisiblePointsToComputeRange = true; }
private void RenderFinishScatterChart(List<NumericDataValue> dataValues, StatisticsRepository.LinearRegression.LinearRegressionResults results, NumericDataValue maxValue, NumericDataValue minValue) { Chart chart = new Chart(); chart.Loaded += new RoutedEventHandler(chart_Loaded); chart.BorderThickness = new Thickness(0); ScatterSeries series = new ScatterSeries(); LinearAxis xaxis = new LinearAxis(); xaxis.Orientation = AxisOrientation.X; xaxis.Title = cbxScatterXAxisField.SelectedItem.ToString(); series.IndependentAxis = xaxis; LinearAxis yaxis = new LinearAxis(); yaxis.Orientation = AxisOrientation.Y; yaxis.Title = cbxScatterYAxisField.SelectedItem.ToString(); series.DependentRangeAxis = yaxis; yaxis.ShowGridLines = (bool)checkboxShowHorizontalGridLines.IsChecked; series.IndependentValuePath = "IndependentValue"; series.DependentValuePath = "DependentValue"; series.ItemsSource = dataValues; chart.Series.Add(series); if (results.variables != null) { decimal coefficient = Convert.ToDecimal(results.variables[0].coefficient); decimal constant = Convert.ToDecimal(results.variables[1].coefficient); NumericDataValue newMaxValue = new NumericDataValue(); newMaxValue.IndependentValue = maxValue.IndependentValue + 1; newMaxValue.DependentValue = (coefficient * maxValue.IndependentValue) + constant; NumericDataValue newMinValue = new NumericDataValue(); newMinValue.IndependentValue = minValue.IndependentValue - 1; newMinValue.DependentValue = (coefficient * minValue.IndependentValue) + constant; List<NumericDataValue> regresValues = new List<NumericDataValue>(); regresValues.Add(newMinValue); regresValues.Add(newMaxValue); LineSeries regression = new LineSeries(); regression.DependentRangeAxis = yaxis; regression.IndependentAxis = xaxis; regression.IndependentValuePath = "IndependentValue"; regression.DependentValuePath = "DependentValue"; regression.ItemsSource = regresValues; chart.Series.Add(regression); series.LegendItems.Clear(); regression.LegendItems.Clear(); chart.Height = 600; if (dataValues.Count > 20) chart.Width = dataValues.Count * 25; else chart.Width = 800; pnlMain.Children.Clear(); pnlMain.Children.Add(chart); } else { pnlMain.Children.Clear(); RenderFinishWithWarning("Insufficient data to produce this chart."); } //RenderFinish(); }
private void AddComplexSampleMeansGrid(StatisticsRepository.ComplexSampleMeans.CSMeansResults results) { Grid grid = new Grid(); grid.Tag = GadgetOptions.MainVariableName; grid.Style = this.Resources["genericOutputGrid"] as Style; grid.Margin = (Thickness)this.Resources["genericElementMargin"]; grid.Visibility = System.Windows.Visibility.Collapsed; StrataGridList.Add(grid); // Setup grid header grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); RowDefinition rowDefHeader = new RowDefinition(); rowDefHeader.Height = new GridLength(30); grid.RowDefinitions.Add(rowDefHeader); grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); Rectangle rctHeader = new Rectangle(); rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style; Grid.SetRow(rctHeader, 0); Grid.SetRowSpan(rctHeader, 3); Grid.SetColumn(rctHeader, 0); Grid.SetColumnSpan(rctHeader, 8); grid.Children.Add(rctHeader); TextBlock txtValHeader = new TextBlock(); txtValHeader.Text = GadgetOptions.MainVariableName; txtValHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtValHeader, 0); Grid.SetColumn(txtValHeader, 1); Grid.SetColumnSpan(txtValHeader, 7); grid.Children.Add(txtValHeader); TextBlock txtCrosstabHeader = new TextBlock(); txtCrosstabHeader.Text = GadgetOptions.CrosstabVariableName; txtCrosstabHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtCrosstabHeader, 1); Grid.SetRowSpan(txtCrosstabHeader, 2); Grid.SetColumn(txtCrosstabHeader, 0); grid.Children.Add(txtCrosstabHeader); TextBlock txtCountHeader = new TextBlock(); txtCountHeader.Text = "Count"; txtCountHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtCountHeader, 1); Grid.SetRowSpan(txtCountHeader, 2); Grid.SetColumn(txtCountHeader, 1); grid.Children.Add(txtCountHeader); TextBlock txtMeanHeader = new TextBlock(); txtMeanHeader.Text = "Mean"; txtMeanHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtMeanHeader, 1); Grid.SetRowSpan(txtMeanHeader, 2); Grid.SetColumn(txtMeanHeader, 2); grid.Children.Add(txtMeanHeader); TextBlock txtStdErrorHeader = new TextBlock(); txtStdErrorHeader.Text = "Std Error"; txtStdErrorHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtStdErrorHeader, 1); Grid.SetRowSpan(txtStdErrorHeader, 2); Grid.SetColumn(txtStdErrorHeader, 3); grid.Children.Add(txtStdErrorHeader); TextBlock txtCIHeader = new TextBlock(); txtCIHeader.Text = "Confidence Limits"; txtCIHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtCIHeader, 1); Grid.SetColumn(txtCIHeader, 4); Grid.SetColumnSpan(txtCIHeader, 2); grid.Children.Add(txtCIHeader); TextBlock txtLowerHeader = new TextBlock(); txtLowerHeader.Text = "Lower"; txtLowerHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtLowerHeader, 2); Grid.SetColumn(txtLowerHeader, 4); grid.Children.Add(txtLowerHeader); TextBlock txtUpperHeader = new TextBlock(); txtUpperHeader.Text = "Upper"; txtUpperHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtUpperHeader, 2); Grid.SetColumn(txtUpperHeader, 5); grid.Children.Add(txtUpperHeader); TextBlock txtMinHeader = new TextBlock(); txtMinHeader.Text = "Minimum"; txtMinHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtMinHeader, 1); Grid.SetRowSpan(txtMinHeader, 2); Grid.SetColumn(txtMinHeader, 6); grid.Children.Add(txtMinHeader); TextBlock txtMaxHeader = new TextBlock(); txtMaxHeader.Text = "Maximum"; txtMaxHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtMaxHeader, 1); Grid.SetRowSpan(txtMaxHeader, 2); Grid.SetColumn(txtMaxHeader, 7); grid.Children.Add(txtMaxHeader); string unknown = "----"; string blank = string.Empty; foreach (StatisticsRepository.ComplexSampleMeans.MeansRow mRow in results.Rows) { grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtRowLabel = new TextBlock(); txtRowLabel.Text = mRow.Label; txtRowLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowLabel.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowLabel, 0); grid.Children.Add(txtRowLabel); TextBlock txtRowCount = new TextBlock(); txtRowCount.Text = mRow.Count.HasValue == true ? mRow.Count.Value.ToString("F4") : blank; if (txtRowCount.Text.EndsWith(".0000")) { txtRowCount.Text = mRow.Count.Value.ToString("F0"); } txtRowCount.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; txtRowCount.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowCount.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowCount, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowCount, 1); grid.Children.Add(txtRowCount); TextBlock txtRowMean = new TextBlock(); txtRowMean.Text = mRow.Mean.HasValue == true ? mRow.Mean.Value.ToString("F4") : unknown; txtRowMean.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; txtRowMean.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowMean.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowMean, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowMean, 2); grid.Children.Add(txtRowMean); TextBlock txtRowStdError = new TextBlock(); txtRowStdError.Text = mRow.StdErr.HasValue == true ? mRow.StdErr.Value.ToString("F4") : unknown; txtRowStdError.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; txtRowStdError.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowStdError.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowStdError, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowStdError, 3); grid.Children.Add(txtRowStdError); TextBlock txtRowLower = new TextBlock(); txtRowLower.Text = mRow.LCL.HasValue == true ? mRow.LCL.Value.ToString("F4") : unknown; txtRowLower.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; txtRowLower.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowLower.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowLower, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowLower, 4); grid.Children.Add(txtRowLower); TextBlock txtRowUpper = new TextBlock(); txtRowUpper.Text = mRow.UCL.HasValue == true ? mRow.UCL.Value.ToString("F4") : unknown; txtRowUpper.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; txtRowUpper.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowUpper.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowUpper, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowUpper, 5); grid.Children.Add(txtRowUpper); TextBlock txtRowMin = new TextBlock(); txtRowMin.Text = mRow.Min.HasValue == true ? mRow.Min.Value.ToString("F4") : blank; txtRowMin.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; txtRowMin.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowMin.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowMin, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowMin, 6); grid.Children.Add(txtRowMin); TextBlock txtRowMax = new TextBlock(); txtRowMax.Text = mRow.Max.HasValue == true ? mRow.Max.Value.ToString("F4") : blank; txtRowMax.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; txtRowMax.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; //txtRowMax.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtRowMax, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowMax, 7); grid.Children.Add(txtRowMax); } // Draw grid borders int rdcount = 0; foreach (RowDefinition rd in grid.RowDefinitions) { int cdcount = 0; foreach (ColumnDefinition cd in grid.ColumnDefinitions) { Border border = new Border(); border.Style = this.Resources["gridCellBorder"] as Style; if (rdcount == 0 && cdcount > 0) { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Bottom, border.BorderThickness.Right, border.BorderThickness.Bottom); } if (cdcount == 0 && rdcount > 0) { border.BorderThickness = new Thickness(border.BorderThickness.Right, border.BorderThickness.Top, border.BorderThickness.Right, border.BorderThickness.Bottom); } if (rdcount == 0 && cdcount > 0 && cdcount < grid.ColumnDefinitions.Count - 1) { border.BorderThickness = new Thickness(0, border.BorderThickness.Bottom, 0, border.BorderThickness.Bottom); } if (rdcount == 1 && (cdcount < 4 || cdcount > 5)) { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Top, border.BorderThickness.Right, 0); } if (rdcount == 1 && cdcount == 4) { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Top, 0, border.BorderThickness.Bottom); } if (rdcount == 0 && cdcount == 0) { border.BorderThickness = new Thickness(1, 1, 1, 1); } //if (rdcount == 0 && cdcount == 0) //{ // border.BorderThickness = new Thickness(1, 1, 1, 0); //} //else if (rdcount == 0 && cdcount == grid.ColumnDefinitions.Count - 1) //{ // border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Top, border.BorderThickness.Right, 0); //} Grid.SetRow(border, rdcount); Grid.SetColumn(border, cdcount); grid.Children.Add(border); cdcount++; } rdcount++; } panelMain.Children.Add(grid); }
private void AddComplexSampleFrequencyGrid(StatisticsRepository.ComplexSampleTables.CSFrequencyResults results) { Grid grid = new Grid(); grid.Tag = GadgetOptions.MainVariableName; grid.Style = this.Resources["genericOutputGrid"] as Style; grid.Margin = (Thickness)this.Resources["genericElementMargin"]; grid.Visibility = System.Windows.Visibility.Collapsed; StrataGridList.Add(grid); // Setup grid header grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); RowDefinition rowDefHeader = new RowDefinition(); rowDefHeader.Height = new GridLength(30); grid.RowDefinitions.Add(rowDefHeader); for (int y = 0; y < grid.ColumnDefinitions.Count; y++) { Rectangle rctHeader = new Rectangle(); rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style; Grid.SetRow(rctHeader, 0); Grid.SetColumn(rctHeader, y); grid.Children.Add(rctHeader); } TextBlock txtValHeader = new TextBlock(); txtValHeader.Text = GadgetOptions.MainVariableName; txtValHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtValHeader, 0); Grid.SetColumn(txtValHeader, 0); grid.Children.Add(txtValHeader); TextBlock txtTotalHeader = new TextBlock(); txtTotalHeader.Text = SharedStrings.TOTAL; txtTotalHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtTotalHeader, 0); Grid.SetColumn(txtTotalHeader, 1); grid.Children.Add(txtTotalHeader); double runningTotal = 0; // Grid rows foreach (StatisticsRepository.ComplexSampleTables.CSRow fRow in results.Rows) { // Value row grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtValueLabel = new TextBlock(); txtValueLabel.Text = fRow.Value; txtValueLabel.FontWeight = FontWeights.Bold; txtValueLabel.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtValueLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtValueLabel, 0); grid.Children.Add(txtValueLabel); TextBlock txtValue = new TextBlock(); txtValue.Text = fRow.Count.ToString(); txtValue.Margin = (Thickness)this.Resources["genericTextMargin"]; txtValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtValue, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtValue, 1); grid.Children.Add(txtValue); // Row % row grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtRowPercentLabel = new TextBlock(); txtRowPercentLabel.Text = "Row %"; txtRowPercentLabel.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtRowPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowPercentLabel, 0); grid.Children.Add(txtRowPercentLabel); TextBlock txtRowPercent = new TextBlock(); txtRowPercent.Text = fRow.RowPercent.ToString("F3"); txtRowPercent.Margin = (Thickness)this.Resources["genericTextMargin"]; txtRowPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtRowPercent, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowPercent, 1); grid.Children.Add(txtRowPercent); // Col % row grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtColPercentLabel = new TextBlock(); txtColPercentLabel.Text = "Col %"; txtColPercentLabel.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtColPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtColPercentLabel, 0); grid.Children.Add(txtColPercentLabel); TextBlock txtColPercent = new TextBlock(); txtColPercent.Text = fRow.ColPercent.ToString("F3"); txtColPercent.Margin = (Thickness)this.Resources["genericTextMargin"]; txtColPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtColPercent, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtColPercent, 1); grid.Children.Add(txtColPercent); // SE % row grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtSEPercentLabel = new TextBlock(); txtSEPercentLabel.Text = "SE %"; txtSEPercentLabel.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtSEPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtSEPercentLabel, 0); grid.Children.Add(txtSEPercentLabel); TextBlock txtSEPercent = new TextBlock(); txtSEPercent.Text = fRow.SE.ToString("F3"); txtSEPercent.Margin = (Thickness)this.Resources["genericTextMargin"]; txtSEPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtSEPercent, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtSEPercent, 1); grid.Children.Add(txtSEPercent); // LCL % row grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtLCLPercentLabel = new TextBlock(); txtLCLPercentLabel.Text = "LCL %"; txtLCLPercentLabel.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtLCLPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtLCLPercentLabel, 0); grid.Children.Add(txtLCLPercentLabel); TextBlock txtLCLPercent = new TextBlock(); txtLCLPercent.Text = fRow.LCL.ToString("F3"); txtLCLPercent.Margin = (Thickness)this.Resources["genericTextMargin"]; txtLCLPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtLCLPercent, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtLCLPercent, 1); grid.Children.Add(txtLCLPercent); // UCL % row grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtUCLPercentLabel = new TextBlock(); txtUCLPercentLabel.Text = "UCL %"; txtUCLPercentLabel.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtUCLPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtUCLPercentLabel, 0); grid.Children.Add(txtUCLPercentLabel); TextBlock txtUCLPercent = new TextBlock(); txtUCLPercent.Text = fRow.UCL.ToString("F3"); txtUCLPercent.Margin = (Thickness)this.Resources["genericTextMargin"]; txtUCLPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtUCLPercent, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtUCLPercent, 1); grid.Children.Add(txtUCLPercent); runningTotal = runningTotal + fRow.Count; } // Setup grid footer RowDefinition rowDefTotal = new RowDefinition(); RowDefinition rowDefDE = new RowDefinition(); grid.RowDefinitions.Add(rowDefTotal); grid.RowDefinitions.Add(rowDefDE); TextBlock txtTotalFooter = new TextBlock(); txtTotalFooter.Text = SharedStrings.TOTAL; txtTotalFooter.FontWeight = FontWeights.Bold; txtTotalFooter.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtTotalFooter, grid.RowDefinitions.Count - 2); Grid.SetColumn(txtTotalFooter, 0); grid.Children.Add(txtTotalFooter); TextBlock txtTotalFooterValue = new TextBlock(); txtTotalFooterValue.Text = runningTotal.ToString(); txtTotalFooterValue.Margin = (Thickness)this.Resources["genericTextMargin"]; txtTotalFooterValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtTotalFooterValue, grid.RowDefinitions.Count - 2); Grid.SetColumn(txtTotalFooterValue, 1); grid.Children.Add(txtTotalFooterValue); TextBlock txtDEFooter = new TextBlock(); txtDEFooter.Text = "Design effect"; txtDEFooter.Margin = (Thickness)this.Resources["genericTextMargin"]; Grid.SetRow(txtDEFooter, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtDEFooter, 0); grid.Children.Add(txtDEFooter); TextBlock txtDEFooterValue = new TextBlock(); txtDEFooterValue.Text = results.Rows[0].DesignEffect.ToString("F4"); txtDEFooterValue.Margin = (Thickness)this.Resources["genericTextMargin"]; txtDEFooterValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtDEFooterValue, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtDEFooterValue, 1); grid.Children.Add(txtDEFooterValue); // Draw grid borders int rdcount = 0; foreach (RowDefinition rd in grid.RowDefinitions) { int cdcount = 0; foreach (ColumnDefinition cd in grid.ColumnDefinitions) { Border border = new Border(); border.Style = this.Resources["gridCellBorder"] as Style; if (rdcount == 0 && cdcount > 0) { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Bottom, border.BorderThickness.Right, border.BorderThickness.Bottom); } if (cdcount == 0 && rdcount > 0) { border.BorderThickness = new Thickness(border.BorderThickness.Right, border.BorderThickness.Top, border.BorderThickness.Right, border.BorderThickness.Bottom); } Grid.SetRow(border, rdcount); Grid.SetColumn(border, cdcount); grid.Children.Add(border); cdcount++; } rdcount++; } panelMain.Children.Add(grid); }
private void SetChartData(List<XYChartData> dataList, StatisticsRepository.LinearRegression.LinearRegressionResults regresResults, NumericDataValue maxValue, NumericDataValue minValue) { List<RegressionChartData> regressionDataList = new List<RegressionChartData>(); ScatterChartParameters chtParameters = (ScatterChartParameters)Parameters; if (regresResults.variables != null) { decimal coefficient = Convert.ToDecimal(regresResults.variables[0].coefficient); decimal constant = Convert.ToDecimal(regresResults.variables[1].coefficient); NumericDataValue newMaxValue = new NumericDataValue(); newMaxValue.IndependentValue = maxValue.IndependentValue; newMaxValue.DependentValue = (coefficient * maxValue.IndependentValue) + constant; NumericDataValue newMinValue = new NumericDataValue(); newMinValue.IndependentValue = minValue.IndependentValue; newMinValue.DependentValue = (coefficient * minValue.IndependentValue) + constant; tblockEquation.Text = "Y = (" + Math.Round(coefficient, 4).ToString() + ")X + " + Math.Round(constant, 4).ToString(); List<NumericDataValue> regresValues = new List<NumericDataValue>(); regresValues.Add(newMinValue); regresValues.Add(newMaxValue); RegressionChartData rChartData = new RegressionChartData(); rChartData.X = (double)newMinValue.IndependentValue; rChartData.Z = (double)newMinValue.DependentValue; regressionDataList.Add(rChartData); rChartData = new RegressionChartData(); rChartData.X = (double)newMaxValue.IndependentValue; rChartData.Z = (double)newMaxValue.DependentValue; regressionDataList.Add(rChartData); } //xAxis.UseOnlyVisiblePointsToComputeRange = true; series0.DataSource = dataList; series1.DataSource = regressionDataList; xyChart.Width = chtParameters.ChartWidth; xyChart.Height = chtParameters.ChartHeight; //xAxis.UseOnlyVisiblePointsToComputeRange = true; }
private void AddComplexSampleTableGrid(StatisticsRepository.ComplexSampleTables.CSTablesResults results) { Grid grid = new Grid(); grid.Tag = GadgetOptions.MainVariableName; grid.Style = this.Resources["genericOutputGrid"] as Style; grid.Margin = (Thickness)this.Resources["genericElementMargin"]; grid.Visibility = System.Windows.Visibility.Collapsed; strataGridList.Add(grid); // Setup grid header grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); // value for (int i = 0; i < results.Rows[0].Cells.Count; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition()); } grid.ColumnDefinitions.Add(new ColumnDefinition()); // total for (int y = 0; y < grid.ColumnDefinitions.Count; y++) { Rectangle rctHeader = new Rectangle(); rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style; Grid.SetRow(rctHeader, 0); Grid.SetRowSpan(rctHeader, 2); Grid.SetColumn(rctHeader, y); grid.Children.Add(rctHeader); } for (int y = 0; y < grid.ColumnDefinitions.Count; y++) { if (y < grid.ColumnDefinitions.Count - 2) { TextBlock txtColumnHeading = new TextBlock(); txtColumnHeading.Text = results.Rows[0].Cells[y].Value; txtColumnHeading.Style = this.Resources["columnHeadingText"] as Style; txtColumnHeading.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtColumnHeading, 1); Grid.SetColumn(txtColumnHeading, y + 1); grid.Children.Add(txtColumnHeading); } } TextBlock txtHeader = new TextBlock(); txtHeader.Text = GadgetOptions.CrosstabVariableName; Field field = DashboardHelper.GetAssociatedField(GadgetOptions.CrosstabVariableName); if (field != null && field is IDataField) { txtHeader.Text = ((IDataField)field).PromptText; } txtHeader.Style = this.Resources["columnHeadingText"] as Style; txtHeader.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtHeader.FontSize = txtHeader.FontSize + 2; Grid.SetRow(txtHeader, 0); Grid.SetColumn(txtHeader, 1); Grid.SetColumnSpan(txtHeader, grid.ColumnDefinitions.Count - 2); grid.Children.Add(txtHeader); TextBlock txtValHeader = new TextBlock(); txtValHeader.Text = GadgetOptions.MainVariableName; txtValHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtValHeader, 0); Grid.SetRowSpan(txtValHeader, 2); Grid.SetColumn(txtValHeader, 0); grid.Children.Add(txtValHeader); TextBlock txtTotalHeader = new TextBlock(); txtTotalHeader.Text = SharedStrings.TOTAL; txtTotalHeader.Style = this.Resources["columnHeadingText"] as Style; Grid.SetRow(txtTotalHeader, 0); Grid.SetRowSpan(txtTotalHeader, 2); Grid.SetColumn(txtTotalHeader, grid.ColumnDefinitions.Count - 1); grid.Children.Add(txtTotalHeader); double grandTotal = 0; for (int i = 0; i < results.Rows.Count - 1; i++) { StatisticsRepository.ComplexSampleTables.TablesRow tRow = results.Rows[i]; foreach (StatisticsRepository.ComplexSampleTables.CSRow fRow in tRow.Cells) { grandTotal = grandTotal + fRow.Count; } } foreach (StatisticsRepository.ComplexSampleTables.TablesRow tRow in results.Rows) { grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtValueLabel = new TextBlock(); txtValueLabel.Text = tRow.Cells[0].Domain; txtValueLabel.FontWeight = FontWeights.Bold; txtValueLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtValueLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtValueLabel, 0); grid.Children.Add(txtValueLabel); grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtRowPercentLabel = new TextBlock(); txtRowPercentLabel.Text = "Row %"; txtRowPercentLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtRowPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtRowPercentLabel, 0); grid.Children.Add(txtRowPercentLabel); grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtColPercentLabel = new TextBlock(); txtColPercentLabel.Text = "Col %"; txtColPercentLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtColPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtColPercentLabel, 0); grid.Children.Add(txtColPercentLabel); grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtSEPercentLabel = new TextBlock(); txtSEPercentLabel.Text = "SE %"; txtSEPercentLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtSEPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtSEPercentLabel, 0); grid.Children.Add(txtSEPercentLabel); grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtLCLPercentLabel = new TextBlock(); txtLCLPercentLabel.Text = "LCL %"; txtLCLPercentLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtLCLPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtLCLPercentLabel, 0); grid.Children.Add(txtLCLPercentLabel); grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtUCLPercentLabel = new TextBlock(); txtUCLPercentLabel.Text = "UCL %"; txtUCLPercentLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtUCLPercentLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtUCLPercentLabel, 0); grid.Children.Add(txtUCLPercentLabel); grid.RowDefinitions.Add(new RowDefinition()); TextBlock txtDesginEffectLabel = new TextBlock(); txtDesginEffectLabel.Text = "Design Effect"; txtDesginEffectLabel.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txtDesginEffectLabel, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtDesginEffectLabel, 0); grid.Children.Add(txtDesginEffectLabel); double runningRowTotal = 0; double runningColPercentTotal = 0; string unknown = "----"; int column = 1; // Grid rows foreach (StatisticsRepository.ComplexSampleTables.CSRow fRow in tRow.Cells) { runningRowTotal = runningRowTotal + fRow.Count; bool zeroCount = false; if (fRow.Count == 0) zeroCount = true; runningColPercentTotal = zeroCount == true ? runningColPercentTotal : runningColPercentTotal + fRow.ColPercent; // Value row TextBlock txtValue = new TextBlock(); txtValue.Text = fRow.Count.ToString(); txtValue.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtValue, grid.RowDefinitions.Count - 7); Grid.SetColumn(txtValue, column); grid.Children.Add(txtValue); // Row % row TextBlock txtRowPercent = new TextBlock(); txtRowPercent.Text = zeroCount == true ? unknown : fRow.RowPercent.ToString("F3"); txtRowPercent.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtRowPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtRowPercent, grid.RowDefinitions.Count - 6); Grid.SetColumn(txtRowPercent, column); grid.Children.Add(txtRowPercent); // Col % row TextBlock txtColPercent = new TextBlock(); txtColPercent.Text = zeroCount == true ? unknown : fRow.ColPercent.ToString("F3"); txtColPercent.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtColPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtColPercent, grid.RowDefinitions.Count - 5); Grid.SetColumn(txtColPercent, column); grid.Children.Add(txtColPercent); // SE % row TextBlock txtSEPercent = new TextBlock(); txtSEPercent.Text = fRow.SE.ToString("F3"); txtSEPercent.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtSEPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtSEPercent, grid.RowDefinitions.Count - 4); Grid.SetColumn(txtSEPercent, column); grid.Children.Add(txtSEPercent); // LCL % row TextBlock txtLCLPercent = new TextBlock(); txtLCLPercent.Text = zeroCount == true ? unknown : fRow.LCL.ToString("F3"); txtLCLPercent.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtLCLPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtLCLPercent, grid.RowDefinitions.Count - 3); Grid.SetColumn(txtLCLPercent, column); grid.Children.Add(txtLCLPercent); // UCL % row TextBlock txtUCLPercent = new TextBlock(); txtUCLPercent.Text = zeroCount == true ? unknown : fRow.UCL.ToString("F3"); txtUCLPercent.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtUCLPercent.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtUCLPercent, grid.RowDefinitions.Count - 2); Grid.SetColumn(txtUCLPercent, column); grid.Children.Add(txtUCLPercent); // DE row TextBlock txtDesignEffect = new TextBlock(); txtDesignEffect.Text = fRow.DesignEffect.ToString("F3"); txtDesignEffect.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtDesignEffect.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtDesignEffect, grid.RowDefinitions.Count - 1); Grid.SetColumn(txtDesignEffect, column); grid.Children.Add(txtDesignEffect); //runningTotal = runningTotal + fRow.Count; column++; } // Total Value row TextBlock txtRowTotalValue = new TextBlock(); txtRowTotalValue.Text = runningRowTotal.ToString(); txtRowTotalValue.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtRowTotalValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtRowTotalValue, grid.RowDefinitions.Count - 7); Grid.SetColumn(txtRowTotalValue, grid.ColumnDefinitions.Count - 1); grid.Children.Add(txtRowTotalValue); // Total Row % row TextBlock txtRowPercentTotalValue = new TextBlock(); txtRowPercentTotalValue.Text = (1).ToString("P"); txtRowPercentTotalValue.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtRowPercentTotalValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtRowPercentTotalValue, grid.RowDefinitions.Count - 6); Grid.SetColumn(txtRowPercentTotalValue, grid.ColumnDefinitions.Count - 1); grid.Children.Add(txtRowPercentTotalValue); // Total Col % row TextBlock txtColPercentTotalValue = new TextBlock(); txtColPercentTotalValue.Text = (tRow.RowColPercent.Value / 100).ToString("P"); //(runningRowTotal / grandTotal).ToString("P"); txtColPercentTotalValue.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtColPercentTotalValue.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txtColPercentTotalValue, grid.RowDefinitions.Count - 5); Grid.SetColumn(txtColPercentTotalValue, grid.ColumnDefinitions.Count - 1); grid.Children.Add(txtColPercentTotalValue); } // Draw grid borders int rdcount = 0; foreach (RowDefinition rd in grid.RowDefinitions) { int cdcount = 0; foreach (ColumnDefinition cd in grid.ColumnDefinitions) { Border border = new Border(); border.Style = this.Resources["gridCellBorder"] as Style; if (rdcount == 0 && cdcount > 0) { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Bottom, border.BorderThickness.Right, border.BorderThickness.Bottom); } if (cdcount == 0 && rdcount > 0) { border.BorderThickness = new Thickness(border.BorderThickness.Right, border.BorderThickness.Top, border.BorderThickness.Right, border.BorderThickness.Bottom); } if (rdcount == 0 && cdcount > 0 && cdcount < grid.ColumnDefinitions.Count - 2) { border.BorderThickness = new Thickness(0, border.BorderThickness.Bottom, 0, border.BorderThickness.Bottom); } if (rdcount == 0 && cdcount == 0) { border.BorderThickness = new Thickness(1, 1, 1, 0); } else if (rdcount == 0 && cdcount == grid.ColumnDefinitions.Count - 1) { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Top, border.BorderThickness.Right, 0); } Grid.SetRow(border, rdcount); Grid.SetColumn(border, cdcount); grid.Children.Add(border); cdcount++; } rdcount++; } panelMain.Children.Add(grid); if (results.OddsRatio.HasValue) { Grid statGrid = new Grid(); statGrid.Margin = (Thickness)this.Resources["genericElementMargin"]; statGrid.Margin = new Thickness(statGrid.Margin.Left, statGrid.Margin.Top + 6, statGrid.Margin.Right, statGrid.Margin.Bottom); statGrid.ColumnDefinitions.Add(new ColumnDefinition()); statGrid.ColumnDefinitions.Add(new ColumnDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); statGrid.RowDefinitions.Add(new RowDefinition()); panelMain.Children.Add(statGrid); statGrid.Tag = "2x2 grid"; TextBlock txtHead = new TextBlock(); txtHead.Text = "Complex Sample Design" + Environment.NewLine + "Analysis of 2x2 Table"; txtHead.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txtHead.FontSize = txtHead.FontSize + 1; txtHead.FontWeight = FontWeights.Bold; Grid.SetRow(txtHead, 0); Grid.SetColumn(txtHead, 0); Grid.SetColumnSpan(txtHead, 2); statGrid.Children.Add(txtHead); TextBlock txt1 = new TextBlock(); txt1.Text = "Odds Ratio (OR)"; txt1.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt1, 1); Grid.SetColumn(txt1, 0); statGrid.Children.Add(txt1); TextBlock txt1a = new TextBlock(); txt1a.Text = results.OddsRatio.Value.ToString("F4"); txt1a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt1a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt1a, 1); Grid.SetColumn(txt1a, 1); statGrid.Children.Add(txt1a); // ***************************************************************** TextBlock txt2 = new TextBlock(); txt2.Text = "Standard Error (SE)"; txt2.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt2, 2); Grid.SetColumn(txt2, 0); statGrid.Children.Add(txt2); TextBlock txt2a = new TextBlock(); txt2a.Text = results.StandardErrorOR.Value.ToString("F4"); txt2a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt2a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt2a, 2); Grid.SetColumn(txt2a, 1); statGrid.Children.Add(txt2a); // ***************************************************************** TextBlock txt3 = new TextBlock(); txt3.Text = "95% Conf. Limits "; txt3.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt3, 3); Grid.SetColumn(txt3, 0); statGrid.Children.Add(txt3); TextBlock txt3a = new TextBlock(); txt3a.Text = "(" + results.LCLOR.Value.ToString("F3") + ", " + results.UCLOR.Value.ToString("F3") + ")"; txt3a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt3a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt3a, 3); Grid.SetColumn(txt3a, 1); statGrid.Children.Add(txt3a); // ***************************************************************** TextBlock txt4 = new TextBlock(); txt4.Text = " "; txt4.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt4, 4); Grid.SetColumn(txt4, 0); statGrid.Children.Add(txt4); // ***************************************************************** TextBlock txt5 = new TextBlock(); txt5.Text = "Risk Ratio (RR)"; txt5.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt5, 5); Grid.SetColumn(txt5, 0); statGrid.Children.Add(txt5); TextBlock txt5a = new TextBlock(); txt5a.Text = results.RiskRatio.Value.ToString("F4"); txt5a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt5a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt5a, 5); Grid.SetColumn(txt5a, 1); statGrid.Children.Add(txt5a); // ***************************************************************** TextBlock txt6 = new TextBlock(); txt6.Text = "Standard Error (SE) "; txt6.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt6, 6); Grid.SetColumn(txt6, 0); statGrid.Children.Add(txt6); TextBlock txt6a = new TextBlock(); txt6a.Text = results.StandardErrorRR.Value.ToString("F4"); txt6a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt6a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt6a, 6); Grid.SetColumn(txt6a, 1); statGrid.Children.Add(txt6a); // ***************************************************************** TextBlock txt7 = new TextBlock(); txt7.Text = "95% Conf. Limits "; txt7.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt7, 7); Grid.SetColumn(txt7, 0); statGrid.Children.Add(txt7); TextBlock txt7a = new TextBlock(); txt7a.Text = "(" + results.LCLRR.Value.ToString("F3") + ", " + results.UCLRR.Value.ToString("F3") + ")"; txt7a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt7a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt7a, 7); Grid.SetColumn(txt7a, 1); statGrid.Children.Add(txt7a); // ***************************************************************** TextBlock txt8 = new TextBlock(); txt8.Text = " "; txt8.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt8, 8); Grid.SetColumn(txt8, 0); statGrid.Children.Add(txt8); TextBlock txt9 = new TextBlock(); txt9.Text = "Risk Difference (RD%)"; txt9.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt9, 9); Grid.SetColumn(txt9, 0); statGrid.Children.Add(txt9); TextBlock txt9a = new TextBlock(); txt9a.Text = results.RiskDifference.Value.ToString("F4"); txt9a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt9a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt9a, 9); Grid.SetColumn(txt9a, 1); statGrid.Children.Add(txt9a); // ***************************************************************** TextBlock txt10 = new TextBlock(); txt10.Text = "Standard Error (SE)"; txt10.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt10, 10); Grid.SetColumn(txt10, 0); statGrid.Children.Add(txt10); TextBlock txt10a = new TextBlock(); txt10a.Text = results.StandardErrorRD.Value.ToString("F4"); txt10a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt10a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt10a, 10); Grid.SetColumn(txt10a, 1); statGrid.Children.Add(txt10a); // ***************************************************************** TextBlock txt11 = new TextBlock(); txt11.Text = "95% Conf. Limits "; txt11.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt11, 11); Grid.SetColumn(txt11, 0); statGrid.Children.Add(txt11); TextBlock txt11a = new TextBlock(); txt11a.Text = "(" + results.LCLRD.Value.ToString("F3") + ", " + results.UCLRD.Value.ToString("F3") + ")"; txt11a.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; txt11a.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; Grid.SetRow(txt11a, 11); Grid.SetColumn(txt11a, 1); statGrid.Children.Add(txt11a); // ***************************************************************** TextBlock txt12 = new TextBlock(); txt12.Text = " "; txt12.Margin = (Thickness)this.Resources["genericTextMarginAlt"]; Grid.SetRow(txt12, 12); Grid.SetColumn(txt12, 0); statGrid.Children.Add(txt12); } }