/// <summary> /// Initializes a new instance of the ColorizationParameters class. /// </summary> /// <param name="parametersToClone">The <see cref="ColorizationParameters"/> /// to clone.</param> public ColorizationParameters(ColorizationParameters parametersToClone) { this.subjectStyles = new XMLSerializableDictionary<string, ColorizationStyle>(); foreach (KeyValuePair<string, ColorizationStyle> kvp in parametersToClone.SubjectStyles) { this.subjectStyles.Add(kvp.Key, (ColorizationStyle)kvp.Value.Clone()); } this.categoryStyles = new XMLSerializableDictionary<string, ColorizationStyle>(); foreach (KeyValuePair<string, ColorizationStyle> kvp in parametersToClone.CategoryStyles) { this.categoryStyles.Add(kvp.Key, (ColorizationStyle)kvp.Value.Clone()); } this.colorizationGradient = parametersToClone.ColorizationGradient != null ? (Gradient)parametersToClone.ColorizationGradient.Clone() : null; this.colorizationMode = parametersToClone.ColorizationMode; }
/// <summary> /// Initializes a new instance of the ColorizationParameters class. /// </summary> /// <param name="parametersToClone">The <see cref="ColorizationParameters"/> /// to clone.</param> public ColorizationParameters(ColorizationParameters parametersToClone) { this.subjectStyles = new XMLSerializableDictionary <string, ColorizationStyle>(); foreach (KeyValuePair <string, ColorizationStyle> kvp in parametersToClone.SubjectStyles) { this.subjectStyles.Add(kvp.Key, (ColorizationStyle)kvp.Value.Clone()); } this.categoryStyles = new XMLSerializableDictionary <string, ColorizationStyle>(); foreach (KeyValuePair <string, ColorizationStyle> kvp in parametersToClone.CategoryStyles) { this.categoryStyles.Add(kvp.Key, (ColorizationStyle)kvp.Value.Clone()); } this.colorizationGradient = parametersToClone.ColorizationGradient != null ? (Gradient)parametersToClone.ColorizationGradient.Clone() : null; this.colorizationMode = parametersToClone.ColorizationMode; }
/////////////////////////////////////////////////////////////////////////////// // Public methods // /////////////////////////////////////////////////////////////////////////////// #region PUBLICMETHODS /// <summary> /// This static method draws a custom tree node in the given bounds /// with the given colorParams. /// </summary> /// <param name="e">The <see cref="DrawTreeNodeEventArgs"/> with the <see cref="TreeNode"/> /// to draw.</param> /// <param name="colorParams">A <see cref="ColorizationParameters"/> with the colors and pens to use.</param> /// <param name="colorRectBounds">The <see cref="Rectangle"/> with the bounds of the color rect.</param> public static void DrawNodes(DrawTreeNodeEventArgs e, ColorizationParameters colorParams, Rectangle colorRectBounds) { colorRectBounds.Width = 20; colorRectBounds.Height -= 1; colorRectBounds.Inflate(-2, -2); if (e.Node.Level == 0) { if (colorParams.ColorizationMode == ColorizationModes.Category) { Pen boundsPen = (Pen)Pens.Red.Clone(); if (colorParams.CategoryStyles.ContainsKey(e.Node.Text)) { boundsPen = (Pen)colorParams.CategoryStyles[e.Node.Text].ConnectionPen.Clone(); } boundsPen.Width = 1; e.Graphics.DrawRectangle(boundsPen, colorRectBounds); } } else { if (colorParams.ColorizationMode != ColorizationModes.Category) { Pen boundsPen = (Pen)Pens.Red.Clone(); if (colorParams.SubjectStyles.ContainsKey(e.Node.Text)) { boundsPen = (Pen)colorParams.SubjectStyles[e.Node.Text].ConnectionPen.Clone(); } boundsPen.Width = 1; e.Graphics.DrawRectangle(boundsPen, colorRectBounds); } } colorRectBounds.Inflate(-2, -2); colorRectBounds.Width += 1; colorRectBounds.Height += 1; Color usedColor = Color.Transparent; if (e.Node.Level == 0) { if (colorParams.ColorizationMode == ColorizationModes.Category) { if (colorParams.CategoryStyles.ContainsKey(e.Node.Text)) { usedColor = colorParams.CategoryStyles[e.Node.Text].FixationPen.Color; } } } else { if (colorParams.ColorizationMode != ColorizationModes.Category) { if (colorParams.SubjectStyles.ContainsKey(e.Node.Text)) { usedColor = colorParams.SubjectStyles[e.Node.Text].FixationPen.Color; } } } e.Graphics.FillRectangle(new SolidBrush(usedColor), colorRectBounds); }
/////////////////////////////////////////////////////////////////////////////// // Construction and Initializing methods // /////////////////////////////////////////////////////////////////////////////// #region CONSTRUCTION /// <summary> /// Initializes a new instance of the ExperimentSettings class. /// </summary> public ExperimentSettings() { this.widthStimulusScreen = 1024; this.heightStimulusScreen = 768; this.documentPath = string.Empty; this.experimentName = string.Empty; this.sqlInstanceName = "SQLEXPRESS"; this.gazeSamplingRate = 60; this.mouseSamplingRate = 10; this.gazeMaxDistance = 20; this.mouseMaxDistance = 20; this.gazeMinSamples = 5; this.mouseMinSamples = 10; this.gazeDiameterDiv = 2; this.mouseDiameterDiv = 5; this.fixationRingSize = 31; this.mergeConsecutiveFixations = true; this.eliminateFirstFixation = false; this.limitForFirstFixation = 300; this.eliminateFirstFixationSimple = false; this.slideShow = new Slideshow(); this.customConnectionString = string.Empty; this.gazeColorParams = new ColorizationParameters(); this.mouseColorParams = new ColorizationParameters(); this.ogamaVersion = new Version(); // Assembly.GetExecutingAssembly().GetName().Version; this.ScreenCaptureFramerate = 10; }
/// <summary> /// The <see cref="Control.Click"/> event handler for the /// <see cref="Button"/> <see cref="btnMousePenStyle"/>. /// Opens a <see cref="PenAndFontStyleDlg"/> and wires update events to /// member methods <see cref="OnPenChanged"/> and <see cref="OnFontStyleChanged"/> /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An empty <see cref="EventArgs"/></param> private void btnMousePenStyle_Click(object sender, EventArgs e) { ColorDefinitionDialog dlg = new ColorDefinitionDialog(this.scanpathsPicture.MouseDrawingMode); dlg.SubjectNodes = this.trvSubjects.Nodes; dlg.ColorParams = this.mouseColorParams; if (dlg.ShowDialog() == DialogResult.OK) { this.mouseColorParams = dlg.ColorParams; this.trvSubjects.Refresh(); this.ReReadSelectedSubjects(); this.scanpathsPicture.Subjects = this.selectedSubjects; // Drawing properties changed, so redraw picture this.scanpathsPicture.DrawFixations(true); } }
/////////////////////////////////////////////////////////////////////////////// // 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(); }