Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            saveFile.FileName = "";

            TextBoxFormat format = GetTextBoxFormat(txtStructure);

            switch (format)
            {
            case TextBoxFormat.Json:
                saveFile.Filter = "JSON Molecule Files (*.json)|*.json|All Files (*.*)|*.*";
                break;

            case TextBoxFormat.Cml:
                saveFile.Filter = "CML Molecule Files (*.cml)|*.cml|All Files (*.*)|*.*";
                break;

            case TextBoxFormat.MolFile:
                saveFile.Filter = "MDL Molecule Files (*.mol)|*.mol|All Files (*.*)|*.*";
                break;

            default:
                saveFile.Filter = "All Files (*.*)|*.*";
                break;
            }

            DialogResult result = saveFile.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.File.WriteAllText(saveFile.FileName, txtStructure.Text);
            }
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            tbFormat = new TextBoxFormat(this.textBox1, 10);
            this.notifyIcon1.BalloonTipText = "Api Start On " + Config.Get().ApiHost;
            this.notifyIcon1.ShowBalloonTip(5);

            this.tbFormat.WriteLine("Api Start On " + Config.Get().ApiHost);
        }
Beispiel #3
0
 private void method_75(IDocument A_0)
 {
     base.m_charFormat = new Spire.Doc.Formatting.CharacterFormat(A_0);
     base.m_charFormat.method_0(this);
     this.m_txbxFormat = new TextBoxFormat(this);
     this.m_txbxFormat.method_0(this);
     this.m_textBody      = new Spire.Doc.Body(base.Document, this);
     base.InternerTextbox = this;
 }
Beispiel #4
0
 internal override void Close()
 {
     base.Close();
     if (this.m_textBody != null)
     {
         this.m_textBody.method_28();
         this.m_textBody = null;
     }
     this.m_txbxFormat = null;
     if (this.table_0 != null)
     {
         this.table_0.Close();
         this.table_0 = null;
     }
 }
Beispiel #5
0
        private void btnConvertUsingBabel_Click(object sender, EventArgs e)
        {
            TextBoxFormat format = GetTextBoxFormat(txtStructure);

            switch (format)
            {
            case TextBoxFormat.Cml:
                txtStructure.Text = ConvertUsingOpenBabel(txtStructure.Text, "cml", "mol");
                break;

            case TextBoxFormat.MolFile:
                txtStructure.Text = ConvertUsingOpenBabel(txtStructure.Text, "mol", "cml");
                break;
            }
            EnableButtons();
        }
Beispiel #6
0
        private TextBoxFormat GetTextBoxFormat(TextBox p_TextBox)
        {
            TextBoxFormat result = TextBoxFormat.Unknown;
            string        temp   = p_TextBox.Text;

            if (temp.Contains("M  END"))
            {
                result = TextBoxFormat.MolFile;
            }
            if (temp.StartsWith("{"))
            {
                result = TextBoxFormat.Json;
            }
            if (temp.StartsWith("<"))
            {
                result = TextBoxFormat.Cml;
            }
            return(result);
        }
Beispiel #7
0
        private void EnableButtons()
        {
            TextBoxFormat format = GetTextBoxFormat(txtStructure);

            switch (format)
            {
            case TextBoxFormat.Json:
                btnConvertModel.Enabled = true;
                btnSend.Enabled         = true;
                break;

            case TextBoxFormat.MolFile:
                btnConvertModel.Enabled = true;
                btnSend.Enabled         = true;
                break;

            case TextBoxFormat.Cml:
                btnConvertModel.Enabled = true;
                btnSend.Enabled         = true;
                break;
            }
        }
Beispiel #8
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            string molecule = txtStructure.Text;

            molecule = molecule.Replace("\r", "");
            TextBoxFormat format = GetTextBoxFormat(txtStructure);

            switch (format)
            {
            case TextBoxFormat.MolFile:
                ExecuteJavaScript("SetMolFile", molecule, nudBondLength.Value);
                break;

            case TextBoxFormat.Cml:
                ExecuteJavaScript("SetCmlFile", molecule, nudBondLength.Value);
                break;

            case TextBoxFormat.Json:
                ExecuteJavaScript("SetJSON", molecule, nudBondLength.Value);
                break;
            }
        }
