Skip to content

Commit

Permalink
Merge pull request #211 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Wycklife authored Oct 27, 2020
2 parents 60efe94 + c2cb32f commit 75bc169
Show file tree
Hide file tree
Showing 104 changed files with 15,195 additions and 7,284 deletions.
2 changes: 1 addition & 1 deletion docs/Download.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2 class="section-heading">Download R-Instat</h2>
<hr class="light">
<p><a href=https://bit.ly/34nr6YN" style="color:blue;" target="_blank">R-Instat 0.6.2 Installer (.exe 483MB)</a></p>
<p><a href=https://bit.ly/3dMDiHg" style="color:blue;" target="_blank">R-Instat 0.6.3 Installer (.exe 550MB)</a></p>
<p>R-Instat is currently a Windows only application. However, it can be accessed on Mac or Linux through use of a Virtual Windows Machine.</p>

<h2 class="section-heading">Installation & Documentation</h2>
Expand Down
151 changes: 150 additions & 1 deletion instat/clsPopup.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,152 @@
Public Class clsPopup
' R- Instat
' Copyright (C) 2015-2017
'
' This program 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.
'
' This program 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 this program. If not, see <http://www.gnu.org/licenses/>.

'''--------------------------------------------------------------------------------------------
''' <summary>
''' An object of this class represents a popup component that's used and displayed as a control.
''' <list type="bullet">
''' <item><description>
''' set contents control of the popup
''' </description></item>
''' <item><description>
''' set size of the popup
''' </description></item>
''' <item><description>
''' specify the display position of the popup relative to the owner. Default is top
''' </description></item>
''' <item><description>
''' attach the owner control and show the popup
''' </description></item>
''' </list>
''' </summary>
'''--------------------------------------------------------------------------------------------
Public Class clsPopup
''' <summary>
''' Event raised when the contents control loses focus.
''' This indicates that the popup is closing.
'''</summary>
Public Event Closing()

''' <summary>
''' Container used as the 'frame' of the popup component
''' </summary>
Private ReadOnly frm As Form

''' <summary>
''' specifies if the popup should hide automatically on lost focus or not
''' </summary>
Public Property AutoHide As Boolean

''' <summary>
''' specifies the position of the popup relative to the owner(control)
''' </summary>
Public Property Position As PopupPosition

''' <summary>
''' enumeration of allowable popup positions
''' </summary>
Public Enum PopupPosition
Top
Below
End Enum

Sub New()
'initialise variables and set defaults
frm = New Form With {
.ShowInTaskbar = False,
.FormBorderStyle = FormBorderStyle.None,
.StartPosition = FormStartPosition.Manual
}
'set default popup behaviours
AutoHide = True
Position = PopupPosition.Top
End Sub

Public Sub SetSize(width As Integer, height As Integer)
SetSize(New Size(width, height))
End Sub

Public Sub SetSize(size As Size)
frm.Size = size
End Sub

Public Sub SetLocation(x As Integer, y As Integer)
SetLocation(New Point(x, y))
End Sub

Public Sub SetLocation(point As Point)
frm.Location = point
End Sub

''' <summary>
''' sets the specified control as the contents control of the popup
''' </summary>
''' <param name="ctr">The System.Windows.Forms.Control to set as the control contained in the popup</param>
Public Sub SetContentControl(ctr As Control)
frm.Controls.Clear() 'remove any existing control first
frm.Controls.Add(ctr)
ctr.Dock = DockStyle.Fill 'the control will always be same size as the from

'attach the event handler that will determine auto closing
AddHandler ctr.LostFocus, Sub()
If AutoHide Then
Hide()
End If
End Sub
End Sub

''' <summary>
''' shows the popup relative to the location of the specified control(owner)
''' and the position specified
''' </summary>
''' <param name="owner">The System.Windows.Forms.Control to set popup location based on</param>
''' <param name="position">PopupPosition to set the position of the popup</param>
Public Sub Show(owner As Control, position As PopupPosition)
Me.Position = position
Show(owner)
End Sub

''' <summary>
''' shows the popup relative to the location of the specified control(owner)
''' and the position set
''' </summary>
''' <param name="owner">The System.Windows.Forms.Control to set popup location based on</param>
Public Sub Show(owner As Control)
'compute and get the location of the specified control relative to screen coordinates
'Don't use Point.Empty, it's not function so use Point(0, 0)
Dim ctrPos As Point = owner.PointToScreen(New Point(0, 0))

'then set location of the popup relative to the position specified
Select Case Position
Case PopupPosition.Top
SetLocation(ctrPos.X - 2, ctrPos.Y - frm.Height - 2)
Case PopupPosition.Below
SetLocation(ctrPos.X - 2, ctrPos.Y + owner.Height - 2)
End Select

'then show popup
frm.Show()
End Sub

''' <summary>
''' raises popup hiding event then hides the popup
''' </summary>
Public Sub Hide()
RaiseEvent Closing()
frm.Close()
End Sub

End Class
17 changes: 11 additions & 6 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ Public Class RLink


''' <summary> The R version major required. </summary>
Private strRVersionMajorRequired As String = "3"
Private strRVersionMajorRequired As String = "4"

''' <summary> The R version minor required. </summary>
Private strRVersionMinorRequired As String = "6"
Private strRVersionMinorRequired As String = "0"

''' <summary> The R version required. </summary>
Private strRVersionRequired As String = strRVersionMajorRequired & "." & strRVersionMinorRequired & ".0"

''' <summary> The R bundled version. </summary>
Private strRBundledVersion As String = "3.6.2"
Private strRBundledVersion As String = "4.0.3"


'''--------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2277,19 +2277,24 @@ Public Class RLink
'''--------------------------------------------------------------------------------------------
Public Sub ViewLastGraph(Optional bAsPlotly As Boolean = False)
Dim clsLastGraph As New RFunction
Dim clsInteractivePlot As New RFunction

clsLastGraph.SetRCommand(strInstatDataObject & "$get_last_graph")

If bAsPlotly Then
Dim clsInteractivePlot As New RFunction
clsLastGraph.AddParameter("print_graph", "FALSE", iPosition:=0)
clsInteractivePlot.SetPackageName("plotly")
clsInteractivePlot.SetRCommand("ggplotly")
clsInteractivePlot.AddParameter("p", clsRFunctionParameter:=clsLastGraph, iPosition:=0)
'Need to set iCallType = 2 to obtain a graph in an interactive viewer.
RunScript(clsInteractivePlot.ToScript(), iCallType:=2, strComment:="View last graph as Plotly", bSeparateThread:=False)
Else
RunScript(clsLastGraph.ToScript(), strComment:="View last graph", bSeparateThread:=False)
Dim strGlobalGraphDisplayOption As String
'store the current set graph display option, to restore after display
strGlobalGraphDisplayOption = Me.strGraphDisplayOption
Me.strGraphDisplayOption = "view_R_viewer"
RunScript(clsLastGraph.ToScript(), iCallType:=3, strComment:="View last graph", bSeparateThread:=False)
'restore the graph display option
Me.strGraphDisplayOption = strGlobalGraphDisplayOption
End If
End Sub

Expand Down
Loading

0 comments on commit 75bc169

Please sign in to comment.