ContentControl3D

Kudos to Josh Smith for the Thriple Project which I incorporated support for (the ContentControl3D IParent.) This codeplex project is available here: http://thriple.codeplex.com/

It allows for a 3-dimensional contentcontrol within which items/composites may be "flipped" in 3-dimensional space, allowing for both a "front" and a "back". Rotate is a key method call for this.

Support for this resides in the FasterWPFExtras .dll.

string cc3DGuid = Guid.NewGuid().ToString();
ContentControl3D ccl3d = new ContentControl3D();
           
ccl3d.Padding = new Thickness(0);
ccl3d.Margin = new Thickness(13, 13, 0, 0);
ccl3d.Initialize(431D, 431D, ContainerType.Grid, Brushes.Black, new Thickness(2), BrushExt.CreateSolidColorBrushFromRGB(30, 30, 30, 50), RotationEasingMode.Pounce, RotationDirection.BottomToTop);
ccl3d.SetCompositeGridDimensions<ContentControl3D>(17, 4, 0.33, GridUnitType.Auto, 100, GridUnitType.Auto);

ccl3d.CameraPrototype = DefaultCameraPrototype;

//SETTINGS
ccl3d.BeginSettings<ContentControl3D>()
                .SetUseLayoutRounding<ContentControl3D>(true)
                //.SetSelectorClassToRow<ContentControl3D>(1, 0, 2, "redlabel")
                .Set<Label, ContentControl3D>(0, 0, "Background", Brushes.WhiteSmoke)
                .Set<TextBox, ContentControl3D>(1, 1, "Text", "")
                .Set<TextBox, ContentControl3D>(2, 1, "Text", "")
                .SetFontToColForLabel(0, 0, 16, "Arial", 11, FontWeights.Bold, FontStyles.Normal)
                .Set<TextBox, ContentControl3D>("MaxHeight", 33D)
                .Set<Label, ContentControl3D>("MaxHeight", 33D)
                .Set<TextBox, ContentControl3D>("MaxWidth", 137D)
                .Set<wpfToolkit.DecimalUpDown, ContentControl3D>("MaxWidth", 137D)
                .Set<ComboBox, ContentControl3D>("MaxWidth", 137D)
                .Set<DatePicker, ContentControl3D>("MaxWidth", 137D)
                .Set<wpfToolkit.MaskedTextBox, ContentControl3D>("MaxWidth", 137D)
                .Set<ComboBox, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<Label, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<TextBox, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<wpfToolkit.DecimalUpDown, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<DatePicker, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .Set<wpfToolkit.MaskedTextBox, ContentControl3D>("Margin", new Thickness(1, 1, 1, 3))
                .SetAttachedProperty<Label, ContentControl3D>("ColumnSpan", 0, 0, 
                 obj => { obj.SetValue(Grid.ColumnSpanProperty, 4); })
                .Set<DatePicker, ContentControl3D>(13, 1, "Background", Brushes.WhiteSmoke)
                .SetToCol<Label, ContentControl3D>(0, 1, 15, "HorizontalContentAlignment", HorizontalAlignment.Right)
                .SetVerticalAlignment<ContentControl3D>(0, 1, VerticalAlignment.Center)
                .SetVerticalAlignment<ContentControl3D>(0, 2, VerticalAlignment.Center)
                .SetVerticalAlignment<ContentControl3D>(2, 1, VerticalAlignment.Bottom)
                .SetVerticalAlignment<ContentControl3D>(3, 1, VerticalAlignment.Top)
                .SetToCol<Label, ContentControl3D>(0, 4, 15, "VerticalAlignment", VerticalAlignment.Center)
            //   .SetToRow<FrameworkElement, ContentControl3D>(1, 0, 3, "Height", 30D)
                .SetItemBorderColorAndThickness(Brushes.Blue, new Thickness(0))
                .EndSettings<ContentControl3D>();

string gridguid1 = null;
gridguid1 = Guid.NewGuid().ToString();
ComboBox cb1 = SetupComboBox();
            
//Additional Comments Multi-Line TextBox
TextBox trex = new TextBox();
trex.InitializeForScrollViewerSupport(350D, 350D, 140D);  //TextBox is NOT an IParent but it is an IScrollViewerStrategy.
ScrollViewerStyle.ApplyToScrollViewer<TextBox>(trex, "PowderBlue", "White", "Blue");
trex.SetValue(Grid.RowSpanProperty, 9);
trex.SetValue(Grid.ColumnSpanProperty, 3);        
trex.Text = "This is an example\n of a\n multi-line textbox.";

Brush reuseBrush = BrushExt.CreateGradientBrush(254, 254, 254, 50, 0, 0, 32, 80, 100, .93, 1, 1, 0, 0);

