Esempio n. 1
0
        protected bool AddManualXPathExpression(string strExistingXPath)
        {
            XPathFilterForm dlg = new XPathFilterForm(strExistingXPath);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strXPath = dlg.FilterExpression;
                Program.AddRecentXPathExpression(strXPath);
                try
                {
                    XPathNodeIterator xpIterator = GetIterator(ref strXPath, false);
                    AddRow(strXPath, xpIterator);
                    return(true);
                }
                catch (ApplicationException ex)
                {
                    // we throw this to cancel
                    if (ex.Message != cstrCaption)
                    {
                        MessageBox.Show(ex.Message, cstrCaption);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, cstrCaption);
                }
            }

            return(false);
        }
Esempio n. 2
0
        private void radioButtonManuallyEntered_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonManuallyEntered.Checked)
            {
                XPathFilterForm dlg = new XPathFilterForm(FilterXPath);
                dlg.Text = "Enter XPath filter expression";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    FilterXPath = dlg.FilterExpression;
                }

                checkedListBox.SelectedIndex = -1;
                checkedListBox.Enabled       = false;
            }
        }
        private void dataGridViewConverterMapping_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            int nColumnIndex = e.ColumnIndex;

            // if the user clicks on the header... that doesn't work
            if (((e.RowIndex < 0) || (e.RowIndex > dataGridViewConverterMapping.Rows.Count)) ||
                ((nColumnIndex < cnXmlPathsColumn) || (nColumnIndex > cnEncConverterColumn)))
            {
                return;
            }

            DataGridViewRow        theRow     = this.dataGridViewConverterMapping.Rows[e.RowIndex];
            string                 strXmlPath = (string)theRow.Cells[cnXmlPathsColumn].Value;
            DataGridViewCell       theCell    = theRow.Cells[e.ColumnIndex];
            DirectableEncConverter aEC        = null;
            XPathNodeIterator      xpIterator = null;

            switch (nColumnIndex)
            {
            case cnXmlPathsColumn:
                if (e.Button == MouseButtons.Right)
                {
                    XPathFilterForm dlg = new XPathFilterForm(strXmlPath);
                    if ((dlg.ShowDialog() == DialogResult.OK) && (strXmlPath != dlg.FilterExpression))
                    {
                        strXmlPath = dlg.FilterExpression;
                        UpdateConverterCellValue(theRow.Cells[cnEncConverterColumn],
                                                 (IsConverterDefined(strXmlPath)) ? (DirectableEncConverter)m_mapEncConverters[strXmlPath]
                                    : (DefaultConverterDefined) ? m_aEcDefault : null);

                        theCell.Value = strXmlPath;
                        Program.AddRecentXPathExpression(strXmlPath);
                        try
                        {
                            xpIterator = GetIterator(ref strXmlPath, false);
                            theRow.Tag = xpIterator;
                            UpdateSampleValue(xpIterator, theRow);
                        }
                        catch (ApplicationException ex)
                        {
                            // we throw this to cancel
                            if (ex.Message != cstrCaption)
                            {
                                MessageBox.Show(ex.Message, cstrCaption);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, cstrCaption);
                        }
                    }
                }
                break;

            case cnExampleDataColumn:
                xpIterator = (XPathNodeIterator)theRow.Tag;
                UpdateSampleValue(xpIterator, theRow);
                break;

            case cnExampleOutputColumn:
                break;

            case cnEncConverterColumn:
                string strExampleData = (string)theRow.Cells[cnExampleDataColumn].Value;

                if (e.Button == MouseButtons.Right)
                {
                    aEC = m_aECLast;
                    if ((m_aECLast == null) && IsConverterDefined(strXmlPath))
                    {
                        m_mapEncConverters.Remove(strXmlPath);
                    }
                }
                else
                {
                    EncConverters aECs = GetEncConverters;
                    if (aECs != null)
                    {
                        IEncConverter aIEC = aECs.AutoSelectWithData(strExampleData, null, ConvType.Unknown, "Choose Converter");
                        if (aIEC != null)
                        {
                            aEC = new DirectableEncConverter(aIEC);
                        }
                        else
                        {
                            CheckForFixedValue(theRow);
                            return;
                        }
                    }
                }

                if (aEC != null)
                {
                    if (IsConverterDefined(strXmlPath))
                    {
                        m_mapEncConverters.Remove(strXmlPath);
                    }
                    DefineConverter(strXmlPath, aEC);
                }

                UpdateExampleDataColumns(theRow, strExampleData);
                UpdateConverterCellValue(theCell, aEC);
                m_aECLast = aEC;
                break;
            }
        }
