Example #1
0
        private void cell_KeyDown(object sender, KeyEventArgs e)
        {
            DataGridCell     dataGridCell     = sender as DataGridCell;
            FrameworkElement frameworkElement = dataGridCell.Content as FrameworkElement;
            bool             flag1            = e.Key == Key.Escape;
            bool             flag2            = flag1;
            bool             flag3            = frameworkElement is TextBox || frameworkElement is ContentPresenter && ((ContentPresenter)frameworkElement).Content == null;
            SampleBasicType  sampleType       = ((SampleDataDialogColumn)dataGridCell.Column).SampleType;

            if (sampleType == SampleBasicType.Number || sampleType == SampleBasicType.String)
            {
                if (flag3)
                {
                    if (flag1)
                    {
                        this.dialog.SampleDataGrid.CancelEdit();
                        flag2 = false;
                    }
                }
                else if (!flag1)
                {
                    this.dialog.SampleDataGrid.BeginEdit();
                    TextBox textBox = dataGridCell.Content as TextBox;
                    if (textBox != null)
                    {
                        textBox.Focus();
                    }
                }
            }
            if (!flag2)
            {
                return;
            }
            this.dialog.Close();
        }
Example #2
0
 private DataTemplate GetTemplateForType(SampleBasicType type, bool editingMode)
 {
     if (editingMode)
     {
         return((DataTemplate)this.dialog.SampleDataGrid.Resources[(object)(type.Name + "CellEditingTemplate")]);
     }
     return((DataTemplate)this.dialog.SampleDataGrid.Resources[(object)(type.Name + "CellTemplate")]);
 }
Example #3
0
 public SampleDataPropertyConfiguration(SampleProperty sampleProperty)
 {
     this.activeType      = (SampleBasicType)sampleProperty.PropertySampleType;
     this.valueGenerators = new Dictionary <SampleBasicType, ISampleTypeConfiguration>();
     foreach (SampleBasicType sampleBasicType in SampleBasicType.SampleBasicTypes)
     {
         string format           = sampleBasicType == sampleProperty.PropertySampleType ? sampleProperty.Format : (string)null;
         string formatParameters = sampleBasicType == sampleProperty.PropertySampleType ? sampleProperty.FormatParameters : (string)null;
         ISampleTypeConfiguration configuration = SampleDataPropertyConfiguration.CreateConfiguration(sampleProperty.DeclaringDataSet, sampleBasicType, format, formatParameters);
         this.valueGenerators.Add(sampleBasicType, configuration);
     }
 }
Example #4
0
 public void SetConfigurationValue(ConfigurationPlaceholder placeholder, object value)
 {
     if (placeholder == ConfigurationPlaceholder.Type)
     {
         this.activeType = (SampleBasicType)((SampleDataConfigurationOption)value).Value;
     }
     else if (placeholder == ConfigurationPlaceholder.NumberLength)
     {
         this.NumberValueGenerator.SetConfigurationValue(placeholder, value);
     }
     else if (placeholder == ConfigurationPlaceholder.ImageFolderBrowser)
     {
         this.ImageValueGenerator.SetConfigurationValue(placeholder, value);
     }
     else
     {
         if (placeholder != ConfigurationPlaceholder.RandomLatinWordCount && placeholder != ConfigurationPlaceholder.RandomLatinWordLength && placeholder != ConfigurationPlaceholder.StringFormat)
         {
             return;
         }
         this.StringValueGenerator.SetConfigurationValue(placeholder, value);
     }
 }
Example #5
0
 private ImageSource GetIconResource(SampleBasicType type, bool mouseOver)
 {
     if (type == null)
     {
         return((ImageSource)null);
     }
     if (TypeConfigurationButton.iconResourcesMouseOn == null)
     {
         TypeConfigurationButton.iconResourcesMouseOn = new Dictionary <SampleBasicType, ImageSource>();
         TypeConfigurationButton.iconResourcesMouseOn.Add(SampleBasicType.Boolean, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriBooleanOn));
         TypeConfigurationButton.iconResourcesMouseOn.Add(SampleBasicType.Image, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriImageOn));
         TypeConfigurationButton.iconResourcesMouseOn.Add(SampleBasicType.Number, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriNumberOn));
         TypeConfigurationButton.iconResourcesMouseOn.Add(SampleBasicType.String, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriStringOn));
     }
     if (TypeConfigurationButton.iconResourcesMouseOff == null)
     {
         TypeConfigurationButton.iconResourcesMouseOff = new Dictionary <SampleBasicType, ImageSource>();
         TypeConfigurationButton.iconResourcesMouseOff.Add(SampleBasicType.Boolean, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriBooleanOff));
         TypeConfigurationButton.iconResourcesMouseOff.Add(SampleBasicType.Image, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriImageOff));
         TypeConfigurationButton.iconResourcesMouseOff.Add(SampleBasicType.Number, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriNumberOff));
         TypeConfigurationButton.iconResourcesMouseOff.Add(SampleBasicType.String, this.GenerateImageSourceFromPath(TypeConfigurationButton.IconUriStringOff));
     }
     return((mouseOver ? TypeConfigurationButton.iconResourcesMouseOn : TypeConfigurationButton.iconResourcesMouseOff)[type]);
 }
Example #6
0
 public static ISampleTypeConfiguration CreateConfiguration(SampleDataSet sampleData, SampleBasicType type, string format, string formatParameters)
 {
     if (type == SampleBasicType.Boolean)
     {
         return((ISampleTypeConfiguration) new SampleBooleanConfiguration());
     }
     if (type == SampleBasicType.Image)
     {
         return((ISampleTypeConfiguration) new SampleImageConfiguration(sampleData, formatParameters));
     }
     if (type == SampleBasicType.Number)
     {
         return((ISampleTypeConfiguration) new SampleNumberConfiguration(formatParameters));
     }
     if (type == SampleBasicType.String)
     {
         return((ISampleTypeConfiguration) new SampleStringConfiguration(format, formatParameters));
     }
     return((ISampleTypeConfiguration)null);
 }
Example #7
0
 public TypeFormatInfo(SampleBasicType sampleType, string format, string formatParameters)
 {
     this.SampleType       = sampleType;
     this.Format           = format;
     this.FormatParameters = formatParameters;
 }