private void Reformat(CustomDialog dialog)
        {
            ITextEditor editor       = UttCodeEditor.GetActiveTextEditor();
            string      selectedText = editor.SelectedText;

            string[]      xmlLines     = FormatXml(GetSelectedString()).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            IDocumentLine documentLine = editor.Document.GetLineForOffset(editor.SelectionStart);
            string        lineText     = documentLine.Text;
            string        indentation  = lineText.Substring(0, lineText.Length - lineText.TrimStart().Length);

            StringBuilder formattedText = new StringBuilder();

            foreach (string line in xmlLines)
            {
                formattedText.AppendLine(indentation + "\"" + line.Replace("\"", "\\\"") + "\"");
            }

            formattedText.Remove(formattedText.Length - Environment.NewLine.Length, Environment.NewLine.Length);

            if (!selectedText.TrimStart().StartsWith("\""))
            {
                formattedText.Insert(0, "\"" + Environment.NewLine);
            }

            if (!selectedText.TrimEnd().EndsWith("\""))
            {
                formattedText.Append(Environment.NewLine + indentation + "\"");
            }


            DocumentUtilitites.FindNextWordStart(editor.Document, documentLine.Offset);

            editor.Document.Replace(editor.SelectionStart, editor.SelectionLength, formattedText.ToString());
            dialog.Close();
        }
Exemple #2
0
        private void Reformat(CustomDialog dialog)
        {
            ITextEditor editor       = UttCodeEditor.GetActiveTextEditor();
            string      selectedText = editor.SelectedText;

            string[]      xmlLines      = FormatXml(GetSelectedString()).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            StringBuilder formattedText = new StringBuilder();

            foreach (string line in xmlLines)
            {
                formattedText.AppendLine("\"" + line.Replace("\"", "\\\"") + "\"");
            }

            formattedText.Remove(formattedText.Length - Environment.NewLine.Length, Environment.NewLine.Length);

            if (!selectedText.StartsWith("\""))
            {
                formattedText.Insert(0, "\"" + Environment.NewLine);
            }

            if (!selectedText.EndsWith("\""))
            {
                formattedText.Append(Environment.NewLine + "\"");
            }

            editor.Document.Replace(editor.SelectionStart, editor.SelectionLength, formattedText.ToString());
            dialog.Close();
        }
 private void OnOkPressed(CustomDialog dialog)
 {
     CommandsSelectorViewModel viewModel = dialog.DataContext as CommandsSelectorViewModel;
       if (viewModel != null)
       {
     dialog.PersistenceData.SetValue<List<string>>("", UsedCommandsListKey, viewModel.GetUsedCommandsList());
       }
       dialog.Save();
       dialog.DialogResult = CustomDialogResult.Ok;
       dialog.Close();
 }
        private void OnOkPressed(CustomDialog dialog)
        {
            CommandsSelectorViewModel viewModel = dialog.DataContext as CommandsSelectorViewModel;

            if (viewModel != null)
            {
                dialog.PersistenceData.SetValue <List <string> >("", UsedCommandsListKey, viewModel.GetUsedCommandsList());
            }
            dialog.Save();
            dialog.DialogResult = CustomDialogResult.Ok;
            dialog.Close();
        }
        private void Reformat(CustomDialog dialog)
        {
            ITextEditor editor = UttCodeEditor.GetActiveTextEditor();
              string selectedText = editor.SelectedText;
              string[] xmlLines = FormatXml(GetSelectedString()).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
              StringBuilder formattedText = new StringBuilder();
              foreach (string line in xmlLines)
              {
            formattedText.AppendLine("\""+line.Replace("\"", "\\\"")+"\"");
              }

              formattedText.Remove(formattedText.Length - Environment.NewLine.Length, Environment.NewLine.Length);

              if (!selectedText.StartsWith("\""))
              {
            formattedText.Insert(0, "\"" + Environment.NewLine);
              }

              if (!selectedText.EndsWith("\""))
              {
            formattedText.Append(Environment.NewLine+"\"");
              }

              editor.Document.Replace(editor.SelectionStart, editor.SelectionLength, formattedText.ToString());
              dialog.Close();
        }
        private void Reformat(CustomDialog dialog)
        {
            ITextEditor editor = UttCodeEditor.GetActiveTextEditor();
              string selectedText = editor.SelectedText;
              string[] xmlLines = FormatXml(GetSelectedString()).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
              IDocumentLine documentLine = editor.Document.GetLineForOffset(editor.SelectionStart);
              string lineText = documentLine.Text;
              string indentation = lineText.Substring(0, lineText.Length - lineText.TrimStart().Length);

              StringBuilder formattedText = new StringBuilder();
              foreach (string line in xmlLines)
              {
            formattedText.AppendLine(indentation+"\""+line.Replace("\"", "\\\"")+"\"");
              }

              formattedText.Remove(formattedText.Length - Environment.NewLine.Length, Environment.NewLine.Length);

              if (!selectedText.TrimStart().StartsWith("\""))
              {
            formattedText.Insert(0, "\"" + Environment.NewLine);
              }

              if (!selectedText.TrimEnd().EndsWith("\""))
              {
            formattedText.Append(Environment.NewLine+indentation+"\"");
              }

              DocumentUtilitites.FindNextWordStart(editor.Document, documentLine.Offset);

              editor.Document.Replace(editor.SelectionStart, editor.SelectionLength, formattedText.ToString());
              dialog.Close();
        }