/// <summary> /// Method called on user control size changed event. /// </summary> /// <param name="sender">The <see cref="object"/> sender of the event.</param> /// <param name="e">Size changed event arguments <see cref="SizeChangedEventArgs"/>.</param> public override void Layout_SizeChanged(object sender, SizeChangedEventArgs e) { // Initialize some variables var blockContent = FindName <FrameworkElement>("BlockMiddleContentName"); var headH = PicturesCollection.FindName <FrameworkElement>("StackPanelBlockHeaderName").RenderSize.Height; var tabContentW = ((Frame)MainBlockContentTabs.SelectedContent).ActualWidth; var tabContentH = ((Frame)MainBlockContentTabs.SelectedContent).ActualHeight; // Arrange this height & width Width = Math.Max(tabContentW, 0); Height = Math.Max(tabContentH, 0); // Arrange BlockMiddleContentName height & width blockContent.Width = Math.Max(Width, 0); blockContent.Height = Math.Max(Height, 0); // Arrange PicturesCollection height & width (no need for width) PicturesCollection.Width = Math.Max(Width, 0); PicturesCollection.Height = Math.Max(Height, 0); // Trace only on debug mode TraceSize(MainBlockContent); TraceSize(this); TraceSize(blockContent); TraceSize(PicturesCollection); }
private void DeletePicture(object id) { try { PicturesCollection.RemoveAll(x => x.Id == Convert.ToString(id)); if (PicturesCollection.Count == 0) { IsPicturesEmpty = true; } } catch (Exception) { } }
static void Main(string[] args) { var window = new OpenGLWindow ( width: 1200, height: 800, title: "Test OpenGL Application", updateFrequency: 60, renderFrequency: 10, backgroundColor: Color.CornflowerBlue, picture: PicturesCollection.GetPicture("Test Picture") ); window.Run(); }
private void AddPicture() { var dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Title = "Select a picture"; dialog.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" + "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" + "Portable Network Graphic (*.png)|*.png"; dialog.ShowDialog(); if (!dialog.FileName.IsNullOrWhiteSpace()) { BitmapImage bitmapImage = new BitmapImage(new Uri(dialog.FileName)); byte[] picture = ImageToByteArray.Convert(bitmapImage); PicturesCollection.Add(new Picture(picture)); IsPicturesEmpty = false; } }
/// <summary> /// Add the observation and raises a popup if missing fields /// </summary> private void AddObservation() { if (Weight <= 0 || BloodPressure <= 0) { ShowServerExceptionWindow(ErrorDescription.MISSING_FIELDS); } else { ServiceObservationReference.Observation observation = new ServiceObservationReference.Observation() { BloodPressure = BloodPressure, Weight = Weight, Comment = Comment, Date = DateTime.Now, Pictures = PicturesCollection.Select(x => x.Content).ToArray(), Prescription = PrescriptionCollection.Select(x => x.Content).ToArray() }; Mediator.Notify("Observations_UC", observation); } }
public static ReportSheetTemplate ParseTemplate(Worksheet sheet, int sheetIndex) { /* Range topRange = RangeHelper.GetRange (sheet, 1, 1, 1, 1).EntireColumn ; */ ReportSheetTemplate tpl = new ReportSheetTemplate(); tpl.sheet = sheet; // Load pics PicturesCollection pictures = sheet.Pictures; List <Rectangle> pics = new List <Rectangle>(); for (int i = 0; i < pictures.Count; i++) { ExcelPicture picture = pictures [i]; pics.Add(new Rectangle(picture.Left, picture.Top, picture.Width, picture.Height)); } tpl.pics = pics; // clear pictures. sheet.Pictures.Clear(); int lastValuedRowIndex = 1; for (int rowIndex = 1; rowIndex < MAX_ROW_COUNT; rowIndex++) { Range range = RangeHelper.GetRange(sheet, 1, rowIndex, 1, 1); string text = (string)range.Value2; if (string.IsNullOrEmpty(text)) { continue; } lastValuedRowIndex = rowIndex; if (text.Equals("sql", StringComparison.CurrentCultureIgnoreCase)) { // here is a SQL. range = RangeHelper.GetRange(sheet, 2, rowIndex, 1, 1); string tableName = range.Value2 as string; if (string.IsNullOrEmpty(tableName)) { continue; } range = RangeHelper.GetRange(sheet, 3, rowIndex, 1, 1); string sql = range.Value2 as string; if (string.IsNullOrEmpty(sql)) { continue; } // add sheet prefix to tableName if (tableName.IndexOf('.') < 0) { tableName = "S" + sheetIndex + "." + tableName; } tpl.sqlList [tableName] = sql; continue; } Dictionary <string, string> blockParams = ParseKeyValuePair(text); TplBlock block = new TplBlock(); block.startColIndex = 2; block.startRowIndex = rowIndex; block.colCount = block.tplColumCount = int.Parse(blockParams ["cols"]); if (blockParams.ContainsKey("name")) { block.name = blockParams ["name"]; } else { block.name = "S" + sheetIndex + ".block" + (tpl.blockList.Count + 1); } // parse chart params if (blockParams.ContainsKey("ischart") && "true".Equals(blockParams ["ischart"])) { block.isChart = true; // parse dataBlock if (blockParams.ContainsKey("datablock")) { block.chartDataBlockName = blockParams["datablock"]; // add sheet prefix to tableName if (block.chartDataBlockName.IndexOf('.') < 0) { block.chartDataBlockName = "S" + sheetIndex + "." + block.chartDataBlockName; } } else { block.chartDataBlockName = "S" + sheetIndex + ".block2"; } // find chartDataBlock for (int i = 0; i < tpl.blockList.Count; i++) { TplBlock blk = tpl.blockList [i]; if (blk.name.Equals(block.chartDataBlockName)) { block.chartDataBlock = blk; } } if (blockParams.ContainsKey("seriesfrom") && "col".Equals(blockParams ["seriesfrom"])) { block.chartSeriesFrom = false; } } int blockRows = block.tplRowCount = int.Parse(blockParams ["rows"]); lastValuedRowIndex += blockRows; if (blockParams.ContainsKey("copy")) { block.copyOnly = "true".Equals(blockParams ["copy"]); } block.tableName = blockParams ["table"]; // add sheet prefix to tableName if (block.tableName.IndexOf('.') < 0) { block.tableName = "S" + sheetIndex + "." + block.tableName; } if (blockParams.ContainsKey("updateallrow")) { block.updateAllRow = "true".Equals(blockParams["updateallrow"]); } if (blockParams.ContainsKey("autofit") && blockParams["autofit"] == "true") { tpl.autoFit = true; } if (blockParams.ContainsKey("joinat")) { if (!int.TryParse(blockParams ["joinat"], out block.joinat)) { block.joinat = -1; } } //if (blockParams.ContainsKey("emptycount")) //{ // if (!int.TryParse(blockParams["emptycount"], out block.defaultEmptyRowsCount)) // block.defaultEmptyRowsCount = 0; //} if (blockParams.ContainsKey("emptytable")) { block.emptyTableName = blockParams["emptytable"]; // add sheet prefix to tableName if (block.emptyTableName.IndexOf('.') < 0) { block.emptyTableName = "S" + sheetIndex + "." + block.emptyTableName; } } if (blockParams.ContainsKey("coltable")) { block.tplColTableName = blockParams["coltable"]; // add sheet prefix to tableName if (block.tplColTableName.IndexOf('.') < 0) { block.tplColTableName = "S" + sheetIndex + "." + block.tplColTableName; } } block.tplRange = RangeHelper.GetRange(sheet, block.startColIndex, block.startRowIndex, block.colCount, blockRows); if (block.copyOnly) // Just return directly. { tpl.blockList.Add(block); continue; } for (int i = 0; i < blockRows; i++) { TplLine line = ParseLine(sheet, block, 3, i + block.startRowIndex, block.colCount); line.tpl = tpl; line.colIndex = 3; line.iOption = GetLineInsertOption(RangeHelper.GetCell(sheet, 2, i + block.startRowIndex).Value2 as string); line.tplCellCount = block.colCount; block.lineList.Add(line); } block.InitDColumn(); if (block.dColumn != null) { block.dColumn.tpl = tpl; } tpl.blockList.Add(block); } tpl.startRowIndex = lastValuedRowIndex + 5; return(tpl); }