Exemplo n.º 1
0
		/// <summary>
		/// Get an image.
		/// </summary>
		/// <param name="file"></param>
		/// <returns></returns>
		public static Image GetImage( string file )
		{
			Image ret = null;
			try
			{
				if( form == null )
					form = new NumberForm("");
				System.IO.Stream s =  
					form.GetType().Assembly.GetManifestResourceStream(file);
				if( s != null )
					ret = Image.FromStream(s);
			}
			catch(Exception e )
			{
				MessageBox.Show(e.Message);
			}
			return ret;
		}
Exemplo n.º 2
0
		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			string text  = "";
			string text2 = "";
			int textStart  = 0;
			int textLength = 0;
			bool splice = false;

			if( richTextBox1.SelectionLength > 0 )
			{
				text = richTextBox1.SelectedText;
				textStart = richTextBox1.SelectionStart;
				textLength = richTextBox1.SelectionLength;
				splice = true;
			}
			else if( richTextBox1.Text.Length > 0)
				text = richTextBox1.Text;

			NumberForm nf = new NumberForm(text);
			
			if( nf.ShowDialog() == DialogResult.OK )
			{
				text2 = nf.GetResult();
				if( text2 != null && text2 != string.Empty )
				{
					if( splice )
					{
						if( text2.EndsWith("\n") && richTextBox1.Text[textStart] == '\n' )
							text2 = text2.Substring(0, text2.Length -1 );

						string tmp = richTextBox1.Text.Substring(0, textStart);
						tmp += text2;
						tmp += richTextBox1.Text.Substring(textStart + textLength );
						SetText( tmp );
					}
					else
						SetText( text2 );
				}
			}
			nf.Dispose();
		}