private void EditMI_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                {
                    DataRowView source   = row.DataBoundItem as DataRowView;
                    Argument    argument = (Argument)source.Row[0];

                    BuiltInType builtInType = TypeInfo.GetBuiltInType(argument.DataType, m_session.TypeTree);

                    object result = new EditComplexValueDlg().ShowDialog(
                        new TypeInfo(builtInType, argument.ValueRank),
                        argument.Name,
                        argument.Value,
                        "Edit Input Argument");

                    if (result != null)
                    {
                        argument.Value = result;
                        UpdateRow(source.Row, argument, new Variant(result), false);
                    }

                    break;
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Exemple #2
0
        private void BrowseBTN_Click(object sender, EventArgs e)
        {
            if (CurrentValueControl == null)
            {
                return;
            }

            object value = new EditComplexValueDlg().ShowDialog(
                m_value.TypeInfo,
                null,
                m_value.Value,
                "Edit Value");

            if (value == null)
            {
                return;
            }

            Value = new Variant(value);

            if (m_ValueChanged != null)
            {
                m_ValueChanged(this, e);
            }
        }
        private void EditValueMI_Click(object sender, EventArgs e)
        {
            try
            {
                // choose the first selected row as the templace.
                WriteValue nodeToWrite = null;

                foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                {
                    DataRowView source = row.DataBoundItem as DataRowView;
                    nodeToWrite = (WriteValue)source.Row[0];
                    break;
                }

                if (nodeToWrite != null)
                {
                    // prompt use to edit value.
                    object value = new EditComplexValueDlg().ShowDialog(
                        m_session,
                        nodeToWrite.NodeId,
                        nodeToWrite.AttributeId,
                        null,
                        nodeToWrite.Value.Value,
                        false,
                        "Edit Value");

                    if (value != null)
                    {
                        // update all selected rows with the new value.
                        foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                        {
                            DataRowView source = row.DataBoundItem as DataRowView;
                            nodeToWrite             = (WriteValue)source.Row[0];
                            nodeToWrite.Value.Value = value;
                            UpdateRow(source.Row, nodeToWrite);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
        private void ViewValueMI_Click(object sender, EventArgs e)
        {
            try
            {
                MonitoredItem monitoredItem = null;
                DataValue     value         = null;

                foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                {
                    DataRowView source = row.DataBoundItem as DataRowView;
                    monitoredItem = (MonitoredItem)source.Row[0];
                    value         = (DataValue)source.Row[11];
                    break;
                }

                if (monitoredItem == null)
                {
                    return;
                }

                m_EditComplexValueDlg     = new EditComplexValueDlg();
                m_EditComplexValueDlg.Tag = monitoredItem;

                m_EditComplexValueDlg.ShowDialog(
                    m_session,
                    monitoredItem.ResolvedNodeId,
                    monitoredItem.AttributeId,
                    null,
                    value.Value,
                    true,
                    "View Data Change");

                m_EditComplexValueDlg = null;
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
        private void FilterDV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex == -1)
                {
                    return;
                }

                DataRowView            source = FilterDV.Rows[e.RowIndex].DataBoundItem as DataRowView;
                FilterDeclarationField field  = (FilterDeclarationField)source.Row[0];

                if (e.ColumnIndex == 5)
                {
                    FilterOperator filterOperator = field.FilterOperator;

                    if (new SetFilterOperatorDlg().ShowDialog(ref filterOperator))
                    {
                        field.FilterEnabled = true;
                        source.Row[5]       = field.FilterEnabled;

                        field.FilterOperator = filterOperator;
                        source.Row[6]        = field.FilterOperator;
                    }

                    return;
                }

                if (e.ColumnIndex == 6)
                {
                    if (field.FilterOperator == FilterOperator.IsNull)
                    {
                        field.FilterValue = Variant.Null;
                        return;
                    }

                    InstanceDeclaration declaration = field.InstanceDeclaration;

                    object result = new EditComplexValueDlg().ShowDialog(
                        m_session,
                        declaration.DisplayName,
                        declaration.DataType,
                        declaration.ValueRank,
                        field.FilterValue.Value,
                        "Edit Filter Value");

                    if (result != null)
                    {
                        field.FilterEnabled = true;
                        source.Row[5]       = field.FilterEnabled;
                        source.Row[6]       = field.FilterOperator;

                        field.FilterValue = new Variant(result);
                        source.Row[7]     = field.FilterValue;
                    }

                    return;
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Exemple #6
0
        private void BrowseBTN_Click(object sender, EventArgs e)
        {
            if (CurrentValueControl == null)
            {
                return;
            }

            object value = new EditComplexValueDlg().ShowDialog(
                m_value.TypeInfo,
                null,
                m_value.Value,
                "Edit Value");
            
            if (value == null)
            {
                return;
            }

            Value = new Variant(value);

            if (m_ValueChanged != null)
            {
                m_ValueChanged(this, e);
            }
        }
        private void EditMI_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                {
                    DataRowView source = row.DataBoundItem as DataRowView;
                    Argument argument = (Argument)source.Row[0];

                    BuiltInType builtInType = TypeInfo.GetBuiltInType(argument.DataType, m_session.TypeTree);

                    object result = new EditComplexValueDlg().ShowDialog(
                        new TypeInfo(builtInType, argument.ValueRank),
                        argument.Name,
                        argument.Value,
                        "Edit Input Argument");

                    if (result != null)
                    {
                        argument.Value = result;
                        UpdateRow(source.Row, argument, new Variant(result), false);
                    }

                    break;
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
        private void ViewValueMI_Click(object sender, EventArgs e)
        {
            try
            {
                MonitoredItem monitoredItem = null;
                DataValue value = null;

                foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                {
                    DataRowView source = row.DataBoundItem as DataRowView;
                    monitoredItem = (MonitoredItem)source.Row[0];
                    value = (DataValue)source.Row[11];
                    break;
                }

                if (monitoredItem == null)
                {
                    return;
                }

                m_EditComplexValueDlg = new EditComplexValueDlg();
                m_EditComplexValueDlg.Tag = monitoredItem;
                    
                m_EditComplexValueDlg.ShowDialog(
                    m_session,
                    monitoredItem.ResolvedNodeId,
                    monitoredItem.AttributeId,
                    null,
                    value.Value,
                    true,
                    "View Data Change");

                m_EditComplexValueDlg = null;
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
        private void FilterDV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex == -1)
                {
                    return;
                }

                DataRowView source = FilterDV.Rows[e.RowIndex].DataBoundItem as DataRowView;
                FilterDeclarationField field = (FilterDeclarationField)source.Row[0];

                if (e.ColumnIndex == 5)
                {
                    FilterOperator filterOperator = field.FilterOperator;

                    if (new SetFilterOperatorDlg().ShowDialog(ref filterOperator))
                    {
                        field.FilterEnabled = true;
                        source.Row[5] = field.FilterEnabled;

                        field.FilterOperator = filterOperator;
                        source.Row[6] = field.FilterOperator;
                    }

                    return;
                }

                if (e.ColumnIndex == 6)
                {
                    if (field.FilterOperator == FilterOperator.IsNull)
                    {
                        field.FilterValue = Variant.Null;
                        return;
                    }

                    InstanceDeclaration declaration = field.InstanceDeclaration;

                    object result = new EditComplexValueDlg().ShowDialog(
                        m_session, 
                        declaration.DisplayName,
                        declaration.DataType, 
                        declaration.ValueRank, 
                        field.FilterValue.Value, 
                        "Edit Filter Value");

                    if (result != null)
                    {
                        field.FilterEnabled = true;
                        source.Row[5] = field.FilterEnabled;
                        source.Row[6] = field.FilterOperator;

                        field.FilterValue = new Variant(result);
                        source.Row[7] = field.FilterValue;
                    }

                    return;
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
        private void EditValueMI_Click(object sender, EventArgs e)
        {
            try
            {
                // choose the first selected row as the templace.
                WriteValue nodeToWrite = null;

                foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                {
                    DataRowView source = row.DataBoundItem as DataRowView;
                    nodeToWrite = (WriteValue)source.Row[0];
                    break;
                }

                if (nodeToWrite != null)
                {
                    // prompt use to edit value.
                    object value = new EditComplexValueDlg().ShowDialog(
                        m_session,
                        nodeToWrite.NodeId,
                        nodeToWrite.AttributeId,
                        null,
                        nodeToWrite.Value.Value,
                        false,
                        "Edit Value");

                    if (value != null)
                    {
                        // update all selected rows with the new value.
                        foreach (DataGridViewRow row in ResultsDV.SelectedRows)
                        {
                            DataRowView source = row.DataBoundItem as DataRowView;
                            nodeToWrite = (WriteValue)source.Row[0];
                            nodeToWrite.Value.Value = value;
                            UpdateRow(source.Row, nodeToWrite);
                        }
                    }
                }            
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }