/** * Constructor */ public ImageButton() { mButton = new System.Windows.Controls.Button(); mStretchForeground = new System.Windows.Media.Stretch(); mStretchForeground = System.Windows.Media.Stretch.None; mStretchBackground = new System.Windows.Media.Stretch(); mStretchBackground = System.Windows.Media.Stretch.Fill; this.createBackgroundImage(); this.createTextBlock(); this.createForegroundImage(); /** * Grid object that holds the text and the foreground and background images * It has only one row and one column * It will display whe widgets one on top of each other */ mGrid = new System.Windows.Controls.Grid(); this.AddWidgetsToGrid(); mButton.Content = mGrid; mButton.HorizontalAlignment = HorizontalAlignment.Left; mButton.VerticalAlignment = VerticalAlignment.Top; fillSpaceVerticalyEnabled = false; fillSpaceHorizontalyEnabled = false; mButton.BorderThickness = new Thickness(0.0); mButton.Margin = new Thickness(0.0); mGrid.Margin = new Thickness(0.0); mButton.Padding = new Thickness(0.0); mBackgroundImage.Margin = new Thickness(0.0); mForegroundImage.Margin = new Thickness(0.0); mView = mButton; //the click handle the button component mButton.Click += new RoutedEventHandler( delegate(Object from, RoutedEventArgs evt) { //create a Memory object of 8 Bytes Memory eventData = new Memory(8); //starting with the 0 Byte we write the eventType const int MAWidgetEventData_eventType = 0; //starting with the 4th Byte we write the widgetHandle const int MAWidgetEventData_widgetHandle = 4; eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_CLICKED); eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle); //posting a CustomEvent mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData); }); }
//private void ImageStretch_Executed(object sender, ExecutedRoutedEventArgs e) //{ // //switch (e.Parameter.ToString()) // //{ // // case "none": // // SetStretchMode(System.Windows.Media.Stretch.None); // // break; // // case "fill": // // SetStretchMode(System.Windows.Media.Stretch.Fill); // // break; // // case "uniform": // // SetStretchMode(System.Windows.Media.Stretch.Uniform); // // break; // // case "uniformtofill": // // SetStretchMode(System.Windows.Media.Stretch.UniformToFill); // // break; // // default: // // SetStretchMode(System.Windows.Media.Stretch.Uniform); // // break; // //} //} private void SetStretchMode(System.Windows.Media.Stretch stretchMode) { userImage.Stretch = stretchMode; sampleImage1.Stretch = stretchMode; sampleImage2.Stretch = stretchMode; sampleImage3.Stretch = stretchMode; sampleImage4.Stretch = stretchMode; sampleImage5.Stretch = stretchMode; mediaUI.Stretch = stretchMode; }
/** * The constructor */ public Image() { mImage = new System.Windows.Controls.Image(); mStretch = new System.Windows.Media.Stretch(); mImage.HorizontalAlignment = HorizontalAlignment.Left; mImage.VerticalAlignment = VerticalAlignment.Top; mStretch = System.Windows.Media.Stretch.None; mImage.Stretch = mStretch; View = mImage; }
/** * The constructor */ public Image() { mImage = new System.Windows.Controls.Image(); mStretch = new System.Windows.Media.Stretch(); mParentCanvas = new Grid(); mImage.HorizontalAlignment = HorizontalAlignment.Left; mImage.VerticalAlignment = VerticalAlignment.Top; mStretch = System.Windows.Media.Stretch.None; mImage.Stretch = mStretch; mParentCanvas.Children.Add(mImage); View = mParentCanvas; }
/** * Constructor */ public ImageButton() { mStretchForeground = new System.Windows.Media.Stretch(); mStretchForeground = System.Windows.Media.Stretch.None; mStretchBackground = new System.Windows.Media.Stretch(); mStretchBackground = System.Windows.Media.Stretch.Fill; this.createBackgroundImage(); this.createTextBlock(); this.createForegroundImage(); /** * Grid object that holds the text and the foreground and background images * It has only one row and one column * It will display whe widgets one on top of each other */ mGrid = new System.Windows.Controls.Grid(); this.AddWidgetsToGrid(); mGrid.Margin = new Thickness(0.0); mBackgroundImage.Margin = new Thickness(0.0); mForegroundImage.Margin = new Thickness(0.0); mBackgroundImage.Width = mGrid.Width - DifferenceSpacer; mBackgroundImage.Height = mGrid.Height - DifferenceSpacer; mBackgroundImage.Stretch = mStretchBackground; // We need to make this view a ContentControl in order to have System.Windows.Controls::Control properties enabled. ContentControl contentControl = new System.Windows.Controls.ContentControl(); contentControl.Content = mGrid; View = contentControl; // the MouseEnter handle for the ImageButton. Used for switching background image. mGrid.MouseEnter += new System.Windows.Input.MouseEventHandler(delegate(Object from, System.Windows.Input.MouseEventArgs evt) { if (mPressedBackgroundImageSource != null) { mNormalBackgroundImageSource = (System.Windows.Media.Imaging.BitmapSource)mBackgroundImage.Source; mBackgroundImage.Source = mPressedBackgroundImageSource; } }); // the MouseLeave handle for the ImageButton. Used for switching background image. mGrid.MouseLeave += new System.Windows.Input.MouseEventHandler(delegate(Object from, System.Windows.Input.MouseEventArgs evt) { if (mNormalBackgroundImageSource != null) { mBackgroundImage.Source = mNormalBackgroundImageSource; mNormalBackgroundImageSource = null; } //create a Memory object of 8 Bytes Memory eventData = new Memory(8); //starting with the 0 Byte we write the eventType const int MAWidgetEventData_eventType = 0; //starting with the 4th Byte we write the widgetHandle const int MAWidgetEventData_widgetHandle = 4; eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_CLICKED); eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle); //posting a CustomEvent mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData); }); }
/** * Constructor */ public ImageButton() { mButton = new System.Windows.Controls.Button(); mStretchForeground = new System.Windows.Media.Stretch(); mStretchForeground = System.Windows.Media.Stretch.None; mStretchBackground = new System.Windows.Media.Stretch(); mStretchBackground = System.Windows.Media.Stretch.Fill; this.createBackgroundImage(); this.createTextBlock(); this.createForegroundImage(); /** * Grid object that holds the text and the foreground and background images * It has only one row and one column * It will display whe widgets one on top of each other */ mGrid = new System.Windows.Controls.Grid(); this.AddWidgetsToGrid(); mButton.Content = mGrid; mButton.HorizontalAlignment = HorizontalAlignment.Left; mButton.VerticalAlignment = VerticalAlignment.Top; mButton.BorderThickness = new Thickness(0.0); mButton.Margin = new Thickness(0.0); mGrid.Margin = new Thickness(0.0); mButton.Padding = new Thickness(0.0); mBackgroundImage.Margin = new Thickness(0.0); mForegroundImage.Margin = new Thickness(0.0); mView = mButton; //the click handle the button component mButton.Click += new RoutedEventHandler( delegate(Object from, RoutedEventArgs evt) { //create a Memory object of 8 Bytes Memory eventData = new Memory(8); //starting with the 0 Byte we write the eventType const int MAWidgetEventData_eventType = 0; //starting with the 4th Byte we write the widgetHandle const int MAWidgetEventData_widgetHandle = 4; eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_CLICKED); eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle); //posting a CustomEvent mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData); }); }
/** * Constructor */ public ListViewItem() { mGrid = new System.Windows.Controls.Grid(); mIcon = new System.Windows.Controls.Image(); mIcon.VerticalAlignment = VerticalAlignment.Center; mStretch = new System.Windows.Media.Stretch(); mText = new System.Windows.Controls.TextBlock(); mText.TextWrapping = TextWrapping.NoWrap; mText.Margin = new Thickness(10); mText.VerticalAlignment = VerticalAlignment.Center; mText.TextAlignment = TextAlignment.Left; mColumn1 = new ColumnDefinition(); mColumn1.Width = new GridLength(1, GridUnitType.Auto); mColumn2 = new ColumnDefinition(); mColumn2.Width = new GridLength(1, GridUnitType.Star); mRow = new RowDefinition(); mRow.Height = new GridLength(1, GridUnitType.Auto); mGrid.RowDefinitions.Add(mRow); mGrid.ColumnDefinitions.Add(mColumn1); mGrid.ColumnDefinitions.Add(mColumn2); Grid.SetRow(mIcon, 0); Grid.SetColumn(mIcon, 0); Grid.SetRow(mText, 0); Grid.SetColumnSpan(mText, 1); Grid.SetColumn(mText, 1); mGrid.Children.Add(mIcon); mGrid.Children.Add(mText); View = mGrid; this.ItemSelected = false; this.ItemsSourceItemIndex = -1; // set the default font color values mFontColor = new SolidColorBrush(Colors.White); mSubtitleFontColor = new SolidColorBrush(Colors.White); }
/** * Constructor */ public ImageButton() { mStretchForeground = new System.Windows.Media.Stretch(); mStretchForeground = System.Windows.Media.Stretch.None; mStretchBackground = new System.Windows.Media.Stretch(); mStretchBackground = System.Windows.Media.Stretch.Fill; this.createBackgroundImage(); this.createTextBlock(); this.createForegroundImage(); /** * Grid object that holds the text and the foreground and background images * It has only one row and one column * It will display whe widgets one on top of each other */ mGrid = new System.Windows.Controls.Grid(); this.AddWidgetsToGrid(); mGrid.Margin = new Thickness(0.0); mBackgroundImage.Margin = new Thickness(0.0); mForegroundImage.Margin = new Thickness(0.0); mBackgroundImage.Width = mGrid.Width - DifferenceSpacer; mBackgroundImage.Height = mGrid.Height - DifferenceSpacer; mBackgroundImage.Stretch = mStretchBackground; mView = mGrid; // the MouseEnter handle for the ImageButton. Used for switching background image. mGrid.MouseEnter += new System.Windows.Input.MouseEventHandler(delegate(Object from, System.Windows.Input.MouseEventArgs evt) { if (mPressedBackgroundImageSource != null) { mNormalBackgroundImageSource = (System.Windows.Media.Imaging.BitmapSource)mBackgroundImage.Source; mBackgroundImage.Source = mPressedBackgroundImageSource; } }); // the MouseLeave handle for the ImageButton. Used for switching background image. mGrid.MouseLeave += new System.Windows.Input.MouseEventHandler(delegate(Object from, System.Windows.Input.MouseEventArgs evt) { if (mNormalBackgroundImageSource != null) { mBackgroundImage.Source = mNormalBackgroundImageSource; mNormalBackgroundImageSource = null; } //create a Memory object of 8 Bytes Memory eventData = new Memory(8); //starting with the 0 Byte we write the eventType const int MAWidgetEventData_eventType = 0; //starting with the 4th Byte we write the widgetHandle const int MAWidgetEventData_widgetHandle = 4; eventData.WriteInt32(MAWidgetEventData_eventType, MoSync.Constants.MAW_EVENT_CLICKED); eventData.WriteInt32(MAWidgetEventData_widgetHandle, mHandle); //posting a CustomEvent mRuntime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_WIDGET, eventData); }); }
/** * Constructor */ public ListViewItem() { mItem = new System.Windows.Controls.ListBoxItem(); mGrid = new System.Windows.Controls.Grid(); mIcon = new System.Windows.Controls.Image(); mIcon.VerticalAlignment = VerticalAlignment.Center; mStretch = new System.Windows.Media.Stretch(); mText = new System.Windows.Controls.TextBlock(); mText.TextWrapping = TextWrapping.NoWrap; mText.Margin = new Thickness(10); mText.VerticalAlignment = VerticalAlignment.Center; mText.TextAlignment = TextAlignment.Left; mColumn1 = new ColumnDefinition(); mColumn1.Width = new GridLength(1, GridUnitType.Auto); mColumn2 = new ColumnDefinition(); mColumn2.Width = new GridLength(1, GridUnitType.Star); mRow = new RowDefinition(); mRow.Height = new GridLength(1, GridUnitType.Auto); mGrid.RowDefinitions.Add(mRow); mGrid.ColumnDefinitions.Add(mColumn1); mGrid.ColumnDefinitions.Add(mColumn2); Grid.SetRow(mIcon, 0); Grid.SetColumn(mIcon, 0); Grid.SetRow(mText, 0); Grid.SetColumnSpan(mText, 1); Grid.SetColumn(mText, 1); mGrid.Children.Add(mIcon); mGrid.Children.Add(mText); mItem.Content = mGrid; mView = mItem; }
//********************************* Media settigns ************************************************* public void set_settings(string[] files, int dt, int bt, int ct, int ec, int et, int fct, System.Windows.Media.Stretch dmode, bool key_state, bool cross_state, string out_path, string name, string attr)// Initialize the presentation settings { New_presentation_stage = "start"; System.Windows.Forms.Cursor.Position = screens_center; // Move cursor to the center of presentation screen System.Windows.Forms.Cursor.Hide(); // Hide cursor when presentation form is active mouse_x = "0"; // cursor X position mouse_y = "0"; // cursor Y position isDrawing = false; // true = log, false = no log timer6.Start(); label1.Font = Properties.Settings.Default.Counter_Font; // counter Font label1.ForeColor = Properties.Settings.Default.Counter_Color; // counter color label2.Font = Properties.Settings.Default.Cross_Font; // fixation cross font label2.ForeColor = Properties.Settings.Default.Cross_Color; // fixation cross color label2.Text = "+"; // fixation symbol label2.Visible = false; // cross label filespaths = files; // filespaths = Form1.listBox1 items in string[] counter_show = ct; // start up counter value if (dt == 0) // if user change duration time to 0, then... { duration_time = 1; // duration_time = 1 millisecond (numericUpDown.Value must be != 0) } else { duration_time = dt * 1000; // (*1000 = seconds) } if (bt == 0) // if user change between time to 0, then... { between_time = 1; // between_time = 1 millisecond (numericUpDown.Value must be != 0) } else { between_time = bt * 1000; // (*1000 = seconds) } if (et == 0) // if user change evaluation time to 0, then... { evaluation_time = 1; // evaluation_time = 1 millisecond (numericUpDown.Value must be != 0) } else { evaluation_time = et * 1000; // (*1000 = seconds) } if (fct == 0) // if user change cross time to 0, then... { cross_time = 1; // cross_time = 1 millisecond (numericUpDown.Value must be != 0) } else { cross_time = fct * 1000; // (*1000 = seconds) } displaymode = dmode; // Initialize displaymode save_file_name = name; // Initialize save_file_name stimuli_output_path = out_path; // Initializepath of emotiv output file attributes_names = attr; // Initialize attributes_names attributes_values = new string[filespaths.Length]; // new string[attributes_names.Count(f => f == ',') + 1];// Initialize attributes_values(counts "," and length = # of "," + 1) attribute_log = false; // Initialize attribute_log evaluation_counter = ec; // Initialize evaluation_counter keystroke_state = key_state; // Initialize keystroke_state fixation_cross = cross_state; // Initialize fixation_cross delimiter = delimiter_return(Properties.Settings.Default.Delimiter); csv.Clear(); // Initialize keystroke log calculate_centers(); // calculate old, new and active screen centers cursor_log = Properties.Settings.Default.Cursor_log; // cursor_log value normalize_value = (double)Properties.Settings.Default.Normalize_Value; // max normalize value for converting pixel to normalize point }