Esempio n. 4
0
		private void radioButtonManuallyEntered_CheckedChanged(object sender, EventArgs e)
		{
			if (radioButtonManuallyEntered.Checked)
			{
				XPathFilterForm dlg = new XPathFilterForm(FilterXPath);
				dlg.Text = "Enter XPath filter expression";
				if (dlg.ShowDialog() == DialogResult.OK)
				{
					FilterXPath = dlg.FilterExpression;
				}

				checkedListBox.SelectedIndex = -1;
				checkedListBox.Enabled = false;
			}
		}
Esempio n. 5
0
		private void dataGridViewConverterMapping_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
		{
			int nColumnIndex = e.ColumnIndex;
			// if the user clicks on the header... that doesn't work
			if (((e.RowIndex < 0) || (e.RowIndex > dataGridViewConverterMapping.Rows.Count))
				|| ((nColumnIndex < cnXmlPathsColumn) || (nColumnIndex > cnEncConverterColumn)))
				return;

			DataGridViewRow theRow = this.dataGridViewConverterMapping.Rows[e.RowIndex];
			string strXmlPath = (string)theRow.Cells[cnXmlPathsColumn].Value;
			DataGridViewCell theCell = theRow.Cells[e.ColumnIndex];
			DirectableEncConverter aEC = null;
			XPathNodeIterator xpIterator = null;
			switch (nColumnIndex)
			{
				case cnXmlPathsColumn:
					if (e.Button == MouseButtons.Right)
					{
						XPathFilterForm dlg = new XPathFilterForm(strXmlPath);
						if ((dlg.ShowDialog() == DialogResult.OK) && (strXmlPath != dlg.FilterExpression))
						{
							strXmlPath = dlg.FilterExpression;
							UpdateConverterCellValue(theRow.Cells[cnEncConverterColumn],
								(IsConverterDefined(strXmlPath)) ? (DirectableEncConverter)m_mapEncConverters[strXmlPath]
									: (DefaultConverterDefined) ? m_aEcDefault : null);

							theCell.Value = strXmlPath;
							Program.AddRecentXPathExpression(strXmlPath);
							try
							{
								xpIterator = GetIterator(ref strXmlPath, false);
								theRow.Tag = xpIterator;
								UpdateSampleValue(xpIterator, theRow);
							}
							catch (ApplicationException ex)
							{
								// we throw this to cancel
								if (ex.Message != cstrCaption)
									MessageBox.Show(ex.Message, cstrCaption);
							}
							catch (Exception ex)
							{
								MessageBox.Show(ex.Message, cstrCaption);
							}
						}
					}
					break;

				case cnExampleDataColumn:
					xpIterator = (XPathNodeIterator)theRow.Tag;
					UpdateSampleValue(xpIterator, theRow);
					break;

				case cnExampleOutputColumn:
					break;

				case cnEncConverterColumn:
					string strExampleData = (string)theRow.Cells[cnExampleDataColumn].Value;

					if (e.Button == MouseButtons.Right)
					{
						aEC = m_aECLast;
						if ((m_aECLast == null) && IsConverterDefined(strXmlPath))
							m_mapEncConverters.Remove(strXmlPath);
					}
					else
					{
						EncConverters aECs = GetEncConverters;
						if (aECs != null)
						{
							IEncConverter aIEC = aECs.AutoSelectWithData(strExampleData, null, ConvType.Unknown, "Choose Converter");
							if (aIEC != null)
								aEC = new DirectableEncConverter(aIEC);
							else
							{
								CheckForFixedValue(theRow);
								return;
							}
						}
					}

					if (aEC != null)
					{
						if (IsConverterDefined(strXmlPath))
							m_mapEncConverters.Remove(strXmlPath);
						DefineConverter(strXmlPath, aEC);
					}

					UpdateExampleDataColumns(theRow, strExampleData);
					UpdateConverterCellValue(theCell, aEC);
					m_aECLast = aEC;
					break;
			}
		}
Esempio n. 6
0
		protected bool AddManualXPathExpression(string strExistingXPath)
		{
			XPathFilterForm dlg = new XPathFilterForm(strExistingXPath);
			if (dlg.ShowDialog() == DialogResult.OK)
			{
				string strXPath = dlg.FilterExpression;
				Program.AddRecentXPathExpression(strXPath);
				try
				{
					XPathNodeIterator xpIterator = GetIterator(ref strXPath, false);
					AddRow(strXPath, xpIterator);
					return true;
				}
				catch (ApplicationException ex)
				{
					// we throw this to cancel
					if (ex.Message != cstrCaption)
						MessageBox.Show(ex.Message, cstrCaption);
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message, cstrCaption);
				}
			}

			return false;
		}