コード例 #1
0
ファイル: DBReplacements.cs プロジェクト: RoChess/mvcentral
        public static void Exchange(int i, int x)
        {
            DBReplacements db1 = Get(i);
            DBReplacements db2 = Get(x);

            if (db1 == null || db2 == null)
            {
                return;
            }
            DBReplacements tdb = new DBReplacements();

            tdb.Enabled    = db1.Enabled;
            tdb.IsRegex    = db1.IsRegex;
            tdb.ToReplace  = db1.ToReplace;
            tdb.With       = db1.With;
            tdb.Before     = db1.Before;
            tdb.TagEnabled = db1.TagEnabled;

            db1.Enabled    = db2.Enabled;
            db1.IsRegex    = db2.IsRegex;
            db1.ToReplace  = db2.ToReplace;
            db1.With       = db2.With;
            db1.Before     = db2.Before;
            db1.TagEnabled = db2.TagEnabled;
            db1.Commit();

            db2.Enabled    = tdb.Enabled;
            db2.IsRegex    = tdb.IsRegex;
            db2.ToReplace  = tdb.ToReplace;
            db2.With       = tdb.With;
            db2.Before     = tdb.Before;
            db2.TagEnabled = tdb.TagEnabled;
            db2.Commit();
        }
コード例 #2
0
ファイル: DBReplacements.cs プロジェクト: RoChess/mvcentral
        public static void add(bool enabled, bool tagenabled, bool before, bool isRegex, string toreplace, string with)
        {
            DBReplacements r1 = new DBReplacements();

            r1.Enabled    = enabled;
            r1.TagEnabled = tagenabled;
            r1.Before     = before;
            r1.IsRegex    = isRegex;
            r1.ToReplace  = toreplace;
            r1.With       = with;
            r1.Commit();
        }
コード例 #3
0
        public static void Exchange(int i, int x)
        {
            DBReplacements db1 = Get(i);
              DBReplacements db2 = Get(x);
              if (db1 == null || db2 == null) return;
              DBReplacements tdb = new DBReplacements();
              tdb.Enabled = db1.Enabled;
              tdb.IsRegex = db1.IsRegex;
              tdb.ToReplace = db1.ToReplace;
              tdb.With = db1.With;
              tdb.Before = db1.Before;
              tdb.TagEnabled = db1.TagEnabled;

              db1.Enabled = db2.Enabled;
              db1.IsRegex = db2.IsRegex;
              db1.ToReplace = db2.ToReplace;
              db1.With = db2.With;
              db1.Before = db2.Before;
              db1.TagEnabled = db2.TagEnabled;
              db1.Commit();

              db2.Enabled = tdb.Enabled;
              db2.IsRegex = tdb.IsRegex;
              db2.ToReplace = tdb.ToReplace;
              db2.With = tdb.With;
              db2.Before = tdb.Before;
              db2.TagEnabled = tdb.TagEnabled;
              db2.Commit();
        }
コード例 #4
0
 public static void add(bool enabled, bool tagenabled, bool before, bool isRegex, string toreplace, string with)
 {
     DBReplacements r1 = new DBReplacements();
       r1.Enabled = enabled;
       r1.TagEnabled = tagenabled;
       r1.Before = before;
       r1.IsRegex = isRegex;
       r1.ToReplace = toreplace;
       r1.With = with;
       r1.Commit();
 }
コード例 #5
0
ファイル: ConfigForm.cs プロジェクト: andrewjswan/mvcentral
        private void SaveAllReplacements()
        {
            // need to save back all the rows
              DBReplacements.ClearAll();

              foreach (DataGridViewRow row in dgvReplace.Rows)
              {
            if (row.Index != dgvReplace.NewRowIndex)
            {
              DBReplacements replacement = new DBReplacements();
              foreach (DataGridViewCell cell in row.Cells)
              {
            switch (cell.OwningColumn.Name)
            {
              case null:
                break;
              case "enabled":
                if (cell.Value == null) cell.Value = true;
                replacement.Enabled = (bool)cell.Value;
                break;
              case "isRegex":
                if (cell.Value == null) cell.Value = false;
                replacement.IsRegex = (bool)cell.Value;
                break;
              case "toreplace":
                if (cell.Value == null) cell.Value = "";
                replacement.ToReplace = (string)cell.Value;
                break;
              case "with":
                if (cell.Value == null) cell.Value = "";
                replacement.With = (string)cell.Value;
                break;
              case "before":
                if (cell.Value == null) cell.Value = false;
                replacement.Before = (bool)cell.Value;
                break;
              case "tagEnabled":
                if (cell.Value == null) cell.Value = false;
                replacement.TagEnabled = (bool)cell.Value;
                break;

            }
              }
              replacement.Commit();
            }
              }
              FilenameParser.reLoadExpressions();
        }
コード例 #6
0
ファイル: ConfigForm.cs プロジェクト: andrewjswan/mvcentral
        private void linkLabelImportStringReplacements_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            OpenFileDialog fd = new OpenFileDialog();
              fd.Filter = "Exported String Replacements (*.strrep)|*.strrep";
              if (fd.ShowDialog() == DialogResult.OK && System.IO.File.Exists(fd.FileName))
              {
            StreamReader r = new StreamReader(fd.FileName);
            //Dialog box to make sure they want to clear out current replacements to import new ones.
            DialogResult result = MessageBox.Show("Press Yes to delete all current string replacements," + Environment.NewLine +
                "and replace them with the imported file." + Environment.NewLine + Environment.NewLine +
                "Press No to append the import string replacements." + Environment.NewLine + Environment.NewLine +
                "Press cancel to Quit", "Import Replacements", MessageBoxButtons.YesNoCancel);
            switch (result)
            {
              case DialogResult.No:
            break;
              case DialogResult.Yes:
            dgvReplace.Rows.Clear();
            DBReplacements.ClearAll();
            logger.Info("Replacements cleared");
            break;
              case DialogResult.Cancel:
            return;
            }

            string line = string.Empty;
            string[] parts;

            // read file and import into database
            while ((line = r.ReadLine()) != null)
            {
              char[] c = { ';' };
              parts = line.Split(c, 6);

              if (parts.Length == 6)
              {
            DBReplacements repl = new DBReplacements();
            try
            {
              if (Convert.ToInt32(parts[0]) == 0 || Convert.ToInt32(parts[0]) == 1) repl.Enabled = Convert.ToBoolean(parts[0].Equals("1"));
              if (Convert.ToInt32(parts[1]) == 0 || Convert.ToInt32(parts[1]) == 1) repl.Before = Convert.ToBoolean(parts[1].Equals("1"));
              if (Convert.ToInt32(parts[2]) == 0 || Convert.ToInt32(parts[2]) == 1) repl.TagEnabled = Convert.ToBoolean(parts[2].Equals("1"));
              if (Convert.ToInt32(parts[3]) == 0 || Convert.ToInt32(parts[3]) == 1) repl.IsRegex = Convert.ToBoolean(parts[3].Equals("1"));
              repl.ToReplace = parts[4];
              repl.With = parts[5];
            }
            catch (Exception ex)
            {
              logger.ErrorException("replacement failed :", ex);
              LoadReplacements();
              r.Close();
              return;
            }
            repl.Commit();
              }
            }
            r.Close();
            logger.Info("String Replacements succesfully imported!");
            LoadReplacements();
              }
        }