Inheritance: global::System.Data.DataRow
Example #1
0
 public WorkerData(string path, Model.FoldersRow folder, BackgroundWorker worker)
 {
     this.path   = path;
     this.folder = folder;
     this.len    = this.path.Length;
     this.model  = folder.Table.DataSet as Model;
     this.worker = worker;
 }
Example #2
0
 private void SaveTo(Model.FoldersRow folder)
 {
     tableIncludes.SaveToIncludes(folder);
     tableExcludes.SaveToExcludes(folder);
     if (editGlobalIncludes)
     {
         tableIncludes.SaveToGlobalIncludes(model);
     }
     if (editGlobalExcludes)
     {
         tableExcludes.SaveToGlobalExcludes(model);
     }
 }
Example #3
0
        public void ReEval(Model.FoldersRow folder)
        {
            if (reEvalWorker != null)
            {
                reEvalWorker.CancelAsync();
                Thread.Sleep(100);
            }

            reEvalWorker = new BackgroundWorker();
            reEvalWorker.WorkerReportsProgress      = false;
            reEvalWorker.WorkerSupportsCancellation = true;
            reEvalWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(ReEvalWorkerCompleted);
            reEvalWorker.DoWork += new DoWorkEventHandler(ReEvalDoWork);
            reEvalWorker.RunWorkerAsync(new WorkerData("", folder, reEvalWorker));
        }
