/////////////////////////////////////////////////////////////////////////////// // Methods and Eventhandling for Background tasks // /////////////////////////////////////////////////////////////////////////////// #region BACKGROUNDWORKER #endregion //BACKGROUNDWORKER /////////////////////////////////////////////////////////////////////////////// // Inherited methods // /////////////////////////////////////////////////////////////////////////////// #region OVERRIDES #endregion //OVERRIDES /////////////////////////////////////////////////////////////////////////////// // Methods for doing main class job // /////////////////////////////////////////////////////////////////////////////// #region METHODS /// <summary> /// This method submits the given <see cref="ColorizationStyle"/> /// to the user interface toolbox items. /// </summary> /// <param name="style">The <see cref="ColorizationStyle"/> to be edited in the UI.</param> private void PopulateStyleGroup(ColorizationStyle style) { this.selectedConnectionsPen = style.ConnectionPen; this.selectedFixationsPen = style.FixationPen; this.selectedFont = style.Font; this.selectedFontColor = style.FontColor; this.pnlPreview.Refresh(); }
/// <summary> /// Initializes a new instance of the ScanpathProperties struct. /// </summary> /// <param name="newSubjectName">The name of the subject.</param> /// <param name="newSubjectCategory">The category of the subject.</param> /// <param name="newGazeStyle">The <see cref="ColorizationStyle"/> for the gaze drawings.</param> /// <param name="newMouseStyle">The <see cref="ColorizationStyle"/> for the mouse drawings.</param> /// <param name="newScanpathString">The <see cref="String"/> with the scanpath characters.</param> public ScanpathProperties( string newSubjectName, string newSubjectCategory, ColorizationStyle newGazeStyle, ColorizationStyle newMouseStyle, string newScanpathString) { this.SubjectName = newSubjectName; this.SubjectCategory = newSubjectCategory; this.GazeStyle = newGazeStyle; this.MouseStyle = newMouseStyle; this.ScanpathString = newScanpathString; }
/// <summary> /// This method updates the <see cref="ColorizationStyle"/> /// of the selected subject or group. /// </summary> private void SubmitStyleToSubjectOrCategory() { ColorizationStyle newStyle = new ColorizationStyle( this.selectedFixationsPen, this.selectedConnectionsPen, this.selectedFont, this.selectedFontColor); switch (this.colorParams.ColorizationMode) { case ColorizationModes.Subject: if (this.trvSubjects.SelectedNode.Level == 1) { this.colorParams.SubjectStyles[this.trvSubjects.SelectedNode.Text] = newStyle; } break; case ColorizationModes.Category: if (this.trvSubjects.SelectedNode.Level == 0) { this.colorParams.CategoryStyles[this.trvSubjects.SelectedNode.Text] = newStyle; this.AssignGroupToSubjects(); } break; case ColorizationModes.Gradient: if (this.trvSubjects.SelectedNode.Level == 1) { this.colorParams.SubjectStyles[this.trvSubjects.SelectedNode.Text] = newStyle; } break; } this.trvSubjects.Refresh(); this.pnlPreview.Refresh(); }
/// <summary> /// Initializes a new instance of the ColorizationStyle class /// by cloneing the given <see cref="ColorizationStyle"/> /// </summary> /// <param name="styleToClone">The <see cref="ColorizationStyle"/> to be cloned.</param> public ColorizationStyle(ColorizationStyle styleToClone) : this(styleToClone.fixationPen, styleToClone.connectionPen, styleToClone.font, styleToClone.fontColor) { }
/////////////////////////////////////////////////////////////////////////////// // Methods and Eventhandling for Background tasks // /////////////////////////////////////////////////////////////////////////////// #region BACKGROUNDWORKER #endregion //BACKGROUNDWORKER /////////////////////////////////////////////////////////////////////////////// // Methods for doing main class job // /////////////////////////////////////////////////////////////////////////////// #region METHODS /// <summary> /// Initialize the subject list with custom coloring. /// </summary> private void InitializeSubjectListAndColors() { this.selectedSubjects = new SortedDictionary<string, ScanpathProperties>(); List<Color> gazeColorTable = new List<Color>(); List<Color> mouseColorTable = new List<Color>(); Font gazeFont = new Font("Arial", 28f); Font mouseFont = new Font("Arial", 28f); ColorizationStyle gazeStyle = new ColorizationStyle( new Pen(Color.Yellow), new Pen(Color.Yellow), gazeFont, Color.Yellow); ColorizationStyle mouseStyle = new ColorizationStyle( new Pen(Color.LightYellow), new Pen(Color.LightYellow), mouseFont, Color.LightYellow); DataView subjectsView = new DataView(Document.ActiveDocument.DocDataSet.Subjects); subjectsView.Sort = "SubjectName ASC"; // Check for saved params in the experiment settings // if they are empty or not as much as subjects in // the current database, refresh all params. bool refreshGazeColorParams = false; if (Document.ActiveDocument.ExperimentSettings.GazeColorParams != null && Document.ActiveDocument.ExperimentSettings.GazeColorParams.SubjectStyles.Count != subjectsView.Count) { refreshGazeColorParams = true; } if (!refreshGazeColorParams) { this.gazeColorParams = (ColorizationParameters)Document.ActiveDocument.ExperimentSettings.GazeColorParams.Clone(); } else { this.gazeColorParams = new ColorizationParameters(); this.gazeColorParams.ColorizationMode = ColorizationModes.Category; gazeColorTable.Add(Color.Red); gazeColorTable.Add(Color.Blue); gazeColorTable.Add(Color.Brown); gazeColorTable.Add(Color.Green); gazeColorTable.Add(Color.Cyan); gazeColorTable.Add(Color.Orange); gazeColorTable.Add(Color.Coral); this.gazeColorParams.CategoryStyles.Add("no category", gazeStyle); } // Check for saved params in the experiment settings // if they are empty or not as much as subjects in // the current database, refresh all params. bool refreshMouseColorParams = false; if (Document.ActiveDocument.ExperimentSettings.MouseColorParams != null && Document.ActiveDocument.ExperimentSettings.MouseColorParams.SubjectStyles.Count != subjectsView.Count) { refreshMouseColorParams = true; } if (!refreshMouseColorParams) { this.mouseColorParams = (ColorizationParameters)Document.ActiveDocument.ExperimentSettings.MouseColorParams.Clone(); } else { this.mouseColorParams = new ColorizationParameters(); this.mouseColorParams.ColorizationMode = ColorizationModes.Category; mouseColorTable.Add(Color.Tomato); mouseColorTable.Add(Color.LightBlue); mouseColorTable.Add(Color.BurlyWood); mouseColorTable.Add(Color.LightGoldenrodYellow); mouseColorTable.Add(Color.LightCyan); mouseColorTable.Add(Color.LightSalmon); mouseColorTable.Add(Color.LightCoral); this.mouseColorParams.CategoryStyles.Add("no category", mouseStyle); } this.trvSubjects.BeginUpdate(); this.trvSubjects.Nodes.Clear(); // Populates a TreeView control with subject category nodes. int categoryCounter = 0; foreach (DataRowView row in subjectsView) { string category = row["Category"].ToString(); if (category == string.Empty || category == " ") { category = "no category"; } if (!this.trvSubjects.Nodes.ContainsKey(category)) { this.trvSubjects.Nodes.Add(category, category, "Category"); if (refreshGazeColorParams) { Color gazeColor = gazeColorTable[categoryCounter]; gazeStyle = new ColorizationStyle(new Pen(gazeColor), new Pen(gazeColor), gazeFont, gazeColor); if (!this.gazeColorParams.CategoryStyles.ContainsKey(category)) { this.gazeColorParams.CategoryStyles.Add(category, gazeStyle); } } if (refreshMouseColorParams) { Color mouseColor = mouseColorTable[categoryCounter]; mouseStyle = new ColorizationStyle(new Pen(mouseColor), new Pen(mouseColor), mouseFont, mouseColor); if (!this.mouseColorParams.CategoryStyles.ContainsKey(category)) { this.mouseColorParams.CategoryStyles.Add(category, mouseStyle); } } categoryCounter++; if (categoryCounter > gazeColorTable.Count) { categoryCounter = 0; } } } // Populates a TreeView control with subject nodes. foreach (DataRowView row in subjectsView) { string category = row["Category"].ToString(); if (category == string.Empty || category == " ") { category = "no category"; } string subjectName = row["SubjectName"].ToString(); this.trvSubjects.Nodes[category].Nodes.Add(subjectName, subjectName, "Subject", "Subject"); } this.trvSubjects.ExpandAll(); if (refreshGazeColorParams) { this.gazeColorParams.SubjectStyles.Clear(); foreach (TreeNode categoryNode in this.trvSubjects.Nodes) { foreach (TreeNode subjectNode in categoryNode.Nodes) { this.gazeColorParams.SubjectStyles.Add( subjectNode.Text, this.gazeColorParams.CategoryStyles[categoryNode.Text]); } } } if (refreshMouseColorParams) { this.mouseColorParams.SubjectStyles.Clear(); foreach (TreeNode categoryNode in this.trvSubjects.Nodes) { foreach (TreeNode subjectNode in categoryNode.Nodes) { this.mouseColorParams.SubjectStyles.Add( subjectNode.Text, this.mouseColorParams.CategoryStyles[categoryNode.Text]); } } } this.trvSubjects.EndUpdate(); foreach (TreeNode categoryNode in this.trvSubjects.Nodes) { categoryNode.Checked = true; this.CheckAllChildNodes(categoryNode, true); } this.ReReadSelectedSubjects(); }