Beispiel #9
0
        private void btnConvertModel_Click(object sender, EventArgs e)
        {
            TextBoxFormat format = GetTextBoxFormat(txtStructure);

            switch (format)
            {
            case TextBoxFormat.Json:
                JSONConverter converter1 = new JSONConverter();
                Model         model1     = converter1.Import((object)txtStructure.Text);
                model1.RebuildMolecules();
                model1.Relabel();
                model1.CustomXmlPartGuid = Guid.NewGuid().ToString("N");
                CMLConverter converter2 = new CMLConverter();
                txtStructure.Text = converter2.Export(model1);
                break;

            case TextBoxFormat.Cml:
                CMLConverter converter3 = new CMLConverter();
                Model        model2     = converter3.Import((object)txtStructure.Text);
                model2.RebuildMolecules();
                model2.Relabel();
                JSONConverter converter4 = new JSONConverter();
                txtStructure.Text = converter4.Export(model2);
                break;

            case TextBoxFormat.MolFile:
                SdFileConverter converter5 = new SdFileConverter();
                Model           model3     = converter5.Import((object)txtStructure.Text);
                model3.RebuildMolecules();
                model3.Relabel();
                CMLConverter converter6 = new CMLConverter();
                txtStructure.Text = converter6.Export(model3);
                break;
            }

            EnableButtons();
        }
		//-------------------------------------------------------------------------------------
		#region << Static Methods >>
		/// <summary>
		/// Отображает контрол.
		/// </summary>
		/// <param name="parent">Родительский контрол, относительно которого эмулируется модальность.</param>
		/// <param name="caption">Текст заголовка контрола.</param>
		/// <param name="image">Изображение заголовка контрола.</param>
		/// <param name="text1">Заголовок первого поля.</param>
		/// <param name="text2">Заголовок второго поля.</param>
		/// <param name="value1">Объект, содержащий значение ввода первого поля.</param>
		/// <param name="value2">Объект, содержащий значение ввода второго поля.</param>
		/// <param name="format">Формат данных ввода.</param>
		/// <param name="formatException">Строка символов исключений формата ввода.</param>
		/// <returns>DialogResult.OK или DialogResult.Cancel</returns>
		public static DialogResult Show(Control parent, string caption, Image image, string text1, string text2,
								 ref string value1, ref string value2, TextBoxFormat format, string formatException)
		{
			SimModalDualInputBox box = new SimModalDualInputBox();
			box.CaptionText = caption;
			box.CaptionImage = image;
			box.Text1 = text1;
			box.Text2 = text2;
			box.Value1 = value1;
			box.Value2 = value2;
			box.ValueFormat = format;
			box.ValueFormatException = formatException;
			box.Show(parent);
			while (box.result == DialogResult.None && box.Visible)
			{
				if (box.IsDisposed || parent.IsDisposed || box.FindForm() == null)
					break;
				Application.DoEvents();
				Thread.Sleep(50);
			}
			if (box.result == DialogResult.OK)
			{
				value1 = box.Value1;
				value2 = box.Value2;
			}
			return box.result == DialogResult.None ? DialogResult.Cancel : box.result;
		}
Beispiel #11
0
  //-------------------------------------------------------------------------------------
  /// <summary>
  /// Отображает контрол во всплывающем контроле.
  /// </summary>
  /// <param name="screenPoint">Положение контрола в оконных координатах.</param>
  /// <param name="caption">Текст метки</param>
  /// <param name="value">Значение ввода</param>
  /// <param name="twoLines">Определяет отображение в две строки.</param>
  /// <param name="format">Формат ввода</param>
  /// <param name="formatException">Строка символов исключений формата.</param>
  /// <param name="width">Ширина</param>
  /// <returns></returns>
  public static SimQuickEdit ShowPopup(Point screenPoint, string caption, string value, bool twoLines,
                                             TextBoxFormat format = TextBoxFormat.NotSet, string formatException = "",
                                             int width = 170)
  {
   SimQuickEdit c = new SimQuickEdit();
   c.Caption = caption;
   c.Value = value;
   c.TwoLines = twoLines;
   c.Format = format;
   c.FormatExceptions = formatException;
   c.ctrl.Width = width;

   c.Show(screenPoint);
   return c;
  }
Beispiel #12
0
		//-------------------------------------------------------------------------------------
		#region << Static Methods >>
		/// <summary>
		/// Отображает контрол.
		/// </summary>
		/// <param name="parent">Родительский контрол, относительно которого эмулируется модальность.</param>
		/// <param name="caption">Текст заголовка контрола.</param>
		/// <param name="image">Изображение заголовка контрола.</param>
		/// <param name="text">Основной текст контрола.</param>
		/// <param name="value">Объект, содержащий значение ввода.</param>
		/// <param name="format">Формат данных ввода.</param>
		/// <param name="formatException">Строка символов исключений формата ввода.</param>
		/// <returns>DialogResult.OK или DialogResult.Cancel</returns>
		public static DialogResult Show(Control parent, ref string value,
										string caption = "Ввод значения",
										string text = "Введите новое значение:",
										Image image = null,
										TextBoxFormat format = TextBoxFormat.NotSet,
										string formatException = "")
		{
			SimModalInputBox box = new SimModalInputBox();
			box.CaptionText = caption;
			box.CaptionImage = image;
			box.Text = text;
			box.Value = value;
			box.ValueFormat = format;
			box.ValueFormatException = formatException;
			box.Show(parent);
			while (box.result == DialogResult.None && box.Visible)
			{
				if (box.IsDisposed || parent.IsDisposed || box.FindForm() == null)
					break;
				Application.DoEvents();
				Thread.Sleep(50);
			}
			if (box.result == DialogResult.OK)
				value = box.Value;
			return box.result == DialogResult.None ? DialogResult.Cancel : box.result;
		}