File size: 34,259 Bytes
b1b3bae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 |
' Table Graphic Object
' Copyright 2008 Daniel Wagner O. de Medeiros
'
' This file is part of DWSIM.
'
' DWSIM is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' DWSIM is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with DWSIM. If not, see <http://www.gnu.org/licenses/>.
Imports System.Linq
Imports DWSIM.Interfaces
Imports System.Xml
Imports DWSIM.SharedClasses.Extras
Imports DWSIM.DrawingTools.Point
Namespace GraphicObjects.Tables
<Serializable()> Public Class MasterTableGraphic
Inherits ShapeGraphic
Implements IDisposable
Protected m_objectfamily As Enums.GraphicObjects.ObjectType = Enums.GraphicObjects.ObjectType.MaterialStream
Protected m_objectlist As Dictionary(Of String, Boolean)
Protected m_propertylist As Dictionary(Of String, Boolean)
Protected m_sortby As String = ""
Protected m_sortableitems As ArrayList
Protected m_sortedlist As List(Of String)
Protected m_items As Dictionary(Of String, List(Of NodeItem))
Public Property ClipboardData As String = ""
Private TagsAndIDs As New Dictionary(Of String, String)
<Xml.Serialization.XmlIgnore> Public Property Flowsheet As Interfaces.IFlowsheet
Public Overrides Function LoadData(data As System.Collections.Generic.List(Of System.Xml.Linq.XElement)) As Boolean
XMLSerializer.XMLSerializer.Deserialize(Me, data)
m_objectlist.Clear()
For Each xel As XElement In (From xel2 As XElement In data Select xel2 Where xel2.Name = "Objects").FirstOrDefault.Elements.ToList
m_objectlist.Add(XmlConvert.DecodeName(xel.Name.LocalName), xel.Value)
Next
m_propertylist.Clear()
For Each xel As XElement In (From xel2 As XElement In data Select xel2 Where xel2.Name = "Properties").FirstOrDefault.Elements.ToList
m_propertylist.Add(XmlConvert.DecodeName(xel.Name.LocalName), xel.Value)
Next
m_sortableitems.Clear()
For Each xel As XElement In (From xel2 As XElement In data Select xel2 Where xel2.Name = "SortableItems").FirstOrDefault.Elements.ToList
m_sortableitems.Add(xel.Value)
Next
'm_sortedlist.Clear()
'For Each xel As XElement In (From xel2 As XElement In data Select xel2 Where xel2.Name = "SortedList").FirstOrDefault.Elements.ToList
' m_sortedlist.Add(xel.Value)
'Next
Return True
End Function
Public Overrides Function SaveData() As System.Collections.Generic.List(Of System.Xml.Linq.XElement)
Dim elements As System.Collections.Generic.List(Of System.Xml.Linq.XElement) = MyBase.SaveData()
With elements
.Add(New XElement("Objects"))
Dim name As String
For Each kvp As KeyValuePair(Of String, Boolean) In m_objectlist
name = XmlConvert.EncodeLocalName(kvp.Key)
elements(elements.Count - 1).Add(New XElement(name, kvp.Value))
Next
.Add(New XElement("Properties"))
For Each kvp As KeyValuePair(Of String, Boolean) In m_propertylist
name = XmlConvert.EncodeLocalName(kvp.Key)
elements(elements.Count - 1).Add(New XElement(name, kvp.Value))
Next
.Add(New XElement("SortableItems"))
For Each item As String In m_sortableitems
elements(elements.Count - 1).Add(New XElement("SortableItem", item))
Next
'.Add(New XElement("SortedList"))
'For Each item As String In m_sortedlist
' elements(elements.Count - 1).Add(New XElement("Object", item))
'Next
End With
Return elements
End Function
#Region "Constructors"
Public Sub New()
Me.ObjectType = Enums.GraphicObjects.ObjectType.GO_MasterTable
m_objectlist = New Dictionary(Of String, Boolean)
m_propertylist = New Dictionary(Of String, Boolean)
m_sortableitems = New ArrayList
m_sortedlist = New List(Of String)
End Sub
Public Sub New(ByVal graphicPosition As Point)
Me.New()
Me.SetPosition(graphicPosition.X, graphicPosition.Y)
End Sub
Public Sub New(ByVal posX As Integer, ByVal posY As Integer)
Me.New(New Point(posX, posY))
End Sub
#End Region
#Region "Properties"
Public Property NumberOfLines As Integer = 1
Property Padding As Integer = 4
Public Property TextColor As SKColor = SKColors.Black
Public Property TextColorDark As SKColor = SKColors.WhiteSmoke
Public Property BorderColor As SKColor = SKColors.Black
Public Property BorderColorDark As SKColor = SKColors.WhiteSmoke
Public Property SortBy() As String
Get
If m_sortby Is Nothing Then m_sortby = "Name | DESC"
Return m_sortby
End Get
Set(ByVal value As String)
m_sortby = value
End Set
End Property
Public ReadOnly Property SortableItems() As String()
Get
If m_sortableitems Is Nothing Then m_sortableitems = New ArrayList
m_sortableitems.Clear()
m_sortableitems.Add("Name | ASC")
m_sortableitems.Add("Name | DESC")
For Each kvp As KeyValuePair(Of String, Boolean) In m_propertylist
If kvp.Value Then
m_sortableitems.Add(Flowsheet.GetTranslatedString(kvp.Key) & " | ASC")
m_sortableitems.Add(Flowsheet.GetTranslatedString(kvp.Key) & " | DESC")
End If
Next
m_sortableitems.Add("Custom")
Return m_sortableitems.ToArray(Type.GetType("System.String"))
End Get
End Property
Public ReadOnly Property NodeItems As Dictionary(Of String, List(Of NodeItem))
Get
Return m_items
End Get
End Property
Public ReadOnly Property PropertyList() As Dictionary(Of String, Boolean)
Get
Return m_propertylist
End Get
End Property
Public ReadOnly Property ObjectList() As Dictionary(Of String, Boolean)
Get
Return m_objectlist
End Get
End Property
Public Property SortedList() As List(Of String)
Get
Return m_sortedlist
End Get
Set(ByVal value As List(Of String))
m_sortedlist = value
End Set
End Property
Public Property ObjectFamily() As Enums.GraphicObjects.ObjectType
Get
Return m_objectfamily
End Get
Set(ByVal value As Enums.GraphicObjects.ObjectType)
m_objectfamily = value
m_objectlist.Clear()
m_propertylist.Clear()
If m_sortby = "" Then m_sortby = "Name | DESC"
End Set
End Property
Public Property ObjectClass As String = ""
Public Property HeaderText() As String = ""
#End Region
Public Sub Update()
Dim su As IUnitsOfMeasure = Flowsheet.FlowsheetOptions.SelectedUnitSystem
Dim nf As String = Flowsheet.FlowsheetOptions.NumberFormat
m_items = New Dictionary(Of String, List(Of NodeItem))
Dim objectstoremove, propstoremove, objectstoadd As New List(Of String)
For Each kvp As KeyValuePair(Of String, Boolean) In m_objectlist
If Flowsheet.GetFlowsheetSimulationObject(kvp.Key) Is Nothing Then
If TagsAndIDs.ContainsKey(kvp.Key) Then
If Flowsheet.SimulationObjects.ContainsKey(TagsAndIDs(kvp.Key)) Then
Dim obj = Flowsheet.SimulationObjects(TagsAndIDs(kvp.Key))
If obj IsNot Nothing Then objectstoadd.Add(obj.GraphicObject.Tag)
End If
End If
objectstoremove.Add(kvp.Key)
End If
Next
For i As Integer = 0 To objectstoremove.Count - 1
m_objectlist.Remove(objectstoremove(i))
Next
For i As Integer = 0 To objectstoadd.Count - 1
m_objectlist.Add(objectstoadd(i), True)
Next
TagsAndIDs = New Dictionary(Of String, String)()
For Each kvp As KeyValuePair(Of String, Boolean) In m_objectlist
Dim obj = Flowsheet.GetFlowsheetSimulationObject(kvp.Key)
If obj IsNot Nothing Then TagsAndIDs.Add(obj.GraphicObject.Tag, obj.Name)
Next
If m_objectfamily = Enums.GraphicObjects.ObjectType.MaterialStream AndAlso m_objectlist.Count > 0 Then
For Each kvp As KeyValuePair(Of String, Boolean) In m_objectlist
If kvp.Value = True Then
Dim myobj As SharedClasses.UnitOperations.BaseClass = Flowsheet.GetFlowsheetSimulationObject(kvp.Key)
If myobj.GraphicObject.ObjectType = Enums.GraphicObjects.ObjectType.MaterialStream Then
For Each kvp2 As KeyValuePair(Of String, Boolean) In m_propertylist
Dim pval = myobj.GetPropertyValue(kvp2.Key)
If pval Is Nothing Then pval = Double.MinValue
If kvp2.Value = True AndAlso pval.Equals(Double.MinValue) Then
propstoremove.Add(kvp2.Key)
End If
Next
End If
For i As Integer = 0 To propstoremove.Count - 1
m_propertylist.Remove(propstoremove(i))
Next
Exit For
End If
Next
End If
For Each kvp As KeyValuePair(Of String, Boolean) In m_objectlist
If kvp.Value = True Then
Dim myobj As SharedClasses.UnitOperations.BaseClass = Flowsheet.GetFlowsheetSimulationObject(kvp.Key)
m_items.Add(kvp.Key, New List(Of NodeItem))
m_items(kvp.Key).Add(New NodeItem(Flowsheet.GetTranslatedString("Objeto"), kvp.Key, "", 0, 0, ""))
If Me.HeaderText = "" Then Me.HeaderText = Flowsheet.GetTranslatedString("MasterTable")
Dim mypropid As String = ""
Dim props() As String = myobj.GetProperties(Interfaces.Enums.PropertyType.ALL)
For Each kvp2 As KeyValuePair(Of String, Boolean) In m_propertylist
If kvp2.Value = True Then
For Each p As String In props
If p = kvp2.Key Then
mypropid = p
Dim value As Object = myobj.GetPropertyValue(mypropid, su)
If Double.TryParse(value, New Double) Then
Dim val = Convert.ToDouble(value)
m_items(kvp.Key).Add(New NodeItem(Flowsheet.GetTranslatedString(kvp2.Key), val.ToString(nf), myobj.GetPropertyUnit(mypropid, su), 0, 0, ""))
Else
If value Is Nothing Then value = ""
m_items(kvp.Key).Add(New NodeItem(Flowsheet.GetTranslatedString(kvp2.Key), value, myobj.GetPropertyUnit(mypropid, su), 0, 0, ""))
End If
Exit For
End If
Next
End If
Next
End If
Next
If m_sortableitems Is Nothing Then m_sortableitems = New ArrayList
If Not m_sortableitems.Contains(m_sortby) Then m_sortby = "Name | DESC"
If m_sortedlist Is Nothing Then m_sortedlist = New List(Of String)
If m_sortby = "Custom" Then
For i As Integer = 0 To objectstoremove.Count - 1
If m_sortedlist.Contains(objectstoremove(i)) Then m_sortedlist.Remove(objectstoremove(i))
Next
objectstoremove = New List(Of String)
For Each s As String In m_sortedlist
If m_objectlist(s) = False Then objectstoremove.Add(s)
Next
For i As Integer = 0 To objectstoremove.Count - 1
If m_sortedlist.Contains(objectstoremove(i)) Then m_sortedlist.Remove(objectstoremove(i))
Next
Else
m_sortedlist.Clear()
Dim p1, p2 As Object
Dim j As Integer = 0
Dim istidx As Integer = 0
Dim isnotname As Boolean
For Each s As String In m_items.Keys
isnotname = False
If j > 0 Then
istidx = 0
For Each ni As NodeItem In m_items(s)
If m_sortby.Contains(ni.Text) Then
isnotname = True
If Double.TryParse(ni.Value, New Double()) Then
p1 = Double.Parse(ni.Value)
For Each s2 As String In m_sortedlist
p2 = Double.Parse(m_items(s2)(m_items(s).IndexOf(ni)).Value)
If m_sortby.Contains("ASC") Then
'ASC
If p1 >= p2 Then
istidx += 1
End If
Else
'DESC
If p1 <= p2 Then
istidx += 1
End If
End If
Next
Else
p1 = ni.Value
For Each s2 As String In m_sortedlist
p2 = m_items(s2)(m_items(s).IndexOf(ni)).Value
If m_sortby.Contains("ASC") Then
'ASC
If p1 >= p2 Then
istidx += 1
End If
Else
'DESC
If p1 <= p2 Then
istidx += 1
End If
End If
Next
End If
m_sortedlist.Insert(istidx, s)
Exit For
End If
Next
If Not isnotname Then
'sort by object's name
p1 = s
istidx = 0
For Each s2 As String In m_sortedlist
p2 = s2
If m_sortby.Contains("ASC") Then
'ASC
If p1 >= p2 Then
istidx += 1
End If
Else
'DESC
If p1 <= p2 Then
istidx += 1
End If
End If
Next
m_sortedlist.Insert(istidx, s)
End If
Else
m_sortedlist.Add(s)
End If
j += 1
Next
End If
End Sub
Dim tpaint, tpaint2, bpaint As SKPaint
Private disposedValue As Boolean
Public Overrides Sub Draw(ByVal g As Object)
Dim canvas As SKCanvas = DirectCast(g, SKCanvas)
If tpaint Is Nothing Then tpaint = New SKPaint()
If tpaint2 Is Nothing Then tpaint2 = New SKPaint()
If bpaint Is Nothing Then bpaint = New SKPaint()
If DrawMode = 0 Then
With tpaint
.TextSize = FontSize
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
If GlobalSettings.Settings.DarkMode Then
.Color = TextColorDark
Else
.Color = TextColor
End If
.IsStroke = False
.Typeface = GetFont()
.FakeBoldText = True
.HintingLevel = SKPaintHinting.Normal
.SubpixelText = True
End With
With tpaint2
.TextSize = FontSize
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
If GlobalSettings.Settings.DarkMode Then
.Color = TextColorDark
Else
.Color = TextColor
End If
.IsStroke = False
.Typeface = GetFont()
.HintingLevel = SKPaintHinting.Normal
.SubpixelText = True
End With
With bpaint
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
If GlobalSettings.Settings.DarkMode Then
.Color = BorderColorDark
Else
.Color = BorderColor
End If
.IsStroke = True
.StrokeWidth = LineWidth
.HintingLevel = SKPaintHinting.Normal
.SubpixelText = True
End With
Else
With tpaint
.TextSize = FontSize
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
.Color = SKColors.Black
.IsStroke = False
.Typeface = GetFont()
.FakeBoldText = True
.HintingLevel = SKPaintHinting.Full
.SubpixelText = True
End With
With tpaint2
.TextSize = FontSize
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
.Color = SKColors.Black
.IsStroke = False
.Typeface = GetFont()
.HintingLevel = SKPaintHinting.Full
.SubpixelText = True
End With
With bpaint
.IsAntialias = GlobalSettings.Settings.DrawingAntiAlias
.Color = SKColors.Black
.IsStroke = True
.StrokeWidth = LineWidth
.HintingLevel = SKPaintHinting.Full
.SubpixelText = True
End With
End If
Update()
Dim k As Integer = 0
For Each bo As Boolean In Me.m_objectlist.Values
If bo Then k += 1
Next
Dim maxL1, maxL2a, maxL3, count, i, maxH, n As Integer
Dim maxL2 As New List(Of Integer)
If SortedList.Count > 0 Then
'determinar comprimento das colunas e altura das linhas
maxL1 = 0
maxL3 = 0
maxH = 0
Dim size As SKSize
Dim ni As NodeItem
If Not m_items Is Nothing Then
i = 0
If Not m_sortedlist Is Nothing Then
For Each s As String In m_sortedlist
maxL2.Add(0)
count = 1
For Each ni In m_items(s)
size = MeasureString(Flowsheet.GetTranslatedString(ni.Text), tpaint)
If size.Width > maxL1 Then maxL1 = size.Width
If size.Height > maxH Then maxH = size.Height
size = MeasureString(ni.Value, tpaint)
If size.Width > maxL2(i) Then maxL2(i) = size.Width
If size.Height > maxH Then maxH = size.Height
size = MeasureString(ni.Unit, tpaint)
If size.Width > maxL3 Then maxL3 = size.Width
If size.Height > maxH Then maxH = size.Height
count += 1
Next
i += 1
Next
Else
For Each s As String In m_items.Keys
maxL2.Add(0)
count = 1
For Each ni In m_items(s)
size = MeasureString(Flowsheet.GetTranslatedString(ni.Text), tpaint)
If size.Width > maxL1 Then maxL1 = size.Width
If size.Height > maxH Then maxH = size.Height
size = MeasureString(ni.Value, tpaint)
If size.Width > maxL2(i) Then maxL2(i) = size.Width
If size.Height > maxH Then maxH = size.Height
size = MeasureString(ni.Unit, tpaint)
If size.Width > maxL3 Then maxL3 = size.Width
If size.Height > maxH Then maxH = size.Height
count += 1
Next
i += 1
Next
End If
Else
End If
Me.Height = (count) * (maxH + 2 * Me.Padding)
If Not m_items Is Nothing Then
If maxL2.Count > 0 Then
maxL2a = maxL2.Max + 3 * Padding
Me.Width = (4 + 2 * m_items.Count / NumberOfLines) * Me.Padding + maxL1 + (k) * maxL2a / NumberOfLines + maxL3
Else
Me.Width = 100
maxL2a = 50
End If
Else
Me.Width = 100
maxL2a = 50
End If
maxL1 = maxL1 + 2 * Padding
maxL3 = maxL3 + 2 * Padding
maxH = maxH + 2 * Padding
size = MeasureString("MEASURE", tpaint)
ClipboardData = HeaderText + vbCrLf
SetClipboardData()
Dim subset, deltaH As Integer
Try
'desenhar textos e retangulos
canvas.DrawText(Me.HeaderText, X + Padding, Y + Padding + size.Height, tpaint)
If Not m_items Is Nothing Then
If maxL2.Count > 0 Then
Dim itemsperline As Integer
If Not m_sortedlist Is Nothing Then
itemsperline = Math.Round(Convert.ToDouble(m_sortedlist.Count) / Convert.ToDouble(NumberOfLines), MidpointRounding.AwayFromZero)
Else
itemsperline = Math.Round(Convert.ToDouble(m_items.Count) / Convert.ToDouble(NumberOfLines), MidpointRounding.AwayFromZero)
End If
If Not m_sortedlist Is Nothing Then
For k = 1 To NumberOfLines
subset = itemsperline
If itemsperline > (m_sortedlist.Count - 1 - (k - 1) * itemsperline) Then
subset = m_sortedlist.Count - (k - 1) * itemsperline
End If
deltaH = (k - 1) * (Height - maxH)
i = 0
For Each s As String In m_sortedlist.GetRange((k - 1) * itemsperline, subset)
canvas.DrawLine(X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + maxH), X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + Height), bpaint)
n = 1
For Each ni In m_items(s)
If i = 0 Then
canvas.DrawText(Flowsheet.GetTranslatedString(ni.Text), X + Padding, deltaH + (Y + n * maxH + Padding + size.Height), tpaint)
End If
If n = 1 Then
canvas.DrawText(ni.Value, (maxL2a - MeasureString(ni.Value, tpaint).Width) + X + maxL1 + i * maxL2a, deltaH + (Y + n * maxH + Padding + size.Height), tpaint)
Else
canvas.DrawText(ni.Value, (maxL2a - MeasureString(ni.Value, tpaint).Width) + X + maxL1 + i * maxL2a, deltaH + (Y + n * maxH + Padding + size.Height), tpaint2)
End If
If i = subset - 1 Then
canvas.DrawText(ni.Unit, X + maxL1 + (itemsperline) * maxL2a + 3 * Padding, deltaH + (Y + n * maxH + Padding + size.Height), tpaint)
End If
canvas.DrawLine(X, deltaH + Y + n * maxH, X + Width, deltaH + Y + n * maxH, bpaint)
n += 1
Next
i += 1
Next
If subset <> itemsperline Then
For i = subset To itemsperline
canvas.DrawLine(X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + maxH), X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + Height), bpaint)
Next
End If
Next
Else
For k = 1 To NumberOfLines
subset = itemsperline
If itemsperline > (m_items.Count - 1 - (k - 1) * itemsperline) Then
subset = m_items.Count - (k - 1) * itemsperline
End If
deltaH = (k - 1) * (Height - maxH)
i = 0
For Each s As String In m_items.Keys.ToList.GetRange((k - 1) * itemsperline, subset)
canvas.DrawLine(X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + maxH), X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + Height), bpaint)
n = 1
For Each ni In m_items(s)
If i = 0 Then
canvas.DrawText(Flowsheet.GetTranslatedString(ni.Text), X + Padding, deltaH + (Y + n * maxH + Padding + size.Height), tpaint)
End If
If n = 1 Then
canvas.DrawText(ni.Value, (maxL2a - MeasureString(ni.Value, tpaint).Width) + X + maxL1 + i * maxL2a, deltaH + (Y + n * maxH + Padding + size.Height), tpaint)
Else
canvas.DrawText(ni.Value, (maxL2a - MeasureString(ni.Value, tpaint).Width) + X + maxL1 + i * maxL2a, deltaH + (Y + n * maxH + Padding + size.Height), tpaint2)
End If
If i = subset - 1 Then
canvas.DrawText(ni.Unit, X + maxL1 + (itemsperline) * maxL2a + 3 * Padding, deltaH + (Y + n * maxH + Padding + size.Height), tpaint)
End If
canvas.DrawLine(X, deltaH + Y + n * maxH, X + Width, deltaH + Y + n * maxH, bpaint)
n += 1
Next
i += 1
Next
If subset <> itemsperline Then
For i = subset To itemsperline
canvas.DrawLine(X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + maxH), X + maxL1 + (i + 1) * maxL2a + Padding, deltaH + (Y + Height), bpaint)
Next
End If
Next
End If
Else
Me.Height = 40
End If
Else
Me.Height = 40
End If
Me.Height = (Me.Height - maxH) * NumberOfLines + maxH
canvas.DrawRect(GetRect(Me.X, Me.Y, Me.Width, Me.Height), bpaint)
canvas.DrawLine(X + maxL1, Y + maxH, X + maxL1, Y + Height, bpaint)
Catch ex As Exception
Dim s = MeasureString("Error drawing table", tpaint)
canvas.DrawText("Error drawing table", X + 10, Y + 40, tpaint)
Me.Width = 20 + s.Width
Me.Height = 80 + s.Height
canvas.DrawRect(GetRect(X, Y, Width, Height), bpaint)
End Try
Else
Dim s = MeasureString("Double-click to edit", tpaint)
canvas.DrawText("Double-click to edit", X + 10, Y + 40, tpaint)
Me.Width = 20 + s.Width
Me.Height = 80 + s.Height
canvas.DrawRect(GetRect(X, Y, Width, Height), bpaint)
End If
End Sub
Public Sub SetClipboardData()
Dim i As Integer = 0
Dim j As Integer = 0
Dim data As String = HeaderText + vbCrLf + "Object"
Dim refitem = m_items.Values.FirstOrDefault
If Not m_items Is Nothing Then
If Not m_sortedlist Is Nothing Then
For Each s As String In m_sortedlist
data += vbTab & m_items(s)(0).Value
Next
data += vbCrLf
For j = 1 To refitem.Count - 1
data += Flowsheet.GetTranslatedString(refitem(j).Text) & vbTab
For Each s As String In m_sortedlist
data += m_items(s)(j).Value & vbTab
Next
data += refitem(j).Unit & vbCrLf
Next
End If
End If
ClipboardData = data
End Sub
Protected Overridable Sub Dispose(disposing As Boolean)
If Not disposedValue Then
tpaint?.Dispose()
tpaint2?.Dispose()
bpaint?.Dispose()
disposedValue = True
End If
End Sub
Public Sub Dispose() Implements IDisposable.Dispose
Dispose(disposing:=True)
GC.SuppressFinalize(Me)
End Sub
End Class
End Namespace
|