Example #4
0
        private void ScannerWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // the background process is complete. We need to inspect
            // our response to see if an error occurred, a cancel was
            // requested or if we completed successfully.

            scannerData.dialog.Close();

            // check to see if an error occurred in the background process.
            if (e.Cancelled)
            {
                scannerData   = null;
                scannerWorker = null;
                return;
            }

            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, "Error");
                scannerData   = null;
                scannerWorker = null;
                return;
            }

            string name  = scannerData.scanner.SuggestName(scannerData.folder);
            string type  = scannerData.scanner.GetName();
            string uname = MakeUniqueName(name);

            try
            {
                Model.FoldersRow folder = model.AddFolder(uname, scannerData.folder, type);
                VisualizeFolder(folder);
                int row = table.TableModel.Rows.Count - 1;
                table.TableModel.Selections.SelectCells(row, 0, row, 2);
                table.EnsureVisible(row, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Unable to add new folder: Folder:'{0}'\nType:'{1}'\nUniqueName:'{2}'\nError: {3}", name, type, uname, ex.Message), "Save failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            scannerData   = null;
            scannerWorker = null;
        }
Example #5
0
        public void RunTest(string path, Model.FoldersRow folder)
        {
            // cancel previous worker if running
            if (worker != null)
            {
                worker.CancelAsync();
                Thread.Sleep(100);
            }

            // create a background worker thread that ReportsProgress & SupportsCancellation
            // hook up the appropriate events.
            worker = new BackgroundWorker();
            worker.WorkerReportsProgress      = true;
            worker.WorkerSupportsCancellation = true;
            worker.ProgressChanged           += new ProgressChangedEventHandler(TesterProgressChanged);
            worker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(TesterWorkerCompleted);
            worker.DoWork += new DoWorkEventHandler(TesterDoWork);
            worker.RunWorkerAsync(new WorkerData(path, folder, worker));
        }
Example #6
0
        internal void SaveToExcludes(Model.FoldersRow folder)
        {
            folder.ClearExcludes();
            Model model = folder.Table.DataSet as Model;

            foreach (Row row in TableModel.Rows)
            {
                if (!row.Cells[0].Checked && row.Cells[0].Text.Length > 0)
                {
                    if (row.Cells[1].ForeColor == Color.Gray)
                    {
                        model.ExcludeFilters.AddExcludeFiltersRow(row.Cells[0].Text, null, folder);
                    }
                    else
                    {
                        model.ExcludeFilters.AddExcludeFiltersRow(row.Cells[0].Text, row.Cells[1].Text, folder);
                    }
                }
            }
        }
Example #7
0
        private void VisualizeFolder(Model.FoldersRow folder)
        {
            XPTable.Models.Row row = new XPTable.Models.Row();

            XPTable.Models.Cell      cell1      = new XPTable.Models.Cell();
            XPTable.Models.CellStyle cellStyle1 = new XPTable.Models.CellStyle();
            XPTable.Models.Cell      cell2      = new XPTable.Models.Cell();
            XPTable.Models.CellStyle cellStyle2 = new XPTable.Models.CellStyle();
            XPTable.Models.Cell      cell3      = new XPTable.Models.Cell();
            XPTable.Models.CellStyle cellStyle3 = new XPTable.Models.CellStyle();

            cell1.Text    = folder.Name;
            cell1.Checked = folder.Enabled;
            cell1.Data    = Detector.Current.GetIcon(folder.Type);
            cell2.Text    = folder.Path;
            cell2.Checked = Directory.Exists(folder.Path);
            cell3.Text    = folder.Type;

            cellStyle1.Font = new System.Drawing.Font("Arial", 8.0F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            cell1.CellStyle = cellStyle1;

            cellStyle2.Font = new System.Drawing.Font("Courier", 8.0F, 0, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            cell2.CellStyle = cellStyle2;

            cellStyle3.Font = new System.Drawing.Font("Arial", 8.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            cell3.CellStyle = cellStyle3;

            row.Cells.AddRange(new XPTable.Models.Cell[] { cell1, cell2, cell3 });
            row.ChildIndex = 0;
            row.Editable   = true;
            row.Tag        = folder;

            StrikeRow(row, !folder.Enabled);

            tableModel.Rows.Add(row);
        }
Example #8
0
        void OnCellPropertyChanged(object sender, XPTable.Events.CellEventArgs e)
        {
            if (e.EventType != XPTable.Events.CellEventType.ValueChanged && e.EventType != XPTable.Events.CellEventType.CheckStateChanged)
            {
                return;
            }
            Model.FoldersRow folder = table.TableModel.Rows[e.Row].Tag as Model.FoldersRow;

            lock (folder)
            {
                // update model with the new value from table
                switch (e.CellPos.Column)
                {
                case 0:                         // project name
                    if (folder.Name != e.Cell.Text)
                    {
                        folder.Name = MakeUniqueName(e.Cell.Text);
                        e.Cell.Text = folder.Name;
                    }
                    folder.Enabled = e.Cell.Checked;
                    StrikeRow(table.TableModel.Rows[e.Row], !folder.Enabled);
                    break;

                case 1:                         // project path
                    folder.Path    = e.Cell.Text;
                    e.Cell.Checked = Directory.Exists(folder.Path);
                    break;

                case 2:                                                            // project type
                    folder.Type = e.Cell.Text;
                    table.TableModel.Rows[e.Row].Cells[0].Data = (int)e.Cell.Data; // set new project icon
                    table.InvalidateCell(e.Row, 0);
                    break;
                }
            }
        }
Example #9
0
        public ProjectFilters(Model model, Model.FoldersRow folder)
        {
            this.model = model;
            this.folder = folder;
            // this must go after InitFrom !
            Model.SettingsRow settings = model.GetSettings();
            this.tableIncludes = new XRefresh.FilterTable(settings.ShowGlobalIncludes, false);
            this.tableExcludes = new XRefresh.FilterTable(settings.ShowGlobalExcludes, false);
            ((System.ComponentModel.ISupportInitialize)(this.tableIncludes)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableExcludes)).BeginInit();
            InitializeComponent();
            //
            // tableIncludes
            //
            this.tableIncludes.AllowDrop = true;
            this.tableIncludes.AlternatingRowColor = System.Drawing.Color.WhiteSmoke;
            this.tableIncludes.CustomEditKey = System.Windows.Forms.Keys.Return;
            this.tableIncludes.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableIncludes.EnableHeaderContextMenu = false;
            this.tableIncludes.ForeColor = System.Drawing.Color.Black;
            this.tableIncludes.FullRowSelect = true;
            this.tableIncludes.GridLines = XPTable.Models.GridLines.Both;
            this.tableIncludes.GridLineStyle = XPTable.Models.GridLineStyle.Dot;
            this.tableIncludes.Location = new System.Drawing.Point(349, 25);
            this.tableIncludes.Name = "tableIncludes";
            this.tableIncludes.NoItemsText = "There are no file filters. Drag and drop a file here ...";
            this.tableIncludes.SelectionBackColor = System.Drawing.Color.Yellow;
            this.tableIncludes.SelectionForeColor = System.Drawing.Color.Black;
            this.tableIncludes.Size = new System.Drawing.Size(340, 140);
            this.tableIncludes.TabIndex = 0;
            this.tableIncludes.Text = "tableIncludes";
            //
            // tableExcludes
            //
            this.tableExcludes.AllowDrop = true;
            this.tableExcludes.AlternatingRowColor = System.Drawing.Color.WhiteSmoke;
            this.tableExcludes.CustomEditKey = System.Windows.Forms.Keys.Return;
            this.tableExcludes.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableExcludes.EnableHeaderContextMenu = false;
            this.tableExcludes.ForeColor = System.Drawing.Color.Black;
            this.tableExcludes.FullRowSelect = true;
            this.tableExcludes.GridLines = XPTable.Models.GridLines.Both;
            this.tableExcludes.GridLineStyle = XPTable.Models.GridLineStyle.Dot;
            this.tableExcludes.Location = new System.Drawing.Point(3, 25);
            this.tableExcludes.Name = "tableExcludes";
            this.tableExcludes.NoItemsText = "There are no file filters. Drag and drop a file here ...";
            this.tableExcludes.SelectionBackColor = System.Drawing.Color.Yellow;
            this.tableExcludes.SelectionForeColor = System.Drawing.Color.Black;
            this.tableExcludes.Size = new System.Drawing.Size(340, 140);
            this.tableExcludes.TabIndex = 3;
            this.tableExcludes.Text = "table2";

            ((System.ComponentModel.ISupportInitialize)(this.tableIncludes)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableExcludes)).EndInit();

            this.tableLayoutPanel.Controls.Add(this.tableIncludes, 1, 1);
            this.tableLayoutPanel.Controls.Add(this.tableExcludes, 0, 1);
            HideDebugger();
            this.Text = folder.Name + " Filters Designer";

            editGlobalIncludes = checkBoxGlobalIncludes.Checked = settings.ShowGlobalIncludes;
            editGlobalExcludes = checkBoxGlobalExcludes.Checked = settings.ShowGlobalExcludes;
            this.checkBoxGlobalIncludes.CheckedChanged += new System.EventHandler(this.checkBoxGlobalIncludes_CheckedChanged);
            this.checkBoxGlobalExcludes.CheckedChanged += new System.EventHandler(this.checkBoxGlobalExcludes_CheckedChanged);

            InitFrom(folder);
            editTestPath.Text = folder.Path;
            tableIncludes.Changed += new FilterTable.ChangedHandler(tableIncludes_Changed);
            tableExcludes.Changed += new FilterTable.ChangedHandler(tableExcludes_Changed);
        }
Example #10
0
 public virtual void SetFolder(Model.FoldersRow folder)
 {
     this.folder = folder;
     folder.ClearIncludes();
     folder.ClearExcludes();
 }
Example #11
0
 public virtual void SetFolder(Model.FoldersRow folder)
 {
     this.folder = folder;
     folder.ClearIncludes();
     folder.ClearExcludes();
 }
Example #12
0
            public ServerMessageRefresh(Model.FoldersRow folder, bool positive)
                : base("DoRefresh")
            {
                lock (folder.activities)
                {
                    DateTime d = DateTime.Now;
                    date = d.ToShortDateString();
                    time = d.ToLongTimeString();
                    root = folder.Path;
                    name = folder.Name;

                    // <path, most significant activity>
                    Dictionary <string, Model.Activity> ops = new Dictionary <string, Model.Activity>();
                    while (folder.activities.Count > 0)
                    {
                        Model.Activity activity   = folder.activities.Dequeue();
                        string         sourcePath = activity.path1;
                        string         destPath   = activity.type == Model.ActivityType.Renamed ? activity.path2 : activity.path1;

                        // here is quite difficult logic to explain
                        // I try to track and accumulate file change events and keep most significant information about what happened to files
                        //
                        // for example Microsoft Visual Studio 200 does this during file save (CTRL+S):
                        //   1) saves file into temporary file (I get 'created' event and possibly many 'changed' events)
                        //   2) deletes old file
                        //   3) renames temporary file to the original name (location)
                        // I need here to track renames and keep up-to-date location
                        // I also keep most significant event: (deleted|created)>renamed>changed
                        // if there was delete and create in row, I then change the event type to 'Changed'

                        Model.Activity lastActivity = null;
                        if (ops.ContainsKey(sourcePath))
                        {
                            lastActivity = ops[sourcePath];
                        }
                        if (ops.ContainsKey(destPath))
                        {
                            lastActivity = ops[destPath];
                        }
                        if (lastActivity != null)
                        {
                            // nonsense of modifying deleted file ? stay on deleted message
                            if (lastActivity.type == Model.ActivityType.Deleted && activity.type == Model.ActivityType.Changed)
                            {
                                activity = lastActivity;
                            }
                            // some apps may delete file and then recreate it, instead of changing it's content
                            if (lastActivity.type == Model.ActivityType.Deleted && (activity.type == Model.ActivityType.Renamed || activity.type == Model.ActivityType.Created))
                            {
                                activity.type  = Model.ActivityType.Changed;
                                activity.path1 = destPath;
                                activity.path2 = "";
                            }
                            // creation is more significant than modification and renaming
                            if (lastActivity.type == Model.ActivityType.Created && (activity.type == Model.ActivityType.Renamed || activity.type == Model.ActivityType.Changed))
                            {
                                activity = lastActivity;
                            }
                            // renaming is more significant to modification
                            if (lastActivity.type == Model.ActivityType.Renamed && activity.type == Model.ActivityType.Changed)
                            {
                                activity = lastActivity;
                            }
                            // purge last activity
                            activity.passed = activity.passed || lastActivity.passed;
                            if (ops.ContainsKey(sourcePath))
                            {
                                ops.Remove(sourcePath);
                            }
                            if (ops.ContainsKey(destPath))
                            {
                                ops.Remove(destPath);
                            }
                        }
                        // store new activity
                        ops.Add(destPath, activity);
                    }

                    int passedCount = 0;
                    foreach (Model.Activity activity in ops.Values)
                    {
                        if (activity.passed)
                        {
                            passedCount++;
                        }
                    }

                    files = new File[passedCount];
                    int i = 0;
                    foreach (Model.Activity activity in ops.Values)
                    {
                        if (activity.passed)
                        {
                            files[i] = new File(root, activity);
                            try // file reading may throw, because someone deletes the file or something, so we should be safe here
                            {
                                if (activity.path1.EndsWith(".css"))
                                {
                                    TextReader tr      = new StreamReader(root + "\\" + files[i].path1);
                                    string     content = tr.ReadToEnd();
                                    tr.Close();
                                    string key = files[i].path1;
                                    contents[key] = content;
                                }
                            }
                            catch (Exception)
                            {
                            }
                            i++;
                        }
                    }
                }
            }
Example #13
0
 private void comboProjects_SelectedIndexChanged(object sender, EventArgs e)
 {
     Model.FoldersRow selectedFolder = comboProjects.SelectedItem as Model.FoldersRow;
     InitFrom(selectedFolder);
     LockTables();
 }
Example #14
0
        public ProjectFilters(Model model, Model.FoldersRow folder)
        {
            this.model  = model;
            this.folder = folder;
            // this must go after InitFrom !
            Model.SettingsRow settings = model.GetSettings();
            this.tableIncludes = new XRefresh.FilterTable(settings.ShowGlobalIncludes, false);
            this.tableExcludes = new XRefresh.FilterTable(settings.ShowGlobalExcludes, false);
            ((System.ComponentModel.ISupportInitialize)(this.tableIncludes)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableExcludes)).BeginInit();
            InitializeComponent();
            //
            // tableIncludes
            //
            this.tableIncludes.AllowDrop           = true;
            this.tableIncludes.AlternatingRowColor = System.Drawing.Color.WhiteSmoke;
            this.tableIncludes.CustomEditKey       = System.Windows.Forms.Keys.Return;
            this.tableIncludes.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableIncludes.EnableHeaderContextMenu = false;
            this.tableIncludes.ForeColor          = System.Drawing.Color.Black;
            this.tableIncludes.FullRowSelect      = true;
            this.tableIncludes.GridLines          = XPTable.Models.GridLines.Both;
            this.tableIncludes.GridLineStyle      = XPTable.Models.GridLineStyle.Dot;
            this.tableIncludes.Location           = new System.Drawing.Point(349, 25);
            this.tableIncludes.Name               = "tableIncludes";
            this.tableIncludes.NoItemsText        = "There are no file filters. Drag and drop a file here ...";
            this.tableIncludes.SelectionBackColor = System.Drawing.Color.Yellow;
            this.tableIncludes.SelectionForeColor = System.Drawing.Color.Black;
            this.tableIncludes.Size               = new System.Drawing.Size(340, 140);
            this.tableIncludes.TabIndex           = 0;
            this.tableIncludes.Text               = "tableIncludes";
            //
            // tableExcludes
            //
            this.tableExcludes.AllowDrop           = true;
            this.tableExcludes.AlternatingRowColor = System.Drawing.Color.WhiteSmoke;
            this.tableExcludes.CustomEditKey       = System.Windows.Forms.Keys.Return;
            this.tableExcludes.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableExcludes.EnableHeaderContextMenu = false;
            this.tableExcludes.ForeColor          = System.Drawing.Color.Black;
            this.tableExcludes.FullRowSelect      = true;
            this.tableExcludes.GridLines          = XPTable.Models.GridLines.Both;
            this.tableExcludes.GridLineStyle      = XPTable.Models.GridLineStyle.Dot;
            this.tableExcludes.Location           = new System.Drawing.Point(3, 25);
            this.tableExcludes.Name               = "tableExcludes";
            this.tableExcludes.NoItemsText        = "There are no file filters. Drag and drop a file here ...";
            this.tableExcludes.SelectionBackColor = System.Drawing.Color.Yellow;
            this.tableExcludes.SelectionForeColor = System.Drawing.Color.Black;
            this.tableExcludes.Size               = new System.Drawing.Size(340, 140);
            this.tableExcludes.TabIndex           = 3;
            this.tableExcludes.Text               = "table2";

            ((System.ComponentModel.ISupportInitialize)(this.tableIncludes)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.tableExcludes)).EndInit();

            this.tableLayoutPanel.Controls.Add(this.tableIncludes, 1, 1);
            this.tableLayoutPanel.Controls.Add(this.tableExcludes, 0, 1);
            HideDebugger();
            this.Text = folder.Name + " Filters Designer";

            editGlobalIncludes = checkBoxGlobalIncludes.Checked = settings.ShowGlobalIncludes;
            editGlobalExcludes = checkBoxGlobalExcludes.Checked = settings.ShowGlobalExcludes;
            this.checkBoxGlobalIncludes.CheckedChanged += new System.EventHandler(this.checkBoxGlobalIncludes_CheckedChanged);
            this.checkBoxGlobalExcludes.CheckedChanged += new System.EventHandler(this.checkBoxGlobalExcludes_CheckedChanged);

            InitFrom(folder);
            editTestPath.Text      = folder.Path;
            tableIncludes.Changed += new FilterTable.ChangedHandler(tableIncludes_Changed);
            tableExcludes.Changed += new FilterTable.ChangedHandler(tableExcludes_Changed);
        }
Example #15
0
 private void InitFrom(Model.FoldersRow folder)
 {
     tableIncludes.InitFrom(folder.GetIncludeFiltersRows(), editGlobalIncludes ? model.GlobalIncludeFilters : null);
     tableExcludes.InitFrom(folder.GetExcludeFiltersRows(), editGlobalExcludes ? model.GlobalExcludeFilters : null);
 }