Exemplo n.º 1
0
    public async Task PerformDiff(string baseName, Func<Stream, Task> baseWriter
      , string compareName, Func<Stream, Task> compareWriter)
    {
      while (string.IsNullOrEmpty(this.DiffToolCommand)
        || this.DiffToolCommand.IndexOf("$(base)", StringComparison.OrdinalIgnoreCase) < 0
        || this.DiffToolCommand.IndexOf("$(compare)", StringComparison.OrdinalIgnoreCase) < 0)
      {
        using (var dialog = new Dialog.SettingsDialog())
        {
          dialog.Filter.Add(s => s.DiffToolCommand);
          dialog.DataSource = this;
          dialog.Message = string.IsNullOrWhiteSpace(this.DiffToolCommand)
            ? "Please specify a diff command. Use the macros '$(base)' and '$(compare)' to specify where these paths should be placed."
            : "The macros '$(base)' and/or '$(compare)' are missing from the diff command; please add them";
          if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            return;
          this.Save();
        }
      }

      var basePath = WriteTempFile(baseName, baseWriter);
      var comparePath = WriteTempFile(compareName, compareWriter);

      var cmd = GetFilePathAndArguments(this.DiffToolCommand
        .Replace("$(base)", "\"" + (await basePath) + "\"", StringComparison.OrdinalIgnoreCase)
        .Replace("$(compare)", "\"" + (await comparePath) + "\"", StringComparison.OrdinalIgnoreCase));
      Process.Start(cmd.Item1, cmd.Item2);
    }
Exemplo n.º 2
0
    public string PromptMergeTool()
    {
      while (string.IsNullOrEmpty(this.MergeToolCommand)
        || this.MergeToolCommand.IndexOf("$(base)", StringComparison.OrdinalIgnoreCase) < 0
        || this.MergeToolCommand.IndexOf("$(local)", StringComparison.OrdinalIgnoreCase) < 0
        || this.MergeToolCommand.IndexOf("$(remote)", StringComparison.OrdinalIgnoreCase) < 0
        || this.MergeToolCommand.IndexOf("$(merge)", StringComparison.OrdinalIgnoreCase) < 0)
      {
        using (var dialog = new Dialog.SettingsDialog())
        {
          dialog.Filter.Add(s => s.MergeToolCommand);
          dialog.DataSource = this;
          dialog.Message = string.IsNullOrWhiteSpace(this.MergeToolCommand)
            ? "Please specify a merge command. Use the macros '$(base)', '$(local)', '$(remote)' and '$(merge)' to specify where these paths should be placed."
            : "The macros '$(base)', '$(local)', '$(remote)' and/or '$(merge)' are missing from the merge command; please add them";
          if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            return null;
          this.Save();
          //Properties.Settings.Default.MergeToolCommand = this.MergeToolCommand;

        }
      }
      return this.MergeToolCommand;
    }
