Skip to content

Commit 2fa4825

Browse files
authored
Merge pull request #35 from tomaz82/cut-copy-paste
Add cut, copy and paste functionality for illumination frames/snippits
2 parents 05634fc + f40a8bc commit 2fa4825

File tree

1 file changed

+142
-7
lines changed

1 file changed

+142
-7
lines changed

b2sbackglassdesigner/b2sbackglassdesigner/formDesigner.vb

Lines changed: 142 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,149 @@ Public Class formDesigner
611611
UpdateStatusBar(Me, Backglass.currentTabPage)
612612
End Sub
613613

614-
Private Sub Cut_Click(sender As System.Object, e As System.EventArgs) Handles tsmiCut.Click
615-
MessageBox.Show("Will be implemented in one of the next versions.", AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Information)
616-
End Sub
617-
Private Sub Copy_Click(sender As System.Object, e As System.EventArgs) Handles tsmiCopy.Click
618-
MessageBox.Show("Will be implemented in one of the next versions.", AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Information)
614+
Private copiedBulb As Illumination.BulbInfo = Nothing
615+
616+
Private Sub Cut_Click(sender As Object, e As EventArgs) Handles tsmiCut.Click
617+
If Backglass.currentTabPage.Mouse.SelectedBulb IsNot Nothing Then
618+
Dim selectedBulb = Backglass.currentTabPage.Mouse.SelectedBulb
619+
620+
' Copy all the properties of the selected bulb (must happen BEFORE removal)
621+
copiedBulb = New Illumination.BulbInfo
622+
copiedBulb.B2SID = selectedBulb.B2SID
623+
copiedBulb.B2SIDType = selectedBulb.B2SIDType
624+
copiedBulb.B2SValue = selectedBulb.B2SValue
625+
copiedBulb.RomID = selectedBulb.RomID
626+
copiedBulb.RomIDType = selectedBulb.RomIDType
627+
copiedBulb.RomInverted = selectedBulb.RomInverted
628+
copiedBulb.Name = selectedBulb.Name
629+
copiedBulb.Text = selectedBulb.Text
630+
copiedBulb.TextAlignment = selectedBulb.TextAlignment
631+
copiedBulb.FontName = selectedBulb.FontName
632+
copiedBulb.FontSize = selectedBulb.FontSize
633+
copiedBulb.FontStyle = selectedBulb.FontStyle
634+
copiedBulb.Visible = selectedBulb.Visible
635+
copiedBulb.Location = selectedBulb.Location
636+
copiedBulb.Size = selectedBulb.Size
637+
copiedBulb.InitialState = selectedBulb.InitialState
638+
copiedBulb.DualMode = selectedBulb.DualMode
639+
copiedBulb.Intensity = selectedBulb.Intensity
640+
copiedBulb.LightColor = selectedBulb.LightColor
641+
copiedBulb.DodgeColor = selectedBulb.DodgeColor
642+
copiedBulb.IlluMode = selectedBulb.IlluMode
643+
copiedBulb.ZOrder = selectedBulb.ZOrder
644+
copiedBulb.IsImageSnippit = selectedBulb.IsImageSnippit
645+
copiedBulb.Image = selectedBulb.Image
646+
647+
' Copy all SnippitInfo properties
648+
copiedBulb.SnippitInfo = New Illumination.SnippitInfo
649+
copiedBulb.SnippitInfo.SnippitType = selectedBulb.SnippitInfo.SnippitType
650+
copiedBulb.SnippitInfo.SnippitMechID = selectedBulb.SnippitInfo.SnippitMechID
651+
copiedBulb.SnippitInfo.SnippitRotatingSteps = selectedBulb.SnippitInfo.SnippitRotatingSteps
652+
copiedBulb.SnippitInfo.SnippitRotatingInterval = selectedBulb.SnippitInfo.SnippitRotatingInterval
653+
copiedBulb.SnippitInfo.SnippitRotatingDirection = selectedBulb.SnippitInfo.SnippitRotatingDirection
654+
copiedBulb.SnippitInfo.SnippitRotatingStopBehaviour = selectedBulb.SnippitInfo.SnippitRotatingStopBehaviour
655+
656+
' Remove the selected bulb from the collection (delete operation)
657+
Backglass.currentBulbs.Remove(selectedBulb)
658+
659+
' Refresh screen
660+
Backglass.currentTabPage.Invalidate()
661+
Backglass.currentTabPage.RefreshIllumination()
662+
End If
619663
End Sub
620-
Private Sub Paste_Click(sender As System.Object, e As System.EventArgs) Handles tsmiPaste.Click
621-
MessageBox.Show("Will be implemented in one of the next versions.", AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Information)
664+
665+
Private Sub Copy_Click(sender As Object, e As EventArgs) Handles tsmiCopy.Click
666+
If Backglass.currentTabPage.Mouse.SelectedBulb IsNot Nothing Then
667+
Dim selectedBulb = Backglass.currentTabPage.Mouse.SelectedBulb
668+
669+
' Copy all the properties of the selected bulb
670+
copiedBulb = New Illumination.BulbInfo
671+
copiedBulb.B2SID = selectedBulb.B2SID
672+
copiedBulb.B2SIDType = selectedBulb.B2SIDType
673+
copiedBulb.B2SValue = selectedBulb.B2SValue
674+
copiedBulb.RomID = selectedBulb.RomID
675+
copiedBulb.RomIDType = selectedBulb.RomIDType
676+
copiedBulb.RomInverted = selectedBulb.RomInverted
677+
copiedBulb.Name = selectedBulb.Name
678+
copiedBulb.Text = selectedBulb.Text
679+
copiedBulb.TextAlignment = selectedBulb.TextAlignment
680+
copiedBulb.FontName = selectedBulb.FontName
681+
copiedBulb.FontSize = selectedBulb.FontSize
682+
copiedBulb.FontStyle = selectedBulb.FontStyle
683+
copiedBulb.Visible = selectedBulb.Visible
684+
copiedBulb.Location = selectedBulb.Location
685+
copiedBulb.Size = selectedBulb.Size
686+
copiedBulb.InitialState = selectedBulb.InitialState
687+
copiedBulb.DualMode = selectedBulb.DualMode
688+
copiedBulb.Intensity = selectedBulb.Intensity
689+
copiedBulb.LightColor = selectedBulb.LightColor
690+
copiedBulb.DodgeColor = selectedBulb.DodgeColor
691+
copiedBulb.IlluMode = selectedBulb.IlluMode
692+
copiedBulb.ZOrder = selectedBulb.ZOrder
693+
copiedBulb.IsImageSnippit = selectedBulb.IsImageSnippit
694+
copiedBulb.Image = selectedBulb.Image
695+
696+
' Copy all SnippitInfo properties
697+
copiedBulb.SnippitInfo = New Illumination.SnippitInfo
698+
copiedBulb.SnippitInfo.SnippitType = selectedBulb.SnippitInfo.SnippitType
699+
copiedBulb.SnippitInfo.SnippitMechID = selectedBulb.SnippitInfo.SnippitMechID
700+
copiedBulb.SnippitInfo.SnippitRotatingSteps = selectedBulb.SnippitInfo.SnippitRotatingSteps
701+
copiedBulb.SnippitInfo.SnippitRotatingInterval = selectedBulb.SnippitInfo.SnippitRotatingInterval
702+
copiedBulb.SnippitInfo.SnippitRotatingDirection = selectedBulb.SnippitInfo.SnippitRotatingDirection
703+
copiedBulb.SnippitInfo.SnippitRotatingStopBehaviour = selectedBulb.SnippitInfo.SnippitRotatingStopBehaviour
704+
End If
705+
End Sub
706+
707+
Private Sub Paste_Click(sender As Object, e As EventArgs) Handles tsmiPaste.Click
708+
If copiedBulb IsNot Nothing Then
709+
' Offset location slightly
710+
copiedBulb.Location.X += 10
711+
copiedBulb.Location.Y += 10
712+
713+
' Create a new illumination bulb with all properties copied
714+
Dim newBulb As New Illumination.BulbInfo
715+
newBulb.ID = Backglass.currentBulbs.Max(Function(b) b.ID) + 1 ' Generate a new unique ID
716+
newBulb.B2SID = copiedBulb.B2SID
717+
newBulb.B2SIDType = copiedBulb.B2SIDType
718+
newBulb.B2SValue = copiedBulb.B2SValue
719+
newBulb.RomID = copiedBulb.RomID
720+
newBulb.RomIDType = copiedBulb.RomIDType
721+
newBulb.RomInverted = copiedBulb.RomInverted
722+
newBulb.Name = copiedBulb.Name
723+
newBulb.Text = copiedBulb.Text
724+
newBulb.TextAlignment = copiedBulb.TextAlignment
725+
newBulb.FontName = copiedBulb.FontName
726+
newBulb.FontSize = copiedBulb.FontSize
727+
newBulb.FontStyle = copiedBulb.FontStyle
728+
newBulb.Visible = copiedBulb.Visible
729+
newBulb.Location = copiedBulb.Location
730+
newBulb.Size = copiedBulb.Size
731+
newBulb.InitialState = copiedBulb.InitialState
732+
newBulb.DualMode = copiedBulb.DualMode
733+
newBulb.Intensity = copiedBulb.Intensity
734+
newBulb.LightColor = copiedBulb.LightColor
735+
newBulb.DodgeColor = copiedBulb.DodgeColor
736+
newBulb.IlluMode = copiedBulb.IlluMode
737+
newBulb.ZOrder = copiedBulb.ZOrder
738+
newBulb.IsImageSnippit = copiedBulb.IsImageSnippit
739+
newBulb.Image = copiedBulb.Image
740+
741+
' Paste all SnippitInfo properties
742+
newBulb.SnippitInfo = New Illumination.SnippitInfo
743+
newBulb.SnippitInfo.SnippitType = copiedBulb.SnippitInfo.SnippitType
744+
newBulb.SnippitInfo.SnippitMechID = copiedBulb.SnippitInfo.SnippitMechID
745+
newBulb.SnippitInfo.SnippitRotatingSteps = copiedBulb.SnippitInfo.SnippitRotatingSteps
746+
newBulb.SnippitInfo.SnippitRotatingInterval = copiedBulb.SnippitInfo.SnippitRotatingInterval
747+
newBulb.SnippitInfo.SnippitRotatingDirection = copiedBulb.SnippitInfo.SnippitRotatingDirection
748+
newBulb.SnippitInfo.SnippitRotatingStopBehaviour = copiedBulb.SnippitInfo.SnippitRotatingStopBehaviour
749+
750+
' Add the new bulb to the collection
751+
Backglass.currentBulbs.Add(newBulb)
752+
753+
' Refresh screen
754+
Backglass.currentTabPage.Invalidate()
755+
Backglass.currentTabPage.RefreshIllumination()
756+
End If
622757
End Sub
623758

624759
Private Sub tsmiDelete_Click(sender As System.Object, e As System.EventArgs) Handles tsmiDelete.Click

0 commit comments

Comments
 (0)