Exemple #1
0
 private void frmTextDiff_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (frmTextDiff._activeTextDiff == this)
     {
         frmTextDiff._activeTextDiff = null;
     }
 }
Exemple #2
0
    private void SendScriptToTextDiff(bool isSource)
    {
      DataRowView row = _bs.Current as DataRowView;
      if (row == null)
      {
        return;
      }

      string script = row["ObjectScript"] as string;
      string caption = String.Format("{0} ({1} | {2})"
          , row["ObjectName"] as string
          , row["CreatedOn"]
          , row["CreatedBy"] as string);

      frmTextDiff diffForm = frmTextDiff.ActiveTextDiff;
      if (diffForm == null)
      {
        diffForm = TextDiffFactory.CreateDiff();
      }

      if (isSource)
      {
        diffForm.diffControl.SourceText = script;
        diffForm.diffControl.SourceHeaderText = caption;
      }
      else
      {
        diffForm.diffControl.DestText = script;
        diffForm.diffControl.DestHeaderText = caption;
      }
      diffForm.Show();
      diffForm.BringToFront();
    }
Exemple #3
0
        private void TextDiffScript(bool isSource)
        {
            string script = ActiveTextArea.SelectionManager.HasSomethingSelected ? ActiveTextArea.SelectionManager.SelectedText : _textEditor.Text;


            frmTextDiff diffForm = frmTextDiff.ActiveTextDiff;

            if (diffForm == null)
            {
                diffForm = TextDiffFactory.CreateDiff();
            }

            if (isSource)
            {
                diffForm.diffControl.SourceText       = script;
                diffForm.diffControl.SourceHeaderText = Caption;
            }
            else
            {
                diffForm.diffControl.DestText       = script;
                diffForm.diffControl.DestHeaderText = Caption;
            }
            diffForm.Show();
            diffForm.BringToFront();
        }
Exemple #4
0
        public static frmTextDiff CreateDiffFromFile(string caption, string sourceFileName, string destFileName)
        {
            frmTextDiff frm = CreateDiff();

            if (!String.IsNullOrEmpty(caption))
            {
                frm.Text = caption;
            }

            frm.diffControl.OpenSourceFile(sourceFileName);
            frm.diffControl.OpenDestFile(destFileName);
            return(frm);
        }
Exemple #5
0
        public static frmTextDiff CreateDiffFromText(string caption, string source, string destination)
        {
            frmTextDiff frm = CreateDiff();

            if (!String.IsNullOrEmpty(caption))
            {
                frm.Text = caption;
            }

            frm.diffControl.SourceText = source;
            frm.diffControl.DestText   = destination;
            return(frm);
        }
Exemple #6
0
    private void SendCurrentObjectToTextDiff(bool isSource)
    {
      if (_bs.Current == null)
      {
        return;
      }

      DataRowView rw = _bs.Current as DataRowView;
      if (rw == null)
        return;

      int objId = (int)rw.Row.ItemArray[0];
      string objType = (string)rw.Row.ItemArray[3];
      string objName = (string)rw.Row.ItemArray[2];
      
      if (DBConstants.DoesObjectTypeHasScript(objType))
      {
        int type = DBConstants.GetDBObjectType(objType);
        string script = ScriptingHelper.GetAlterScript(_connParams, _connParams.Database, objId, type);

        frmTextDiff diffForm = frmTextDiff.ActiveTextDiff;
        if (diffForm == null)
        {
          diffForm = TextDiffFactory.CreateDiff();
        }

        if (isSource)
        {
          diffForm.diffControl.SourceText = script;
          diffForm.diffControl.SourceHeaderText = objName;
        }
        else
        {
          diffForm.diffControl.DestText = script;
          diffForm.diffControl.DestHeaderText = objName;
        }
        diffForm.Show();
        diffForm.BringToFront();
      }
    }
Exemple #7
0
    private void SendSelectedObjectToTextDiffEx(bool isSource)
    {
      if (grd.SelectedRows.Count == 0)
      {
        return;
      }

      int objId = -1;
      string objType = String.Empty;
      string objName = String.Empty;
      IList<frmScriptEditor> editors = new List<frmScriptEditor>();

      foreach (DataGridViewRow row in grd.SelectedRows)
      {
        DataGridViewCell cellObjid = row.Cells[0];
        DataGridViewCell cellName = row.Cells[2];
        DataGridViewCell cellType = row.Cells[3];

        if (cellName.ValueType != typeof(string) || cellName.Value == null)
        {
          continue;
        }

        if (cellType.ValueType != typeof(string) || cellType.Value == null)
        {
          continue;
        }

        if (cellObjid.ValueType != typeof(int) || cellObjid.Value == null)
        {
          continue;
        }

        objId = (int)cellObjid.Value;
        objType = (string)cellType.Value;
        objName = (string)cellName.Value;

        if (DBConstants.DoesObjectTypeHasScript(objType))
        {
          int type = DBConstants.GetDBObjectType(objType);
          string script = ScriptingHelper.GetAlterScript(_connParams, _connParams.Database, objId, type);

          frmTextDiff diffForm = frmTextDiff.ActiveTextDiff;
          if (diffForm == null)
          {
            diffForm = TextDiffFactory.CreateDiff();
          }

          if (isSource)
          {
            diffForm.diffControl.SourceText = script;
            diffForm.diffControl.SourceHeaderText = objName;
          }
          else
          {
            diffForm.diffControl.DestText = script;
            diffForm.diffControl.DestHeaderText = objName;
          }
          diffForm.Show();
          diffForm.BringToFront();
          break;
        }
      }
    }
Exemple #8
0
        public static frmTextDiff CreateDiff()
        {
            frmTextDiff frm = new frmTextDiff();

            return(frm);
        }
Exemple #9
0
        public void DiffFile(string caption, string sourceFileName, string destinationFileName)
        {
            frmTextDiff frm = TextDiffFactory.CreateDiffFromFile(caption, sourceFileName, destinationFileName);

            frm.Show();
        }
Exemple #10
0
        public void DiffText(string caption, string source, string destination)
        {
            frmTextDiff frm = TextDiffFactory.CreateDiffFromText(caption, source, destination);

            frm.Show();
        }
Exemple #11
0
 private void frmTextDiff_Activated(object sender, EventArgs e)
 {
     frmTextDiff._activeTextDiff = this;
 }