Exemple #1
0
 private string GetCellToolTip(DataGridViewCell aCell, SendToEditorForms eOutputForm, bool bIsLegacy)
 {
     if (aCell.Value != null)
     {
         char   ch = (char)aCell.Value;
         string str;
         if (bIsLegacy)
         {
             str = String.Format("char: {0}, dec: \"{1}\", hex: \"{2}\"",
                                 GetStringForEditorInsertion(ch, SendToEditorForms.eQuotedString),
                                 GetStringForEditorInsertion(ch, SendToEditorForms.eDecimal),
                                 GetStringForEditorInsertion(ch, SendToEditorForms.eHexadecimal));
         }
         else
         {
             str = String.Format("char: {0}, name: \"{1}\", value: \"{2}\"",
                                 GetStringForEditorInsertion(ch, SendToEditorForms.eQuotedString),
                                 GetStringForEditorInsertion(ch, SendToEditorForms.eUnicodeName),
                                 GetStringForEditorInsertion(ch, SendToEditorForms.eUnicodeValues));
         }
         return(str);
     }
     else
     {
         return(null);
     }
 }
Exemple #2
0
        private void OnCellMouseDown(MyDataGridView dataGridViewCharacters, ref Button btnZoom, Font font, TableLayoutPanel ZoomButtonParent,
                                     SendToEditorForms eOutputForm, bool bIsLegacy, DataGridViewCellMouseEventArgs e)
        {
            if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))
            {
                m_mbButtonDown = e.Button;

                DataGridViewCell aCell = dataGridViewCharacters.Rows[e.RowIndex].Cells[e.ColumnIndex];
                if (m_mbButtonDown == MouseButtons.Right)
                {
                    // simply selecting the cell will trigger the zoom button update
                    //  (but only if it's already activated)
                    if (btnZoom == null)
                    {
                        ShowZoomButton(ref btnZoom, font, ZoomButtonParent, eOutputForm, bIsLegacy, aCell);
                    }
                    else if (!btnZoom.Visible)
                    {
                        btnZoom.Show();
                    }

                    // either way, select the cell
                    aCell.Selected = true;
                }
            }
        }
Exemple #3
0
        private void OnSelectionChanged(DataGridView dataGridViewCharacters, ref Button btnZoom, Font font,
                                        TableLayoutPanel ZoomButtonParent, SendToEditorForms eOutputForm, bool bIsLegacy)
        {
            if (dataGridViewCharacters.SelectedCells.Count > 0)
            {
                DataGridViewCell aCell = dataGridViewCharacters.SelectedCells[0];
                this.toolStripStatusLabel.Text = GetCellToolTip(aCell, eOutputForm, bIsLegacy);

                if ((btnZoom != null) && btnZoom.Visible)
                {
                    ShowZoomButton(ref btnZoom, font, ZoomButtonParent, eOutputForm, bIsLegacy, aCell);
                }
            }
        }
Exemple #4
0
 private void OnCellMouseLeave(DataGridView dataGridViewCharacters, SendToEditorForms eOutputForm, DataGridViewCellEventArgs e)
 {
     if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))
     {
         object oValue = dataGridViewCharacters.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
         if ((m_mbButtonDown == MouseButtons.Left) && (oValue != null))
         {
             char   ch  = (char)dataGridViewCharacters.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
             string str = GetStringForEditorInsertion(ch, eOutputForm);
             DoDragDrop(str, DragDropEffects.Copy);
             m_mbButtonDown = MouseButtons.None;                      // so it doesn't leave us in a weird state
         }
     }
 }
Exemple #5
0
        private string GetStringForEditorInsertion(char ch, SendToEditorForms eOutputForm)
        {
            string str = null;

            switch (eOutputForm)
            {
            case SendToEditorForms.eDecimal:
                byte[] abyDec = CharToByteArr(ch, m_nCodePageLegacy);
                foreach (byte byDec in abyDec)
                {
                    str += String.Format("{0:D} ", (int)byDec);
                }
                str = str.Substring(0, str.Length - 1);
                break;

            case SendToEditorForms.eHexadecimal:
                byte[] abyHex = CharToByteArr(ch, m_nCodePageLegacy);
                foreach (byte byHex in abyHex)
                {
                    str += String.Format("0x{0:X2} ", (int)byHex);
                }
                str = str.Substring(0, str.Length - 1);
                break;

            case SendToEditorForms.eUnicodeValues:
                str = String.Format("U+{0:X4}", (int)ch);
                break;

            case SendToEditorForms.eQuotedString:
                str = String.Format("\"{0}\"", ch);
                break;

            case SendToEditorForms.eUnicodeName:
                str = Program.GetUnicodeName(ch);
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }

            return(str);
        }