Exemplo n.º 3
0
    public EditorWindow() : base()
    {
      InitializeComponent();

      this.TitleLabel = lblTitle;
      this.MaximizeLabel = lblMaximize;
      this.MinimizeLabel = lblMinimize;
      this.CloseLabel = lblClose;
      this.LeftBorderPanel = pnlLeft;
      this.TopLeftCornerPanel = pnlTopLeft;
      this.TopLeftPanel = pnlLeftTop;
      this.TopBorderPanel = pnlTop;
      this.TopRightCornerPanel = pnlTopRight;
      this.TopRightPanel = pnlRightTop;
      this.RightBorderPanel = pnlRight;
      this.BottomRightCornerPanel = pnlBottomRight;
      this.BottomBorderPanel = pnlBottom;
      this.BottomLeftCornerPanel = pnlBottomLeft;
      this.InitializeTheme();

      InitializeDpi();

      menuStrip.Renderer = new SimpleToolstripRenderer() { BaseColor = Color.White };
      lblConnection.Font = FontAwesome.Font;
      lblConnection.Text = FontAwesome.Fa_cloud.ToString();
      lblSoapAction.Font = FontAwesome.Font;
      lblSoapAction.Text = FontAwesome.Fa_bolt.ToString();
      picLogo.Image = Properties.Resources.logo_black;
      btnPanelToggle.BackColor = Color.White;
      picLogo.MouseDown += SystemLabel_MouseDown;
      picLogo.MouseUp += SystemLabel_MouseUp;

      this.KeyPreview = true;
      this.PreferredMode = OutputType.Any;

      _uid = GetUid();
      var assy = Assembly.GetExecutingAssembly().GetName().Version;
      this.lblVersion.Text = "v" + assy.ToString();

      tbcOutputView.TabsVisible = false;

      btnSoapAction.Visible = false;
      lblSoapAction.Visible = false;
      exploreButton.Visible = false;
      btnSubmit.Visible = false;

      treeItems.CanExpandGetter = m => ((IEditorTreeNode)m).HasChildren;
      treeItems.ChildrenGetter = m => ((IEditorTreeNode)m).GetChildren();
      colName.ImageGetter = m => ((IEditorTreeNode)m).Image.Key;

      foreach (var icon in Icons.All)
      {
        treeItems.SmallImageList.Images.Add(icon.Key, icon.Gdi);
      }

      _clock.Interval = 250;
      _clock.Tick += _clock_Tick;
      _panelCollapsed = Properties.Settings.Default.EditorWindowPanelCollapsed;
      UpdatePanelCollapsed();

      _linkGenerator = new Editor.AmlLinkElementGenerator();
      _linkGenerator.AmlLinkClicked += _linkGenerator_AmlLinkClicked;

      tbcOutputView.SelectedTab = pgTools;

      inputEditor.SelectionChanged += inputEditor_SelectionChanged;
      inputEditor.FindAllAction = res => SetResult(res, 0);
      inputEditor.BindToolStripItem(mniCut, System.Windows.Input.ApplicationCommands.Cut);
      inputEditor.BindToolStripItem(mniCopy, System.Windows.Input.ApplicationCommands.Copy);
      inputEditor.BindToolStripItem(mniPaste, System.Windows.Input.ApplicationCommands.Paste);
      inputEditor.BindToolStripItem(mniUndo, System.Windows.Input.ApplicationCommands.Undo);
      inputEditor.BindToolStripItem(mniRedo, System.Windows.Input.ApplicationCommands.Redo);

      UpdateTitle(null);

      if (_recentDocs.Count < 1 && !string.IsNullOrEmpty(Properties.Settings.Default.RecentDocument))
      {
        try
        {
          lock (_lock)
          {
            _recentDocs.RaiseListChangedEvents = false;
            foreach (var path in (Properties.Settings.Default.RecentDocument ?? "").Split('|').Where(d => !string.IsNullOrEmpty(d)))
            {
              _recentDocs.Add(path);
            }
          }
        }
        finally
        {
          _recentDocs.RaiseListChangedEvents = true;
        }
      }
      BuildRecentDocsMenu();
      _recentDocs.ListChanged += (s, e) => BuildRecentDocsMenu();

      // Wire up the commands
      _commands = new UiCommandManager(this);
      inputEditor.KeyDown += _commands.OnKeyDown;
      outputEditor.KeyDown += _commands.OnKeyDown;
      _commands.Add<Control>(btnEditConnections, e => e.KeyCode == Keys.Q && e.Modifiers == Keys.Control, ChangeConnection);
      _commands.Add<Control>(btnSoapAction, e => e.KeyCode == Keys.M && e.Modifiers == Keys.Control, ChangeSoapAction);
      _commands.Add<Editor.FullEditor>(mniNewDocument, e => e.KeyCode == Keys.N && e.Modifiers == (Keys.Control), c =>
      {
        c.NewFile();
        UpdateTitle(null);
      });
      _commands.Add<Control>(mniNewWindow, e => e.KeyCode == Keys.N && e.Modifiers == (Keys.Control | Keys.Shift), c => NewWindow().Show());
      _commands.Add<Editor.FullEditor>(mniOpen, e => e.KeyCode == Keys.O && e.Modifiers == Keys.Control, c =>
      {
        using (var dialog = new OpenFileDialog())
        {
          if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
          {
            OpenFile(c, dialog.FileName);
          }
        }
      });
      _commands.Add<Editor.FullEditor>(mniSave, e => e.KeyCode == Keys.S && e.Modifiers == Keys.Control, c => Save(c, false));
      _commands.Add<Editor.FullEditor>(mniSaveAs, e => e.KeyCode == Keys.S && e.Modifiers == (Keys.Control | Keys.Shift), c => Save(c, true));
      _commands.Add<Editor.FullEditor>(mniFind, null, c => c.Find());
      _commands.Add<Editor.FullEditor>(mniFindNext, null, c => c.FindNext());
      _commands.Add<Editor.FullEditor>(mniFindPrevious, null, c => c.FindPrevious());
      _commands.Add<Editor.FullEditor>(mniReplace, null, c => c.Replace());
      _commands.Add<Editor.FullEditor>(mniGoTo, e => e.KeyCode == Keys.G && e.Modifiers == Keys.Control, c =>
      {
        using (var dialog = new InputBox())
        {
          dialog.Caption = "Go To Line";
          dialog.Message = string.Format("Line Number (1 - {0}):", c.Editor.LineCount);
          int line;
          if (dialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK
            && int.TryParse(dialog.Value, out line)
            && line >= 1
            && line <= c.Editor.LineCount)
          {
            var targetLine = c.Editor.TextArea.TextView.GetOrConstructVisualLine(c.Editor.Document.GetLineByNumber(line));
            var docHeight = c.Editor.TextArea.TextView.DocumentHeight;
            var winHeight = c.Editor.TextArea.TextView.ActualHeight;
            var target = Math.Min(docHeight, Math.Max(0, (int)(targetLine.VisualTop - (winHeight - targetLine.Height) / 2.0)));
            c.Editor.ScrollToVerticalOffset(target);
            c.Editor.TextArea.Caret.Line = line;
          }
        }
      });
      _commands.Add<Editor.FullEditor>(mniTidy, e => e.KeyCode == Keys.T && e.Modifiers == Keys.Control, c => TransformSelection(c, c.Helper.Format));
      _commands.Add<Editor.FullEditor>(mniMinify, null, c => TransformSelection(c, c.Helper.Minify));
      _commands.Add<Editor.FullEditor>(mniMd5Encode, null, c => c.ReplaceSelectionSegments(t => ConnectionDataExtensions.CalcMD5(t)));
      _commands.Add<Editor.FullEditor>(mniBase64Encode, null, c => c.ReplaceSelectionSegments(t => Convert.ToBase64String(Encoding.UTF8.GetBytes(t))));
      _commands.Add<Editor.FullEditor>(mniBase64Decode, null, c => c.ReplaceSelectionSegments(t => Encoding.UTF8.GetString(Convert.FromBase64String(t))));
      _commands.Add<Editor.FullEditor>(mniDoubleToSingleQuotes, null, c => c.ReplaceSelectionSegments(t => t.Replace('"', '\'')));
      _commands.Add<Editor.FullEditor>(mniSingleToDoubleQuotes, null, c => c.ReplaceSelectionSegments(t => t.Replace('\'', '"')));
      _commands.Add<Editor.FullEditor>(mniUppercase, null, c => c.TransformUppercase());
      _commands.Add<Editor.FullEditor>(mniLowercase, null, c => c.TransformLowercase());
      _commands.Add<Editor.FullEditor>(mniMoveUpCurrentLine, null, c => c.MoveLineUp());
      _commands.Add<Editor.FullEditor>(mniMoveDownCurrentLine, null, c => c.MoveLineDown());
      _commands.Add<Editor.FullEditor>(mniToggleSingleLineComment, e => e.Modifiers == Keys.Control && e.KeyCode == Keys.Q, LineToggleComment);
      _commands.Add<Editor.FullEditor>(mniSingleLineComment, e => e.Modifiers == Keys.Control && e.KeyCode == Keys.K, LineComment);
      _commands.Add<Editor.FullEditor>(mniSingleLineUncomment, e => e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.K, LineUncomment);
      _commands.Add<Editor.FullEditor>(mniBlockComment, e => e.Modifiers == (Keys.Control | Keys.Shift) && e.KeyCode == Keys.Q, BlockComment);
      _commands.Add<Editor.FullEditor>(mniBlockUncomment, null, BlockUncomment);
      _commands.Add<Editor.FullEditor>(mniInsertNewGuid, null, c => c.ReplaceSelectionSegments(t => Guid.NewGuid().ToString("N").ToUpperInvariant()));
      _commands.Add<Editor.FullEditor>(mniXmlToEntity, null, c => c.ReplaceSelectionSegments(t => {
        try
        {
          var sb = new System.Text.StringBuilder();
          var settings = new XmlWriterSettings();
          settings.Indent = false;
          settings.OmitXmlDeclaration = true;
          using (var strWriter = new StringWriter(sb))
          using (var writer = XmlWriter.Create(strWriter, settings))
          {
            writer.WriteStartElement("a");
            writer.WriteValue(t);
            writer.WriteEndElement();
          }
          return sb.ToString(3, sb.Length - 7);
        }
        catch (XmlException)
        {
          return t.Replace("<", "&lt;").Replace(">", "&gt;").Replace("&", "&amp;");
        }
      }));
      _commands.Add<Editor.FullEditor>(mniEntityToXml, null, c => c.ReplaceSelectionSegments(t => {
        try
        {
          var xml = "<a>" + t + "</a>";
          using (var strReader = new StringReader(xml))
          using (var reader = XmlReader.Create(strReader))
          {
            while (reader.Read())
            {
              if (reader.NodeType == XmlNodeType.Text)
              {
                return reader.Value;
              }
            }
          }
        }
        catch (XmlException)
        {
          return t.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
        }
        return t;
      }));
      _commands.Add<Control>(mniPreferences, null, c =>
      {
        using (var dialog = new Dialog.SettingsDialog())
        {
          dialog.Message = "Configure Innovator Admin";
          dialog.ShowDialog();
        }
      });
    }
Exemplo n.º 4
0
 private void mniRunBatch_Click(object sender, EventArgs e)
 {
   try
   {
     using (var dialog = new Dialog.SettingsDialog())
     {
       dialog.Filter.Add(s => s.BatchSize);
       dialog.Filter.Add(s => s.ThreadCount);
       dialog.DataSource = Settings.Current;
       dialog.Message = "Please verify the batch size and thread count settings";
       if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
         return;
     }
     Submit(inputEditor.Helper.GetCurrentQuery(inputEditor.Document, inputEditor.Editor.CaretOffset)
       ?? inputEditor.Text, OutputType.Any, Settings.Current.BatchSize, Settings.Current.ThreadCount);
   }
   catch (Exception ex)
   {
     Utils.HandleError(ex);
   }
 }