//FRONT SIDE
Border ccl3dBorder1 = ccl3d.BeginComposite<ContentControl3D>(gridguid1)
                 .AddLabel<ContentControl3D>(0, 0, "Front Side: Click Here to Rotate", Brushes.Transparent)
                 .SubscribeEventOnChild<Label, ContentControl3D, MouseButtonEventArgs>(0, 0, "PreviewMouseDown", ((o, ev) =>
                 {
                     ccl3d.Rotate();
                 }))
                   .AddLabel<ContentControl3D>(1, 0, "Attraction:", reuseBrush)
                   .AddLabel<ContentControl3D>(2, 0, "Location:", reuseBrush)
                   .AddLabel<ContentControl3D>(4, 0, "Flight:", reuseBrush)
                   .AddLabel<ContentControl3D>(5, 0, "Hotel:", reuseBrush)
                   .AddLabel<ContentControl3D>(3, 0, "Parking Garage Color:", reuseBrush)
                   .AddLabel<ContentControl3D>(6, 0, "Currency (Max $999.99):", reuseBrush)
                   .AddLabel<ContentControl3D>(7, 0, "Percent (Max 100.00):", reuseBrush)
                   .AddLabel<ContentControl3D>(8, 0, "Rental Car Company:", reuseBrush)
                   .AddLabel<ContentControl3D>(9, 0, "Reason for Travel:", reuseBrush)
                  // .AddLabel<ContentControl3D>(10, 0, "Children:", reuseBrush)
                   .AddLabelSettingBackgroundViaStyle<ContentControl3D>(10, 0, "Children:", reuseBrush)
                   .AddLabel<ContentControl3D>(11, 0, "Favorite Sport:", reuseBrush)
                   .AddLabel<ContentControl3D>(12, 0, "Favorite Food:", reuseBrush)
                   .AddLabel<ContentControl3D>(13, 0, "Date of Travel:", reuseBrush)
                   .AddLabel<ContentControl3D>(14, 0, "Phone Number:", reuseBrush)
                   .AddNumericTextBox<ContentControl3D>(6, 1, 139D, 23D, 299.99M, 999.99M, 0.00M, 1.00M, "C2", true)
                   .ModifyAtXY<wpfToolkit.DecimalUpDown, ContentControl3D>(6, 1, de => { de.SetSelectorClass("decimalControl"); })
                   .AddNumericTextBox<ContentControl3D>(7, 1, 139D, 23D, .99M, 1.00M, 0.00M, .010M, "P2", true)
                   .ModifyAtXY<wpfToolkit.DecimalUpDown, ContentControl3D>(7, 1, de => { de.SetSelectorClass("decimalControl"); })
                   .AddAnything<TextBox, ContentControl3D>(1, 1).ModifyAtXY<TextBox, ContentControl3D>(1, 1, k => { k.Text = "hello world!"; k.Background = Brushes.Gold; })
                   .AddAnything<TextBox, ContentControl3D>(2, 1)
                   .AddExisting<ComboBox, ContentControl3D>(3, 1, cb1)
                   .AddAnything<TextBox, ContentControl3D>(4, 1)
                   .AddAnything<TextBox, ContentControl3D>(5, 1)
                   .AddAnything<TextBox, ContentControl3D>(8, 1)
                   .AddAnything<TextBox, ContentControl3D>(9, 1)

                  .DataBindOneChildsPropertyToAnother<Label, TextBox, ContentControl3D>(10, 0, 9, 1, Label.ContentProperty, TextBox.TextProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay)
                  
                   .AddAnything<TextBox, ContentControl3D>(10, 1)
                   .AddAnything<TextBox, ContentControl3D>(11, 1)
                   .AddAnything<TextBox, ContentControl3D>(12, 1)             
                   .AddAnything<DatePicker, ContentControl3D>(13, 1)
                   .AddFixedLengthMaskedTextBox<ContentControl3D>(14, 1, "(219) 999-9999", "(000) 000-0000", true, true)
                   .EndComposite(new ContentControl3DArgs(ContentControlEnum.Front));
            
         //   ccl3dBorder1.DataBindContainersPropertyToParents<Grid, ContentControl3D>(Grid.MarginProperty, ContentControl3D.MarginProperty, System.Windows.Data.UpdateSourceTrigger.PropertyChanged, System.Windows.Data.BindingMode.OneWay, new TestConverter());

//BACK SIDE
Border ccl3dBorder2 = ccl3d.BeginComposite<ContentControl3D>()
                 .AddLabel<ContentControl3D>(0, 0, "Back Side: Click Here to Rotate", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(1, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(1, 1, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(2, 0, "Additional Comments:", reuseBrush)
                 .AddExisting<TextBox, ContentControl3D>(3, 0, trex)
                 .AddLabel<ContentControl3D>(11, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(12, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(13, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(14, 0, "", Brushes.Transparent)
                 .AddLabel<ContentControl3D>(15, 0, "Special Needs:", reuseBrush)
                 .AddAnything<TextBox, ContentControl3D>(16, 0)
                 .SubscribeEventOnChild<Label, ContentControl3D, MouseButtonEventArgs>(0, 0, "PreviewMouseDown",(o, ev) =>
                 {
                     ccl3d.Rotate();
                 })
                 .EndComposite(new ContentControl3DArgs(ContentControlEnum.Back));
          
//Override Settings
ccl3dBorder1.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinWidthProperty, 334D);
ccl3dBorder1.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinHeightProperty, 34D);

ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinWidthProperty, 334D);
ccl3dBorder2.GetChildFromComposite<TextBox, ContentControl3D>(16, 0).SetValue(Label.MinWidthProperty, 334D);
ccl3dBorder2.GetChildFromComposite<TextBox, ContentControl3D>(3, 0).SetValue(Label.MinWidthProperty, 334D);
ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(0, 0).SetValue(Label.MinHeightProperty, 34D);
ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(2, 0).SetValue(Grid.ColumnSpanProperty, 3);
ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(15, 0).SetValue(Grid.ColumnSpanProperty, 4);
ccl3dBorder2.GetChildFromComposite<TextBox, ContentControl3D>(16, 0).SetValue(Grid.ColumnSpanProperty, 4);
ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(2, 0).SetValue(Label.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
ccl3dBorder2.GetChildFromComposite<Label, ContentControl3D>(15, 0).SetValue(Label.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
     

Last edited Apr 15, 2014 at 5:45 AM by stagathome0069, version 7

Comments

No comments yet.