Exemple #6
0
        private void ShowZoomButton(ref Button btnZoom, Font font, TableLayoutPanel ZoomButtonParent,
                                    SendToEditorForms eOutputForm, bool bIsLegacy, DataGridViewCell aCell)
        {
            if (aCell.Value == null)
            {
                return;
            }

            ZoomButtonParent.SuspendLayout();
            if (btnZoom == null)
            {
                btnZoom = new Button();
                Font fontLarge = Program.GetSafeFont(font.Name, font.SizeInPoints * 3);
                btnZoom.Font       = fontLarge;
                btnZoom.Anchor     = AnchorStyles.None;
                btnZoom.BackColor  = System.Drawing.SystemColors.Menu;
                btnZoom.MouseDown += new MouseEventHandler(btnZoom_MouseDown);
                btnZoom.Tag        = eOutputForm;
                ZoomButtonParent.Controls.Add(btnZoom, 2, 0);
                ZoomButtonParent.SetRowSpan(btnZoom, 2);
            }

            // initialize it with the space padded character and then get the preferred size
            //  (pad with a space on the left to correctly display 'zero forward offset' glyphs
            //  and on the right, so it's centered and looks nicer).
            btnZoom.Text = String.Format("{0}", aCell.Value.ToString());
            Size sz = btnZoom.GetPreferredSize(btnZoom.Size);

            btnZoom.Size = new Size(sz.Width, sz.Height);
            ZoomButtonParent.ResumeLayout();
            ZoomButtonParent.PerformLayout();

            // then fill it with the details from the clicked character
            string strTooltip      = aCell.ToolTipText;
            int    nIndexDelimiter = strTooltip.LastIndexOf(';');

            strTooltip = GetCellToolTip(aCell, eOutputForm, bIsLegacy) + "; Click to insert in map";
            toolTip.SetToolTip(btnZoom, strTooltip);
            return;
        }
