diff --git a/instat/Model/Output/clsOutputElement.vb b/instat/Model/Output/clsOutputElement.vb index af040279fb7..f7666ab51c8 100644 --- a/instat/Model/Output/clsOutputElement.vb +++ b/instat/Model/Output/clsOutputElement.vb @@ -85,11 +85,15 @@ Public Class clsOutputElement _strOutput = strOutput End Sub - ''' + ''' ''' Gets formatted R Script, split into R Script Elements ''' ''' Public ReadOnly Property FormattedRScript As List(Of clsRScriptElement) + + 'todo. + 'this function may end up being called multiple times. For long scripts initialising clsRScript And getting tokens takes lot of time. You can test this effect by pasting new data frame that has many columns. + 'should the operation of getting tokens be done just once then stored to be reused f need be? Get Dim _lstRScriptElements As New List(Of clsRScriptElement) Try diff --git a/instat/UserControl/ucrOutputPage.vb b/instat/UserControl/ucrOutputPage.vb index e1328bbaee6..50d49de8c82 100644 --- a/instat/UserControl/ucrOutputPage.vb +++ b/instat/UserControl/ucrOutputPage.vb @@ -133,7 +133,7 @@ Public Class ucrOutputPage 'whether it's just a script output 'todo. temporary fix. Output element should always have an R script - If outputElement.FormattedRScript IsNot Nothing Then + If outputElement.Script IsNot Nothing Then AddNewScript(outputElement) End If diff --git a/instat/dlgPasteNewColumns.Designer.vb b/instat/dlgPasteNewColumns.Designer.vb index d68cd84fe90..a2760572e76 100644 --- a/instat/dlgPasteNewColumns.Designer.vb +++ b/instat/dlgPasteNewColumns.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class dlgPasteNewColumns Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,22 +20,252 @@ Partial Class dlgPasteNewColumns 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. - _ + Private Sub InitializeComponent() + Me.ucrDFSelected = New instat.ucrDataFrame() + Me.panelNoDataPreview = New System.Windows.Forms.Panel() + Me.lblNoDataPreview = New System.Windows.Forms.Label() + Me.lblConfirmText = New System.Windows.Forms.Label() + Me.lblLinesToPreview = New System.Windows.Forms.Label() + Me.lblPreviewHeader = New System.Windows.Forms.Label() + Me.btnRefreshPreview = New System.Windows.Forms.Button() + Me.grdDataPreview = New unvell.ReoGrid.ReoGridControl() + Me.ucrSaveNewDFName = New instat.ucrSave() + Me.ucrNudPreviewLines = New instat.ucrNud() + Me.ucrChkRowHeader = New instat.ucrCheck() + Me.ucrBase = New instat.ucrButtons() + Me.rdoColumns = New System.Windows.Forms.RadioButton() + Me.rdoDataFrame = New System.Windows.Forms.RadioButton() + Me.ucrPnl = New instat.UcrPanel() + Me.ucrChkKeepExstingCols = New instat.ucrCheck() + Me.panelNoDataPreview.SuspendLayout() Me.SuspendLayout() ' + 'ucrDFSelected + ' + Me.ucrDFSelected.AutoSize = True + Me.ucrDFSelected.bDropUnusedFilterLevels = False + Me.ucrDFSelected.bUseCurrentFilter = True + Me.ucrDFSelected.Location = New System.Drawing.Point(5, 265) + Me.ucrDFSelected.Margin = New System.Windows.Forms.Padding(0) + Me.ucrDFSelected.Name = "ucrDFSelected" + Me.ucrDFSelected.Size = New System.Drawing.Size(177, 50) + Me.ucrDFSelected.TabIndex = 0 + ' + 'panelNoDataPreview + ' + Me.panelNoDataPreview.Controls.Add(Me.lblNoDataPreview) + Me.panelNoDataPreview.Location = New System.Drawing.Point(5, 70) + Me.panelNoDataPreview.Name = "panelNoDataPreview" + Me.panelNoDataPreview.Size = New System.Drawing.Size(572, 186) + Me.panelNoDataPreview.TabIndex = 36 + ' + 'lblNoDataPreview + ' + Me.lblNoDataPreview.AutoSize = True + Me.lblNoDataPreview.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.lblNoDataPreview.Location = New System.Drawing.Point(201, 66) + Me.lblNoDataPreview.Name = "lblNoDataPreview" + Me.lblNoDataPreview.Size = New System.Drawing.Size(168, 25) + Me.lblNoDataPreview.TabIndex = 0 + Me.lblNoDataPreview.Text = "No Data Loaded" + ' + 'lblConfirmText + ' + Me.lblConfirmText.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblConfirmText.Location = New System.Drawing.Point(358, 271) + Me.lblConfirmText.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) + Me.lblConfirmText.Name = "lblConfirmText" + Me.lblConfirmText.Size = New System.Drawing.Size(219, 46) + Me.lblConfirmText.TabIndex = 35 + Me.lblConfirmText.Text = "Click Ok to paste data to new data frame" + ' + 'lblLinesToPreview + ' + Me.lblLinesToPreview.AutoSize = True + Me.lblLinesToPreview.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblLinesToPreview.Location = New System.Drawing.Point(315, 50) + Me.lblLinesToPreview.Name = "lblLinesToPreview" + Me.lblLinesToPreview.Size = New System.Drawing.Size(88, 13) + Me.lblLinesToPreview.TabIndex = 34 + Me.lblLinesToPreview.Text = "Lines to Preview:" + ' + 'lblPreviewHeader + ' + Me.lblPreviewHeader.AutoSize = True + Me.lblPreviewHeader.Location = New System.Drawing.Point(5, 50) + Me.lblPreviewHeader.Name = "lblPreviewHeader" + Me.lblPreviewHeader.Size = New System.Drawing.Size(119, 13) + Me.lblPreviewHeader.TabIndex = 33 + Me.lblPreviewHeader.Text = "Preview of copied data:" + ' + 'btnRefreshPreview + ' + Me.btnRefreshPreview.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.btnRefreshPreview.Location = New System.Drawing.Point(477, 45) + Me.btnRefreshPreview.Name = "btnRefreshPreview" + Me.btnRefreshPreview.Size = New System.Drawing.Size(100, 23) + Me.btnRefreshPreview.TabIndex = 29 + Me.btnRefreshPreview.Text = "Refresh Preview" + Me.btnRefreshPreview.UseVisualStyleBackColor = True + ' + 'grdDataPreview + ' + Me.grdDataPreview.BackColor = System.Drawing.Color.White + Me.grdDataPreview.ColumnHeaderContextMenuStrip = Nothing + Me.grdDataPreview.LeadHeaderContextMenuStrip = Nothing + Me.grdDataPreview.Location = New System.Drawing.Point(5, 70) + Me.grdDataPreview.Name = "grdDataPreview" + Me.grdDataPreview.Readonly = True + Me.grdDataPreview.RowHeaderContextMenuStrip = Nothing + Me.grdDataPreview.Script = Nothing + Me.grdDataPreview.SheetTabContextMenuStrip = Nothing + Me.grdDataPreview.SheetTabNewButtonVisible = False + Me.grdDataPreview.SheetTabVisible = True + Me.grdDataPreview.SheetTabWidth = 60 + Me.grdDataPreview.ShowScrollEndSpacing = True + Me.grdDataPreview.Size = New System.Drawing.Size(572, 186) + Me.grdDataPreview.TabIndex = 32 + ' + 'ucrSaveNewDFName + ' + Me.ucrSaveNewDFName.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrSaveNewDFName.Location = New System.Drawing.Point(5, 269) + Me.ucrSaveNewDFName.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.ucrSaveNewDFName.Name = "ucrSaveNewDFName" + Me.ucrSaveNewDFName.Size = New System.Drawing.Size(263, 24) + Me.ucrSaveNewDFName.TabIndex = 30 + ' + 'ucrNudPreviewLines + ' + Me.ucrNudPreviewLines.AutoSize = True + Me.ucrNudPreviewLines.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) + Me.ucrNudPreviewLines.Increment = New Decimal(New Integer() {1, 0, 0, 0}) + Me.ucrNudPreviewLines.Location = New System.Drawing.Point(420, 45) + Me.ucrNudPreviewLines.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.ucrNudPreviewLines.Maximum = New Decimal(New Integer() {10000, 0, 0, 0}) + Me.ucrNudPreviewLines.Minimum = New Decimal(New Integer() {10, 0, 0, 0}) + Me.ucrNudPreviewLines.Name = "ucrNudPreviewLines" + Me.ucrNudPreviewLines.Size = New System.Drawing.Size(50, 20) + Me.ucrNudPreviewLines.TabIndex = 28 + Me.ucrNudPreviewLines.Value = New Decimal(New Integer() {10, 0, 0, 0}) + ' + 'ucrChkRowHeader + ' + Me.ucrChkRowHeader.AutoSize = True + Me.ucrChkRowHeader.Checked = False + Me.ucrChkRowHeader.Location = New System.Drawing.Point(141, 47) + Me.ucrChkRowHeader.Name = "ucrChkRowHeader" + Me.ucrChkRowHeader.Size = New System.Drawing.Size(169, 23) + Me.ucrChkRowHeader.TabIndex = 27 + ' + 'ucrBase + ' + Me.ucrBase.AutoSize = True + Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrBase.Location = New System.Drawing.Point(62, 323) + Me.ucrBase.Name = "ucrBase" + Me.ucrBase.Size = New System.Drawing.Size(408, 52) + Me.ucrBase.TabIndex = 31 + ' + 'rdoColumns + ' + Me.rdoColumns.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoColumns.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoColumns.FlatAppearance.BorderSize = 2 + Me.rdoColumns.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoColumns.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoColumns.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoColumns.Location = New System.Drawing.Point(278, 9) + Me.rdoColumns.Name = "rdoColumns" + Me.rdoColumns.Size = New System.Drawing.Size(99, 27) + Me.rdoColumns.TabIndex = 39 + Me.rdoColumns.TabStop = True + Me.rdoColumns.Text = "Columns" + Me.rdoColumns.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoColumns.UseVisualStyleBackColor = True + ' + 'rdoDataFrame + ' + Me.rdoDataFrame.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoDataFrame.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoDataFrame.FlatAppearance.BorderSize = 2 + Me.rdoDataFrame.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoDataFrame.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoDataFrame.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoDataFrame.Location = New System.Drawing.Point(176, 9) + Me.rdoDataFrame.Name = "rdoDataFrame" + Me.rdoDataFrame.Size = New System.Drawing.Size(105, 27) + Me.rdoDataFrame.TabIndex = 38 + Me.rdoDataFrame.TabStop = True + Me.rdoDataFrame.Text = "Data Frame" + Me.rdoDataFrame.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoDataFrame.UseVisualStyleBackColor = True + ' + 'ucrPnl + ' + Me.ucrPnl.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnl.Location = New System.Drawing.Point(134, 7) + Me.ucrPnl.Name = "ucrPnl" + Me.ucrPnl.Size = New System.Drawing.Size(286, 29) + Me.ucrPnl.TabIndex = 37 + ' + 'ucrChkKeepExstingCols + ' + Me.ucrChkKeepExstingCols.AutoSize = True + Me.ucrChkKeepExstingCols.Checked = False + Me.ucrChkKeepExstingCols.Location = New System.Drawing.Point(170, 287) + Me.ucrChkKeepExstingCols.Name = "ucrChkKeepExstingCols" + Me.ucrChkKeepExstingCols.Size = New System.Drawing.Size(183, 23) + Me.ucrChkKeepExstingCols.TabIndex = 40 + ' 'dlgPasteNewColumns ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(533, 292) + Me.ClientSize = New System.Drawing.Size(585, 383) + Me.Controls.Add(Me.ucrChkKeepExstingCols) + Me.Controls.Add(Me.rdoColumns) + Me.Controls.Add(Me.rdoDataFrame) + Me.Controls.Add(Me.ucrPnl) + Me.Controls.Add(Me.panelNoDataPreview) + Me.Controls.Add(Me.lblConfirmText) + Me.Controls.Add(Me.lblLinesToPreview) + Me.Controls.Add(Me.lblPreviewHeader) + Me.Controls.Add(Me.btnRefreshPreview) + Me.Controls.Add(Me.grdDataPreview) + Me.Controls.Add(Me.ucrSaveNewDFName) + Me.Controls.Add(Me.ucrNudPreviewLines) + Me.Controls.Add(Me.ucrChkRowHeader) + Me.Controls.Add(Me.ucrBase) + Me.Controls.Add(Me.ucrDFSelected) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.Margin = New System.Windows.Forms.Padding(2) Me.Name = "dlgPasteNewColumns" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen - Me.Text = "Paste Data to New Column(s)" + Me.Text = "Paste New" + Me.panelNoDataPreview.ResumeLayout(False) + Me.panelNoDataPreview.PerformLayout() Me.ResumeLayout(False) + Me.PerformLayout() End Sub + + Friend WithEvents ucrDFSelected As ucrDataFrame + Friend WithEvents panelNoDataPreview As Panel + Friend WithEvents lblNoDataPreview As Label + Friend WithEvents lblConfirmText As Label + Friend WithEvents lblLinesToPreview As Label + Friend WithEvents lblPreviewHeader As Label + Friend WithEvents btnRefreshPreview As Button + Friend WithEvents grdDataPreview As unvell.ReoGrid.ReoGridControl + Friend WithEvents ucrSaveNewDFName As ucrSave + Friend WithEvents ucrNudPreviewLines As ucrNud + Friend WithEvents ucrChkRowHeader As ucrCheck + Friend WithEvents ucrBase As ucrButtons + Friend WithEvents rdoColumns As RadioButton + Friend WithEvents rdoDataFrame As RadioButton + Friend WithEvents ucrPnl As UcrPanel + Friend WithEvents ucrChkKeepExstingCols As ucrCheck End Class diff --git a/instat/dlgPasteNewColumns.vb b/instat/dlgPasteNewColumns.vb index 506442412c2..00457514b89 100644 --- a/instat/dlgPasteNewColumns.vb +++ b/instat/dlgPasteNewColumns.vb @@ -1,5 +1,233 @@ -Public Class dlgPasteNewColumns +' 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 . +Imports RDotNet +Imports instat.Translations +Public Class dlgPasteNewColumns + Private bFirstLoad As Boolean = True + Private bReset As Boolean = True + Private clsReadClipDataRFunction As New RFunction + Private clsImportColsToExistingDFRFunction As RFunction + 'used to prevent TestOkEnabled from being called multiple times when loading the dialog. + Private bValidatePasteData As Boolean = False + Private Sub dlgPasteNewColumns_Load(sender As Object, e As EventArgs) Handles MyBase.Load + If bFirstLoad Then + InitialiseDialog() + bFirstLoad = False + End If + If bReset Then + SetDefaults() + End If + SetClipBoardDataParameter() 'reset the clip board data parameter value + SetRCodeForControls(bReset) + bReset = False + bValidatePasteData = True + TestOkEnabled() + autoTranslate(Me) + End Sub + + Private Sub dlgPasteNewColumns_Closed(sender As Object, e As EventArgs) Handles Me.Closed + bValidatePasteData = False + End Sub + + Private Sub InitialiseDialog() + ucrBase.iHelpTopicID = 160 + + '---------------------------- + ucrPnl.AddRadioButton(rdoDataFrame) + ucrPnl.AddRadioButton(rdoColumns) + ucrPnl.AddFunctionNamesCondition(rdoDataFrame, frmMain.clsRLink.strInstatDataObject & "$add_columns_to_data", bNewIsPositive:=False) + ucrPnl.AddFunctionNamesCondition(rdoColumns, frmMain.clsRLink.strInstatDataObject & "$add_columns_to_data", bNewIsPositive:=True) + ucrPnl.AddToLinkedControls({ucrDFSelected, ucrChkKeepExstingCols}, {rdoColumns}, bNewLinkedAddRemoveParameter:=False, bNewLinkedHideIfParameterMissing:=True) + + ucrChkRowHeader.SetText("First row is header") + ucrChkRowHeader.SetParameter(New RParameter("header", 1)) + ucrChkRowHeader.SetValuesCheckedAndUnchecked("TRUE", "FALSE") + + ucrNudPreviewLines.SetMinMax(iNewMin:=10, iNewMax:=1000) + '---------------------------- + + 'paste as data frame + '---------------------------- + ucrSaveNewDFName.SetIsTextBox() + ucrSaveNewDFName.SetSaveTypeAsDataFrame() + ucrSaveNewDFName.SetLabelText("New Data Frame Name:") + ucrSaveNewDFName.SetPrefix("data") + '---------------------------- + + 'paste as column + '---------------------------- + ucrDFSelected.SetText("Paste copied data to:") + ucrDFSelected.SetParameter(New RParameter("data_name", 0)) + ucrDFSelected.SetParameterIsString() + + ucrChkKeepExstingCols.SetText("Keep existing columns") + ucrChkKeepExstingCols.SetParameter(New RParameter("use_col_name_as_prefix", 2)) + ucrChkKeepExstingCols.SetValuesCheckedAndUnchecked("TRUE", "FALSE") + '---------------------------- + + ucrNudPreviewLines.Minimum = 10 + End Sub + + Private Sub SetDefaults() + clsImportColsToExistingDFRFunction = New RFunction + clsReadClipDataRFunction = New RFunction + + ucrNudPreviewLines.Value = 10 + ucrSaveNewDFName.Reset() + ucrDFSelected.Reset() + + 'todo. some clip data values work well with read_delim R function. + 'that's why readr references have been left here for future testing and reference. + 'clsReadClipDataRFunction.SetPackageName("readr") + 'clsReadClipDataRFunction.SetRCommand("read_delim") + 'clsReadClipDataRFunction.AddParameter("col_names", strParameterValue:="TRUE", iPosition:=1) + + clsReadClipDataRFunction.SetPackageName("clipr") + clsReadClipDataRFunction.SetRCommand("read_clip_tbl") + clsReadClipDataRFunction.AddParameter("header", strParameterValue:="TRUE", iPosition:=1) + + clsImportColsToExistingDFRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_columns_to_data") + clsImportColsToExistingDFRFunction.AddParameter("col_data", clsRFunctionParameter:=clsReadClipDataRFunction, iPosition:=1) + clsImportColsToExistingDFRFunction.AddParameter("use_col_name_as_prefix", strParameterValue:="TRUE", iPosition:=2) + + ucrBase.clsRsyntax.SetBaseRFunction(clsReadClipDataRFunction) + End Sub + + Private Sub SetRCodeForControls(bReset As Boolean) + ucrChkRowHeader.SetRCode(clsReadClipDataRFunction, bReset) + + ucrSaveNewDFName.SetRCode(clsReadClipDataRFunction, bReset) + + ucrDFSelected.SetRCode(clsImportColsToExistingDFRFunction, bReset) + ucrChkKeepExstingCols.SetRCode(clsImportColsToExistingDFRFunction, bReset) + ucrPnl.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub + + Private Sub SetClipBoardDataParameter() + 'please note addition of this parameter makes the execution of the R code take longer + 'compared to letting R read from the clipboard. + 'However this has been added to achieve reproducibility in future + Try + 'clipboard data may have an empty line which is ignored by clipr so just trim it here to get accurate length + 'escape any double quotes because of how clipr is implemented. See issue #7199 for more details + Dim clipBoardText As String = My.Computer.Clipboard.GetText.Trim().Replace("""", "\""") + Dim arrStrTemp() As String = clipBoardText.Split(New String() {Environment.NewLine}, StringSplitOptions.None) + If arrStrTemp.Length > 1000 Then + MsgBox("Requested clipboard data has more than 1000 rows. Only a maximum of 1000 rows can be pasted") + clipBoardText = "" + End If + clsReadClipDataRFunction.AddParameter("x", Chr(34) & clipBoardText & Chr(34), iPosition:=0) + Catch ex As Exception + 'this error could be due to large clipboard data + MsgBox("Requested clipboard operation did not succeed. Large data detected") + End Try + End Sub + + + ''' + ''' validates copied data and displays it for preview. + ''' + ''' returns true if copied data can be pasted to the selected data frame or false if not + Private Function ValidateAndPreviewCopiedData() As Boolean + Try + 'reset feedback controls default states + panelNoDataPreview.Visible = True + lblConfirmText.Text = "" + lblConfirmText.ForeColor = Color.Red + + Dim clsTempReadClipBoardDataRFunction As RFunction = clsReadClipDataRFunction.Clone() + + clsTempReadClipBoardDataRFunction.RemoveAssignTo() 'remove assign to before getting the script + Dim dfTemp As DataFrame = frmMain.clsRLink.RunInternalScriptGetValue(clsTempReadClipBoardDataRFunction.ToScript(), bSilent:=True)?.AsDataFrame + If dfTemp Is Nothing OrElse dfTemp.RowCount = 0 Then + Return False + End If + + 'preview data + frmMain.clsGrids.FillSheet(dfTemp, "temp", grdDataPreview, bIncludeDataTypes:=False, iColMax:=frmMain.clsGrids.iMaxCols, iRowMax:=ucrNudPreviewLines.Value) + lblConfirmText.Text = "Columns: " & dfTemp.ColumnCount & " | Rows: " & dfTemp.RowCount & Environment.NewLine & "Click Ok to paste data." + lblConfirmText.ForeColor = Color.Green + panelNoDataPreview.Visible = False + Return True + Catch ex As Exception + lblConfirmText.Text = "Could not preview data. Data cannot be pasted." + panelNoDataPreview.Visible = True + Return False + End Try + + End Function + + Private Sub TestOkEnabled(Optional bValidateCopiedData As Boolean = True) + Dim enableOK As Boolean = False + If rdoDataFrame.Checked Then + enableOK = ucrSaveNewDFName.IsComplete() + ElseIf rdoColumns.Checked Then + enableOK = Not String.IsNullOrEmpty(ucrDFSelected.strCurrDataFrame) + End If + If bValidateCopiedData Then + enableOK = ValidateAndPreviewCopiedData() + End If + ucrBase.OKEnabled(enableOK) + End Sub + + Private Sub ucrPnl_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnl.ControlValueChanged + If rdoDataFrame.Checked Then + clsReadClipDataRFunction.RemoveAssignTo() + ucrBase.clsRsyntax.SetBaseRFunction(clsReadClipDataRFunction) + ucrSaveNewDFName.Visible = True 'todo. can this be done through the custom panel control? + ucrSaveNewDFName.Reset() + ElseIf rdoColumns.Checked Then + clsReadClipDataRFunction.SetAssignToObject("data") + ucrBase.clsRsyntax.SetBaseRFunction(clsImportColsToExistingDFRFunction) + ucrSaveNewDFName.Visible = False 'todo. can this be done through the custom panel control? + ucrSaveNewDFName.SetName("") 'forces the save control to not include import function + End If + + If bValidatePasteData Then + TestOkEnabled(bValidateCopiedData:=False) + End If + End Sub + + Private Sub btnRefreshPreview_Click(sender As Object, e As EventArgs) Handles btnRefreshPreview.Click + SetClipBoardDataParameter() + TestOkEnabled() + End Sub + + Private Sub ucrPreviewControls_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkRowHeader.ControlValueChanged, ucrNudPreviewLines.ControlValueChanged + If bValidatePasteData Then + TestOkEnabled(bValidateCopiedData:=ucrChangedControl IsNot ucrNudPreviewLines) + End If + End Sub + + Private Sub ucrControls_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrDFSelected.ControlContentsChanged, ucrSaveNewDFName.ControlContentsChanged, ucrChkKeepExstingCols.ControlContentsChanged + If bValidatePasteData Then + 'disabled unnecessary validation of copied data because it may take long for large datasets + TestOkEnabled(bValidateCopiedData:=ucrchangedControl IsNot ucrSaveNewDFName AndAlso ucrchangedControl IsNot ucrDFSelected AndAlso ucrchangedControl IsNot ucrChkKeepExstingCols) + End If + End Sub + + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + bValidatePasteData = False + SetDefaults() + SetClipBoardDataParameter() + SetRCodeForControls(True) + bValidatePasteData = True + TestOkEnabled() + End Sub + End Class \ No newline at end of file diff --git a/instat/dlgPasteNewDataFrame.Designer.vb b/instat/dlgPasteNewDataFrame.Designer.vb deleted file mode 100644 index bf595b3946e..00000000000 --- a/instat/dlgPasteNewDataFrame.Designer.vb +++ /dev/null @@ -1,194 +0,0 @@ - _ -Partial Class dlgPasteNewDataFrame - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - - Private Sub InitializeComponent() - Me.grdDataPreview = New unvell.ReoGrid.ReoGridControl() - Me.lblPreviewHeader = New System.Windows.Forms.Label() - Me.btnRefreshPreview = New System.Windows.Forms.Button() - Me.ucrBase = New instat.ucrButtons() - Me.lblLinesToPreview = New System.Windows.Forms.Label() - Me.ucrNudPreviewLines = New instat.ucrNud() - Me.ucrChkRowHeader = New instat.ucrCheck() - Me.lblConfirmText = New System.Windows.Forms.Label() - Me.ucrSaveNewDFName = New instat.ucrSave() - Me.panelNoDataPreview = New System.Windows.Forms.Panel() - Me.lblNoDataPreview = New System.Windows.Forms.Label() - Me.panelNoDataPreview.SuspendLayout() - Me.SuspendLayout() - ' - 'grdDataPreview - ' - Me.grdDataPreview.BackColor = System.Drawing.Color.White - Me.grdDataPreview.ColumnHeaderContextMenuStrip = Nothing - Me.grdDataPreview.LeadHeaderContextMenuStrip = Nothing - Me.grdDataPreview.Location = New System.Drawing.Point(10, 35) - Me.grdDataPreview.Name = "grdDataPreview" - Me.grdDataPreview.Readonly = True - Me.grdDataPreview.RowHeaderContextMenuStrip = Nothing - Me.grdDataPreview.Script = Nothing - Me.grdDataPreview.SheetTabContextMenuStrip = Nothing - Me.grdDataPreview.SheetTabNewButtonVisible = False - Me.grdDataPreview.SheetTabVisible = True - Me.grdDataPreview.SheetTabWidth = 60 - Me.grdDataPreview.ShowScrollEndSpacing = True - Me.grdDataPreview.Size = New System.Drawing.Size(572, 166) - Me.grdDataPreview.TabIndex = 14 - ' - 'lblPreviewHeader - ' - Me.lblPreviewHeader.AutoSize = True - Me.lblPreviewHeader.Location = New System.Drawing.Point(10, 15) - Me.lblPreviewHeader.Name = "lblPreviewHeader" - Me.lblPreviewHeader.Size = New System.Drawing.Size(119, 13) - Me.lblPreviewHeader.TabIndex = 18 - Me.lblPreviewHeader.Text = "Preview of copied data:" - ' - 'btnRefreshPreview - ' - Me.btnRefreshPreview.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.btnRefreshPreview.Location = New System.Drawing.Point(470, 10) - Me.btnRefreshPreview.Name = "btnRefreshPreview" - Me.btnRefreshPreview.Size = New System.Drawing.Size(100, 23) - Me.btnRefreshPreview.TabIndex = 3 - Me.btnRefreshPreview.Text = "Refresh Preview" - Me.btnRefreshPreview.UseVisualStyleBackColor = True - ' - 'ucrBase - ' - Me.ucrBase.AutoSize = True - Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(10, 276) - Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(405, 52) - Me.ucrBase.TabIndex = 5 - ' - 'lblLinesToPreview - ' - Me.lblLinesToPreview.AutoSize = True - Me.lblLinesToPreview.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblLinesToPreview.Location = New System.Drawing.Point(320, 15) - Me.lblLinesToPreview.Name = "lblLinesToPreview" - Me.lblLinesToPreview.Size = New System.Drawing.Size(88, 13) - Me.lblLinesToPreview.TabIndex = 22 - Me.lblLinesToPreview.Text = "Lines to Preview:" - ' - 'ucrNudPreviewLines - ' - Me.ucrNudPreviewLines.AutoSize = True - Me.ucrNudPreviewLines.DecimalPlaces = New Decimal(New Integer() {0, 0, 0, 0}) - Me.ucrNudPreviewLines.Increment = New Decimal(New Integer() {1, 0, 0, 0}) - Me.ucrNudPreviewLines.Location = New System.Drawing.Point(413, 10) - Me.ucrNudPreviewLines.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) - Me.ucrNudPreviewLines.Maximum = New Decimal(New Integer() {10000, 0, 0, 0}) - Me.ucrNudPreviewLines.Minimum = New Decimal(New Integer() {10, 0, 0, 0}) - Me.ucrNudPreviewLines.Name = "ucrNudPreviewLines" - Me.ucrNudPreviewLines.Size = New System.Drawing.Size(50, 20) - Me.ucrNudPreviewLines.TabIndex = 2 - Me.ucrNudPreviewLines.Value = New Decimal(New Integer() {10, 0, 0, 0}) - ' - 'ucrChkRowHeader - ' - Me.ucrChkRowHeader.AutoSize = True - Me.ucrChkRowHeader.Checked = False - Me.ucrChkRowHeader.Location = New System.Drawing.Point(146, 12) - Me.ucrChkRowHeader.Name = "ucrChkRowHeader" - Me.ucrChkRowHeader.Size = New System.Drawing.Size(169, 23) - Me.ucrChkRowHeader.TabIndex = 1 - ' - 'lblConfirmText - ' - Me.lblConfirmText.AutoSize = True - Me.lblConfirmText.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblConfirmText.Location = New System.Drawing.Point(10, 215) - Me.lblConfirmText.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) - Me.lblConfirmText.Name = "lblConfirmText" - Me.lblConfirmText.Size = New System.Drawing.Size(189, 13) - Me.lblConfirmText.TabIndex = 24 - Me.lblConfirmText.Text = "Click Ok to paste data to new columns" - ' - 'ucrSaveNewDFName - ' - Me.ucrSaveNewDFName.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveNewDFName.Location = New System.Drawing.Point(10, 243) - Me.ucrSaveNewDFName.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) - Me.ucrSaveNewDFName.Name = "ucrSaveNewDFName" - Me.ucrSaveNewDFName.Size = New System.Drawing.Size(246, 24) - Me.ucrSaveNewDFName.TabIndex = 4 - ' - 'panelNoDataPreview - ' - Me.panelNoDataPreview.Controls.Add(Me.lblNoDataPreview) - Me.panelNoDataPreview.Location = New System.Drawing.Point(10, 35) - Me.panelNoDataPreview.Name = "panelNoDataPreview" - Me.panelNoDataPreview.Size = New System.Drawing.Size(572, 166) - Me.panelNoDataPreview.TabIndex = 26 - ' - 'lblNoDataPreview - ' - Me.lblNoDataPreview.AutoSize = True - Me.lblNoDataPreview.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.lblNoDataPreview.Location = New System.Drawing.Point(121, 64) - Me.lblNoDataPreview.Name = "lblNoDataPreview" - Me.lblNoDataPreview.Size = New System.Drawing.Size(168, 25) - Me.lblNoDataPreview.TabIndex = 0 - Me.lblNoDataPreview.Text = "No Data Loaded" - ' - 'dlgPasteNewDataFrame - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi - Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(599, 339) - Me.Controls.Add(Me.panelNoDataPreview) - Me.Controls.Add(Me.ucrSaveNewDFName) - Me.Controls.Add(Me.lblConfirmText) - Me.Controls.Add(Me.lblLinesToPreview) - Me.Controls.Add(Me.ucrNudPreviewLines) - Me.Controls.Add(Me.ucrChkRowHeader) - Me.Controls.Add(Me.ucrBase) - Me.Controls.Add(Me.lblPreviewHeader) - Me.Controls.Add(Me.btnRefreshPreview) - Me.Controls.Add(Me.grdDataPreview) - Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow - Me.Margin = New System.Windows.Forms.Padding(2) - Me.Name = "dlgPasteNewDataFrame" - Me.Text = "Paste Data to New Data Frame" - Me.panelNoDataPreview.ResumeLayout(False) - Me.panelNoDataPreview.PerformLayout() - Me.ResumeLayout(False) - Me.PerformLayout() - - End Sub - - Friend WithEvents grdDataPreview As unvell.ReoGrid.ReoGridControl - Friend WithEvents lblPreviewHeader As Label - Friend WithEvents btnRefreshPreview As Button - Friend WithEvents ucrBase As ucrButtons - Friend WithEvents lblLinesToPreview As Label - Friend WithEvents ucrNudPreviewLines As ucrNud - Friend WithEvents ucrChkRowHeader As ucrCheck - Friend WithEvents lblConfirmText As Label - Friend WithEvents ucrSaveNewDFName As ucrSave - Friend WithEvents panelNoDataPreview As Panel - Friend WithEvents lblNoDataPreview As Label -End Class diff --git a/instat/dlgPasteNewDataFrame.resx b/instat/dlgPasteNewDataFrame.resx deleted file mode 100644 index 1af7de150c9..00000000000 --- a/instat/dlgPasteNewDataFrame.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/instat/dlgPasteNewDataFrame.vb b/instat/dlgPasteNewDataFrame.vb deleted file mode 100644 index 32d0a021d8f..00000000000 --- a/instat/dlgPasteNewDataFrame.vb +++ /dev/null @@ -1,183 +0,0 @@ -' 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 . - -Imports RDotNet -Imports instat.Translations -Public Class dlgPasteNewDataFrame - - Private bFirstLoad As Boolean = True - Private bReset As Boolean = True - Private clsAddDataFunction, clsDataListFunction, clsPasteFunction As New RFunction - - Private Sub dlgPasteNewDataFrame_Load(sender As Object, e As EventArgs) Handles MyBase.Load - If bFirstLoad Then - InitialiseDialog() - bFirstLoad = False - End If - If bReset Then - SetDefaults() - End If - 'reset the clip board data parameter value - SetClipBoardDataParameter() - SetRCodeForControls(bReset) - bReset = False - TestOkEnabled() - autoTranslate(Me) - End Sub - - Private Sub InitialiseDialog() - 'todo. attach the help id later - 'ucrBase.iHelpTopicID = - - ucrSaveNewDFName.SetIsTextBox() - ucrSaveNewDFName.SetSaveTypeAsDataFrame() - ucrSaveNewDFName.SetLabelText("New Data Frame Name:") - ucrSaveNewDFName.SetPrefix("data") - - ucrChkRowHeader.SetText("First row is header") - ucrChkRowHeader.SetParameter(New RParameter("header", 1)) - - ucrNudPreviewLines.SetMinMax(iNewMin:=10, iNewMax:=1000) - End Sub - - Private Sub SetDefaults() - clsAddDataFunction = New RFunction - clsDataListFunction = New RFunction - clsPasteFunction = New RFunction - - 'todo 29/05/2021. this is temporarily done this way because of how - 'function ConstructAssignTo in clsRCodeStructure is currently implemented. - 'It doesn't construct "assignTo" statements correctly - clsAddDataFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_data") - clsAddDataFunction.AddParameter("data_tables", clsRFunctionParameter:=clsDataListFunction, iPosition:=0) - clsDataListFunction.SetRCommand("list") - clsDataListFunction.AddParameter(strParameterName:=ucrSaveNewDFName.GetText, clsRFunctionParameter:=clsPasteFunction, iPosition:=0) - - clsPasteFunction.SetPackageName("clipr") - clsPasteFunction.SetRCommand("read_clip_tbl") - SetClipBoardDataParameter() - clsPasteFunction.AddParameter("header", "TRUE", iPosition:=1) - - ucrBase.clsRsyntax.SetBaseRFunction(clsAddDataFunction) - - ucrNudPreviewLines.Value = 10 - ucrSaveNewDFName.Reset() - End Sub - - Private Sub SetRCodeForControls(bReset As Boolean) - ucrChkRowHeader.SetRCode(clsPasteFunction, bReset) - 'todo 29/05/2021. this is temporarily commented out - 'ucrSaveNewDFName.SetRCode(clsPasteFunction, bReset) - End Sub - - ''' - ''' enables base "OK" and "ToScript" buttons if all entries are valid, disables if not. - ''' - ''' if true, copied data will also be validated - Private Sub TestOkEnabled(Optional bValidateCopiedData As Boolean = True) - 'validation of copied data isn't necessary for situations like checking the typed data frame name - If bValidateCopiedData Then - ucrBase.OKEnabled(ucrSaveNewDFName.IsComplete AndAlso ValidateAndPreviewCopiedData()) - Else - ucrBase.OKEnabled(ucrSaveNewDFName.IsComplete) - End If - End Sub - - Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset - SetDefaults() - SetRCodeForControls(True) - TestOkEnabled() - End Sub - - Private Sub ucrSaveNewDFName_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrSaveNewDFName.ControlContentsChanged - clsDataListFunction.ClearParameters() - clsDataListFunction.AddParameter(strParameterName:=ucrSaveNewDFName.GetText, clsRFunctionParameter:=clsPasteFunction) - 'TestOkEnabled called here because validation of copied data is not necessary and may take long for large data - TestOkEnabled(bValidateCopiedData:=False) - End Sub - - Private Sub ucrControls_ControlValueChangedChanged(ucrchangedControl As ucrCore) Handles ucrChkRowHeader.ControlValueChanged, ucrNudPreviewLines.ControlValueChanged - 'TestOkEnabled called here because ucrChkRowHeader.ControlContentsChanged event is called before the R code is set by the control - 'todo. this could be changed if the ucrCheck raising of ControlContentsChanged event is modified - TestOkEnabled() - End Sub - - Private Sub btnRefreshPreview_Click(sender As Object, e As EventArgs) Handles btnRefreshPreview.Click - SetClipBoardDataParameter() - TestOkEnabled() - End Sub - - Private Sub SetClipBoardDataParameter() - 'please note addition of this parameter makes the execution of the R code take longer - 'compared to letting R read from the clipboard. - 'However this has been added to achieve reproducibility in future - Try - Dim clipBoardText As String = My.Computer.Clipboard.GetText - Dim arrStrTemp() As String = clipBoardText.Split(New String() {Environment.NewLine}, StringSplitOptions.None) - If arrStrTemp.Length > 1000 Then - MsgBox("Requested clipboard data has more than 1000 rows. Only a maximum of 1000 rows can be pasted") - clsPasteFunction.AddParameter("x", Chr(34) & "" & Chr(34), iPosition:=0) - Else - clsPasteFunction.AddParameter("x", Chr(34) & clipBoardText & Chr(34), iPosition:=0) - End If - Catch ex As Exception - 'this error could be due to large clipboard data - MsgBox("Requested clipboard operation did not succeed. Large data detected") - End Try - End Sub - - ''' - ''' validates copied data and displays it for preview. - ''' - ''' returns true if copied data can be pasted to the selected data frame or false if not - Private Function ValidateAndPreviewCopiedData() As Boolean - Dim bValid As Boolean = False - Dim dfTemp As DataFrame - Dim expTemp As SymbolicExpression - Dim clsTempImport As RFunction - - 'set feedback controls default states - panelNoDataPreview.Visible = True - lblConfirmText.Text = "" - lblConfirmText.ForeColor = Color.Red - - 'use clipr::read_clip_tbl command to check if structure of data can be pasted to a data frame - clsTempImport = clsPasteFunction.Clone() - 'limit the rows to those set in the ucrNudPreviewLines control - clsTempImport.AddParameter("nrows", ucrNudPreviewLines.Value) - - 'get the data frame produced by clipr data frame - expTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsTempImport.ToScript(), bSilent:=True) - dfTemp = expTemp?.AsDataFrame - If dfTemp IsNot Nothing Then - Try - 'try to preview the data - frmMain.clsGrids.FillSheet(dfTemp, "temp", grdDataPreview, bIncludeDataTypes:=False, iColMax:=frmMain.clsGrids.iMaxCols) - bValid = True - lblConfirmText.Text = GetTranslation("Click Ok to paste data to new data frames.") - lblConfirmText.ForeColor = Color.Green - Catch - lblConfirmText.Text = GetTranslation("Could not preview data. Cannot be pasted.") - End Try - Else - lblConfirmText.Text = GetTranslation("Could not preview data. Cannot be pasted.") - End If - - panelNoDataPreview.Visible = Not bValid - Return bValid - End Function - -End Class diff --git a/instat/dlgPasteSpecial.Designer.vb b/instat/dlgPasteSpecial.Designer.vb deleted file mode 100644 index eee66821a29..00000000000 --- a/instat/dlgPasteSpecial.Designer.vb +++ /dev/null @@ -1,52 +0,0 @@ - _ -Partial Class dlgPasteSpecial - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - _ - Private Sub InitializeComponent() - Me.UcrCheck1 = New instat.ucrCheck() - Me.SuspendLayout() - ' - 'UcrCheck1 - ' - Me.UcrCheck1.AutoSize = True - Me.UcrCheck1.Checked = False - Me.UcrCheck1.Location = New System.Drawing.Point(172, 48) - Me.UcrCheck1.Name = "UcrCheck1" - Me.UcrCheck1.Size = New System.Drawing.Size(100, 23) - Me.UcrCheck1.TabIndex = 0 - ' - 'dlgPasteSpecial - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi - Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(545, 196) - Me.Controls.Add(Me.UcrCheck1) - Me.Name = "dlgPasteSpecial" - Me.Text = "dlgPasteSpecial" - Me.ResumeLayout(False) - Me.PerformLayout() - - End Sub - - Friend WithEvents UcrCheck1 As ucrCheck -End Class diff --git a/instat/dlgPasteSpecial.resx b/instat/dlgPasteSpecial.resx deleted file mode 100644 index 1af7de150c9..00000000000 --- a/instat/dlgPasteSpecial.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/instat/dlgPasteSpecial.vb b/instat/dlgPasteSpecial.vb deleted file mode 100644 index b518e796823..00000000000 --- a/instat/dlgPasteSpecial.vb +++ /dev/null @@ -1,5 +0,0 @@ -Public Class dlgPasteSpecial - Private Sub dlgPasteSpecial_Load(sender As Object, e As EventArgs) Handles MyBase.Load - - End Sub -End Class \ No newline at end of file diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index 134a95884a7..569780b40b2 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -360,10 +360,8 @@ Partial Class frmMain Me.mnuEdit = New System.Windows.Forms.ToolStripMenuItem() Me.mnuEditFind = New System.Windows.Forms.ToolStripMenuItem() Me.mnuEditCopy = New System.Windows.Forms.ToolStripMenuItem() - Me.mnuEditCopySpecial = New System.Windows.Forms.ToolStripMenuItem() Me.mnuEditPaste = New System.Windows.Forms.ToolStripMenuItem() - Me.mnuPasteSpecial = New System.Windows.Forms.ToolStripMenuItem() - Me.mnuEditPasteNewDataFrame = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuEditPasteNew = New System.Windows.Forms.ToolStripMenuItem() Me.mnuEditWordwrap = New System.Windows.Forms.ToolStripMenuItem() Me.mnuEditSelectAll = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator71 = New System.Windows.Forms.ToolStripSeparator() @@ -2842,7 +2840,7 @@ Partial Class frmMain ' 'mnuEdit ' - Me.mnuEdit.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuEditFind, Me.mnuEditCopy, Me.mnuEditCopySpecial, Me.mnuEditPaste, Me.mnuPasteSpecial, Me.mnuEditPasteNewDataFrame, Me.mnuEditWordwrap, Me.mnuEditSelectAll, Me.ToolStripSeparator71, Me.mnuEditScript}) + Me.mnuEdit.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuEditFind, Me.mnuEditCopy, Me.mnuEditPaste, Me.mnuEditPasteNew, Me.mnuEditWordwrap, Me.mnuEditSelectAll, Me.ToolStripSeparator71, Me.mnuEditScript}) Me.mnuEdit.Name = "mnuEdit" Me.mnuEdit.Size = New System.Drawing.Size(58, 29) Me.mnuEdit.Tag = "Edit" @@ -2852,7 +2850,7 @@ Partial Class frmMain ' Me.mnuEditFind.Name = "mnuEditFind" Me.mnuEditFind.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.F), System.Windows.Forms.Keys) - Me.mnuEditFind.Size = New System.Drawing.Size(366, 34) + Me.mnuEditFind.Size = New System.Drawing.Size(270, 34) Me.mnuEditFind.Tag = "Find" Me.mnuEditFind.Text = "Find" ' @@ -2860,70 +2858,47 @@ Partial Class frmMain ' Me.mnuEditCopy.Name = "mnuEditCopy" Me.mnuEditCopy.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys) - Me.mnuEditCopy.Size = New System.Drawing.Size(366, 34) + Me.mnuEditCopy.Size = New System.Drawing.Size(270, 34) Me.mnuEditCopy.Tag = "Copy" Me.mnuEditCopy.Text = "Copy" ' - 'mnuEditCopySpecial - ' - Me.mnuEditCopySpecial.Enabled = False - Me.mnuEditCopySpecial.Name = "mnuEditCopySpecial" - Me.mnuEditCopySpecial.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Alt) _ - Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys) - Me.mnuEditCopySpecial.Size = New System.Drawing.Size(366, 34) - Me.mnuEditCopySpecial.Tag = "Copy_Special" - Me.mnuEditCopySpecial.Text = "Copy Special" - Me.mnuEditCopySpecial.Visible = False - ' 'mnuEditPaste ' Me.mnuEditPaste.Name = "mnuEditPaste" Me.mnuEditPaste.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.V), System.Windows.Forms.Keys) - Me.mnuEditPaste.Size = New System.Drawing.Size(366, 34) + Me.mnuEditPaste.Size = New System.Drawing.Size(270, 34) Me.mnuEditPaste.Tag = "Paste" Me.mnuEditPaste.Text = "Paste" ' - 'mnuPasteSpecial - ' - Me.mnuPasteSpecial.Enabled = False - Me.mnuPasteSpecial.Name = "mnuPasteSpecial" - Me.mnuPasteSpecial.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Alt) _ - Or System.Windows.Forms.Keys.V), System.Windows.Forms.Keys) - Me.mnuPasteSpecial.Size = New System.Drawing.Size(366, 34) - Me.mnuPasteSpecial.Tag = "Paste" - Me.mnuPasteSpecial.Text = "Paste New Columns" - Me.mnuPasteSpecial.Visible = False - ' - 'mnuEditPasteNewDataFrame + 'mnuEditPasteNew ' - Me.mnuEditPasteNewDataFrame.Name = "mnuEditPasteNewDataFrame" - Me.mnuEditPasteNewDataFrame.Size = New System.Drawing.Size(366, 34) - Me.mnuEditPasteNewDataFrame.Tag = "Paste" - Me.mnuEditPasteNewDataFrame.Text = "Paste New Data Frame" + Me.mnuEditPasteNew.Name = "mnuEditPasteNew" + Me.mnuEditPasteNew.Size = New System.Drawing.Size(270, 34) + Me.mnuEditPasteNew.Text = "Paste New" ' 'mnuEditWordwrap ' Me.mnuEditWordwrap.Name = "mnuEditWordwrap" - Me.mnuEditWordwrap.Size = New System.Drawing.Size(366, 34) + Me.mnuEditWordwrap.Size = New System.Drawing.Size(270, 34) Me.mnuEditWordwrap.Text = "Wordwrap" ' 'mnuEditSelectAll ' Me.mnuEditSelectAll.Name = "mnuEditSelectAll" Me.mnuEditSelectAll.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.A), System.Windows.Forms.Keys) - Me.mnuEditSelectAll.Size = New System.Drawing.Size(366, 34) + Me.mnuEditSelectAll.Size = New System.Drawing.Size(270, 34) Me.mnuEditSelectAll.Tag = "Select_All" Me.mnuEditSelectAll.Text = "Select All " ' 'ToolStripSeparator71 ' Me.ToolStripSeparator71.Name = "ToolStripSeparator71" - Me.ToolStripSeparator71.Size = New System.Drawing.Size(363, 6) + Me.ToolStripSeparator71.Size = New System.Drawing.Size(267, 6) ' 'mnuEditScript ' Me.mnuEditScript.Name = "mnuEditScript" - Me.mnuEditScript.Size = New System.Drawing.Size(366, 34) + Me.mnuEditScript.Size = New System.Drawing.Size(270, 34) Me.mnuEditScript.Text = "Script" ' 'stsStrip @@ -3231,7 +3206,6 @@ Partial Class frmMain Me.mnuBar.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow Me.mnuBar.Location = New System.Drawing.Point(0, 0) Me.mnuBar.Name = "mnuBar" - Me.mnuBar.Padding = New System.Windows.Forms.Padding(6, 2, 0, 2) Me.mnuBar.RenderMode = System.Windows.Forms.ToolStripRenderMode.System Me.mnuBar.ShowItemToolTips = True Me.mnuBar.Size = New System.Drawing.Size(1251, 33) @@ -4914,7 +4888,7 @@ Partial Class frmMain Me.splOverall.BackColor = System.Drawing.Color.LightGray Me.splOverall.Dock = System.Windows.Forms.DockStyle.Fill Me.splOverall.Location = New System.Drawing.Point(0, 72) - Me.splOverall.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.splOverall.Margin = New System.Windows.Forms.Padding(4) Me.splOverall.Name = "splOverall" Me.splOverall.Orientation = System.Windows.Forms.Orientation.Horizontal ' @@ -4937,7 +4911,7 @@ Partial Class frmMain Me.splExtraWindows.BackColor = System.Drawing.Color.LightGray Me.splExtraWindows.Dock = System.Windows.Forms.DockStyle.Fill Me.splExtraWindows.Location = New System.Drawing.Point(0, 0) - Me.splExtraWindows.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.splExtraWindows.Margin = New System.Windows.Forms.Padding(4) Me.splExtraWindows.Name = "splExtraWindows" ' 'splExtraWindows.Panel1 @@ -4959,7 +4933,7 @@ Partial Class frmMain Me.splMetadata.BackColor = System.Drawing.Color.LightGray Me.splMetadata.Dock = System.Windows.Forms.DockStyle.Fill Me.splMetadata.Location = New System.Drawing.Point(0, 0) - Me.splMetadata.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.splMetadata.Margin = New System.Windows.Forms.Padding(4) Me.splMetadata.Name = "splMetadata" ' 'splMetadata.Panel1 @@ -5016,7 +4990,7 @@ Partial Class frmMain Me.splDataOutput.BackColor = System.Drawing.Color.LightGray Me.splDataOutput.Dock = System.Windows.Forms.DockStyle.Fill Me.splDataOutput.Location = New System.Drawing.Point(0, 0) - Me.splDataOutput.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.splDataOutput.Margin = New System.Windows.Forms.Padding(4) Me.splDataOutput.Name = "splDataOutput" ' 'splDataOutput.Panel1 @@ -5104,7 +5078,7 @@ Partial Class frmMain Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.IsMdiContainer = True Me.MainMenuStrip = Me.mnuBar - Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.Margin = New System.Windows.Forms.Padding(4) Me.Name = "frmMain" Me.Text = "R-Instat .." Me.WindowState = System.Windows.Forms.FormWindowState.Maximized @@ -5170,7 +5144,6 @@ Partial Class frmMain Friend WithEvents mnuFIleExit As ToolStripMenuItem Friend WithEvents mnuEdit As ToolStripMenuItem Friend WithEvents mnuEditCopy As ToolStripMenuItem - Friend WithEvents mnuEditCopySpecial As ToolStripMenuItem Friend WithEvents mnuEditPaste As ToolStripMenuItem Friend WithEvents mnuEditSelectAll As ToolStripMenuItem Friend WithEvents mnuEditFind As ToolStripMenuItem @@ -5704,9 +5677,7 @@ Partial Class frmMain Friend WithEvents ToolStripSeparator70 As ToolStripSeparator Friend WithEvents mnuClimaticCheckDataCheckStationLocations As ToolStripMenuItem Friend WithEvents mnuClimaticFileImportfromClimateDataStore As ToolStripMenuItem - Friend WithEvents mnuEditPasteNewDataFrame As ToolStripMenuItem Friend WithEvents mnuTbLan As ToolStripButton - Friend WithEvents mnuPasteSpecial As ToolStripMenuItem Friend WithEvents mnuLastGraph As ToolStripSplitButton Friend WithEvents mnuRViewer As ToolStripMenuItem Friend WithEvents mnuploty As ToolStripMenuItem @@ -5786,4 +5757,5 @@ Partial Class frmMain Friend WithEvents mnuPrepareCheckDataPivotTable As ToolStripMenuItem Friend WithEvents ToolStripSeparator50 As ToolStripSeparator + Friend WithEvents mnuEditPasteNew As ToolStripMenuItem End Class diff --git a/instat/frmMain.vb b/instat/frmMain.vb index cfb72eaa9cf..b555cd7b9a5 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -2420,10 +2420,6 @@ Public Class frmMain dlgImportERA5Data.ShowDialog() End Sub - Private Sub mnuEditPasteNewDataFrame_Click(sender As Object, e As EventArgs) Handles mnuEditPasteNewDataFrame.Click - dlgPasteNewDataFrame.ShowDialog() - End Sub - Private Sub mnuTbLan_Click(sender As Object, e As EventArgs) Handles mnuTbLan.Click If strCurrLang <> "en-GB" Then strCurrLang = "en-GB" @@ -2449,6 +2445,22 @@ Public Class frmMain End If End Sub + Private Sub mnuEditPaste_Click(sender As Object, e As EventArgs) Handles mnuEditPaste.Click + If ctrActive.Equals(ucrDataViewer) Then + ucrDataViewer.PasteValuesToDataFrame() + ElseIf ctrActive.Equals(ucrColumnMeta) Then + 'todo + ElseIf ctrActive.Equals(ucrDataFrameMeta) Then + 'todo + ElseIf ctrActive.Equals(ucrScriptWindow) Then + ucrScriptWindow.PasteText() + End If + End Sub + + Private Sub mnuEditPasteNew_Click(sender As Object, e As EventArgs) Handles mnuEditPasteNew.Click + dlgPasteNewColumns.ShowDialog() + End Sub + Private Sub mnuEditScript_Click(sender As Object, e As EventArgs) Handles mnuEditScript.Click dlgScript.ShowDialog() End Sub @@ -2603,4 +2615,5 @@ Public Class frmMain Private Sub mnuToolsCheckForUpdates_Click(sender As Object, e As EventArgs) Handles mnuToolsCheckForUpdates.Click CheckForUpdates() End Sub + End Class diff --git a/instat/instat.vbproj b/instat/instat.vbproj index b850753f663..1d5045c78be 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -491,18 +491,6 @@ Form - - dlgPasteNewDataFrame.vb - - - Form - - - dlgPasteSpecial.vb - - - Form - dlgScript.vb @@ -3069,12 +3057,6 @@ dlgPasteNewColumns.vb - - dlgPasteNewDataFrame.vb - - - dlgPasteSpecial.vb - dlgRandomSplit.vb diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 1d2fdc62855..bd57034b5f9 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -635,9 +635,6 @@ DataSheet$set("public", "add_columns_to_data", function(col_name = "", col_data, use_col_name_as_prefix = TRUE } } - if(use_col_name_as_prefix && length(col_name) > 1) { - stop("Cannot use col_name as prefix when col_name is a vector.") - } if(length(col_name) != num_cols) { use_col_name_as_prefix = TRUE @@ -658,7 +655,7 @@ DataSheet$set("public", "add_columns_to_data", function(col_name = "", col_data, if(require_correct_length) stop("Length of new column must be divisible by the length of the data frame") else curr_col <- rep(curr_col, length.out = self$get_data_frame_length()) } - if(use_col_name_as_prefix) curr_col_name = self$get_next_default_column_name(col_name) + if(use_col_name_as_prefix) curr_col_name = self$get_next_default_column_name(col_name[[i]]) else curr_col_name = col_name[[i]] curr_col_name <- make.names(iconv(curr_col_name, to = "ASCII//TRANSLIT", sub = ".")) new_col_names <- c(new_col_names, curr_col_name) @@ -1019,23 +1016,45 @@ DataSheet$set("public", "replace_value_in_data", function(col_names, rows, old_v } ) +#reads passed clipboard data and saves it to selected data frame DataSheet$set("public", "paste_from_clipboard", function(col_names, start_row_pos = 1, first_clip_row_is_header = FALSE, clip_board_text) { - #reads data from clipboard and saves it to selected columns + #get the clipboard text contents as a data frame clip_tbl <- clipr::read_clip_tbl(x = clip_board_text, header = first_clip_row_is_header) + + #get the selected data frame current_tbl <- self$get_data_frame(use_current_filter = FALSE) + #check if copied data rows are more than current data rows + if( nrow(clip_tbl) > nrow(current_tbl) ){ + stop(paste("rows copied cannot be more than number of rows in the data frame.", + "Current data frame rows:", nrow(current_tbl), ". Copied rows:", nrow(clip_tbl)) ) + } + + + #if column names are missing then just add the clip data as new columns and quit function + if( missing(col_names) ){ + #append missing values if rows are less than the selected data frame. + #new column rows should be equal to existing column rows + if( nrow(clip_tbl) < nrow(current_tbl) ){ + empty_values_df <- data.frame(data = matrix(data = NA, nrow = ( nrow(current_tbl) - nrow(clip_tbl) ), ncol = ncol(clip_tbl) )) + names(empty_values_df) <- names(clip_tbl) + clip_tbl <- rbind(clip_tbl, empty_values_df) + } + new_col_names <- colnames(clip_tbl) + for(index in seq_along(new_col_names)){ + self$add_columns_to_data(col_name = new_col_names[index], col_data = clip_tbl[, index]) + } + return() + } + + #for existing column names #check if number of copied columns and selected columns are equal if(ncol(clip_tbl) != length(col_names)){ stop(paste("number of columns are not the same.", "Selected columns:", length(col_names), ". Copied columns:", ncol(clip_tbl)) ) } - #check if copied data rows are more than current data rows - if( nrow(clip_tbl) > nrow(current_tbl) ){ - stop(paste("rows copied cannot be more than number of rows in the data frame.", - "Current data frame rows:", nrow(current_tbl), ". Copied rows:", nrow(clip_tbl)) ) - } #check copied data integrity for(index in seq_along(col_names)){ diff --git a/instat/ucrDataView.Designer.vb b/instat/ucrDataView.Designer.vb index 7d6281e9dd9..4f7047f131e 100644 --- a/instat/ucrDataView.Designer.vb +++ b/instat/ucrDataView.Designer.vb @@ -49,7 +49,6 @@ Partial Class ucrDataView Me.ToolStripSeparator13 = New System.Windows.Forms.ToolStripSeparator() Me.mnuEditCell2 = New System.Windows.Forms.ToolStripMenuItem() Me.mnuDeleteCells2 = New System.Windows.Forms.ToolStripMenuItem() - Me.mnuPaste = New System.Windows.Forms.ToolStripMenuItem() Me.toolStripMenuItem2 = New System.Windows.Forms.ToolStripSeparator() Me.mnuConvertToFactor = New System.Windows.Forms.ToolStripMenuItem() Me.mnuCovertToOrderedFactors = New System.Windows.Forms.ToolStripMenuItem() @@ -75,8 +74,6 @@ Partial Class ucrDataView Me.ToolStripSeparator14 = New System.Windows.Forms.ToolStripSeparator() Me.mnuEditCell = New System.Windows.Forms.ToolStripMenuItem() Me.mnuDeleteCells = New System.Windows.Forms.ToolStripMenuItem() - Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator() - Me.mnuCellPasteRange = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator5 = New System.Windows.Forms.ToolStripSeparator() Me.mnuConvertToFact = New System.Windows.Forms.ToolStripMenuItem() Me.mnuConvertToOrderedFactor = New System.Windows.Forms.ToolStripMenuItem() @@ -166,9 +163,9 @@ Partial Class ucrDataView 'columnContextMenuStrip ' Me.columnContextMenuStrip.ImageScalingSize = New System.Drawing.Size(20, 20) - Me.columnContextMenuStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuColumnRename, Me.mnuDuplicateColumn, Me.mnuReorderColumns, Me.mnuInsertColsBefore, Me.mnuInsertColsAfter, Me.mnuDeleteCol, Me.ToolStripSeparator13, Me.mnuEditCell2, Me.mnuDeleteCells2, Me.mnuPaste, Me.toolStripMenuItem2, Me.mnuConvertToFactor, Me.mnuCovertToOrderedFactors, Me.mnuConvertText, Me.mnuConvertToLogical, Me.mnuConvertVariate, Me.ToolStripSeparator1, Me.mnuLevelsLabels, Me.toolStripMenuItem21, Me.mnuSort, Me.mnuColumnAddComment, Me.mnuColumnFilterRows, Me.mnuColumnContextColumnSelection, Me.mnuColumnContextRemoveCurrentColumnSelection, Me.mnuClearColumnFilter, Me.ToolStripSeparator8, Me.mnuHelp}) + Me.columnContextMenuStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuColumnRename, Me.mnuDuplicateColumn, Me.mnuReorderColumns, Me.mnuInsertColsBefore, Me.mnuInsertColsAfter, Me.mnuDeleteCol, Me.ToolStripSeparator13, Me.mnuEditCell2, Me.mnuDeleteCells2, Me.toolStripMenuItem2, Me.mnuConvertToFactor, Me.mnuCovertToOrderedFactors, Me.mnuConvertText, Me.mnuConvertToLogical, Me.mnuConvertVariate, Me.ToolStripSeparator1, Me.mnuLevelsLabels, Me.toolStripMenuItem21, Me.mnuSort, Me.mnuColumnAddComment, Me.mnuColumnFilterRows, Me.mnuColumnContextColumnSelection, Me.mnuColumnContextRemoveCurrentColumnSelection, Me.mnuClearColumnFilter, Me.ToolStripSeparator8, Me.mnuHelp}) Me.columnContextMenuStrip.Name = "columnContextMenuStrip" - Me.columnContextMenuStrip.Size = New System.Drawing.Size(215, 518) + Me.columnContextMenuStrip.Size = New System.Drawing.Size(215, 496) ' 'mnuColumnRename ' @@ -225,12 +222,6 @@ Partial Class ucrDataView Me.mnuDeleteCells2.Size = New System.Drawing.Size(214, 22) Me.mnuDeleteCells2.Text = "Delete Cell(s)" ' - 'mnuPaste - ' - Me.mnuPaste.Name = "mnuPaste" - Me.mnuPaste.Size = New System.Drawing.Size(214, 22) - Me.mnuPaste.Text = "Paste" - ' 'toolStripMenuItem2 ' Me.toolStripMenuItem2.Name = "toolStripMenuItem2" @@ -332,9 +323,9 @@ Partial Class ucrDataView 'cellContextMenuStrip ' Me.cellContextMenuStrip.ImageScalingSize = New System.Drawing.Size(20, 20) - Me.cellContextMenuStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuRenameColumn, Me.mnuDuplColumn, Me.mnuReorderColumn, Me.mnuDeleteCol2, Me.ToolStripSeparator14, Me.mnuEditCell, Me.mnuDeleteCells, Me.ToolStripSeparator3, Me.mnuCellPasteRange, Me.ToolStripSeparator5, Me.mnuConvertToFact, Me.mnuConvertToOrderedFactor, Me.mnuConvertToCharacter, Me.mnuConvertToLogic, Me.mnuConvertToNumeric, Me.ToolStripSeparator6, Me.mnuLabelsLevel, Me.ToolStripSeparator7, Me.mnuSorts, Me.mnuComment, Me.mnuFilterRows, Me.mnuCellContextColumnSelection, Me.mnuCellContextRemoveCurrentColumnSelection, Me.mnuRemoveCurrentFilters, Me.ToolStripSeparator9, Me.mnuHelp1}) + Me.cellContextMenuStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuRenameColumn, Me.mnuDuplColumn, Me.mnuReorderColumn, Me.mnuDeleteCol2, Me.ToolStripSeparator14, Me.mnuEditCell, Me.mnuDeleteCells, Me.ToolStripSeparator5, Me.mnuConvertToFact, Me.mnuConvertToOrderedFactor, Me.mnuConvertToCharacter, Me.mnuConvertToLogic, Me.mnuConvertToNumeric, Me.ToolStripSeparator6, Me.mnuLabelsLevel, Me.ToolStripSeparator7, Me.mnuSorts, Me.mnuComment, Me.mnuFilterRows, Me.mnuCellContextColumnSelection, Me.mnuCellContextRemoveCurrentColumnSelection, Me.mnuRemoveCurrentFilters, Me.ToolStripSeparator9, Me.mnuHelp1}) Me.cellContextMenuStrip.Name = "cellContextMenuStrip" - Me.cellContextMenuStrip.Size = New System.Drawing.Size(215, 480) + Me.cellContextMenuStrip.Size = New System.Drawing.Size(215, 452) ' 'mnuRenameColumn ' @@ -378,17 +369,6 @@ Partial Class ucrDataView Me.mnuDeleteCells.Size = New System.Drawing.Size(214, 22) Me.mnuDeleteCells.Text = "Delete Cell(s)" ' - 'ToolStripSeparator3 - ' - Me.ToolStripSeparator3.Name = "ToolStripSeparator3" - Me.ToolStripSeparator3.Size = New System.Drawing.Size(211, 6) - ' - 'mnuCellPasteRange - ' - Me.mnuCellPasteRange.Name = "mnuCellPasteRange" - Me.mnuCellPasteRange.Size = New System.Drawing.Size(214, 22) - Me.mnuCellPasteRange.Text = "Paste" - ' 'ToolStripSeparator5 ' Me.ToolStripSeparator5.Name = "ToolStripSeparator5" @@ -1093,7 +1073,6 @@ Partial Class ucrDataView Friend WithEvents mnuLevelsLabels As ToolStripMenuItem Friend WithEvents ToolStripSeparator1 As ToolStripSeparator Friend WithEvents mnuReorderColumns As ToolStripMenuItem - Friend WithEvents ToolStripSeparator3 As ToolStripSeparator Friend WithEvents mnuRenameColumn As ToolStripMenuItem Friend WithEvents mnuDuplColumn As ToolStripMenuItem Friend WithEvents mnuReorderColumn As ToolStripMenuItem @@ -1112,8 +1091,6 @@ Partial Class ucrDataView Friend WithEvents mnuComment As ToolStripMenuItem Friend WithEvents mnuColumnAddComment As ToolStripMenuItem Friend WithEvents mnuBottomAddComment As ToolStripMenuItem - Private WithEvents mnuPaste As ToolStripMenuItem - Friend WithEvents mnuCellPasteRange As ToolStripMenuItem Friend WithEvents TblPanPageDisplay As TableLayoutPanel Friend WithEvents lblColLast As Label Friend WithEvents lblRowBack As Label diff --git a/instat/ucrDataView.vb b/instat/ucrDataView.vb index 417be28f5bf..908a73a9fcd 100644 --- a/instat/ucrDataView.vb +++ b/instat/ucrDataView.vb @@ -65,7 +65,6 @@ Public Class ucrDataView mnuInsertColsBefore.Visible = False mnuInsertColsAfter.Visible = False - mnuPaste.Visible = False autoTranslate(Me) If RuntimeInformation.IsOSPlatform(OSPlatform.Linux) Then @@ -791,24 +790,10 @@ Public Class ucrDataView dlgAddComment.ShowDialog() End Sub - Private Sub mnuPaste_Click(sender As Object, e As EventArgs) Handles mnuPaste.Click - PasteValuesToDataFrame() - End Sub - - '''' - '''' event raised on menu toolstrip click - '''' paste data starting from selected cells - '''' - '''' - '''' - Private Sub mnuCellPasteRange_Click(sender As Object, e As EventArgs) Handles mnuCellPasteRange.Click - PasteValuesToDataFrame() - End Sub - ''' ''' pastes data from clipboard to data view ''' - Private Sub PasteValuesToDataFrame() + Public Sub PasteValuesToDataFrame() Dim strClipBoardText As String = My.Computer.Clipboard.GetText If String.IsNullOrEmpty(strClipBoardText) Then MsgBox("No data available for pasting.", MsgBoxStyle.Information, "No Data")