コード例 #1
0
        private bool checkIECIdentifier(string value, SharedMemoryVariable shmVar)
        {
            if (!SharedMemoryVariableList.IsValidIECIdentifier(value))
            {
                MessageBox.Show("The entered name is not a valid IEC 61131 identifier.\n\nPlease enter a valid name.", "Validation Failed", MessageBoxButton.OK, MessageBoxImage.Information);

                ShmVarsEditor.boolHasInvalidValue = true;
                ShmVarsEditor.strNewValidValue    = ShmVarsEditor.GetUniqueVarName();
                shmVar.Name = ShmVarsEditor.strNewValidValue;
                return(false);
            }

            return(true);
        }
コード例 #2
0
        private bool checkUniqueIdentifier(string value, SharedMemoryVariable shmVar)
        {
            if (!SharedMemoryVariableList.IsUniqueIdentifier(value, shmVar))
            {
                MessageBox.Show("The entered name already exists as a shared memory variable.\n\nPlease enter a unique name.", "Validation Failed", MessageBoxButton.OK, MessageBoxImage.Information);

                ShmVarsEditor.boolHasInvalidValue = true;
                ShmVarsEditor.strNewValidValue    = ShmVarsEditor.GetUniqueVarName();
                shmVar.Name = ShmVarsEditor.strNewValidValue;
                return(false);
            }

            return(true);
        }
コード例 #3
0
        private void DeleteSelectedRows()
        {
            if (xref == null)
            {
                return;
            }

            if (ShmVarDataGrid.SelectedItems.Count > 0 && MessageBox.Show("Do you really want to delete all selected variables?", "ViGET V2.0", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
            {
                return;
            }

            foreach (var item in ShmVarDataGrid.SelectedItems)
            {
                SharedMemoryVariable shmVar = item as SharedMemoryVariable;
                if (shmVar.ConnectionCounter > 0)
                {
                    MessageBox.Show("At least one of the selected variables can not be deleted, because it is connected.\n\nNone of the selected variables will be deleted.", "Delete Not Possible");
                    return;
                }
            }

            int indexOfLastDeletedRow = -1;

            //remove all selected rows(shared memory variables)
            while (ShmVarDataGrid.SelectedItems.Count > 0)
            {
                indexOfLastDeletedRow = ShmVarDataGrid.SelectedIndex;
                xref.GetSharedMemoryManager().RemoveShmVar((ShmVarDataGrid.SelectedItem as SharedMemoryVariable).Name);
            }

            //first set focus
            ShmVarDataGrid.Focus();

            //set selected either the last row or the row below last deleted row
            ShmVarDataGrid.SelectedIndex = Math.Min(indexOfLastDeletedRow, ListOfShmVariables.Count - 1);

            //make the selected item visible
            if (ShmVarDataGrid.SelectedItem != null)
            {
                //then create a new cell info, with the item we wish to edit and the column number of the cell we want in edit mode
                DataGridCellInfo cellInfo = new DataGridCellInfo(ShmVarDataGrid.SelectedItem, ShmVarDataGrid.Columns[0]);
                //set the cell to be the active one
                ShmVarDataGrid.CurrentCell = cellInfo;
                //scroll the item into view
                ShmVarDataGrid.ScrollIntoView(ShmVarDataGrid.SelectedItem);
            }
        }