Exemple #7
0
 private void SendToEditor(char ch, SendToEditorForms eOutputForm)
 {
     Program.AddStringToEditor(GetStringForEditorInsertion(ch, eOutputForm));
 }
		private void OnSelectionChanged(DataGridView dataGridViewCharacters, ref Button btnZoom, Font font,
			TableLayoutPanel ZoomButtonParent, SendToEditorForms eOutputForm, bool bIsLegacy)
		{
			if (dataGridViewCharacters.SelectedCells.Count > 0)
			{
				DataGridViewCell aCell = dataGridViewCharacters.SelectedCells[0];
				this.toolStripStatusLabel.Text = GetCellToolTip(aCell, eOutputForm, bIsLegacy);

				if ((btnZoom != null) && btnZoom.Visible)
					ShowZoomButton(ref btnZoom, font, ZoomButtonParent, eOutputForm, bIsLegacy, aCell);
			}
		}
		private string GetCellToolTip(DataGridViewCell aCell, SendToEditorForms eOutputForm, bool bIsLegacy)
		{
			if (aCell.Value != null)
			{
				char ch = (char)aCell.Value;
				string str;
				if (bIsLegacy)
				{
					str = String.Format("char: {0}, dec: \"{1}\", hex: \"{2}\"",
						GetStringForEditorInsertion(ch, SendToEditorForms.eQuotedString),
						GetStringForEditorInsertion(ch, SendToEditorForms.eDecimal),
						GetStringForEditorInsertion(ch, SendToEditorForms.eHexadecimal));
				}
				else
				{
					str = String.Format("char: {0}, name: \"{1}\", value: \"{2}\"",
						GetStringForEditorInsertion(ch, SendToEditorForms.eQuotedString),
						GetStringForEditorInsertion(ch, SendToEditorForms.eUnicodeName),
						GetStringForEditorInsertion(ch, SendToEditorForms.eUnicodeValues));
				}
				return str;
			}
			else
				return null;
		}
		private void SendToEditor(char ch, SendToEditorForms eOutputForm)
		{
			Program.AddStringToEditor(GetStringForEditorInsertion(ch, eOutputForm));
		}
		private string GetStringForEditorInsertion(char ch, SendToEditorForms eOutputForm)
		{
			string str = null;
			switch (eOutputForm)
			{
				case SendToEditorForms.eDecimal:
					byte[] abyDec = CharToByteArr(ch, m_nCodePageLegacy);
					foreach (byte byDec in abyDec)
						str += String.Format("{0:D} ", (int)byDec);
					str = str.Substring(0, str.Length - 1);
					break;

				case SendToEditorForms.eHexadecimal:
					byte[] abyHex = CharToByteArr(ch, m_nCodePageLegacy);
					foreach (byte byHex in abyHex)
						str += String.Format("0x{0:X2} ", (int)byHex);
					str = str.Substring(0, str.Length - 1);
					break;

				case SendToEditorForms.eUnicodeValues:
					str = String.Format("U+{0:X4}", (int)ch);
					break;

				case SendToEditorForms.eQuotedString:
					str = String.Format("\"{0}\"", ch);
					break;

				case SendToEditorForms.eUnicodeName:
					str = Program.GetUnicodeName(ch);
					break;

				default:
					System.Diagnostics.Debug.Assert(false);
					break;
			}

			return str;
		}
		private void ShowZoomButton(ref Button btnZoom, Font font, TableLayoutPanel ZoomButtonParent,
			SendToEditorForms eOutputForm, bool bIsLegacy, DataGridViewCell aCell)
		{
			if (aCell.Value == null)
				return;

			ZoomButtonParent.SuspendLayout();
			if (btnZoom == null)
			{
				btnZoom = new Button();
				Font fontLarge = Program.GetSafeFont(font.Name, font.SizeInPoints * 3);
				btnZoom.Font = fontLarge;
				btnZoom.Anchor = AnchorStyles.None;
				btnZoom.BackColor = System.Drawing.SystemColors.Menu;
				btnZoom.MouseDown += new MouseEventHandler(btnZoom_MouseDown);
				btnZoom.Tag = eOutputForm;
				ZoomButtonParent.Controls.Add(btnZoom, 2, 0);
				ZoomButtonParent.SetRowSpan(btnZoom, 2);
			}

			// initialize it with the space padded character and then get the preferred size
			//  (pad with a space on the left to correctly display 'zero forward offset' glyphs
			//  and on the right, so it's centered and looks nicer).
			btnZoom.Text = String.Format("{0}", aCell.Value.ToString());
			Size sz = btnZoom.GetPreferredSize(btnZoom.Size);
			btnZoom.Size = new Size(sz.Width, sz.Height);
			ZoomButtonParent.ResumeLayout();
			ZoomButtonParent.PerformLayout();

			// then fill it with the details from the clicked character
			string strTooltip = aCell.ToolTipText;
			int nIndexDelimiter = strTooltip.LastIndexOf(';');
			strTooltip = GetCellToolTip(aCell, eOutputForm, bIsLegacy) + "; Click to insert in map";
			toolTip.SetToolTip(btnZoom, strTooltip);
			return;
		}
		private void OnCellMouseLeave(DataGridView dataGridViewCharacters, SendToEditorForms eOutputForm, DataGridViewCellEventArgs e)
		{
			if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))
			{
				object oValue = dataGridViewCharacters.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
				if ((m_mbButtonDown == MouseButtons.Left) && (oValue != null))
				{
					char ch = (char)dataGridViewCharacters.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
					string str = GetStringForEditorInsertion(ch, eOutputForm);
					DoDragDrop(str, DragDropEffects.Copy);
					m_mbButtonDown = MouseButtons.None;  // so it doesn't leave us in a weird state
				}
			}
		}
		private void OnCellMouseDown(MyDataGridView dataGridViewCharacters, ref Button btnZoom, Font font, TableLayoutPanel ZoomButtonParent,
			SendToEditorForms eOutputForm, bool bIsLegacy, DataGridViewCellMouseEventArgs e)
		{
			if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))
			{
				m_mbButtonDown = e.Button;

				DataGridViewCell aCell = dataGridViewCharacters.Rows[e.RowIndex].Cells[e.ColumnIndex];
				if (m_mbButtonDown == MouseButtons.Right)
				{
					// simply selecting the cell will trigger the zoom button update
					//  (but only if it's already activated)
					if (btnZoom == null)
						ShowZoomButton(ref btnZoom, font, ZoomButtonParent, eOutputForm, bIsLegacy, aCell);
					else if (!btnZoom.Visible)
						btnZoom.Show();

					// either way, select the cell
					aCell.Selected = true;
				}
			}
		}