コード例 #1
0
ファイル: XamlReader.cs プロジェクト: modulexcite/Avalonia
        public static void Load(Stream stream, object component)
        {
            DependencyObject dependencyObject = component as DependencyObject;
            NameScope nameScope = new NameScope();

            if (dependencyObject != null)
            {
                NameScope.SetNameScope(dependencyObject, nameScope);
            }

            XmlReader xml = XmlReader.Create(stream);
            XamlXmlReader reader = new XamlXmlReader(xml);
            XamlObjectWriter writer = new XamlObjectWriter(
                new XamlSchemaContext(),
                new XamlObjectWriterSettings
                {
                    RootObjectInstance = component,
                    ExternalNameScope = nameScope,
                    RegisterNamesOnExternalNamescope = true,
                    XamlSetValueHandler = SetValue,
                });
            
            while (reader.Read())
            {
                writer.WriteNode(reader);
            }
        }
コード例 #2
0
        public void Cannot_Register_New_Element_With_Existing_Name()
        {
            var target = new NameScope();

            target.Register("foo", new object());
            Assert.Throws<ArgumentException>(() => target.Register("foo", new object()));
        }
コード例 #3
0
        public void Register_Registers_Element()
        {
            var target = new NameScope();
            var element = new object();

            target.Register("foo", element);

            Assert.Same(element, target.Find("foo"));
        }
コード例 #4
0
        public void Unregister_Unregisters_Element()
        {
            var target = new NameScope();
            var element = new object();

            target.Register("foo", element);
            target.Unregister("foo");

            Assert.Null(target.Find("foo"));
        }
コード例 #5
0
        public void Can_Register_Same_Element_More_Than_Once()
        {
            var target = new NameScope();
            var element = new object();

            target.Register("foo", element);
            target.Register("foo", element);

            Assert.Same(element, target.Find("foo"));
        }
コード例 #6
0
ファイル: XamlParser.cs プロジェクト: shana/moon
		public XamlParser (XamlContext context) 
		{
			Context = context;
			DefaultXmlns = String.Empty;
			Xmlns = new Dictionary<string,string> ();
			IgnorableXmlns = new List<string> ();
			NameScope = new NameScope ();

			NameScope.Temporary = true;
		}
コード例 #7
0
		public virtual IFile ResolveFile(string name, NameScope scope)
		{
			return (IFile)Resolve(name, NodeType.File, scope);
		}
コード例 #8
0
		public void Visit(RootNode node, INode parentNode)
		{
			var ns = new NameScope();
			node.Namescope = ns;
			scopes[node] = ns;
		}
コード例 #9
0
ファイル: TemplatedControl.cs プロジェクト: Arlorean/Perspex
        /// <inheritdoc/>
        public sealed override void ApplyTemplate()
        {
            if (!_templateApplied)
            {
                VisualChildren.Clear();

                if (Template != null)
                {
                    _templateLog.Verbose("Creating control template");

                    var child = Template.Build(this);
                    var nameScope = new NameScope();
                    NameScope.SetNameScope((Control)child, nameScope);

                    // We need to call SetupTemplateControls twice:
                    // - Once before the controls are added to the visual/logical trees so that the
                    //   TemplatedParent property is set and names are registered; if 
                    //   TemplatedParent is not set when the control is added to the logical tree, 
                    //   then styles with the /template/ selector won't match.
                    // - Once after the controls are added to the logical tree (and thus styled) to
                    //   call ApplyTemplate on nested templated controls and register any of our
                    //   templated children that appear as children of presenters in these nested
                    //   templated child controls.
                    SetupTemplateControls(child, nameScope);
                    VisualChildren.Add(child);
                    ((ISetLogicalParent)child).SetParent(this);
                    SetupTemplateControls(child, nameScope);

                    OnTemplateApplied(new TemplateAppliedEventArgs(nameScope));
                }

                _templateApplied = true;
            }
        }
コード例 #10
0
        private StackPanel ReturnStackPanel2()
        {
            // <SnippetAutoLayoutContentParentedUIElementExample>
            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());

            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Margin = new Thickness(20, 0, 0, 0);
            TextBlock myTextBlock = new TextBlock();

            myTextBlock.Margin = new Thickness(0, 10, 0, 0);
            myTextBlock.Text   = "The UIElement";
            myStackPanel.Children.Add(myTextBlock);

            Button myButton = new Button();

            myButton.Content = "Hello, World";
            myButton.Width   = 70;
            this.RegisterName("MyButton", myButton);
            myStackPanel.Children.Add(myButton);

            TextBlock myTextBlock2 = new TextBlock();

            myTextBlock2.Margin = new Thickness(0, 10, 0, 0);
            myTextBlock2.Text   = "AutoLayoutContent: True";
            myStackPanel.Children.Add(myTextBlock2);

            Rectangle myRectangle = new Rectangle();

            myRectangle.Width           = 100;
            myRectangle.Height          = 100;
            myRectangle.Stroke          = Brushes.Black;
            myRectangle.StrokeThickness = 1;

            // Create the Fill for the rectangle using a VisualBrush.
            VisualBrush myVisualBrush = new VisualBrush();

            myVisualBrush.AutoLayoutContent = true;
            Binding buttonBinding = new Binding();

            buttonBinding.ElementName = "MyButton";
            BindingOperations.SetBinding(myVisualBrush, VisualBrush.VisualProperty, buttonBinding);

            // Set the fill of the Rectangle to the Visual Brush.
            myRectangle.Fill = myVisualBrush;

            // Add the first rectangle.
            myStackPanel.Children.Add(myRectangle);

            TextBlock myTextBlock3 = new TextBlock();

            myTextBlock3.Margin = new Thickness(0, 10, 0, 0);
            myTextBlock3.Text   = "AutoLayoutContent: False";
            myStackPanel.Children.Add(myTextBlock3);

            Rectangle myRectangle2 = new Rectangle();

            myRectangle2.Width           = 100;
            myRectangle2.Height          = 100;
            myRectangle2.Stroke          = Brushes.Black;
            myRectangle2.StrokeThickness = 1;

            // Create the Fill for the rectangle using a VisualBrush.
            VisualBrush myVisualBrush2 = new VisualBrush();

            myVisualBrush2.AutoLayoutContent = false;
            Binding buttonBinding2 = new Binding();

            buttonBinding2.ElementName = "MyButton";
            BindingOperations.SetBinding(myVisualBrush2, VisualBrush.VisualProperty, buttonBinding2);

            // Set the fill of the Rectangle to the Visual Brush.
            myRectangle2.Fill = myVisualBrush2;

            myStackPanel.Children.Add(myRectangle2);

            // </SnippetAutoLayoutContentParentedUIElementExample>
            return(myStackPanel);
        }
コード例 #11
0
ファイル: QueryUploadPage.cs プロジェクト: XiaoBaiXJ/RFID
        private void InitializeComponent()
        {
            if (ResourceLoader.ResourceProvider != null && ResourceLoader.ResourceProvider(typeof(QueryUploadPage).GetTypeInfo().Assembly.GetName(), "Views/QueryUploadPage.xaml") != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(base.GetType()) != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            BindingExtension  bindingExtension  = new BindingExtension();
            ColumnDefinition  columnDefinition  = new ColumnDefinition();
            ColumnDefinition  columnDefinition2 = new ColumnDefinition();
            RowDefinition     rowDefinition     = new RowDefinition();
            Label             label             = new Label();
            Label             label2            = new Label();
            Grid              grid = new Grid();
            BindingExtension  bindingExtension2 = new BindingExtension();
            DataTemplate      dataTemplate      = new DataTemplate();
            ListView          listView          = new ListView();
            StackLayout       stackLayout       = new StackLayout();
            BindingExtension  bindingExtension3 = new BindingExtension();
            BindingExtension  bindingExtension4 = new BindingExtension();
            ActivityIndicator activityIndicator = new ActivityIndicator();
            Grid              grid2             = new Grid();
            NameScope         nameScope         = new NameScope();

            NameScope.SetNameScope(this, nameScope);
            NameScope.SetNameScope(grid2, nameScope);
            NameScope.SetNameScope(stackLayout, nameScope);
            NameScope.SetNameScope(grid, nameScope);
            NameScope.SetNameScope(columnDefinition, nameScope);
            NameScope.SetNameScope(columnDefinition2, nameScope);
            NameScope.SetNameScope(rowDefinition, nameScope);
            NameScope.SetNameScope(label, nameScope);
            NameScope.SetNameScope(label2, nameScope);
            NameScope.SetNameScope(listView, nameScope);
            NameScope.SetNameScope(activityIndicator, nameScope);
            bindingExtension.Path = "Title";
            BindingBase binding = ((IMarkupExtension <BindingBase>)bindingExtension).ProvideValue(null);

            this.SetBinding(Page.TitleProperty, binding);
            stackLayout.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(0.0));
            stackLayout.SetValue(StackLayout.SpacingProperty, 0.0);
            grid.SetValue(VisualElement.BackgroundColorProperty, Color.Silver);
            grid.SetValue(Grid.RowSpacingProperty, 5.0);
            grid.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(10.0, 5.0, 10.0, 5.0));
            columnDefinition.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition);
            columnDefinition2.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("3*"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition2);
            rowDefinition.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("40"));
            grid.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition);
            label.SetValue(Grid.ColumnProperty, 0);
            label.SetValue(Label.TextProperty, "运单描述");
            label.SetValue(Label.TextColorProperty, new Color(0.501960813999176, 0.501960813999176, 0.501960813999176, 1.0));
            BindableObject         bindableObject        = label;
            BindableProperty       fontSizeProperty      = Label.FontSizeProperty;
            IExtendedTypeConverter extendedTypeConverter = new FontSizeConverter();
            string value = "Default";
            XamlServiceProvider xamlServiceProvider = new XamlServiceProvider();
            Type typeFromHandle = typeof(IProvideValueTarget);

            object[] array = new object[0 + 5];
            array[0] = label;
            array[1] = grid;
            array[2] = stackLayout;
            array[3] = grid2;
            array[4] = this;
            xamlServiceProvider.Add(typeFromHandle, new SimpleValueTargetProvider(array, Label.FontSizeProperty));
            xamlServiceProvider.Add(typeof(INameScopeProvider), new NameScopeProvider
            {
                NameScope = nameScope
            });
            Type typeFromHandle2 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver = new XmlNamespaceResolver();

            xmlNamespaceResolver.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver.Add("layout", "clr-namespace:RFID.Layout");
            xamlServiceProvider.Add(typeFromHandle2, new XamlTypeResolver(xmlNamespaceResolver, typeof(QueryUploadPage).GetTypeInfo().Assembly));
            xamlServiceProvider.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(16, 75)));
            bindableObject.SetValue(fontSizeProperty, extendedTypeConverter.ConvertFromInvariantString(value, xamlServiceProvider));
            label.SetValue(View.HorizontalOptionsProperty, LayoutOptions.FillAndExpand);
            label.SetValue(View.VerticalOptionsProperty, LayoutOptions.Center);
            label.SetValue(Label.HorizontalTextAlignmentProperty, new TextAlignmentConverter().ConvertFromInvariantString("Start"));
            grid.Children.Add(label);
            label2.SetValue(Grid.ColumnProperty, 1);
            label2.SetValue(Label.TextProperty, "运单照片");
            BindableObject         bindableObject2        = label2;
            BindableProperty       fontSizeProperty2      = Label.FontSizeProperty;
            IExtendedTypeConverter extendedTypeConverter2 = new FontSizeConverter();
            string value2 = "Default";
            XamlServiceProvider xamlServiceProvider2 = new XamlServiceProvider();
            Type typeFromHandle3 = typeof(IProvideValueTarget);

            object[] array2 = new object[0 + 5];
            array2[0] = label2;
            array2[1] = grid;
            array2[2] = stackLayout;
            array2[3] = grid2;
            array2[4] = this;
            xamlServiceProvider2.Add(typeFromHandle3, new SimpleValueTargetProvider(array2, Label.FontSizeProperty));
            xamlServiceProvider2.Add(typeof(INameScopeProvider), new NameScopeProvider
            {
                NameScope = nameScope
            });
            Type typeFromHandle4 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver2 = new XmlNamespaceResolver();

            xmlNamespaceResolver2.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver2.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver2.Add("layout", "clr-namespace:RFID.Layout");
            xamlServiceProvider2.Add(typeFromHandle4, new XamlTypeResolver(xmlNamespaceResolver2, typeof(QueryUploadPage).GetTypeInfo().Assembly));
            xamlServiceProvider2.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(17, 61)));
            bindableObject2.SetValue(fontSizeProperty2, extendedTypeConverter2.ConvertFromInvariantString(value2, xamlServiceProvider2));
            label2.SetValue(Label.TextColorProperty, Color.Black);
            label2.SetValue(View.HorizontalOptionsProperty, LayoutOptions.FillAndExpand);
            label2.SetValue(View.VerticalOptionsProperty, LayoutOptions.Center);
            grid.Children.Add(label2);
            stackLayout.Children.Add(grid);
            listView.SetValue(ListView.SelectionModeProperty, ListViewSelectionMode.None);
            listView.SetValue(ListView.RowHeightProperty, 90);
            bindingExtension2.Path = "QueryWaybills";
            BindingBase binding2 = ((IMarkupExtension <BindingBase>)bindingExtension2).ProvideValue(null);

            listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, binding2);
            IDataTemplate dataTemplate2 = dataTemplate;

            QueryUploadPage.< InitializeComponent > _anonXamlCDataTemplate_3 <InitializeComponent> _anonXamlCDataTemplate_ = new QueryUploadPage.< InitializeComponent > _anonXamlCDataTemplate_3();
            object[]          array3 = new object[0 + 5];
            array3[0] = dataTemplate;
            array3[1] = listView;
            array3[2] = stackLayout;
            array3[3] = grid2;
            array3[4] = this;
コード例 #12
0
        /// <inheritdoc/>
        public sealed override void ApplyTemplate()
        {
            if (!_templateApplied)
            {
                ClearVisualChildren();

                if (Template != null)
                {
                    _templateLog.Verbose("Creating control template");

                    var child = Template.Build(this);
                    var nameScope = new NameScope();
                    NameScope.SetNameScope((Control)child, nameScope);

                    // We need to call SetTemplatedParentAndApplyChildTemplates twice - once
                    // before the controls are added to the visual tree so that the logical
                    // tree can be set up before styling is applied.
                    ((ISetLogicalParent)child).SetParent(this);
                    SetupTemplateControls(child, nameScope);

                    // And again after the controls are added to the visual tree, and have their
                    // styling and thus Template property set.
                    AddVisualChild((Visual)child);
                    SetupTemplateControls(child, nameScope);

                    OnTemplateApplied(nameScope);
                }

                _templateApplied = true;
            }
        }
コード例 #13
0
        private async void Setup()
        {
            this.ApplyWindowSettings();
            this.tbDebug.KeyDown += new System.Windows.Input.KeyEventHandler(this.tbDebug_KeyDown);
            this.SetupNotifyIcon();
            this.lvGames.SelectionChanged += new SelectionChangedEventHandler(this.lvGames_SelectionChanged);
            System.Windows.Controls.ContextMenu contextMenu = this.lvGames.ContextMenu;
            NameScope.SetNameScope(contextMenu, NameScope.GetNameScope(this));
            System.Windows.Controls.MenuItem miRemove     = (System.Windows.Controls.MenuItem)contextMenu.Items[1];
            System.Windows.Controls.MenuItem miRescrape   = (System.Windows.Controls.MenuItem)contextMenu.Items[3];
            System.Windows.Controls.MenuItem miSaveStates = (System.Windows.Controls.MenuItem)contextMenu.Items[4];
            System.Windows.Controls.MenuItem miWideScreen = (System.Windows.Controls.MenuItem)contextMenu.Items[13];
            System.Windows.Controls.MenuItem miPlay       = (System.Windows.Controls.MenuItem)contextMenu.Items[0];
            miRescrape.Click += new RoutedEventHandler(this.miRescrape_Click);
            this.lvGames.ContextMenuOpening += new ContextMenuEventHandler(this.lvGames_ContextMenuOpening);
            this.miRemoveStates.Click       += (o, e) => this.DeleteSaveStates();
            this.lvGames.AllowDrop           = true;
            this.lvGames.Drop += async delegate(object o, System.Windows.DragEventArgs e) {
                string[] data  = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
                string[] files = (from s in data
                                  where GameData.AcceptableFormats.Any <string>(frm => Path.GetExtension(s).Equals(frm, StringComparison.InvariantCultureIgnoreCase))
                                  select s).ToArray <string>();
                await GameManager.AddGamesFromImages(files);
            };
            miPlay.Click += delegate(object o, RoutedEventArgs e) {
                int count = this.lvGames.SelectedItems.Count;
                if ((count != 0) && (count <= 1))
                {
                    this.LaunchGame((Game)this.lvGames.SelectedItem, false);
                }
            };
            miRemove.Click += delegate(object o, RoutedEventArgs e) {
                List <Game> games = this.lvGames.SelectedItems.Cast <Game>().ToList <Game>();
                this.RemoveSelectedGames(games);
            };
            miSaveStates.Click          += (o, e) => this.ShowSaveStates();
            miWideScreen.Click          += (o, e) => this.ShowWideScreenResults();
            this._t                      = new DispatcherTimer(TimeSpan.FromMilliseconds(200.0), DispatcherPriority.DataBind, new EventHandler(this.Filter), this.Dispatcher);
            this.btnSaveWidePatch.Click += async delegate(object o, RoutedEventArgs e) {
                Game g = (Game)this.lvGames.Tag;
                if (g != null)
                {
                    string crc = await GameManager.FetchCRC(g);

                    if (!Directory.Exists(Settings.Default.pcsx2Dir + @"\Cheats"))
                    {
                        Directory.CreateDirectory(Settings.Default.pcsx2Dir + @"\Cheats");
                    }
                    string contents = new TextRange(this.rtbResults.Document.ContentStart, this.rtbResults.Document.ContentEnd).Text;
                    try
                    {
                        File.WriteAllText(Settings.Default.pcsx2Dir + @"\Cheats\" + crc + ".pnach", contents);
                        Toaster.Instance.ShowToast(string.Format("Successfully saved patch for {0} as {1}.pnatch", g.Title, crc), 0xdac);
                        this.HideWidescreenResults();
                    }
                    catch (Exception exception)
                    {
                        Toaster.Instance.ShowToast("An error occured when trying to save the patch: " + exception.Message);
                    }
                }
            };
            this.btnStacked.Click += delegate(object o, RoutedEventArgs e) {
                this.ClearViewStates(this.btnStacked);
                this.SwitchView("gridView");
            };
            this.btnTile.Click += delegate(object o, RoutedEventArgs e) {
                this.ClearViewStates(this.btnTile);
                this.SwitchView("tileView");
            };
            this.btnTV.Click       += (o, e) => this.SwitchView("tv");
            this.lvGames.MouseDown += delegate(object o, MouseButtonEventArgs e) {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    this.lvGames.UnselectAll();
                }
            };
            this.PreviewKeyDown    += new System.Windows.Input.KeyEventHandler(this.MainWindow_PreviewKeyDown);
            this.lvGames.MouseDown += delegate(object o, MouseButtonEventArgs e) {
                if (e.MiddleButton == MouseButtonState.Pressed)
                {
                    this.lvGames.UnselectAll();
                }
            };
            this.lvScrape.MouseDoubleClick += delegate(object o, MouseButtonEventArgs e) {
                int count = this.lvScrape.SelectedItems.Count;
                if ((count != 0) && (count <= 1))
                {
                    this.Rescrape();
                }
            };
            this.tbSearch.GotFocus += delegate(object o, RoutedEventArgs e) {
                if ((this.tbSearch.Text == "Search") || this.tbSearch.Text.IsEmpty())
                {
                    this.tbSearch.Text = string.Empty;
                }
            };
            this.tbSearch.LostFocus += delegate(object o, RoutedEventArgs e) {
                if (this.tbSearch.Text.IsEmpty())
                {
                    this.tbSearch.Text = "Search";
                }
            };
            this.tbSearch.TextChanged += new TextChangedEventHandler(this.tbSearch_TextChanged);
            this.tbSearch.KeyDown     += delegate(object o, System.Windows.Input.KeyEventArgs e) {
                if (e.Key == Key.Escape)
                {
                    this.tbSearch.Text = "Search";
                    this.lvGames.Focus();
                }
            };
            await GameManager.BuildDatabase();

            GameManager.GenerateDirectories();
            GameManager.LoadXml();
            Console.WriteLine("loaded xml");
            await GameManager.GenerateUserLibrary();

            GameManager.UpdateGamesToLatestCompatibility();
            string defaultView = Settings.Default.defaultView;

            if (defaultView != null)
            {
                if (!(defaultView == "Stacked"))
                {
                    if (defaultView == "Tile")
                    {
                        this.SwitchView("tileView");
                        this.ClearViewStates(this.btnTile);
                    }
                    else if (defaultView == "TV")
                    {
                        this.SwitchView("tv");
                        this.ClearViewStates(this.btnStacked);
                    }
                }
                else
                {
                    this.SwitchView("gridView");
                    this.ClearViewStates(this.btnStacked);
                }
            }
            string defaultSort = Settings.Default.defaultSort;

            if (defaultSort != null)
            {
                if (!(defaultSort == "Alphabetical"))
                {
                    if (defaultSort == "Serial")
                    {
                        this.ApplySort("Serial", ListSortDirection.Ascending);
                    }
                    else if (defaultSort == "Default")
                    {
                    }
                }
                else
                {
                    this.ApplySort("Title", ListSortDirection.Ascending);
                }
            }
        }
コード例 #14
0
ファイル: Binding.cs プロジェクト: zhangJianjian97/Avalonia
        protected override ExpressionObserver CreateExpressionObserver(IAvaloniaObject target, AvaloniaProperty targetProperty, object anchor, bool enableDataValidation)
        {
            Contract.Requires <ArgumentNullException>(target != null);
            anchor = anchor ?? DefaultAnchor?.Target;

            enableDataValidation = enableDataValidation && Priority == BindingPriority.LocalValue;

            INameScope nameScope = null;

            NameScope?.TryGetTarget(out nameScope);

            var(node, mode) = ExpressionObserverBuilder.Parse(Path, enableDataValidation, TypeResolver, nameScope);

            if (ElementName != null)
            {
                return(CreateElementObserver(
                           (target as IStyledElement) ?? (anchor as IStyledElement),
                           ElementName,
                           node));
            }
            else if (Source != null)
            {
                return(CreateSourceObserver(Source, node));
            }
            else if (RelativeSource == null)
            {
                if (mode == SourceMode.Data)
                {
                    return(CreateDataContextObserver(
                               target,
                               node,
                               targetProperty == StyledElement.DataContextProperty,
                               anchor));
                }
                else
                {
                    return(CreateSourceObserver(
                               (target as IStyledElement) ?? (anchor as IStyledElement),
                               node));
                }
            }
            else if (RelativeSource.Mode == RelativeSourceMode.DataContext)
            {
                return(CreateDataContextObserver(
                           target,
                           node,
                           targetProperty == StyledElement.DataContextProperty,
                           anchor));
            }
            else if (RelativeSource.Mode == RelativeSourceMode.Self)
            {
                return(CreateSourceObserver(
                           (target as IStyledElement) ?? (anchor as IStyledElement),
                           node));
            }
            else if (RelativeSource.Mode == RelativeSourceMode.TemplatedParent)
            {
                return(CreateTemplatedParentObserver(
                           (target as IStyledElement) ?? (anchor as IStyledElement),
                           node));
            }
            else if (RelativeSource.Mode == RelativeSourceMode.FindAncestor)
            {
                if (RelativeSource.Tree == TreeType.Visual && RelativeSource.AncestorType == null)
                {
                    throw new InvalidOperationException("AncestorType must be set for RelativeSourceMode.FindAncestor when searching the visual tree.");
                }

                return(CreateFindAncestorObserver(
                           (target as IStyledElement) ?? (anchor as IStyledElement),
                           RelativeSource,
                           node));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
コード例 #15
0
        public SolidColorBrushExample()
        {
            Title      = "SolidColorBrush Animation Example";
            Background = Brushes.White;

            // Create a NameScope for the page so
            // that Storyboards can be used.
            NameScope.SetNameScope(this, new NameScope());

            // Create a Rectangle.
            Rectangle aRectangle = new Rectangle();

            aRectangle.Width  = 100;
            aRectangle.Height = 100;

            // Create a SolidColorBrush to paint
            // the rectangle's fill. The Opacity
            // and Color properties of the brush
            // will be animated.
            SolidColorBrush myAnimatedBrush = new SolidColorBrush();

            myAnimatedBrush.Color = Colors.Orange;
            aRectangle.Fill       = myAnimatedBrush;

            // Register the brush's name with the page
            // so that it can be targeted by storyboards.
            this.RegisterName("MyAnimatedBrush", myAnimatedBrush);

            //
            // Animate the brush's color to gray when
            // the mouse enters the rectangle.
            //
            ColorAnimation mouseEnterColorAnimation = new ColorAnimation();

            mouseEnterColorAnimation.To       = Colors.Gray;
            mouseEnterColorAnimation.Duration = TimeSpan.FromSeconds(1);
            Storyboard.SetTargetName(mouseEnterColorAnimation, "MyAnimatedBrush");
            Storyboard.SetTargetProperty(
                mouseEnterColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty));
            Storyboard mouseEnterStoryboard = new Storyboard();

            mouseEnterStoryboard.Children.Add(mouseEnterColorAnimation);
            aRectangle.MouseEnter += delegate(object sender, MouseEventArgs e)
            {
                mouseEnterStoryboard.Begin(this);
            };

            //
            // Animate the brush's color to orange when
            // the mouse leaves the rectangle.
            //
            ColorAnimation mouseLeaveColorAnimation = new ColorAnimation();

            mouseLeaveColorAnimation.To       = Colors.Orange;
            mouseLeaveColorAnimation.Duration = TimeSpan.FromSeconds(1);
            Storyboard.SetTargetName(mouseLeaveColorAnimation, "MyAnimatedBrush");
            Storyboard.SetTargetProperty(
                mouseLeaveColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty));
            Storyboard mouseLeaveStoryboard = new Storyboard();

            mouseLeaveStoryboard.Children.Add(mouseLeaveColorAnimation);
            aRectangle.MouseLeave += delegate(object sender, MouseEventArgs e)
            {
                mouseLeaveStoryboard.Begin(this);
            };

            //
            // Animate the brush's opacity to 0 and back when
            // the left mouse button is pressed over the rectangle.
            //
            DoubleAnimation opacityAnimation = new DoubleAnimation();

            opacityAnimation.To          = 0.0;
            opacityAnimation.Duration    = TimeSpan.FromSeconds(0.5);
            opacityAnimation.AutoReverse = true;
            Storyboard.SetTargetName(opacityAnimation, "MyAnimatedBrush");
            Storyboard.SetTargetProperty(
                opacityAnimation, new PropertyPath(SolidColorBrush.OpacityProperty));
            Storyboard mouseLeftButtonDownStoryboard = new Storyboard();

            mouseLeftButtonDownStoryboard.Children.Add(opacityAnimation);
            aRectangle.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e)
            {
                mouseLeftButtonDownStoryboard.Begin(this);
            };

            StackPanel mainPanel = new StackPanel();

            mainPanel.Margin = new Thickness(20);
            mainPanel.Children.Add(aRectangle);
            Content = mainPanel;
        }
コード例 #16
0
 private void InitializeComponent()
 {
     ResourceLoader.ResourceLoadingQuery resourceLoadingQuery = new ResourceLoader.ResourceLoadingQuery();
     resourceLoadingQuery.set_AssemblyName(typeof(ExamsPage).GetTypeInfo().Assembly.GetName());
     resourceLoadingQuery.set_ResourcePath("Views/ExamsPage.xaml");
     resourceLoadingQuery.set_Instance((object)this);
     if (ResourceLoader.CanProvideContentFor(resourceLoadingQuery))
     {
         this.__InitComponentRuntime();
     }
     else if (XamlLoader.get_XamlFileProvider() != null && XamlLoader.get_XamlFileProvider()(((object)this).GetType()) != null)
     {
         this.__InitComponentRuntime();
     }
     else
     {
         TranslateExtension      translateExtension1 = new TranslateExtension();
         StaticResourceExtension resourceExtension1  = new StaticResourceExtension();
         BindingExtension        bindingExtension1   = new BindingExtension();
         TranslateExtension      translateExtension2 = new TranslateExtension();
         Setter                  setter1             = new Setter();
         DataTrigger             dataTrigger1        = new DataTrigger(typeof(MvxContentPage));
         BindingExtension        bindingExtension2   = new BindingExtension();
         TranslateExtension      translateExtension3 = new TranslateExtension();
         Setter                  setter2             = new Setter();
         DataTrigger             dataTrigger2        = new DataTrigger(typeof(MvxContentPage));
         BindingExtension        bindingExtension3   = new BindingExtension();
         TranslateExtension      translateExtension4 = new TranslateExtension();
         Setter                  setter3             = new Setter();
         DataTrigger             dataTrigger3        = new DataTrigger(typeof(MvxContentPage));
         RowDefinition           rowDefinition1      = new RowDefinition();
         RowDefinition           rowDefinition2      = new RowDefinition();
         BindingExtension        bindingExtension4   = new BindingExtension();
         EmptyView               emptyView           = new EmptyView();
         StaticResourceExtension resourceExtension2  = new StaticResourceExtension();
         BindingExtension        bindingExtension5   = new BindingExtension();
         BindingExtension        bindingExtension6   = new BindingExtension();
         BindingExtension        bindingExtension7   = new BindingExtension();
         BindingExtension        bindingExtension8   = new BindingExtension();
         DataTemplate            dataTemplate1       = new DataTemplate();
         ListView                listView            = new ListView((ListViewCachingStrategy)1);
         Grid      grid = new Grid();
         ExamsPage examsPage;
         NameScope nameScope = (NameScope)(NameScope.GetNameScope((BindableObject)(examsPage = this)) ?? (INameScope) new NameScope());
         NameScope.SetNameScope((BindableObject)examsPage, (INameScope)nameScope);
         ((INameScope)nameScope).RegisterName("Page", (object)examsPage);
         if (((Element)examsPage).get_StyleId() == null)
         {
             ((Element)examsPage).set_StyleId("Page");
         }
         this.Page = (MvxContentPage <ExamsViewModel>)examsPage;
         translateExtension1.Text = "Exams_Page_Title";
         TranslateExtension  translateExtension5  = translateExtension1;
         XamlServiceProvider xamlServiceProvider1 = new XamlServiceProvider();
         Type     type1     = typeof(IProvideValueTarget);
         object[] objArray1 = new object[0 + 1];
         objArray1[0] = (object)examsPage;
         SimpleValueTargetProvider valueTargetProvider1;
         object obj1 = (object)(valueTargetProvider1 = new SimpleValueTargetProvider(objArray1, (object)Xamarin.Forms.Page.TitleProperty, (INameScope)nameScope));
         xamlServiceProvider1.Add(type1, (object)valueTargetProvider1);
         xamlServiceProvider1.Add(typeof(IReferenceProvider), obj1);
         Type type2 = typeof(IXamlTypeResolver);
         XmlNamespaceResolver namespaceResolver1 = new XmlNamespaceResolver();
         namespaceResolver1.Add("", "http://xamarin.com/schemas/2014/forms");
         namespaceResolver1.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
         namespaceResolver1.Add("controls", "clr-namespace:Ekreta.Mobile.Core.Controls;assembly=Ekreta.Mobile.Core");
         namespaceResolver1.Add("d", "http://xamarin.com/schemas/2014/forms/design");
         namespaceResolver1.Add("extensions", "clr-namespace:Ekreta.Mobile.Core.Extensions;assembly=Ekreta.Mobile.Core");
         namespaceResolver1.Add("ffimageloading", "clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms");
         namespaceResolver1.Add("ios", "clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core");
         namespaceResolver1.Add("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
         namespaceResolver1.Add("mvvmcross", "clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms");
         namespaceResolver1.Add("viewModels", "clr-namespace:Ekreta.Mobile.Core.ViewModels;assembly=Ekreta.Mobile.Core");
         XamlTypeResolver xamlTypeResolver1 = new XamlTypeResolver((IXmlNamespaceResolver)namespaceResolver1, typeof(ExamsPage).GetTypeInfo().Assembly);
         xamlServiceProvider1.Add(type2, (object)xamlTypeResolver1);
         xamlServiceProvider1.Add(typeof(IXmlLineInfoProvider), (object)new XmlLineInfoProvider((IXmlLineInfo) new XmlLineInfo(15, 5)));
         object obj2 = ((IMarkupExtension)translateExtension5).ProvideValue((IServiceProvider)xamlServiceProvider1);
         ((Xamarin.Forms.Page)examsPage).set_Title((string)obj2);
         ((BindableObject)examsPage).SetValue((BindableProperty)Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page.UseSafeAreaProperty, (object)true);
         resourceExtension1.set_Key("PageBackgroundColor");
         StaticResourceExtension resourceExtension3   = resourceExtension1;
         XamlServiceProvider     xamlServiceProvider2 = new XamlServiceProvider();
         Type     type3     = typeof(IProvideValueTarget);
         object[] objArray2 = new object[0 + 1];
         objArray2[0] = (object)examsPage;
         SimpleValueTargetProvider valueTargetProvider2;
         object obj3 = (object)(valueTargetProvider2 = new SimpleValueTargetProvider(objArray2, (object)VisualElement.BackgroundColorProperty, (INameScope)nameScope));
         xamlServiceProvider2.Add(type3, (object)valueTargetProvider2);
         xamlServiceProvider2.Add(typeof(IReferenceProvider), obj3);
         Type type4 = typeof(IXamlTypeResolver);
         XmlNamespaceResolver namespaceResolver2 = new XmlNamespaceResolver();
         namespaceResolver2.Add("", "http://xamarin.com/schemas/2014/forms");
         namespaceResolver2.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
         namespaceResolver2.Add("controls", "clr-namespace:Ekreta.Mobile.Core.Controls;assembly=Ekreta.Mobile.Core");
         namespaceResolver2.Add("d", "http://xamarin.com/schemas/2014/forms/design");
         namespaceResolver2.Add("extensions", "clr-namespace:Ekreta.Mobile.Core.Extensions;assembly=Ekreta.Mobile.Core");
         namespaceResolver2.Add("ffimageloading", "clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms");
         namespaceResolver2.Add("ios", "clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core");
         namespaceResolver2.Add("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
         namespaceResolver2.Add("mvvmcross", "clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms");
         namespaceResolver2.Add("viewModels", "clr-namespace:Ekreta.Mobile.Core.ViewModels;assembly=Ekreta.Mobile.Core");
         XamlTypeResolver xamlTypeResolver2 = new XamlTypeResolver((IXmlNamespaceResolver)namespaceResolver2, typeof(ExamsPage).GetTypeInfo().Assembly);
         xamlServiceProvider2.Add(type4, (object)xamlTypeResolver2);
         xamlServiceProvider2.Add(typeof(IXmlLineInfoProvider), (object)new XmlLineInfoProvider((IXmlLineInfo) new XmlLineInfo(18, 5)));
         object obj4 = ((IMarkupExtension)resourceExtension3).ProvideValue((IServiceProvider)xamlServiceProvider2);
         ((VisualElement)examsPage).set_BackgroundColor((Color)obj4);
         bindingExtension1.set_Path("HasInternetConnection");
         BindingBase bindingBase1 = ((IMarkupExtension <BindingBase>)bindingExtension1).ProvideValue((IServiceProvider)null);
         dataTrigger1.set_Binding(bindingBase1);
         dataTrigger1.set_Value((object)"True");
         setter1.set_Property((BindableProperty)Xamarin.Forms.Page.TitleProperty);
         translateExtension2.Text = "Exams_Page_Title";
         TranslateExtension  translateExtension6  = translateExtension2;
         XamlServiceProvider xamlServiceProvider3 = new XamlServiceProvider();
         Type     type5     = typeof(IProvideValueTarget);
         object[] objArray3 = new object[0 + 3];
         objArray3[0] = (object)setter1;
         objArray3[1] = (object)dataTrigger1;
         objArray3[2] = (object)examsPage;
         SimpleValueTargetProvider valueTargetProvider3;
         object obj5 = (object)(valueTargetProvider3 = new SimpleValueTargetProvider(objArray3, (object)typeof(Setter).GetRuntimeProperty("Value"), (INameScope)nameScope));
         xamlServiceProvider3.Add(type5, (object)valueTargetProvider3);
         xamlServiceProvider3.Add(typeof(IReferenceProvider), obj5);
         Type type6 = typeof(IXamlTypeResolver);
         XmlNamespaceResolver namespaceResolver3 = new XmlNamespaceResolver();
         namespaceResolver3.Add("", "http://xamarin.com/schemas/2014/forms");
         namespaceResolver3.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
         namespaceResolver3.Add("controls", "clr-namespace:Ekreta.Mobile.Core.Controls;assembly=Ekreta.Mobile.Core");
         namespaceResolver3.Add("d", "http://xamarin.com/schemas/2014/forms/design");
         namespaceResolver3.Add("extensions", "clr-namespace:Ekreta.Mobile.Core.Extensions;assembly=Ekreta.Mobile.Core");
         namespaceResolver3.Add("ffimageloading", "clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms");
         namespaceResolver3.Add("ios", "clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core");
         namespaceResolver3.Add("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
         namespaceResolver3.Add("mvvmcross", "clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms");
         namespaceResolver3.Add("viewModels", "clr-namespace:Ekreta.Mobile.Core.ViewModels;assembly=Ekreta.Mobile.Core");
         XamlTypeResolver xamlTypeResolver3 = new XamlTypeResolver((IXmlNamespaceResolver)namespaceResolver3, typeof(ExamsPage).GetTypeInfo().Assembly);
         xamlServiceProvider3.Add(type6, (object)xamlTypeResolver3);
         xamlServiceProvider3.Add(typeof(IXmlLineInfoProvider), (object)new XmlLineInfoProvider((IXmlLineInfo) new XmlLineInfo(28, 38)));
         object obj6 = ((IMarkupExtension)translateExtension6).ProvideValue((IServiceProvider)xamlServiceProvider3);
         setter1.set_Value(obj6);
         ((ICollection <Setter>)dataTrigger1.get_Setters()).Add(setter1);
         ((ICollection <TriggerBase>)((BindableObject)examsPage).GetValue((BindableProperty)VisualElement.TriggersProperty)).Add((TriggerBase)dataTrigger1);
         bindingExtension2.set_Path("HasInternetConnection");
         BindingBase bindingBase2 = ((IMarkupExtension <BindingBase>)bindingExtension2).ProvideValue((IServiceProvider)null);
         dataTrigger2.set_Binding(bindingBase2);
         dataTrigger2.set_Value((object)"False");
         setter2.set_Property((BindableProperty)Xamarin.Forms.Page.TitleProperty);
         translateExtension3.Text = "Exams_Page_Offline_Title";
         TranslateExtension  translateExtension7  = translateExtension3;
         XamlServiceProvider xamlServiceProvider4 = new XamlServiceProvider();
         Type     type7     = typeof(IProvideValueTarget);
         object[] objArray4 = new object[0 + 3];
         objArray4[0] = (object)setter2;
         objArray4[1] = (object)dataTrigger2;
         objArray4[2] = (object)examsPage;
         SimpleValueTargetProvider valueTargetProvider4;
         object obj7 = (object)(valueTargetProvider4 = new SimpleValueTargetProvider(objArray4, (object)typeof(Setter).GetRuntimeProperty("Value"), (INameScope)nameScope));
         xamlServiceProvider4.Add(type7, (object)valueTargetProvider4);
         xamlServiceProvider4.Add(typeof(IReferenceProvider), obj7);
         Type type8 = typeof(IXamlTypeResolver);
         XmlNamespaceResolver namespaceResolver4 = new XmlNamespaceResolver();
         namespaceResolver4.Add("", "http://xamarin.com/schemas/2014/forms");
         namespaceResolver4.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
         namespaceResolver4.Add("controls", "clr-namespace:Ekreta.Mobile.Core.Controls;assembly=Ekreta.Mobile.Core");
         namespaceResolver4.Add("d", "http://xamarin.com/schemas/2014/forms/design");
         namespaceResolver4.Add("extensions", "clr-namespace:Ekreta.Mobile.Core.Extensions;assembly=Ekreta.Mobile.Core");
         namespaceResolver4.Add("ffimageloading", "clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms");
         namespaceResolver4.Add("ios", "clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core");
         namespaceResolver4.Add("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
         namespaceResolver4.Add("mvvmcross", "clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms");
         namespaceResolver4.Add("viewModels", "clr-namespace:Ekreta.Mobile.Core.ViewModels;assembly=Ekreta.Mobile.Core");
         XamlTypeResolver xamlTypeResolver4 = new XamlTypeResolver((IXmlNamespaceResolver)namespaceResolver4, typeof(ExamsPage).GetTypeInfo().Assembly);
         xamlServiceProvider4.Add(type8, (object)xamlTypeResolver4);
         xamlServiceProvider4.Add(typeof(IXmlLineInfoProvider), (object)new XmlLineInfoProvider((IXmlLineInfo) new XmlLineInfo(34, 38)));
         object obj8 = ((IMarkupExtension)translateExtension7).ProvideValue((IServiceProvider)xamlServiceProvider4);
         setter2.set_Value(obj8);
         ((ICollection <Setter>)dataTrigger2.get_Setters()).Add(setter2);
         ((ICollection <TriggerBase>)((BindableObject)examsPage).GetValue((BindableProperty)VisualElement.TriggersProperty)).Add((TriggerBase)dataTrigger2);
         bindingExtension3.set_Path("IsOffline");
         BindingBase bindingBase3 = ((IMarkupExtension <BindingBase>)bindingExtension3).ProvideValue((IServiceProvider)null);
         dataTrigger3.set_Binding(bindingBase3);
         dataTrigger3.set_Value((object)"True");
         setter3.set_Property((BindableProperty)Xamarin.Forms.Page.TitleProperty);
         translateExtension4.Text = "Exams_Page_Offline_Title";
         TranslateExtension  translateExtension8  = translateExtension4;
         XamlServiceProvider xamlServiceProvider5 = new XamlServiceProvider();
         Type     type9     = typeof(IProvideValueTarget);
         object[] objArray5 = new object[0 + 3];
         objArray5[0] = (object)setter3;
         objArray5[1] = (object)dataTrigger3;
         objArray5[2] = (object)examsPage;
         SimpleValueTargetProvider valueTargetProvider5;
         object obj9 = (object)(valueTargetProvider5 = new SimpleValueTargetProvider(objArray5, (object)typeof(Setter).GetRuntimeProperty("Value"), (INameScope)nameScope));
         xamlServiceProvider5.Add(type9, (object)valueTargetProvider5);
         xamlServiceProvider5.Add(typeof(IReferenceProvider), obj9);
         Type type10 = typeof(IXamlTypeResolver);
         XmlNamespaceResolver namespaceResolver5 = new XmlNamespaceResolver();
         namespaceResolver5.Add("", "http://xamarin.com/schemas/2014/forms");
         namespaceResolver5.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
         namespaceResolver5.Add("controls", "clr-namespace:Ekreta.Mobile.Core.Controls;assembly=Ekreta.Mobile.Core");
         namespaceResolver5.Add("d", "http://xamarin.com/schemas/2014/forms/design");
         namespaceResolver5.Add("extensions", "clr-namespace:Ekreta.Mobile.Core.Extensions;assembly=Ekreta.Mobile.Core");
         namespaceResolver5.Add("ffimageloading", "clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms");
         namespaceResolver5.Add("ios", "clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core");
         namespaceResolver5.Add("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
         namespaceResolver5.Add("mvvmcross", "clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms");
         namespaceResolver5.Add("viewModels", "clr-namespace:Ekreta.Mobile.Core.ViewModels;assembly=Ekreta.Mobile.Core");
         XamlTypeResolver xamlTypeResolver5 = new XamlTypeResolver((IXmlNamespaceResolver)namespaceResolver5, typeof(ExamsPage).GetTypeInfo().Assembly);
         xamlServiceProvider5.Add(type10, (object)xamlTypeResolver5);
         xamlServiceProvider5.Add(typeof(IXmlLineInfoProvider), (object)new XmlLineInfoProvider((IXmlLineInfo) new XmlLineInfo(40, 38)));
         object obj10 = ((IMarkupExtension)translateExtension8).ProvideValue((IServiceProvider)xamlServiceProvider5);
         setter3.set_Value(obj10);
         ((ICollection <Setter>)dataTrigger3.get_Setters()).Add(setter3);
         ((ICollection <TriggerBase>)((BindableObject)examsPage).GetValue((BindableProperty)VisualElement.TriggersProperty)).Add((TriggerBase)dataTrigger3);
         ((BindableObject)rowDefinition1).SetValue((BindableProperty)RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*"));
         ((DefinitionCollection <RowDefinition>)((BindableObject)grid).GetValue((BindableProperty)Grid.RowDefinitionsProperty)).Add(rowDefinition1);
         ((BindableObject)rowDefinition2).SetValue((BindableProperty)RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("Auto"));
         ((DefinitionCollection <RowDefinition>)((BindableObject)grid).GetValue((BindableProperty)Grid.RowDefinitionsProperty)).Add(rowDefinition2);
         bindingExtension4.set_Path("ItemsCount");
         BindingBase bindingBase4 = ((IMarkupExtension <BindingBase>)bindingExtension4).ProvideValue((IServiceProvider)null);
         ((BindableObject)emptyView).SetBinding((BindableProperty)BindableObject.BindingContextProperty, bindingBase4);
         ((ICollection <View>)grid.get_Children()).Add((View)emptyView);
         resourceExtension2.set_Key("ListViewMonthGroupHeaderTemplate");
         StaticResourceExtension resourceExtension4   = resourceExtension2;
         XamlServiceProvider     xamlServiceProvider6 = new XamlServiceProvider();
         Type     type11    = typeof(IProvideValueTarget);
         object[] objArray6 = new object[0 + 3];
         objArray6[0] = (object)listView;
         objArray6[1] = (object)grid;
         objArray6[2] = (object)examsPage;
         SimpleValueTargetProvider valueTargetProvider6;
         object obj11 = (object)(valueTargetProvider6 = new SimpleValueTargetProvider(objArray6, (object)ListView.GroupHeaderTemplateProperty, (INameScope)nameScope));
         xamlServiceProvider6.Add(type11, (object)valueTargetProvider6);
         xamlServiceProvider6.Add(typeof(IReferenceProvider), obj11);
         Type type12 = typeof(IXamlTypeResolver);
         XmlNamespaceResolver namespaceResolver6 = new XmlNamespaceResolver();
         namespaceResolver6.Add("", "http://xamarin.com/schemas/2014/forms");
         namespaceResolver6.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
         namespaceResolver6.Add("controls", "clr-namespace:Ekreta.Mobile.Core.Controls;assembly=Ekreta.Mobile.Core");
         namespaceResolver6.Add("d", "http://xamarin.com/schemas/2014/forms/design");
         namespaceResolver6.Add("extensions", "clr-namespace:Ekreta.Mobile.Core.Extensions;assembly=Ekreta.Mobile.Core");
         namespaceResolver6.Add("ffimageloading", "clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms");
         namespaceResolver6.Add("ios", "clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core");
         namespaceResolver6.Add("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
         namespaceResolver6.Add("mvvmcross", "clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms");
         namespaceResolver6.Add("viewModels", "clr-namespace:Ekreta.Mobile.Core.ViewModels;assembly=Ekreta.Mobile.Core");
         XamlTypeResolver xamlTypeResolver6 = new XamlTypeResolver((IXmlNamespaceResolver)namespaceResolver6, typeof(ExamsPage).GetTypeInfo().Assembly);
         xamlServiceProvider6.Add(type12, (object)xamlTypeResolver6);
         xamlServiceProvider6.Add(typeof(IXmlLineInfoProvider), (object)new XmlLineInfoProvider((IXmlLineInfo) new XmlLineInfo(51, 13)));
         object obj12 = ((IMarkupExtension)resourceExtension4).ProvideValue((IServiceProvider)xamlServiceProvider6);
         listView.set_GroupHeaderTemplate((DataTemplate)obj12);
         ((BindableObject)listView).SetValue((BindableProperty)ListView.HasUnevenRowsProperty, (object)true);
         ((BindableObject)listView).SetValue((BindableProperty)ListView.IsGroupingEnabledProperty, (object)true);
         ((BindableObject)listView).SetValue((BindableProperty)ListView.IsPullToRefreshEnabledProperty, (object)true);
         bindingExtension5.set_Path("IsLoading");
         BindingBase bindingBase5 = ((IMarkupExtension <BindingBase>)bindingExtension5).ProvideValue((IServiceProvider)null);
         ((BindableObject)listView).SetBinding((BindableProperty)ListView.IsRefreshingProperty, bindingBase5);
         bindingExtension6.set_Path("Items");
         BindingBase bindingBase6 = ((IMarkupExtension <BindingBase>)bindingExtension6).ProvideValue((IServiceProvider)null);
         ((BindableObject)listView).SetBinding((BindableProperty)ItemsView <Cell> .ItemsSourceProperty, bindingBase6);
         bindingExtension7.set_Path("RefreshCommand");
         BindingBase bindingBase7 = ((IMarkupExtension <BindingBase>)bindingExtension7).ProvideValue((IServiceProvider)null);
         ((BindableObject)listView).SetBinding((BindableProperty)ListView.RefreshCommandProperty, bindingBase7);
         bindingExtension8.set_Mode((BindingMode)1);
         bindingExtension8.set_Path("SelectedItem");
         BindingBase bindingBase8 = ((IMarkupExtension <BindingBase>)bindingExtension8).ProvideValue((IServiceProvider)null);
         ((BindableObject)listView).SetBinding((BindableProperty)ListView.SelectedItemProperty, bindingBase8);
         DataTemplate dataTemplate2 = dataTemplate1;
         // ISSUE: object of a compiler-generated type is created
         // ISSUE: variable of a compiler-generated type
         ExamsPage.\u003CInitializeComponent\u003E_anonXamlCDataTemplate_17 xamlCdataTemplate17 = new ExamsPage.\u003CInitializeComponent\u003E_anonXamlCDataTemplate_17();
         object[] objArray7 = new object[0 + 4];
         objArray7[0] = (object)dataTemplate1;
         objArray7[1] = (object)listView;
         objArray7[2] = (object)grid;
         objArray7[3] = (object)examsPage;
         // ISSUE: reference to a compiler-generated field
         xamlCdataTemplate17.parentValues = objArray7;
         // ISSUE: reference to a compiler-generated field
         xamlCdataTemplate17.root = examsPage;
         // ISSUE: reference to a compiler-generated method
         Func <object> func = new Func <object>(xamlCdataTemplate17.LoadDataTemplate);
         ((IDataTemplate)dataTemplate2).set_LoadTemplate(func);
         ((BindableObject)listView).SetValue((BindableProperty)ItemsView <Cell> .ItemTemplateProperty, (object)dataTemplate1);
         ((ICollection <View>)grid.get_Children()).Add((View)listView);
         ((BindableObject)examsPage).SetValue((BindableProperty)ContentPage.ContentProperty, (object)grid);
     }
 }
コード例 #17
0
        public FrameworkContentElementStoryboardExample()
        {
            // Create a name scope for the document.
            NameScope.SetNameScope(this, new NameScope());
            this.Background = Brushes.White;

            // Create a run of text.
            Run theText = new Run(
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." +
                "Ut non lacus. Nullam a ligula id leo adipiscing ornare." +
                " Duis mattis. ");

            // Create a TextEffect
            TextEffect animatedSpecialEffect = new TextEffect();

            animatedSpecialEffect.Foreground    = Brushes.OrangeRed;
            animatedSpecialEffect.PositionStart = 0;
            animatedSpecialEffect.PositionCount = 0;

            // Assign the TextEffect a name by
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations
            this.RegisterName("animatedSpecialEffect", animatedSpecialEffect);

            // Apply the text effect to the run.
            theText.TextEffects = new TextEffectCollection();
            theText.TextEffects.Add(animatedSpecialEffect);

            // Create a paragraph to contain the run.
            Paragraph animatedParagraph = new Paragraph(theText);

            animatedParagraph.Background = Brushes.LightGray;
            animatedParagraph.Padding    = new Thickness(20);

            this.Blocks.Add(animatedParagraph);
            BlockUIContainer controlsContainer = new BlockUIContainer();

            //
            // Create an animation and a storyboard to animate the
            // text effect.
            //
            Int32Animation countAnimation =
                new Int32Animation(0, 127, TimeSpan.FromSeconds(10));

            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect");
            Storyboard.SetTargetProperty(countAnimation,
                                         new PropertyPath(TextEffect.PositionCountProperty));
            myStoryboard = new Storyboard();
            myStoryboard.Children.Add(countAnimation);

            //
            // Create a button to start the storyboard.
            //
            Button beginButton = new Button();

            beginButton.Content = "Begin";
            beginButton.Click  += new RoutedEventHandler(beginButton_Clicked);

            controlsContainer.Child = beginButton;
            this.Blocks.Add(controlsContainer);
        }
コード例 #18
0
        // animation:
        private Storyboard IntilaizeStory(Point start, Point end, long colorID)
        {
            // Create a NameScope for the page so that
            // we can use Storyboards.
            NameScope.SetNameScope(PublicParameters.MainWindow.Canvas_SensingFeild, new NameScope());

            // Create a rectangle.
            Border aRectangle = new Border();

            aRectangle.CornerRadius = new CornerRadius(2);
            aRectangle.Width        = 7;
            aRectangle.Height       = 7;
            int cid = Convert.ToInt16(colorID % PublicParameters.RandomColors.Count);

            aRectangle.Background      = new SolidColorBrush(PublicParameters.RandomColors[cid]);
            aRectangle.BorderThickness = new Thickness(1);
            aRectangle.BorderBrush     = new SolidColorBrush(Colors.Black);

            MovedObjectStack.Push(aRectangle);

            // Create a transform. This transform
            // will be used to move the rectangle.
            TranslateTransform animatedTranslateTransform = new TranslateTransform();

            // Register the transform's name with the page
            // so that they it be targeted by a Storyboard.
            PublicParameters.MainWindow.Canvas_SensingFeild.RegisterName("AnimatedTranslateTransform", animatedTranslateTransform);
            aRectangle.RenderTransform = animatedTranslateTransform;
            PublicParameters.MainWindow.Canvas_SensingFeild.Children.Add(aRectangle);



            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure   pFigure       = new PathFigure(); // add the figure.

            pFigure.StartPoint = start;                    // define the start point of the Figure.
            LineSegment lineSegment = new LineSegment();   // move according to line.

            lineSegment.Point = end;                       // set the end point.
            pFigure.Segments.Add(lineSegment);             // add the line to the figure.
            animationPath.Figures.Add(pFigure);            // add the figure to the path.

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a DoubleAnimationUsingPath to move the
            // rectangle horizontally along the path by animating
            // its TranslateTransform.
            DoubleAnimationUsingPath translateXAnimation =
                new DoubleAnimationUsingPath();

            translateXAnimation.PathGeometry = animationPath;
            translateXAnimation.Duration     = TimeSpan.FromSeconds(Properties.Settings.Default.AnimationSpeed);

            // Set the Source property to X. This makes
            // the animation generate horizontal offset values from
            // the path information.
            translateXAnimation.Source = PathAnimationSource.X;

            // Set the animation to target the X property
            // of the TranslateTransform named "AnimatedTranslateTransform".
            Storyboard.SetTargetName(translateXAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateXAnimation,
                                         new PropertyPath(TranslateTransform.XProperty));

            // Create a DoubleAnimationUsingPath to move the
            // rectangle vertically along the path by animating
            // its TranslateTransform.
            DoubleAnimationUsingPath translateYAnimation =
                new DoubleAnimationUsingPath();

            translateYAnimation.PathGeometry = animationPath;
            translateYAnimation.Duration     = TimeSpan.FromSeconds(Properties.Settings.Default.AnimationSpeed);

            // Set the Source property to Y. This makes
            // the animation generate vertical offset values from
            // the path information.
            translateYAnimation.Source = PathAnimationSource.Y;

            // Set the animation to target the Y property
            // of the TranslateTransform named "AnimatedTranslateTransform".
            Storyboard.SetTargetName(translateYAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation,
                                         new PropertyPath(TranslateTransform.YProperty));

            // Create a Storyboard to contain and apply the animations.
            Storyboard pathAnimationStoryboard = new Storyboard();

            //pathAnimationStoryboard.RepeatBehavior = RepeatBehavior.Forever;
            pathAnimationStoryboard.Children.Add(translateXAnimation);
            pathAnimationStoryboard.Children.Add(translateYAnimation);



            return(pathAnimationStoryboard);
        }
        private void InitializeComponent()
        {
            var nameScope = new global::Windows.UI.Xaml.NameScope();

            NameScope.SetNameScope(this, nameScope);
            IsParsing = true
            ;
            // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 1:2)
            Content =
                new global::Windows.UI.Xaml.Controls.Grid
            {
                IsParsing = true
                ,
                RowDefinitions =
                {
                    new global::Windows.UI.Xaml.Controls.RowDefinition
                    {
                        Height = new Windows.UI.Xaml.GridLength(80f, Windows.UI.Xaml.GridUnitType.Pixel) /* Windows.UI.Xaml.GridLength/, 80, RowDefinition/Height */,
                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 10:14)
                    }
                    ,
                    new global::Windows.UI.Xaml.Controls.RowDefinition
                    {
                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 11:14)
                    }
                    ,
                }

                ,
                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 8:6)
                Children =
                {
                    new global::Windows.UI.Xaml.Controls.TextBlock
                    {
                        IsParsing = true
                        ,
                        Text                = "Budget Master" /* string/, Budget Master, TextBlock/Text */,
                        Margin              = new global::Windows.UI.Xaml.Thickness(20) /* Windows.UI.Xaml.Thickness/, 20, TextBlock/Margin */,
                        FontSize            = 30d /* double/, 30, TextBlock/FontSize */,
                        HorizontalAlignment = global::Windows.UI.Xaml.HorizontalAlignment.Center /* Windows.UI.Xaml.HorizontalAlignment/, Center, TextBlock/HorizontalAlignment */,
                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 13:10)
                    }
                    .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler1)(c1 =>
                    {
                        global::Windows.UI.Xaml.Controls.Grid.SetRow(c1, 0 /* int/, 0, Grid/Row */);
                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c1, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                        c1.CreationComplete();
                    }
                                                                                                                                                          ))
                    ,
                    new global::Windows.UI.Xaml.Controls.Grid
                    {
                        IsParsing = true
                        ,
                        ColumnDefinitions =
                        {
                            new global::Windows.UI.Xaml.Controls.ColumnDefinition
                            {
                                Width = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Star) /* Windows.UI.Xaml.GridLength/, *, ColumnDefinition/Width */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 20:18)
                            }
                            ,
                            new global::Windows.UI.Xaml.Controls.ColumnDefinition
                            {
                                Width = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Star) /* Windows.UI.Xaml.GridLength/, *, ColumnDefinition/Width */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 21:18)
                            }
                            ,
                            new global::Windows.UI.Xaml.Controls.ColumnDefinition
                            {
                                Width = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Star) /* Windows.UI.Xaml.GridLength/, *, ColumnDefinition/Width */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 22:18)
                            }
                            ,
                        }

                        ,
                        RowDefinitions =
                        {
                            new global::Windows.UI.Xaml.Controls.RowDefinition
                            {
                                Height = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Auto) /* Windows.UI.Xaml.GridLength/, auto, RowDefinition/Height */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 25:18)
                            }
                            ,
                            new global::Windows.UI.Xaml.Controls.RowDefinition
                            {
                                Height = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Auto) /* Windows.UI.Xaml.GridLength/, auto, RowDefinition/Height */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 26:18)
                            }
                            ,
                            new global::Windows.UI.Xaml.Controls.RowDefinition
                            {
                                Height = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Auto) /* Windows.UI.Xaml.GridLength/, auto, RowDefinition/Height */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 27:18)
                            }
                            ,
                            new global::Windows.UI.Xaml.Controls.RowDefinition
                            {
                                Height = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Auto) /* Windows.UI.Xaml.GridLength/, auto, RowDefinition/Height */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 28:18)
                            }
                            ,
                        }

                        ,
                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 18:10)
                        Children =
                        {
                            new global::Windows.UI.Xaml.Controls.TextBlock
                            {
                                IsParsing = true
                                ,
                                Text = "Email:" /* string/, Email:, TextBlock/Text */,
                                HorizontalAlignment = global::Windows.UI.Xaml.HorizontalAlignment.Right /* Windows.UI.Xaml.HorizontalAlignment/, Right, TextBlock/HorizontalAlignment */,
                                Margin = new global::Windows.UI.Xaml.Thickness(0, 5, 5, 0) /* Windows.UI.Xaml.Thickness/, 0,5,5,0, TextBlock/Margin */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 30:14)
                            }
                            .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler1)(c9 =>
                            {
                                global::Windows.UI.Xaml.Controls.Grid.SetRow(c9, 0 /* int/, 0, Grid/Row */);
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c9, 0 /* int/, 0, Grid/Column */);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c9, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                c9.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                            new global::Windows.UI.Xaml.Controls.TextBox
                            {
                                IsParsing = true
                                ,
                                Margin = new global::Windows.UI.Xaml.Thickness(0, 5, 0, 0) /* Windows.UI.Xaml.Thickness/, 0,5,0,0, TextBox/Margin */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 35:14)
                            }
                            .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler3)(c10 =>
                            {
                                global::Windows.UI.Xaml.Controls.Grid.SetRow(c10, 0 /* int/, 0, Grid/Row */);
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c10, 1 /* int/, 1, Grid/Column */);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c10, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                c10.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                            new global::Windows.UI.Xaml.Controls.TextBlock
                            {
                                IsParsing = true
                                ,
                                Text = "Password:"******"file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                c11.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                            new global::Windows.UI.Xaml.Controls.PasswordBox
                            {
                                IsParsing = true
                                ,
                                Margin = new global::Windows.UI.Xaml.Thickness(0, 5, 0, 0) /* Windows.UI.Xaml.Thickness/, 0,5,0,0, PasswordBox/Margin */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 43:14)
                            }
                            .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler4)(c12 =>
                            {
                                global::Windows.UI.Xaml.Controls.Grid.SetRow(c12, 1 /* int/, 1, Grid/Row */);
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c12, 1 /* int/, 1, Grid/Column */);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c12, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                c12.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                            new global::Windows.UI.Xaml.Controls.Grid
                            {
                                IsParsing = true
                                ,
                                Margin            = new global::Windows.UI.Xaml.Thickness(0, 5, 0, 0) /* Windows.UI.Xaml.Thickness/, 0,5,0,0, Grid/Margin */,
                                ColumnDefinitions =
                                {
                                    new global::Windows.UI.Xaml.Controls.ColumnDefinition
                                    {
                                        Width = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Star) /* Windows.UI.Xaml.GridLength/, *, ColumnDefinition/Width */,
                                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 50:22)
                                    }
                                    ,
                                    new global::Windows.UI.Xaml.Controls.ColumnDefinition
                                    {
                                        Width = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Star) /* Windows.UI.Xaml.GridLength/, *, ColumnDefinition/Width */,
                                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 51:22)
                                    }
                                    ,
                                }

                                ,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 46:14)
                                Children =
                                {
                                    new global::Windows.UI.Xaml.Controls.Button
                                    {
                                        IsParsing = true
                                        ,
                                        Content = @"Login" /* object/, Login, Button/Content */,
                                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 53:18)
                                    }
                                    .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler5)(c15 =>
                                    {
                                        global::Windows.UI.Xaml.Controls.Grid.SetRow(c15, 2 /* int/, 2, Grid/Row */);
                                        global::Windows.UI.Xaml.Controls.Grid.SetColumn(c15, 0 /* int/, 0, Grid/Column */);
                                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c15, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                        c15.CreationComplete();
                                    }
                                                                                                                                                                          ))
                                    ,
                                    new global::Windows.UI.Xaml.Controls.Button
                                    {
                                        IsParsing = true
                                        ,
                                        Content             = @"Clear form" /* object/, Clear form, Button/Content */,
                                        HorizontalAlignment = global::Windows.UI.Xaml.HorizontalAlignment.Right /* Windows.UI.Xaml.HorizontalAlignment/, Right, Button/HorizontalAlignment */,
                                        // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 56:18)
                                    }
                                    .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler5)(c16 =>
                                    {
                                        global::Windows.UI.Xaml.Controls.Grid.SetRow(c16, 2 /* int/, 2, Grid/Row */);
                                        global::Windows.UI.Xaml.Controls.Grid.SetColumn(c16, 1 /* int/, 1, Grid/Column */);
                                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c16, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                        c16.CreationComplete();
                                    }
                                                                                                                                                                          ))
                                    ,
                                }
                            }
                            .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler6)(c17 =>
                            {
                                global::Windows.UI.Xaml.Controls.Grid.SetRow(c17, 2 /* int/, 2, Grid/Row */);
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c17, 1 /* int/, 1, Grid/Column */);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c17, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                c17.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                            new global::Windows.UI.Xaml.Controls.HyperlinkButton
                            {
                                IsParsing = true
                                ,
                                Content = @"Create new account" /* object/, Create new account, HyperlinkButton/Content */,
                                // Source ..\..\..\..\..\..\..\BudgetAppUNO.Shared\MainPage.xaml (Line 62:14)
                            }
                            .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler7)(c18 =>
                            {
                                global::Windows.UI.Xaml.Controls.Grid.SetRow(c18, 3 /* int/, 3, Grid/Row */);
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c18, 1 /* int/, 1, Grid/Column */);
                                global::Windows.UI.Xaml.Controls.Grid.SetColumnSpan(c18, 2 /* int/, 2, Grid/ColumnSpan */);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c18, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                                c18.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                        }
                    }
                    .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler6)(c19 =>
                    {
                        global::Windows.UI.Xaml.Controls.Grid.SetRow(c19, 1 /* int/, 1, Grid/Row */);
                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c19, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                        c19.CreationComplete();
                    }
                                                                                                                                                          ))
                    ,
                }
            }
            .MainPage_deef2be07f81d4f75693fe4b685dfac6_XamlApply((MainPage_deef2be07f81d4f75693fe4b685dfac6XamlApplyExtensions.XamlApplyHandler6)(c20 =>
            {
                global::Uno.UI.ResourceResolverSingleton.Instance.ApplyResource(c20, global::Windows.UI.Xaml.Controls.Grid.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, context: global::BudgetAppUNO.Droid.GlobalStaticResources.__ParseContext_);
                /* _isTopLevelDictionary:False */
                this._component_0 = c20;
                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c20, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                c20.CreationComplete();
            }
                                                                                                                                                  ))
            ;

            this
            .Apply((c21 =>
            {
                // Source C:\Users\bbdnet1522\source\repos\BudgetAppUNO\BudgetAppUNO.Shared\MainPage.xaml (Line 1:2)

                // WARNING Property c21.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator
            }
                    ))
            .Apply((c22 =>
            {
                // Class BudgetAppUNO.MainPage
                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c22, "file:///C:/Users/bbdnet1522/source/repos/BudgetAppUNO/BudgetAppUNO.Shared/MainPage.xaml");
                c22.CreationComplete();
            }
                    ))
            ;
            OnInitializeCompleted();

            Bindings = new MainPage_Bindings(this);
            Loading += delegate
            {
                _component_0.UpdateResourceBindings();
            }
            ;
        }
コード例 #20
0
		/// <summary>
		/// <see cref="INode.Resolve(string, NodeType, NameScope)"/>
		/// </summary>
		/// <remarks>
		/// The default implementation validates the NameScope by calling IsScopeValid(Uri, NameScope)
		/// and then calls the current object's FileSystem's <c>Resolve(string, NodeType)</c>
		/// method.
		/// </remarks>		
		public abstract INode Resolve(string name, NodeType nodeType, NameScope scope);
コード例 #21
0
ファイル: XamlParser.cs プロジェクト: dfr0/moon
		public XamlParser (XamlContext context) 
		{
			Context = context;
			NameScope = new NameScope ();
		}
コード例 #22
0
        public RectAnimationUsingKeyFramesExample()
        {
            Title      = "RectAnimationUsingKeyFrames Example";
            Background = Brushes.White;
            Margin     = new Thickness(20);

            // Create a NameScope for this page so that
            // Storyboards can be used.
            NameScope.SetNameScope(this, new NameScope());

            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Orientation         = Orientation.Vertical;
            myStackPanel.HorizontalAlignment = HorizontalAlignment.Center;

            //Add the Path Element
            Path myPath = new Path();

            myPath.Stroke          = Brushes.Black;
            myPath.Fill            = Brushes.LemonChiffon;
            myPath.StrokeThickness = 1;

            // Create a RectangleGeometry to specify the Path data.
            RectangleGeometry myRectangleGeometry = new RectangleGeometry();

            myRectangleGeometry.Rect = new Rect(0, 200, 100, 100);
            myPath.Data = myRectangleGeometry;

            myStackPanel.Children.Add(myPath);

            // Assign the TranslateTransform a name so that
            // it can be targeted by a Storyboard.
            this.RegisterName(
                "AnimatedRectangleGeometry", myRectangleGeometry);

            // Create a RectAnimationUsingKeyFrames to
            // animate the RectangleGeometry.
            RectAnimationUsingKeyFrames rectAnimation
                = new RectAnimationUsingKeyFrames();

            rectAnimation.Duration = TimeSpan.FromSeconds(6);

            // Set the animation to repeat forever.
            rectAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Animate position, width, and height in first 2 seconds. LinearRectKeyFrame creates
            // a smooth, linear animation between values.
            rectAnimation.KeyFrames.Add(
                new LinearRectKeyFrame(
                    new Rect(600, 50, 200, 50),                    // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))) // KeyTime
                );

            // In the next half second, change height to 10. DiscreteRectKeyFrame creates a
            // sudden "jump" between values.
            rectAnimation.KeyFrames.Add(
                new DiscreteRectKeyFrame(
                    new Rect(600, 50, 200, 10),                      // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2.5))) // KeyTime
                );

            // In the final 2 seconds of the animation, go back to the starting position, width, and height.
            // Spline key frames like SplineRectKeyFrame creates a variable transition between values depending
            // on the KeySpline property. In this example, the animation starts off slow but toward the end of
            // the time segment, it speeds up exponentially.
            rectAnimation.KeyFrames.Add(
                new SplineRectKeyFrame(
                    new Rect(0, 200, 100, 100),                      // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(4.5)), // KeyTime
                    new KeySpline(0.6, 0.0, 0.9, 0.0)                // KeySpline
                    )
                );

            // Set the animation to target the Rect property
            // of the object named "AnimatedRectangleGeometry."
            Storyboard.SetTargetName(rectAnimation, "AnimatedRectangleGeometry");
            Storyboard.SetTargetProperty(
                rectAnimation, new PropertyPath(RectangleGeometry.RectProperty));

            // Create a storyboard to apply the animation.
            Storyboard rectStoryboard = new Storyboard();

            rectStoryboard.Children.Add(rectAnimation);

            // Start the storyboard after the rectangle loads.
            myPath.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                rectStoryboard.Begin(this);
            };

            Content = myStackPanel;
        }
コード例 #23
0
        public OpacityAnimationExample()
        {
            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());

            this.WindowTitle = "Opacity Animation Example";
            this.Background  = Brushes.White;

            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Margin = new Thickness(20);

            //
            //  Clicking on this button animates its opacity.
            //
            Button opacityAnimatedButton = new Button();

            opacityAnimatedButton.Name = "opacityAnimatedButton";
            this.RegisterName(opacityAnimatedButton.Name, opacityAnimatedButton);
            opacityAnimatedButton.Content = "A Button";
            myStackPanel.Children.Add(opacityAnimatedButton);

            //
            //  Create an animation to animate the opacity of a button
            //
            DoubleAnimation myOpacityDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myOpacityDoubleAnimation, opacityAnimatedButton.Name);
            Storyboard.SetTargetProperty(myOpacityDoubleAnimation, new PropertyPath(Button.OpacityProperty));
            myOpacityDoubleAnimation.From        = 1;
            myOpacityDoubleAnimation.To          = 0;
            myOpacityDoubleAnimation.Duration    = new Duration(TimeSpan.FromMilliseconds(5000));
            myOpacityDoubleAnimation.AutoReverse = true;

            //
            //  Create a Storyboard to contain the animations and add the animations to the Storyboard
            //
            Storyboard myOpacityStoryboard = new Storyboard();

            myOpacityStoryboard.Children.Add(myOpacityDoubleAnimation);

            //
            //  Create EventTriggers and a BeginStoryboard action to start
            //  the storyboard
            BeginStoryboard myOpacityBeginStoryboard = new BeginStoryboard();
            EventTrigger    myOpacityEventTrigger    = new EventTrigger();

            myOpacityEventTrigger.RoutedEvent = Button.ClickEvent;
            myOpacityEventTrigger.SourceName  = opacityAnimatedButton.Name;
            myStackPanel.Triggers.Add(myOpacityEventTrigger);

            myOpacityBeginStoryboard.Storyboard = myOpacityStoryboard;
            myOpacityEventTrigger.Actions.Add(myOpacityBeginStoryboard);



            //
            //  Clicking on this button animates the opacity of the brush used to paint the background.
            //
            Button opacityBrushPaintedButton = new Button();

            opacityBrushPaintedButton.Name = "opacityBrushPaintedButton";
            this.RegisterName(opacityBrushPaintedButton.Name, opacityBrushPaintedButton);
            opacityBrushPaintedButton.Content = "A Button";
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();

            this.RegisterName("mySolidColorBrush", mySolidColorBrush);
            mySolidColorBrush.Color = Colors.Orange;
            opacityBrushPaintedButton.Background = mySolidColorBrush;
            myStackPanel.Children.Add(opacityBrushPaintedButton);

            //
            //  Create an animation to animate the opacity of the brush used to paint the background of the button.
            //
            DoubleAnimation myBackgroundOpacityDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myBackgroundOpacityDoubleAnimation, "mySolidColorBrush");
            Storyboard.SetTargetProperty(myBackgroundOpacityDoubleAnimation, new PropertyPath(Brush.OpacityProperty));

            myBackgroundOpacityDoubleAnimation.From        = 1;
            myBackgroundOpacityDoubleAnimation.To          = 0;
            myBackgroundOpacityDoubleAnimation.Duration    = new Duration(TimeSpan.FromSeconds(5));
            myBackgroundOpacityDoubleAnimation.AutoReverse = true;

            Storyboard myBackgroundOpacityStoryboard = new Storyboard();

            myBackgroundOpacityStoryboard.Children.Add(myBackgroundOpacityDoubleAnimation);

            //
            //  Create EventTriggers and a BeginStoryboard action to start
            //  the storyboard
            BeginStoryboard myBackgroundOpacityBeginStoryboard = new BeginStoryboard();
            EventTrigger    myBackgroundOpacityEventTrigger    = new EventTrigger();

            myBackgroundOpacityEventTrigger.RoutedEvent = Button.ClickEvent;
            myBackgroundOpacityEventTrigger.SourceName  = opacityBrushPaintedButton.Name;
            myStackPanel.Triggers.Add(myBackgroundOpacityEventTrigger);

            myBackgroundOpacityBeginStoryboard.Storyboard = myBackgroundOpacityStoryboard;
            myBackgroundOpacityEventTrigger.Actions.Add(myBackgroundOpacityBeginStoryboard);

            this.Content = myStackPanel;
        }
コード例 #24
0
ファイル: BeginTimeExample.cs プロジェクト: wzchua/docs
        public BeginTimeExample()
        {
            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());

            this.WindowTitle = "BeginTime Example";

            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Margin = new Thickness(20);

            Border          myBorder          = new Border();
            Color           myColor           = new Color();
            SolidColorBrush mySolidColorBrush = new SolidColorBrush(Color.FromArgb(153, 255, 255, 255));

            mySolidColorBrush.Color = myColor;
            myBorder.Background     = mySolidColorBrush;

            TextBlock myTextBlock = new TextBlock();

            myTextBlock.Margin = new Thickness(20);
            myTextBlock.Text   = "This example shows how the BeginTime property determines when a timeline starts.";
            myTextBlock.Text  += " Several rectangles are animated by DoubleAnimations with identical durations and";
            myTextBlock.Text  += " target values, but with different BeginTime settings.";
            myBorder.Child     = myTextBlock;
            myStackPanel.Children.Add(myBorder);

            myTextBlock      = new TextBlock();
            myTextBlock.Text = "Animation BeginTime: \"0:0:0\" ";
            myStackPanel.Children.Add(myTextBlock);

            Rectangle defaultBeginTimeRectangle = new Rectangle();

            defaultBeginTimeRectangle.Name = "defaultBeginTimeRectangle";
            this.RegisterName(defaultBeginTimeRectangle.Name, defaultBeginTimeRectangle);
            defaultBeginTimeRectangle.Width  = 20;
            defaultBeginTimeRectangle.Height = 20;
            myColor           = new Color();
            mySolidColorBrush = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255));
            defaultBeginTimeRectangle.Fill = mySolidColorBrush;
            defaultBeginTimeRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            myStackPanel.Children.Add(defaultBeginTimeRectangle);

            myTextBlock        = new TextBlock();
            myTextBlock.Margin = new Thickness(0, 20, 0, 0);
            myTextBlock.Text   = "Animation BeginTime: \"0:0:5\" \n";
            myStackPanel.Children.Add(myTextBlock);

            Rectangle delayedBeginTimeRectangle = new Rectangle();

            delayedBeginTimeRectangle.Name = "delayedBeginTimeRectangle";
            this.RegisterName(delayedBeginTimeRectangle.Name, delayedBeginTimeRectangle);
            delayedBeginTimeRectangle.Width  = 20;
            delayedBeginTimeRectangle.Height = 20;
            myColor           = new Color();
            mySolidColorBrush = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255));
            delayedBeginTimeRectangle.Fill = mySolidColorBrush;
            delayedBeginTimeRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            myStackPanel.Children.Add(delayedBeginTimeRectangle);

            myTextBlock      = new TextBlock();
            myTextBlock.Text = "\nParent Timeline BeginTime: \"0:0:5\" \nAnimation BeginTime: \"0:0:5\" ";
            myStackPanel.Children.Add(myTextBlock);

            Rectangle delayedAnimationWithDelayedParentRectangle = new Rectangle();

            delayedAnimationWithDelayedParentRectangle.Name = "delayedAnimationWithDelayedParentRectangle";
            this.RegisterName(delayedAnimationWithDelayedParentRectangle.Name,
                              delayedAnimationWithDelayedParentRectangle);
            delayedAnimationWithDelayedParentRectangle.Width  = 20;
            delayedAnimationWithDelayedParentRectangle.Height = 20;
            myColor           = new Color();
            mySolidColorBrush = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255));
            delayedAnimationWithDelayedParentRectangle.Fill = mySolidColorBrush;
            delayedAnimationWithDelayedParentRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            myStackPanel.Children.Add(delayedAnimationWithDelayedParentRectangle);

            //
            //  Create an animation with no delay in the start time.
            //
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myDoubleAnimation, defaultBeginTimeRectangle.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.WidthProperty));
            myDoubleAnimation.From         = 20;
            myDoubleAnimation.To           = 400;
            myDoubleAnimation.BeginTime    = TimeSpan.FromSeconds(0);
            myDoubleAnimation.Duration     = new Duration(TimeSpan.FromMilliseconds(2000));
            myDoubleAnimation.FillBehavior = FillBehavior.HoldEnd;

            //
            //  Create an animation with a 5 second delay in the start time.
            //
            DoubleAnimation myDelayedDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myDelayedDoubleAnimation, delayedBeginTimeRectangle.Name);
            Storyboard.SetTargetProperty(myDelayedDoubleAnimation, new PropertyPath(Rectangle.WidthProperty));
            myDelayedDoubleAnimation.BeginTime    = TimeSpan.FromSeconds(5);
            myDelayedDoubleAnimation.From         = 20;
            myDelayedDoubleAnimation.To           = 400;
            myDelayedDoubleAnimation.Duration     = new Duration(TimeSpan.FromMilliseconds(2000));
            myDelayedDoubleAnimation.FillBehavior = FillBehavior.HoldEnd;

            //
            //  Create an animation with a 5 second delay in both the parent and
            //  child timelines.
            //
            ParallelTimeline myParallelTimeline = new ParallelTimeline();

            myParallelTimeline.BeginTime = TimeSpan.FromSeconds(5);
            DoubleAnimation myParallelDelayedDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myParallelDelayedDoubleAnimation,
                                     delayedAnimationWithDelayedParentRectangle.Name);
            Storyboard.SetTargetProperty(myParallelDelayedDoubleAnimation,
                                         new PropertyPath(Rectangle.WidthProperty));
            myParallelDelayedDoubleAnimation.From         = 20;
            myParallelDelayedDoubleAnimation.To           = 400;
            myParallelDelayedDoubleAnimation.Duration     = new Duration(TimeSpan.FromMilliseconds(2000));
            myParallelDelayedDoubleAnimation.FillBehavior = FillBehavior.HoldEnd;
            myParallelDelayedDoubleAnimation.BeginTime    = TimeSpan.FromSeconds(5);

            //
            // Create a Storyboard to contain the animations and add the animations to the Storyboard
            //
            Storyboard myStoryboard = new Storyboard();

            myStoryboard.Children.Add(myDoubleAnimation);
            myStoryboard.Children.Add(myDelayedDoubleAnimation);
            myParallelTimeline.Children.Add(myParallelDelayedDoubleAnimation);
            myStoryboard.Children.Add(myParallelTimeline);

            //
            //  Create the button to restart the animations
            //
            Button myButton = new Button();

            myButton.Margin = new Thickness(0, 30, 0, 0);
            myButton.HorizontalAlignment = HorizontalAlignment.Left;
            myButton.Content             = "Restart Animations";
            myStackPanel.Children.Add(myButton);

            //
            //  Create an EventTrigger and a BeginStoryboard action to start
            //    the storyboard
            //
            BeginStoryboard myBeginStoryboard = new BeginStoryboard();

            myBeginStoryboard.Storyboard = myStoryboard;
            EventTrigger myEventTrigger = new EventTrigger();

            myEventTrigger.RoutedEvent = Button.ClickEvent;
            myEventTrigger.SourceName  = myButton.Name;
            myEventTrigger.Actions.Add(myBeginStoryboard);
            myStackPanel.Triggers.Add(myEventTrigger);

            this.Content = myStackPanel;
        }
コード例 #25
0
        public SizeAnimationExample()
        {
            // Create a NameScope for this page so that
            // Storyboards can be used.
            NameScope.SetNameScope(this, new NameScope());

            // Create an ArcSegment to define the geometry of the path.
            // The Size property of this segment is animated.
            ArcSegment myArcSegment = new ArcSegment();

            myArcSegment.Size           = new Size(90, 80);
            myArcSegment.SweepDirection = SweepDirection.Clockwise;
            myArcSegment.Point          = new Point(500, 200);

            // Assign the segment a name so that
            // it can be targeted by a Storyboard.
            this.RegisterName(
                "myArcSegment", myArcSegment);

            PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();

            myPathSegmentCollection.Add(myArcSegment);

            // Create a PathFigure to be used for the PathGeometry of myPath.
            PathFigure myPathFigure = new PathFigure();

            // Set the starting point for the PathFigure specifying that the
            // geometry starts at point 100,200.
            myPathFigure.StartPoint = new Point(100, 200);

            myPathFigure.Segments = myPathSegmentCollection;

            PathFigureCollection myPathFigureCollection = new PathFigureCollection();

            myPathFigureCollection.Add(myPathFigure);

            PathGeometry myPathGeometry = new PathGeometry();

            myPathGeometry.Figures = myPathFigureCollection;

            // Create a path to draw a geometry with.
            Path myPath = new Path();

            myPath.Stroke          = Brushes.Black;
            myPath.StrokeThickness = 1;

            // specify the shape of the path using the path geometry.
            myPath.Data = myPathGeometry;

            SizeAnimation mySizeAnimation = new SizeAnimation();

            mySizeAnimation.Duration = TimeSpan.FromSeconds(2);

            // Set the animation to repeat forever.
            mySizeAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Set the From and To properties of the animation.
            mySizeAnimation.From = new Size(90, 80);
            mySizeAnimation.To   = new Size(200, 200);

            // Set the animation to target the Size property
            // of the object named "myArcSegment."
            Storyboard.SetTargetName(mySizeAnimation, "myArcSegment");
            Storyboard.SetTargetProperty(
                mySizeAnimation, new PropertyPath(ArcSegment.SizeProperty));

            // Create a storyboard to apply the animation.
            Storyboard ellipseStoryboard = new Storyboard();

            ellipseStoryboard.Children.Add(mySizeAnimation);

            // Start the storyboard when the Path loads.
            myPath.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                ellipseStoryboard.Begin(this);
            };

            Canvas containerCanvas = new Canvas();

            containerCanvas.Children.Add(myPath);

            Content = containerCanvas;
        }
コード例 #26
0
        public ControlTemplateStoryboardExample()
        {
            ControlTemplate myControlTemplate =
                new ControlTemplate(typeof(Button));
            FrameworkElementFactory borderFactory =
                new FrameworkElementFactory(typeof(Border));
            FrameworkElementFactory contentPresenterFactory
                = new FrameworkElementFactory(typeof(ContentPresenter));

            borderFactory.AppendChild(contentPresenterFactory);
            myControlTemplate.VisualTree = borderFactory;

            /*
             * borderFactory.SetValue(Border.BackgroundProperty,
             *   TemplateBindingExpression(Button.BackgroundProperty));*/

            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());

            this.WindowTitle = "Controlling a Storyboard";
            this.Background  = Brushes.White;

            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Margin = new Thickness(20);

            // Create a rectangle.
            Rectangle myRectangle = new Rectangle();

            myRectangle.Width  = 100;
            myRectangle.Height = 20;
            myRectangle.Margin = new Thickness(12, 0, 0, 5);
            myRectangle.Fill   = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255));
            myRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            myStackPanel.Children.Add(myRectangle);

            // Assign the rectangle a name by
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations.
            this.RegisterName("myRectangle", myRectangle);

            //
            // Create an animation and a storyboard to animate the
            // rectangle.
            //
            DoubleAnimation myDoubleAnimation =
                new DoubleAnimation(100, 500, new Duration(TimeSpan.FromSeconds(5)));

            Storyboard.SetTargetName(myDoubleAnimation, "myRectangle");
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.WidthProperty));
            myStoryboard = new Storyboard();
            myStoryboard.Children.Add(myDoubleAnimation);

            //
            // Create a button to start the storyboard.
            //
            Button beginButton = new Button();

            beginButton.Template = myControlTemplate;
            beginButton.Content  = "Begin";
            beginButton.Click   += new RoutedEventHandler(beginButton_Clicked);

            myStackPanel.Children.Add(beginButton);
            this.Content = myStackPanel;
        }
コード例 #27
0
        public PointAnimationUsingKeyFramesExample()
        {
            Title      = "PointAnimationUsingKeyFrames Example";
            Background = Brushes.White;
            Margin     = new Thickness(20);

            // Create a NameScope for this page so that
            // Storyboards can be used.
            NameScope.SetNameScope(this, new NameScope());

            // Create an EllipseGeometry.
            EllipseGeometry myAnimatedEllipseGeometry =
                new EllipseGeometry(new Point(200, 100), 15, 15);

            // Assign the EllipseGeometry a name so that
            // it can be targeted by a Storyboard.
            this.RegisterName(
                "MyAnimatedEllipseGeometry", myAnimatedEllipseGeometry);

            // Create a Path element to display the geometry.
            Path aPath = new Path();

            aPath.Fill = Brushes.Blue;
            aPath.Data = myAnimatedEllipseGeometry;

            // Create a Canvas to contain the path.
            Canvas containerCanvas = new Canvas();

            containerCanvas.Width  = 500;
            containerCanvas.Height = 400;
            containerCanvas.Children.Add(aPath);

            // Create a PointAnimationUsingKeyFrames to
            // animate the EllipseGeometry.
            PointAnimationUsingKeyFrames centerPointAnimation
                = new PointAnimationUsingKeyFrames();

            centerPointAnimation.Duration = TimeSpan.FromSeconds(5);

            // Animate from the starting position to (100,300)
            // over the first half-second using linear
            // interpolation.
            centerPointAnimation.KeyFrames.Add(
                new LinearPointKeyFrame(
                    new Point(100, 300),                             // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.5))) // KeyTime
                );

            // Animate from (100,300) (the value of the previous key frame)
            // to (400,300) at 1 second using discrete interpolation.
            // Because the interpolation is discrete, the ellipse will appear
            // to "jump" to (400,300) at 1 second.
            centerPointAnimation.KeyFrames.Add(
                new DiscretePointKeyFrame(
                    new Point(400, 300),                           // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))) // KeyTime
                );

            // Animate from (400,300) (the value of the previous key frame) to (200,100)
            // over two seconds, starting at 1 second (the key time of the
            // last key frame) and ending at 3 seconds.
            centerPointAnimation.KeyFrames.Add(
                new SplinePointKeyFrame(
                    new Point(200, 100),                           // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3)), // KeyTime
                    new KeySpline(0.6, 0.0, 0.9, 0.0)              // KeySpline
                    )
                );

            // Set the animation to repeat forever.
            centerPointAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Set the animation to target the Center property
            // of the object named "MyAnimatedEllipseGeometry".
            Storyboard.SetTargetName(centerPointAnimation, "MyAnimatedEllipseGeometry");
            Storyboard.SetTargetProperty(
                centerPointAnimation, new PropertyPath(EllipseGeometry.CenterProperty));

            // Create a storyboard to apply the animation.
            Storyboard ellipseStoryboard = new Storyboard();

            ellipseStoryboard.Children.Add(centerPointAnimation);

            // Start the storyboard when the Path loads.
            aPath.Loaded += delegate(object sender, RoutedEventArgs e)
            {
                ellipseStoryboard.Begin(this);
            };

            Content = containerCanvas;
        }
コード例 #28
0
        private void InitializeComponent()
        {
            if (ResourceLoader.ResourceProvider != null && ResourceLoader.ResourceProvider(typeof(MineCell).GetTypeInfo().Assembly.GetName(), "Layout/MineCell.xaml") != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(base.GetType()) != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            ColumnDefinition     columnDefinition     = new ColumnDefinition();
            ColumnDefinition     columnDefinition2    = new ColumnDefinition();
            ColumnDefinition     columnDefinition3    = new ColumnDefinition();
            BindingExtension     bindingExtension     = new BindingExtension();
            TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer();
            BindingExtension     bindingExtension2    = new BindingExtension();
            SvgCachedImage       svgCachedImage       = new SvgCachedImage();
            BindingExtension     bindingExtension3    = new BindingExtension();
            Label          label           = new Label();
            SvgCachedImage svgCachedImage2 = new SvgCachedImage();
            Grid           grid            = new Grid();
            NameScope      nameScope       = new NameScope();

            NameScope.SetNameScope(this, nameScope);
            NameScope.SetNameScope(grid, nameScope);
            NameScope.SetNameScope(columnDefinition, nameScope);
            NameScope.SetNameScope(columnDefinition2, nameScope);
            NameScope.SetNameScope(columnDefinition3, nameScope);
            NameScope.SetNameScope(tapGestureRecognizer, nameScope);
            NameScope.SetNameScope(svgCachedImage, nameScope);
            ((INameScope)nameScope).RegisterName("icon", svgCachedImage);
            if (svgCachedImage.StyleId == null)
            {
                svgCachedImage.StyleId = "icon";
            }
            NameScope.SetNameScope(label, nameScope);
            ((INameScope)nameScope).RegisterName("label", label);
            if (label.StyleId == null)
            {
                label.StyleId = "label";
            }
            NameScope.SetNameScope(svgCachedImage2, nameScope);
            this.icon  = svgCachedImage;
            this.label = label;
            grid.SetValue(Grid.ColumnSpacingProperty, 10.0);
            grid.SetValue(Layout.PaddingProperty, new Thickness(20.0, 0.0, 15.0, 0.0));
            columnDefinition.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("24"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition);
            columnDefinition2.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition2);
            columnDefinition3.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("15"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition3);
            bindingExtension.Path = "SelectCommand";
            BindingBase binding = ((IMarkupExtension <BindingBase>)bindingExtension).ProvideValue(null);

            tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, binding);
            grid.GestureRecognizers.Add(tapGestureRecognizer);
            svgCachedImage.SetValue(Grid.ColumnProperty, 0);
            svgCachedImage.SetValue(VisualElement.WidthRequestProperty, 24.0);
            svgCachedImage.SetValue(VisualElement.HeightRequestProperty, 24.0);
            svgCachedImage.SetValue(CachedImage.AspectProperty, Aspect.AspectFit);
            bindingExtension2.Path = "Icon";
            BindingBase binding2 = ((IMarkupExtension <BindingBase>)bindingExtension2).ProvideValue(null);

            svgCachedImage.SetBinding(CachedImage.SourceProperty, binding2);
            svgCachedImage.SetValue(View.VerticalOptionsProperty, LayoutOptions.Center);
            grid.Children.Add(svgCachedImage);
            label.SetValue(Grid.ColumnProperty, 1);
            BindableObject         bindableObject        = label;
            BindableProperty       fontSizeProperty      = Label.FontSizeProperty;
            IExtendedTypeConverter extendedTypeConverter = new FontSizeConverter();
            string value = "Default";
            XamlServiceProvider xamlServiceProvider = new XamlServiceProvider();
            Type typeFromHandle = typeof(IProvideValueTarget);

            object[] array = new object[0 + 3];
            array[0] = label;
            array[1] = grid;
            array[2] = this;
            xamlServiceProvider.Add(typeFromHandle, new SimpleValueTargetProvider(array, Label.FontSizeProperty));
            xamlServiceProvider.Add(typeof(INameScopeProvider), new NameScopeProvider
            {
                NameScope = nameScope
            });
            Type typeFromHandle2 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver = new XmlNamespaceResolver();

            xmlNamespaceResolver.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver.Add("svg", "clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms");
            xamlServiceProvider.Add(typeFromHandle2, new XamlTypeResolver(xmlNamespaceResolver, typeof(MineCell).GetTypeInfo().Assembly));
            xamlServiceProvider.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(14, 36)));
            bindableObject.SetValue(fontSizeProperty, extendedTypeConverter.ConvertFromInvariantString(value, xamlServiceProvider));
            label.SetValue(Label.TextColorProperty, Color.Black);
            bindingExtension3.Path = "Title";
            BindingBase binding3 = ((IMarkupExtension <BindingBase>)bindingExtension3).ProvideValue(null);

            label.SetBinding(Label.TextProperty, binding3);
            label.SetValue(View.VerticalOptionsProperty, LayoutOptions.Center);
            label.SetValue(Label.HorizontalTextAlignmentProperty, new TextAlignmentConverter().ConvertFromInvariantString("Start"));
            grid.Children.Add(label);
            svgCachedImage2.SetValue(Grid.ColumnProperty, 2);
            svgCachedImage2.SetValue(VisualElement.WidthRequestProperty, 15.0);
            svgCachedImage2.SetValue(VisualElement.HeightRequestProperty, 15.0);
            svgCachedImage2.SetValue(CachedImage.AspectProperty, Aspect.AspectFit);
            svgCachedImage2.SetValue(CachedImage.SourceProperty, new FFImageLoading.Forms.ImageSourceConverter().ConvertFromInvariantString("rightarrow.svg"));
            svgCachedImage2.SetValue(View.VerticalOptionsProperty, LayoutOptions.Center);
            grid.Children.Add(svgCachedImage2);
            this.View = grid;
        }
コード例 #29
0
        private XAML3.INameScopeDictionary HuntAroundForARootNameScope(ObjectWriterFrame rootFrame)
        {
            Debug.Assert(rootFrame.Depth == 1);

            object inst = rootFrame.Instance;

            if (inst == null && rootFrame.XamlType.IsNameScope)
            {
                throw new InvalidOperationException(SR.Get(SRID.NameScopeOnRootInstance));
            }

            XAML3.INameScopeDictionary nameScopeDictionary = null;

            nameScopeDictionary = inst as XAML3.INameScopeDictionary;

            if (nameScopeDictionary == null)
            {
                XAML3.INameScope nameScope = inst as XAML3.INameScope;
                if (nameScope != null)
                {
                    nameScopeDictionary = new NameScopeDictionary(nameScope);
                }
            }

            // If the root instance isn't a name scope
            // then perhaps it designated a property as the name scope.
            if (nameScopeDictionary == null)
            {
                XamlType xamlType = rootFrame.XamlType;
                if (xamlType.UnderlyingType != null)
                {
                    // Get the Name Scope Property (from attribute on the class)
                    XamlMember nameScopeProperty = TypeReflector.LookupNameScopeProperty(xamlType);
                    if (nameScopeProperty != null)
                    {
                        // Read the value of the property.  If it is an object we are good.
                        // if it is null create a stock name scope dictionary object and assign it back.
                        XAML3.INameScope nameScope = (XAML3.INameScope)_runtime.GetValue(inst, nameScopeProperty, false);
                        if (nameScope == null)
                        {
#if TARGETTING35SP1
                            nameScopeDictionary = new NameScopeDictionary(new NameScope());
#else
                            nameScopeDictionary = new NameScope();
#endif
                            _runtime.SetValue(inst, nameScopeProperty, nameScopeDictionary);
                        }
                        else
                        {
                            nameScopeDictionary = nameScope as XAML3.INameScopeDictionary;
                            if (nameScopeDictionary == null)
                            {
                                nameScopeDictionary = new NameScopeDictionary(nameScope);
                            }
                        }
                    }
                }
            }

            if (nameScopeDictionary == null && _settings != null &&
                _settings.RegisterNamesOnExternalNamescope)
            {
                ObjectWriterFrame frameZero = (ObjectWriterFrame)rootFrame.Previous;
                nameScopeDictionary = frameZero.NameScopeDictionary;
            }

            // Otherwise we still need a namescope at the root of the parse
            // for our own usage.  For IXamlNameResolver() to use.
            if (nameScopeDictionary == null)
            {
#if TARGETTING35SP1
                nameScopeDictionary = new NameScopeDictionary(new NameScope());
#else
                nameScopeDictionary = new NameScope();
#endif
            }

            rootFrame.NameScopeDictionary = nameScopeDictionary;
            return(nameScopeDictionary);
        }
コード例 #30
0
        public MultipleNameScopesExample()
        {
            this.Background        = Brushes.White;
            mainPanel              = new StackPanel();
            mainPanel.Background   = Brushes.Gray;
            childPanel1            = new StackPanel();
            childPanel1.Background = Brushes.Orange;
            mainPanel.Children.Add(childPanel1);
            childPanel2            = new StackPanel();
            childPanel2.Background = Brushes.Red;
            mainPanel.Children.Add(childPanel2);

            // Create a name scope for each panel.
            NameScope.SetNameScope(mainPanel, new NameScope());
            NameScope.SetNameScope(childPanel1, new NameScope());
            NameScope.SetNameScope(childPanel2, new NameScope());

            // Create a rectangle, add it to childPanel1,
            // and register its name with childPanel1.
            rectangle1        = new Rectangle();
            rectangle1.Width  = 50;
            rectangle1.Height = 50;
            rectangle1.Fill   = Brushes.Blue;
            childPanel1.RegisterName("rectangle1", rectangle1);
            childPanel1.Children.Add(rectangle1);

            // Animate rectangle1's width.
            DoubleAnimation myDoubleAnimation =
                new DoubleAnimation(10, 100, new Duration(TimeSpan.FromSeconds(3)));

            Storyboard.SetTargetName(myDoubleAnimation, "rectangle1");
            Storyboard.SetTargetProperty(myDoubleAnimation,
                                         new PropertyPath(Rectangle.WidthProperty));
            storyboard1 = new Storyboard();
            storyboard1.Children.Add(myDoubleAnimation);

            Button startRectangle1AnimationButton = new Button();

            startRectangle1AnimationButton.Content = "Start rectangle1 Animation";
            startRectangle1AnimationButton.Click  +=
                new RoutedEventHandler(startRectangle1AnimationButton_clicked);
            mainPanel.Children.Add(startRectangle1AnimationButton);


            // Create a rectangle, add it to childPanel1,
            // but register its name with mainPanel.
            rectangle2        = new Rectangle();
            rectangle2.Width  = 50;
            rectangle2.Height = 50;
            rectangle2.Fill   = Brushes.Black;
            mainPanel.RegisterName("rectangle2", rectangle2);
            childPanel1.Children.Add(rectangle2);

            // Animate rectangle2's width.
            myDoubleAnimation =
                new DoubleAnimation(10, 100, new Duration(TimeSpan.FromSeconds(3)));
            Storyboard.SetTargetName(myDoubleAnimation, "rectangle2");
            Storyboard.SetTargetProperty(myDoubleAnimation,
                                         new PropertyPath(Rectangle.WidthProperty));
            storyboard2 = new Storyboard();
            storyboard2.Children.Add(myDoubleAnimation);

            Button startRectangle2AnimationButton = new Button();

            startRectangle2AnimationButton.Content = "Start rectangle2 Animation";
            startRectangle2AnimationButton.Click  +=
                new RoutedEventHandler(startRectangle2AnimationButton_clicked);
            mainPanel.Children.Add(startRectangle2AnimationButton);



            this.Content = mainPanel;
        }
コード例 #31
0
		internal static NameScope GetNameScope([NotNull] this MethodDeclarationSyntax methodDeclaration, [NotNull] SemanticModel semanticModel,
											   bool includeLocals)
		{
			var parameters = methodDeclaration.ParameterList.Parameters.Select(parameter => parameter.Identifier.ValueText);
			var locals = methodDeclaration.Descendants<VariableDeclaratorSyntax>().Select(local => local.Identifier.ValueText);
			var baseSymbols = semanticModel.LookupBaseMembers(methodDeclaration.Body.SpanStart);
			var selfSymbols = semanticModel.LookupSymbols(methodDeclaration.SpanStart);

			var nameScope = new NameScope();
			nameScope.AddRange(parameters);
			nameScope.AddRange(baseSymbols.Select(symbol => symbol.Name));
			nameScope.AddRange(selfSymbols.Select(symbol => symbol.Name));

			if (includeLocals)
				nameScope.AddRange(locals);

			return nameScope;
		}
コード例 #32
0
        public void Lataj(Particle Czastka, List <List <int> > animKoordynaty)
        {
            NameScope.SetNameScope(mapa.Mw, new NameScope());


            TranslateTransform animatedTranslateTransform =
                new TranslateTransform();


            mapa.Mw.RegisterName("AnimatedTranslateTransform", animatedTranslateTransform);

            Czastka.ReturnImage().RenderTransform = animatedTranslateTransform;


            PathGeometry animationPath = new PathGeometry();
            PathFigure   pFigure       = new PathFigure();


            pFigure.StartPoint = new Point(animKoordynaty[0][0] - X0(Czastka.ReturnImage()), animKoordynaty[0][1] - Y0(Czastka.ReturnImage()));
            List <LineSegment> odcinki = new List <LineSegment>();

            for (int i = 0; i < animKoordynaty.Count - 1; i++)
            {
                odcinki.Add(new LineSegment());
                odcinki[i].Point = new Point(animKoordynaty[i + 1][0] - X0(Czastka.ReturnImage()), animKoordynaty[i + 1][1] - Y0(Czastka.ReturnImage()));
                pFigure.Segments.Add(odcinki[i]);
            }



            animationPath.Figures.Add(pFigure);


            animationPath.Freeze();


            DoubleAnimationUsingPath translateXAnimation =
                new DoubleAnimationUsingPath();

            translateXAnimation.PathGeometry      = animationPath;
            translateXAnimation.Duration          = TimeSpan.FromSeconds(5);
            translateXAnimation.AccelerationRatio = Czastka.TimeAnimation;

            translateXAnimation.Source = PathAnimationSource.X;


            Storyboard.SetTargetName(translateXAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateXAnimation,
                                         new PropertyPath(TranslateTransform.XProperty));


            DoubleAnimationUsingPath translateYAnimation =
                new DoubleAnimationUsingPath();

            translateYAnimation.PathGeometry      = animationPath;
            translateYAnimation.Duration          = TimeSpan.FromSeconds(5);
            translateYAnimation.AccelerationRatio = Czastka.TimeAnimation;

            translateYAnimation.Source = PathAnimationSource.Y;


            Storyboard.SetTargetName(translateYAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation,
                                         new PropertyPath(TranslateTransform.YProperty));



            pathAnimationStoryboard.Children.Add(translateXAnimation);
            pathAnimationStoryboard.Children.Add(translateYAnimation);



            {
                pathAnimationStoryboard.Begin(mapa.Mw);
            };
        }
コード例 #33
0
		public virtual IDirectory ResolveDirectory(string name, NameScope scope)
		{
			return (IDirectory)Resolve(name, NodeType.Directory, scope);
		}
コード例 #34
0
        public void Visit(ElementNode node, INode parentNode)
        {
            object value = null;

            XamlParseException xpe;
            var type = XamlParser.GetElementType(node.XmlType, node, Context.RootElement?.GetType().GetTypeInfo().Assembly,
                                                 out xpe);

            if (xpe != null)
            {
                throw xpe;
            }

            Context.Types[node] = type;
            string ctorargname;

            if (IsXaml2009LanguagePrimitive(node))
            {
                value = CreateLanguagePrimitive(type, node);
            }
            else if (node.Properties.ContainsKey(XmlName.xArguments) || node.Properties.ContainsKey(XmlName.xFactoryMethod))
            {
                value = CreateFromFactory(type, node);
            }
            else if (
                type.GetTypeInfo()
                .DeclaredConstructors.Any(
                    ci =>
                    ci.IsPublic && ci.GetParameters().Length != 0 &&
                    ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof(ParameterAttribute)))) &&
                ValidateCtorArguments(type, node, out ctorargname))
            {
                value = CreateFromParameterizedConstructor(type, node);
            }
            else if (!type.GetTypeInfo().DeclaredConstructors.Any(ci => ci.IsPublic && ci.GetParameters().Length == 0) &&
                     !ValidateCtorArguments(type, node, out ctorargname))
            {
                throw new XamlParseException($"The Property {ctorargname} is required to create a {type?.FullName} object.", node);
            }
            else
            {
                //this is a trick as the DataTemplate parameterless ctor is internal, and we can't CreateInstance(..., false) on WP7
                try
                {
                    if (type == typeof(DataTemplate))
                    {
                        value = new DataTemplate();
                    }
                    if (type == typeof(ControlTemplate))
                    {
                        value = new ControlTemplate();
                    }
                    if (value == null && node.CollectionItems.Any() && node.CollectionItems.First() is ValueNode)
                    {
                        var serviceProvider = new XamlServiceProvider(node, Context);
                        var converted       = ((ValueNode)node.CollectionItems.First()).Value.ConvertTo(type, () => type.GetTypeInfo(),
                                                                                                        serviceProvider);
                        if (converted != null && converted.GetType() == type)
                        {
                            value = converted;
                        }
                    }
                    if (value == null)
                    {
                        value = Activator.CreateInstance(type);
                    }
                }
                catch (TargetInvocationException e)
                {
                    if (e.InnerException is XamlParseException || e.InnerException is XmlException)
                    {
                        throw e.InnerException;
                    }
                    throw;
                }
            }

            Values[node] = value;

            var markup = value as IMarkupExtension;

            if (markup != null && (value is TypeExtension || value is StaticExtension || value is ArrayExtension))
            {
                var serviceProvider = new XamlServiceProvider(node, Context);

                var visitor = new ApplyPropertiesVisitor(Context);
                foreach (var cnode in node.Properties.Values.ToList())
                {
                    cnode.Accept(visitor, node);
                }
                foreach (var cnode in node.CollectionItems)
                {
                    cnode.Accept(visitor, node);
                }

                value = markup.ProvideValue(serviceProvider);

                INode xKey;
                if (!node.Properties.TryGetValue(XmlName.xKey, out xKey))
                {
                    xKey = null;
                }

                node.Properties.Clear();
                node.CollectionItems.Clear();

                if (xKey != null)
                {
                    node.Properties.Add(XmlName.xKey, xKey);
                }

                Values[node] = value;
            }

            if (value is BindableObject)
            {
                NameScope.SetNameScope(value as BindableObject, node.Namescope);
            }
        }
コード例 #35
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="name"></param>
		/// <param name="scope"></param>
		/// <returns></returns>		
		public virtual INode Resolve(string name, NameScope scope)
		{
			return Resolve(name, NodeType.Any, scope);
		}
コード例 #36
0
ファイル: TemplatedControl.cs プロジェクト: KvanTTT/Perspex
        /// <inheritdoc/>
        public sealed override void ApplyTemplate()
        {
            if (!_templateApplied)
            {
                if (VisualChildren.Count > 0)
                {
                    foreach (var child in this.GetTemplateChildren())
                    {
                        child.SetValue(TemplatedParentProperty, null);
                    }

                    VisualChildren.Clear();
                }

                if (Template != null)
                {
                    _templateLog.Verbose("Creating control template");

                    var child = Template.Build(this);
                    var nameScope = new NameScope();
                    NameScope.SetNameScope((Control)child, nameScope);
                    child.SetValue(TemplatedParentProperty, this);
                    RegisterNames(child, nameScope);
                    ((ISetLogicalParent)child).SetParent(this);
                    VisualChildren.Add(child);

                    OnTemplateApplied(new TemplateAppliedEventArgs(nameScope));
                }

                _templateApplied = true;
            }
        }
        private void InitializeComponent()
        {
            var nameScope = new global::Windows.UI.Xaml.NameScope();

            NameScope.SetNameScope(this, nameScope);
            IsParsing = true
            ;
            // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 1:2)
            Content =
                new global::Windows.UI.Xaml.Controls.Grid
            {
                IsParsing = true
                ,
                RowDefinitions =
                {
                    new global::Windows.UI.Xaml.Controls.RowDefinition
                    {
                        Height = new Windows.UI.Xaml.GridLength(50f, Windows.UI.Xaml.GridUnitType.Pixel) /* Windows.UI.Xaml.GridLength/, 50, RowDefinition/Height */,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 13:8)
                    }
                    ,
                    new global::Windows.UI.Xaml.Controls.RowDefinition
                    {
                        Height = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Star) /* Windows.UI.Xaml.GridLength/, *, RowDefinition/Height */,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 14:8)
                    }
                    ,
                    new global::Windows.UI.Xaml.Controls.RowDefinition
                    {
                        Height = new Windows.UI.Xaml.GridLength(300f, Windows.UI.Xaml.GridUnitType.Pixel) /* Windows.UI.Xaml.GridLength/, 300, RowDefinition/Height */,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 15:8)
                    }
                    ,
                }

                ,
                ColumnDefinitions =
                {
                    new global::Windows.UI.Xaml.Controls.ColumnDefinition
                    {
                        Width = new Windows.UI.Xaml.GridLength(200f, Windows.UI.Xaml.GridUnitType.Pixel) /* Windows.UI.Xaml.GridLength/, 200, ColumnDefinition/Width */,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 18:8)
                    }
                    ,
                    new global::Windows.UI.Xaml.Controls.ColumnDefinition
                    {
                        Width = new Windows.UI.Xaml.GridLength(1f, Windows.UI.Xaml.GridUnitType.Star) /* Windows.UI.Xaml.GridLength/, *, ColumnDefinition/Width */,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 19:8)
                    }
                    ,
                }

                ,
                // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 11:4)
                Children =
                {
                    new global::Windows.UI.Xaml.Controls.StackPanel
                    {
                        IsParsing = true
                        ,
                        Orientation = global::Windows.UI.Xaml.Controls.Orientation.Horizontal /* Windows.UI.Xaml.Controls.Orientation/, Horizontal, StackPanel/Orientation */,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 21:6)
                        Children =
                        {
                            new global::Windows.UI.Xaml.Controls.Button
                            {
                                IsParsing = true
                                ,
                                Name = "Open",
                                // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 22:8)
                                Content = "Open"
                                ,
                            }
                            .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler2)(c5 =>
                            {
                                nameScope.RegisterName("Open", c5);
                                this.Open = c5;
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c5, 0 /* int/, 0, Grid/Column */);
                                var Click_ButtonOpen_That = (this as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;
                                c5.Click += (ButtonOpen_sender, ButtonOpen_e) => (Click_ButtonOpen_That.Target as MainPage)?.ButtonOpen(ButtonOpen_sender, ButtonOpen_e);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c5, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                                c5.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                            new global::Windows.UI.Xaml.Controls.Button
                            {
                                IsParsing = true
                                ,
                                Name = "OpenFolder",
                                // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 23:8)
                                Content = "Open Folder"
                                ,
                            }
                            .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler2)(c6 =>
                            {
                                nameScope.RegisterName("OpenFolder", c6);
                                this.OpenFolder = c6;
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c6, 0 /* int/, 0, Grid/Column */);
                                var Click_Openfolder_That = (this as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;
                                c6.Click += (Openfolder_sender, Openfolder_e) => (Click_Openfolder_That.Target as MainPage)?.Openfolder(Openfolder_sender, Openfolder_e);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c6, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                                c6.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                            new global::Windows.UI.Xaml.Controls.Button
                            {
                                IsParsing = true
                                ,
                                Name = "Save",
                                // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 24:8)
                                Content = "Save"
                                ,
                            }
                            .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler2)(c7 =>
                            {
                                nameScope.RegisterName("Save", c7);
                                this.Save = c7;
                                global::Windows.UI.Xaml.Controls.Grid.SetColumn(c7, 0 /* int/, 0, Grid/Column */);
                                var Click_Savefile_That = (this as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;
                                c7.Click += (Savefile_sender, Savefile_e) => (Click_Savefile_That.Target as MainPage)?.Savefile(Savefile_sender, Savefile_e);
                                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c7, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                                c7.CreationComplete();
                            }
                                                                                                                                                                  ))
                            ,
                        }
                    }
                    .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler3)(c8 =>
                    {
                        global::Windows.UI.Xaml.Controls.Grid.SetColumn(c8, 0 /* int/, 0, Grid/Column */);
                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c8, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                        c8.CreationComplete();
                    }
                                                                                                                                                          ))
                    ,
                    new global::UnoEditor.Shared.Views.fileview
                    {
                        IsParsing = true
                        ,
                        Name = "fileviewer1",
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 26:6)
                    }
                    .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler4)(c9 =>
                    {
                        nameScope.RegisterName("fileviewer1", c9);
                        this.fileviewer1 = c9;
                        global::Windows.UI.Xaml.Controls.Grid.SetColumn(c9, 0 /* int/, 0, Grid/Column */);
                        global::Windows.UI.Xaml.Controls.Grid.SetRow(c9, 1 /* int/, 1, Grid/Row */);
                        global::Windows.UI.Xaml.Controls.Grid.SetRowSpan(c9, 2 /* int/, 2, Grid/RowSpan */);
                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c9, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                        c9.CreationComplete();
                    }
                                                                                                                                                          ))
                    ,
                    new global::UnoEditor.Shared.Views.Editor.Editor
                    {
                        IsParsing = true
                        ,
                        Name     = "editor1",
                        filepath = "E:\\test.js" /* string/, E:\test.js, Editor/filepath */,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 27:6)
                    }
                    .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler5)(c10 =>
                    {
                        nameScope.RegisterName("editor1", c10);
                        this.editor1 = c10;
                        global::Windows.UI.Xaml.Controls.Grid.SetColumn(c10, 1 /* int/, 1, Grid/Column */);
                        global::Windows.UI.Xaml.Controls.Grid.SetRow(c10, 1 /* int/, 1, Grid/Row */);
                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c10, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                        c10.CreationComplete();
                    }
                                                                                                                                                          ))
                    ,
                    new global::UnoEditor.Shared.Views.Terminal2
                    {
                        IsParsing = true
                        ,
                        // Source ..\..\..\..\..\..\..\UnoEditor.Shared\MainPage.xaml (Line 28:6)
                    }
                    .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler6)(c11 =>
                    {
                        global::Windows.UI.Xaml.Controls.Grid.SetColumn(c11, 1 /* int/, 1, Grid/Column */);
                        global::Windows.UI.Xaml.Controls.Grid.SetRow(c11, 2 /* int/, 2, Grid/Row */);
                        global::Uno.UI.FrameworkElementHelper.SetBaseUri(c11, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                        c11.CreationComplete();
                    }
                                                                                                                                                          ))
                    ,
                }
            }
            .MainPage_77666adaa098a2b86ef8a14e7904941d_XamlApply((MainPage_77666adaa098a2b86ef8a14e7904941dXamlApplyExtensions.XamlApplyHandler7)(c12 =>
            {
                global::Uno.UI.ResourceResolver.ApplyResource(c12, global::Windows.UI.Xaml.Controls.Grid.BackgroundProperty, "ApplicationPageBackgroundThemeBrush", isThemeResourceExtension: true, context: global::UnoEditor.macOS.GlobalStaticResources.__ParseContext_);
                this._component_0 = c12;
                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c12, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                c12.CreationComplete();
            }
                                                                                                                                                  ))
            ;

            this
            .Apply((c13 =>
            {
                // Source E:\Reposs\UnoEditor\UnoEditor\UnoEditor.Shared\MainPage.xaml (Line 1:2)

                // WARNING Property c13.base does not exist on {http://schemas.microsoft.com/winfx/2006/xaml/presentation}Page, the namespace is http://www.w3.org/XML/1998/namespace. This error was considered irrelevant by the XamlFileGenerator
            }
                    ))
            .Apply((c14 =>
            {
                // Class UnoEditor.MainPage
                global::Uno.UI.FrameworkElementHelper.SetBaseUri(c14, "file:///E:/Reposs/UnoEditor/UnoEditor/UnoEditor.Shared/MainPage.xaml");
                c14.CreationComplete();
            }
                    ))
            ;
            OnInitializeCompleted();
            InitializeXamlOwner();
            Loading += delegate
            {
                _component_0.UpdateResourceBindings();
            }
            ;
        }
コード例 #38
0
        public GamesPage()
        {
            InitializeComponent();
            NameScope.SetNameScope(dgcm, NameScope.GetNameScope(this));

            VM = MainViewModel.Default.GamesViewModel;

            VM.ConfirmationShow = (s1, s2) =>
            {
                var dialog = new ModernDialog
                {
                    Title   = s1,
                    Content = s2
                };

                MessageBoxResult result = MessageBoxResult.Cancel;
                var yesButton           = new Button()
                {
                    Content = "Да",
                    Margin  = new Thickness(2, 0, 2, 0)
                };
                yesButton.Click += (o, ea) =>
                {
                    result = MessageBoxResult.Yes;
                    dialog.Close();
                };
                var noButton = new Button()
                {
                    Content    = "Нет",
                    Margin     = new Thickness(2, 0, 2, 0),
                    FontWeight = FontWeights.Bold,
                    IsDefault  = true
                };
                noButton.Click += (o, ea) =>
                {
                    result = MessageBoxResult.No;
                    dialog.Close();
                };
                dialog.Buttons = new Button[] { yesButton, noButton };


                dialog.ShowDialog();

                if (result == MessageBoxResult.Yes)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            };
            VM.TextSearchStarted = () =>
            {
                tbFilter.Focus();
                Keyboard.Focus(tbFilter);
            };
            dg.Focus();
            Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.ContextIdle,
                new Action(() => Keyboard.Focus(dg)));
            dg.SyncSortWithView();

            VM.Refreshed = () => dg.ScrollToCurrentItem();

            DataContext = VM;
        }
コード例 #39
0
ファイル: NameScope.cs プロジェクト: kangaroo/moon
		public static void SetNameScope (DependencyObject dob, NameScope scope)
		{
			dob.SetValue (NameScope.NameScopeProperty, scope);
		}
コード例 #40
0
        public BooleanAnimationUsingKeyFramesExample()
        {
            Title      = "BooleanAnimationUsingKeyFrames Example";
            Background = Brushes.White;
            Margin     = new Thickness(20);

            // Create a NameScope for this page so that
            // Storyboards can be used.
            NameScope.SetNameScope(this, new NameScope());

            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Orientation = Orientation.Vertical;
            myStackPanel.Margin      = new Thickness(20);

            // Create a TextBlock to introduce the example.
            TextBlock myTextBlock = new TextBlock();

            myTextBlock.Text = "Click the button to animate its IsEnabled property"
                               + " with aBooleanAnimationUsingKeyFrames animation.";
            myStackPanel.Children.Add(myTextBlock);

            // Create the Button that is the target of the animation.
            Button myButton = new Button();

            myButton.Margin  = new Thickness(200);
            myButton.Content = "Click Me";

            myStackPanel.Children.Add(myButton);


            // Assign the Button a name so that
            // it can be targeted by a Storyboard.
            this.RegisterName(
                "AnimatedButton", myButton);

            // Create a BooleanAnimationUsingKeyFrames to
            // animate the IsEnabled property of the Button.
            BooleanAnimationUsingKeyFrames booleanAnimation
                = new BooleanAnimationUsingKeyFrames();

            booleanAnimation.Duration = TimeSpan.FromSeconds(4);


            // All the key frames defined below are DiscreteBooleanKeyFrames.
            // Discrete key frames create sudden "jumps" between values
            // (no interpolation). Only discrete key frames can be used
            // for Boolean key frame animations.

            // Value at the beginning is false
            booleanAnimation.KeyFrames.Add(
                new DiscreteBooleanKeyFrame(
                    false,                                           // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.0))) // KeyTime
                );

            // Value becomes true after the first second.
            booleanAnimation.KeyFrames.Add(
                new DiscreteBooleanKeyFrame(
                    true,                                            // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1.0))) // KeyTime
                );

            // Value becomes false after the 2nd second.
            booleanAnimation.KeyFrames.Add(
                new DiscreteBooleanKeyFrame(
                    false,                                           // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2.0))) // KeyTime
                );

            // Value becomes true after the third second.
            booleanAnimation.KeyFrames.Add(
                new DiscreteBooleanKeyFrame(
                    true,                                            // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3.0))) // KeyTime
                );

            // Value becomes false after 3 and half seconds.
            booleanAnimation.KeyFrames.Add(
                new DiscreteBooleanKeyFrame(
                    false,                                           // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(3.5))) // KeyTime
                );

            // Value becomes true after the fourth second.
            booleanAnimation.KeyFrames.Add(
                new DiscreteBooleanKeyFrame(
                    true,                                            // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(4.0))) // KeyTime
                );

            // Set the animation to target the IsEnabled property
            // of the object named "AnimatedButton".
            Storyboard.SetTargetName(booleanAnimation, "AnimatedButton");
            Storyboard.SetTargetProperty(
                booleanAnimation, new PropertyPath(Button.IsEnabledProperty));

            // Create a storyboard to apply the animation.
            Storyboard myStoryboard = new Storyboard();

            myStoryboard.Children.Add(booleanAnimation);

            // Start the storyboard when the button is clicked.
            myButton.Click += delegate(object sender, RoutedEventArgs e)
            {
                myStoryboard.Begin(this);
            };

            Content = myStackPanel;
        }
コード例 #41
0
        XamlObject ParseObject(XmlElement element)
        {
            Type elementType = settings.TypeFinder.GetType(element.NamespaceURI, element.LocalName);

            if (elementType == null)
            {
                elementType = settings.TypeFinder.GetType(element.NamespaceURI, element.LocalName + "Extension");
                if (elementType == null)
                {
                    throw new XamlLoadException("Cannot find type " + element.Name);
                }
            }

            XmlSpace   oldXmlSpace      = currentXmlSpace;
            XamlObject parentXamlObject = currentXamlObject;

            if (element.HasAttribute("xml:space"))
            {
                currentXmlSpace = (XmlSpace)Enum.Parse(typeof(XmlSpace), element.GetAttribute("xml:space"), true);
            }

            XamlPropertyInfo defaultProperty = GetDefaultProperty(elementType);

            XamlTextValue initializeFromTextValueInsteadOfConstructor = null;

            if (defaultProperty == null)
            {
                int  numberOfTextNodes = 0;
                bool onlyTextNodes     = true;
                foreach (XmlNode childNode in element.ChildNodes)
                {
                    if (childNode.NodeType == XmlNodeType.Text)
                    {
                        numberOfTextNodes++;
                    }
                    else if (childNode.NodeType == XmlNodeType.Element)
                    {
                        onlyTextNodes = false;
                    }
                }
                if (onlyTextNodes && numberOfTextNodes == 1)
                {
                    foreach (XmlNode childNode in element.ChildNodes)
                    {
                        if (childNode.NodeType == XmlNodeType.Text)
                        {
                            initializeFromTextValueInsteadOfConstructor = (XamlTextValue)ParseValue(childNode);
                        }
                    }
                }
            }

            object instance;

            if (initializeFromTextValueInsteadOfConstructor != null)
            {
                instance = TypeDescriptor.GetConverter(elementType).ConvertFromString(
                    document.GetTypeDescriptorContext(null),
                    CultureInfo.InvariantCulture,
                    initializeFromTextValueInsteadOfConstructor.Text);
            }
            else
            {
                instance = settings.CreateInstanceCallback(elementType, emptyObjectArray);
            }

            XamlObject obj = new XamlObject(document, element, elementType, instance);

            currentXamlObject = obj;
            obj.ParentObject  = parentXamlObject;

            if (parentXamlObject == null && obj.Instance is DependencyObject)
            {
                NameScope.SetNameScope((DependencyObject)obj.Instance, new NameScope());
            }

            ISupportInitialize iSupportInitializeInstance = instance as ISupportInitialize;

            if (iSupportInitializeInstance != null)
            {
                iSupportInitializeInstance.BeginInit();
            }

            foreach (XmlAttribute attribute in element.Attributes)
            {
                if (attribute.Value.StartsWith("clr-namespace", StringComparison.OrdinalIgnoreCase))
                {
                    // the format is "clr-namespace:<Namespace here>;assembly=<Assembly name here>"
                    var clrNamespace = attribute.Value.Split(new[] { ':', ';', '=' });
                    if (clrNamespace.Length == 4)
                    {
                        // get the assembly name
                        var assembly = settings.TypeFinder.LoadAssembly(clrNamespace[3]);
                        if (assembly != null)
                        {
                            settings.TypeFinder.RegisterAssembly(assembly);
                        }
                    }
                    else
                    {
                        // if no assembly name is there, then load the assembly of the opened file.
                        var assembly = settings.TypeFinder.LoadAssembly(null);
                        if (assembly != null)
                        {
                            settings.TypeFinder.RegisterAssembly(assembly);
                        }
                    }
                }
                if (attribute.NamespaceURI == XamlConstants.XmlnsNamespace)
                {
                    continue;
                }
                if (attribute.Name == "xml:space")
                {
                    continue;
                }
                if (GetAttributeNamespace(attribute) == XamlConstants.XamlNamespace)
                {
                    if (attribute.LocalName == "Name")
                    {
                        try {
                            NameScopeHelper.NameChanged(obj, null, attribute.Value);
                        } catch (Exception x) {
                            ReportException(x, attribute);
                        }
                    }
                    continue;
                }

                ParseObjectAttribute(obj, attribute);
            }

            if (!(obj.Instance is Style))
            {
                ParseObjectContent(obj, element, defaultProperty, initializeFromTextValueInsteadOfConstructor);
            }

            if (iSupportInitializeInstance != null)
            {
                iSupportInitializeInstance.EndInit();
            }

            currentXmlSpace   = oldXmlSpace;
            currentXamlObject = parentXamlObject;

            return(obj);
        }
コード例 #42
0
ファイル: PhotoCell.cs プロジェクト: XiaoBaiXJ/RFID
        private void InitializeComponent()
        {
            if (ResourceLoader.ResourceProvider != null && ResourceLoader.ResourceProvider(typeof(PhotoCell).GetTypeInfo().Assembly.GetName(), "Layout/PhotoCell.xaml") != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(base.GetType()) != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            ColumnDefinition columnDefinition  = new ColumnDefinition();
            ColumnDefinition columnDefinition2 = new ColumnDefinition();
            RowDefinition    rowDefinition     = new RowDefinition();
            Label            label             = new Label();
            PhotoView        photoView         = new PhotoView();
            StackLayout      stackLayout       = new StackLayout();
            StackLayout      stackLayout2      = new StackLayout();
            ScrollView       scrollView        = new ScrollView();
            Grid             grid      = new Grid();
            NameScope        nameScope = new NameScope();

            NameScope.SetNameScope(this, nameScope);
            NameScope.SetNameScope(grid, nameScope);
            NameScope.SetNameScope(columnDefinition, nameScope);
            NameScope.SetNameScope(columnDefinition2, nameScope);
            NameScope.SetNameScope(rowDefinition, nameScope);
            NameScope.SetNameScope(label, nameScope);
            ((INameScope)nameScope).RegisterName("label", label);
            if (label.StyleId == null)
            {
                label.StyleId = "label";
            }
            NameScope.SetNameScope(scrollView, nameScope);
            NameScope.SetNameScope(stackLayout2, nameScope);
            NameScope.SetNameScope(photoView, nameScope);
            ((INameScope)nameScope).RegisterName("firstPhoto", photoView);
            if (photoView.StyleId == null)
            {
                photoView.StyleId = "firstPhoto";
            }
            NameScope.SetNameScope(stackLayout, nameScope);
            ((INameScope)nameScope).RegisterName("photoSL", stackLayout);
            if (stackLayout.StyleId == null)
            {
                stackLayout.StyleId = "photoSL";
            }
            this.label      = label;
            this.firstPhoto = photoView;
            this.photoSL    = stackLayout;
            grid.SetValue(VisualElement.BackgroundColorProperty, Color.White);
            grid.SetValue(Grid.RowSpacingProperty, 5.0);
            grid.SetValue(Layout.PaddingProperty, new Thickness(10.0, 5.0, 10.0, 5.0));
            columnDefinition.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition);
            columnDefinition2.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("3*"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition2);
            rowDefinition.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("Auto"));
            grid.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition);
            BindableObject         bindableObject        = label;
            BindableProperty       fontSizeProperty      = Label.FontSizeProperty;
            IExtendedTypeConverter extendedTypeConverter = new FontSizeConverter();
            string value = "Default";
            XamlServiceProvider xamlServiceProvider = new XamlServiceProvider();
            Type typeFromHandle = typeof(IProvideValueTarget);

            object[] array = new object[0 + 3];
            array[0] = label;
            array[1] = grid;
            array[2] = this;
            xamlServiceProvider.Add(typeFromHandle, new SimpleValueTargetProvider(array, Label.FontSizeProperty));
            xamlServiceProvider.Add(typeof(INameScopeProvider), new NameScopeProvider
            {
                NameScope = nameScope
            });
            Type typeFromHandle2 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver = new XmlNamespaceResolver();

            xmlNamespaceResolver.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver.Add("layout", "clr-namespace:RFID.Layout");
            xmlNamespaceResolver.Add("svg", "clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms");
            xamlServiceProvider.Add(typeFromHandle2, new XamlTypeResolver(xmlNamespaceResolver, typeof(PhotoCell).GetTypeInfo().Assembly));
            xamlServiceProvider.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(16, 20)));
            bindableObject.SetValue(fontSizeProperty, extendedTypeConverter.ConvertFromInvariantString(value, xamlServiceProvider));
            label.SetValue(Label.TextColorProperty, new Color(0.501960813999176, 0.501960813999176, 0.501960813999176, 1.0));
            label.SetValue(View.VerticalOptionsProperty, LayoutOptions.Center);
            label.SetValue(View.HorizontalOptionsProperty, LayoutOptions.FillAndExpand);
            label.SetValue(Label.HorizontalTextAlignmentProperty, new TextAlignmentConverter().ConvertFromInvariantString("Start"));
            label.SetValue(Grid.ColumnProperty, 0);
            grid.Children.Add(label);
            scrollView.SetValue(Grid.ColumnProperty, 1);
            scrollView.SetValue(ScrollView.OrientationProperty, ScrollOrientation.Horizontal);
            scrollView.SetValue(View.HorizontalOptionsProperty, LayoutOptions.FillAndExpand);
            stackLayout2.SetValue(StackLayout.OrientationProperty, StackOrientation.Horizontal);
            photoView.Finished += this.Handle_Finished;
            photoView.Closed   += this.Handle_Closed;
            stackLayout2.Children.Add(photoView);
            stackLayout.SetValue(StackLayout.OrientationProperty, StackOrientation.Horizontal);
            stackLayout2.Children.Add(stackLayout);
            scrollView.Content = stackLayout2;
            grid.Children.Add(scrollView);
            this.View = grid;
        }
コード例 #43
0
ファイル: SpeedExample.cs プロジェクト: zhimaqiao51/docs
        public SpeedExample()
        {
            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());

            this.WindowTitle = "Speed Example";

            StackPanel myStackPanel = new StackPanel();

            myStackPanel.Margin = new Thickness(20);

            TextBlock myTextBlock = new TextBlock();

            myTextBlock.Text = "Speed=\"1\"";
            myStackPanel.Children.Add(myTextBlock);

            //
            //  Create the rectangles to animate
            //
            Rectangle defaultSpeedRectangle = new Rectangle();

            defaultSpeedRectangle.Name = "defaultSpeedRectangle";
            this.RegisterName(defaultSpeedRectangle.Name, defaultSpeedRectangle);
            defaultSpeedRectangle.Width  = 20;
            defaultSpeedRectangle.Height = 20;
            SolidColorBrush mySolidColorBrush = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255));

            defaultSpeedRectangle.Fill = mySolidColorBrush;
            defaultSpeedRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            myStackPanel.Children.Add(defaultSpeedRectangle);

            myTextBlock        = new TextBlock();
            myTextBlock.Margin = new Thickness(0, 20, 0, 0);
            myTextBlock.Text   = "Speed=\"2\"";
            myStackPanel.Children.Add(myTextBlock);

            Rectangle fasterRectangle = new Rectangle();

            fasterRectangle.Name = "fasterRectangle";
            this.RegisterName(fasterRectangle.Name, fasterRectangle);
            fasterRectangle.Width  = 20;
            fasterRectangle.Height = 20;
            mySolidColorBrush      = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255));
            fasterRectangle.Fill   = mySolidColorBrush;
            fasterRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            myStackPanel.Children.Add(fasterRectangle);

            myTextBlock        = new TextBlock();
            myTextBlock.Margin = new Thickness(0, 20, 0, 0);
            myTextBlock.Text   = "Speed=\"0.5\"";
            myStackPanel.Children.Add(myTextBlock);

            Rectangle slowerRectangle = new Rectangle();

            slowerRectangle.Name = "slowerRectangle";
            this.RegisterName(slowerRectangle.Name, slowerRectangle);
            slowerRectangle.Width  = 20;
            slowerRectangle.Height = 20;
            mySolidColorBrush      = new SolidColorBrush(Color.FromArgb(170, 51, 51, 255));
            slowerRectangle.Fill   = mySolidColorBrush;
            slowerRectangle.HorizontalAlignment = HorizontalAlignment.Left;
            myStackPanel.Children.Add(slowerRectangle);

            //
            //  Creates an animation with the default speed ratio value of 1
            //
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myDoubleAnimation, defaultSpeedRectangle.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Rectangle.WidthProperty));
            myDoubleAnimation.From       = 20;
            myDoubleAnimation.To         = 400;
            myDoubleAnimation.Duration   = new Duration(TimeSpan.FromMilliseconds(2000));
            myDoubleAnimation.SpeedRatio = 1;

            //
            //  Creates an animation with the speed ratio value of 2
            //
            DoubleAnimation myDoubleSpeedRatioDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myDoubleSpeedRatioDoubleAnimation, fasterRectangle.Name);
            Storyboard.SetTargetProperty(myDoubleSpeedRatioDoubleAnimation,
                                         new PropertyPath(Rectangle.WidthProperty));
            myDoubleSpeedRatioDoubleAnimation.From       = 20;
            myDoubleSpeedRatioDoubleAnimation.To         = 400;
            myDoubleSpeedRatioDoubleAnimation.Duration   = new Duration(TimeSpan.FromMilliseconds(2000));
            myDoubleSpeedRatioDoubleAnimation.SpeedRatio = 2;

            //
            //  Creates an animation with the speed ratio value of 0.5
            //
            DoubleAnimation myHalvedSpeedRatioDoubleAnimation = new DoubleAnimation();

            Storyboard.SetTargetName(myHalvedSpeedRatioDoubleAnimation, slowerRectangle.Name);
            Storyboard.SetTargetProperty(myHalvedSpeedRatioDoubleAnimation, new PropertyPath(Rectangle.WidthProperty));
            myHalvedSpeedRatioDoubleAnimation.From       = 20;
            myHalvedSpeedRatioDoubleAnimation.To         = 400;
            myHalvedSpeedRatioDoubleAnimation.Duration   = new Duration(TimeSpan.FromMilliseconds(2000));
            myHalvedSpeedRatioDoubleAnimation.SpeedRatio = 0.5;

            //
            //  Create a Storyboard to contain the animations and add the animations to the Storyboard
            //
            Storyboard myStoryboard = new Storyboard();

            myStoryboard.Children.Add(myDoubleAnimation);
            myStoryboard.Children.Add(myDoubleSpeedRatioDoubleAnimation);
            myStoryboard.Children.Add(myHalvedSpeedRatioDoubleAnimation);

            //
            //  Create the button to restart the animations.
            //
            Button myButton = new Button();

            myButton.Margin = new Thickness(0, 30, 0, 0);
            myButton.HorizontalAlignment = HorizontalAlignment.Left;
            myButton.Content             = "Restart Animations";
            myStackPanel.Children.Add(myButton);

            //
            //  Create an EventTrigger and a BeginStoryboard action to start the storyboard
            //
            BeginStoryboard myBeginStoryboard = new BeginStoryboard();

            myBeginStoryboard.Storyboard = myStoryboard;

            EventTrigger myEventTrigger = new EventTrigger();

            myEventTrigger.RoutedEvent = Button.ClickEvent;
            myEventTrigger.SourceName  = myButton.Name;
            myEventTrigger.Actions.Add(myBeginStoryboard);
            myStackPanel.Triggers.Add(myEventTrigger);

            this.Content = myStackPanel;
        }
コード例 #44
0
        private void InitializeComponent()
        {
            if (ResourceLoader.ResourceProvider != null && ResourceLoader.ResourceProvider(typeof(DriverPage).GetTypeInfo().Assembly.GetName(), "Views/DriverPage.xaml") != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(base.GetType()) != null)
            {
                this.__InitComponentRuntime();
                return;
            }
            BindingExtension       bindingExtension       = new BindingExtension();
            RowDefinition          rowDefinition          = new RowDefinition();
            RowDefinition          rowDefinition2         = new RowDefinition();
            ColumnDefinition       columnDefinition       = new ColumnDefinition();
            ColumnDefinition       columnDefinition2      = new ColumnDefinition();
            BindingExtension       bindingExtension2      = new BindingExtension();
            TranslateExtension     translateExtension     = new TranslateExtension();
            BindingExtension       bindingExtension3      = new BindingExtension();
            BindingExtension       bindingExtension4      = new BindingExtension();
            EventToCommandBehavior eventToCommandBehavior = new EventToCommandBehavior();
            SearchBar            searchBar            = new SearchBar();
            BindingExtension     bindingExtension5    = new BindingExtension();
            TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer();
            SvgCachedImage       svgCachedImage       = new SvgCachedImage();
            Grid                   grid = new Grid();
            BindingExtension       bindingExtension6       = new BindingExtension();
            BindingExtension       bindingExtension7       = new BindingExtension();
            EventToCommandBehavior eventToCommandBehavior2 = new EventToCommandBehavior();
            DataTemplate           dataTemplate            = new DataTemplate();
            ListView               listView  = new ListView();
            Grid                   grid2     = new Grid();
            NameScope              nameScope = new NameScope();

            NameScope.SetNameScope(this, nameScope);
            NameScope.SetNameScope(grid2, nameScope);
            NameScope.SetNameScope(rowDefinition, nameScope);
            NameScope.SetNameScope(rowDefinition2, nameScope);
            NameScope.SetNameScope(grid, nameScope);
            NameScope.SetNameScope(columnDefinition, nameScope);
            NameScope.SetNameScope(columnDefinition2, nameScope);
            NameScope.SetNameScope(searchBar, nameScope);
            NameScope.SetNameScope(eventToCommandBehavior, nameScope);
            NameScope.SetNameScope(svgCachedImage, nameScope);
            NameScope.SetNameScope(tapGestureRecognizer, nameScope);
            NameScope.SetNameScope(listView, nameScope);
            ((INameScope)nameScope).RegisterName("listview", listView);
            if (listView.StyleId == null)
            {
                listView.StyleId = "listview";
            }
            NameScope.SetNameScope(eventToCommandBehavior2, nameScope);
            this.listview = listView;
            this.SetValue(ViewModelLocator.AutowireViewModelProperty, new bool?(true));
            bindingExtension.Path = "Title";
            BindingBase binding = ((IMarkupExtension <BindingBase>)bindingExtension).ProvideValue(null);

            this.SetBinding(Page.TitleProperty, binding);
            rowDefinition.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("Auto"));
            grid2.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition);
            rowDefinition2.SetValue(RowDefinition.HeightProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*"));
            grid2.GetValue(Grid.RowDefinitionsProperty).Add(rowDefinition2);
            grid.SetValue(Grid.RowProperty, 0);
            grid.SetValue(VisualElement.BackgroundColorProperty, Color.White);
            grid.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(10.0));
            grid.SetValue(Grid.ColumnSpacingProperty, 10.0);
            columnDefinition.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("*"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition);
            columnDefinition2.SetValue(ColumnDefinition.WidthProperty, new GridLengthTypeConverter().ConvertFromInvariantString("24"));
            grid.GetValue(Grid.ColumnDefinitionsProperty).Add(columnDefinition2);
            searchBar.SetValue(Grid.ColumnProperty, 0);
            bindingExtension2.Path = "SearchText";
            BindingBase binding2 = ((IMarkupExtension <BindingBase>)bindingExtension2).ProvideValue(null);

            searchBar.SetBinding(SearchBar.TextProperty, binding2);
            translateExtension.Text = "search";
            IMarkupExtension    markupExtension     = translateExtension;
            XamlServiceProvider xamlServiceProvider = new XamlServiceProvider();
            Type typeFromHandle = typeof(IProvideValueTarget);

            object[] array = new object[0 + 4];
            array[0] = searchBar;
            array[1] = grid;
            array[2] = grid2;
            array[3] = this;
            xamlServiceProvider.Add(typeFromHandle, new SimpleValueTargetProvider(array, SearchBar.PlaceholderProperty));
            xamlServiceProvider.Add(typeof(INameScopeProvider), new NameScopeProvider
            {
                NameScope = nameScope
            });
            Type typeFromHandle2 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver = new XmlNamespaceResolver();

            xmlNamespaceResolver.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver.Add("prism", "clr-namespace:Prism.Mvvm;assembly=Prism.Forms");
            xmlNamespaceResolver.Add("local", "clr-namespace:RFID");
            xmlNamespaceResolver.Add("b", "clr-namespace:Prism.Behaviors;assembly=Prism.Forms");
            xmlNamespaceResolver.Add("svg", "clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms");
            xamlServiceProvider.Add(typeFromHandle2, new XamlTypeResolver(xmlNamespaceResolver, typeof(DriverPage).GetTypeInfo().Assembly));
            xamlServiceProvider.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(21, 65)));
            object placeholder = markupExtension.ProvideValue(xamlServiceProvider);

            searchBar.Placeholder = placeholder;
            searchBar.SetValue(SearchBar.TextColorProperty, new Color(0.501960813999176, 0.501960813999176, 0.501960813999176, 1.0));
            bindingExtension3.Path = "SearchCommand";
            BindingBase binding3 = ((IMarkupExtension <BindingBase>)bindingExtension3).ProvideValue(null);

            searchBar.SetBinding(SearchBar.SearchCommandProperty, binding3);
            searchBar.SetValue(VisualElement.BackgroundColorProperty, new Color(0.93725490570068359, 0.93725490570068359, 0.93725490570068359, 1.0));
            eventToCommandBehavior.SetValue(EventToCommandBehavior.EventNameProperty, "TextChanged");
            bindingExtension4.Path = "SearchCommand";
            BindingBase binding4 = ((IMarkupExtension <BindingBase>)bindingExtension4).ProvideValue(null);

            eventToCommandBehavior.SetBinding(EventToCommandBehavior.CommandProperty, binding4);
            ((ICollection <Behavior>)searchBar.GetValue(VisualElement.BehaviorsProperty)).Add(eventToCommandBehavior);
            grid.Children.Add(searchBar);
            svgCachedImage.SetValue(Grid.ColumnProperty, 1);
            svgCachedImage.SetValue(VisualElement.WidthRequestProperty, 24.0);
            svgCachedImage.SetValue(VisualElement.HeightRequestProperty, 24.0);
            svgCachedImage.SetValue(CachedImage.SourceProperty, new FFImageLoading.Forms.ImageSourceConverter().ConvertFromInvariantString("plus.svg"));
            bindingExtension5.Path = "AddCommand";
            BindingBase binding5 = ((IMarkupExtension <BindingBase>)bindingExtension5).ProvideValue(null);

            tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, binding5);
            svgCachedImage.GestureRecognizers.Add(tapGestureRecognizer);
            grid.Children.Add(svgCachedImage);
            grid2.Children.Add(grid);
            listView.SetValue(Grid.RowProperty, 1);
            listView.SetValue(VisualElement.BackgroundColorProperty, new Color(0.98039215803146362, 0.98039215803146362, 0.98039215803146362, 1.0));
            bindingExtension6.Path = "SearchSource";
            BindingBase binding6 = ((IMarkupExtension <BindingBase>)bindingExtension6).ProvideValue(null);

            listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, binding6);
            listView.ItemSelected += this.Handle_ItemSelected;
            eventToCommandBehavior2.SetValue(EventToCommandBehavior.EventNameProperty, "ItemTapped");
            bindingExtension7.Path = "SelectCommand";
            BindingBase binding7 = ((IMarkupExtension <BindingBase>)bindingExtension7).ProvideValue(null);

            eventToCommandBehavior2.SetBinding(EventToCommandBehavior.CommandProperty, binding7);
            eventToCommandBehavior2.SetValue(EventToCommandBehavior.EventArgsParameterPathProperty, "Item");
            ((ICollection <Behavior>)listView.GetValue(VisualElement.BehaviorsProperty)).Add(eventToCommandBehavior2);
            IDataTemplate dataTemplate2 = dataTemplate;

            DriverPage.< InitializeComponent > _anonXamlCDataTemplate_6 <InitializeComponent> _anonXamlCDataTemplate_ = new DriverPage.< InitializeComponent > _anonXamlCDataTemplate_6();
            object[]     array2 = new object[0 + 4];
            array2[0] = dataTemplate;
            array2[1] = listView;
            array2[2] = grid2;
            array2[3] = this;
コード例 #45
0
 public ResourceDictionary()
 {
     _Res = new Dictionary<object, object>();
     _NameScope = new NameScope();
     _MergedDictionaries = new Collection<ResourceDictionary>();
 }
コード例 #46
0
ファイル: CreateObject.cs プロジェクト: sangchul1011/TizenFX
        public void Do()
        {
            object obj = null;

            if (0 == globalDataList.GatheredInstances.Count && null != globalDataList.Root)
            {
                obj = globalDataList.Root;
            }
            else
            {
                var type = globalDataList.GatheredTypes[typeIndex];

                var xFactoryMethod = (0 <= xFactoryMethodIndex) ? globalDataList.GatheredMethods[xFactoryMethodIndex] : null;

                if (null == paramList)
                {
                    if (null == xFactoryMethod)
                    {
                        obj = Activator.CreateInstance(type);
                    }
                    else
                    {
                        obj = xFactoryMethod.Invoke(null, Array.Empty <object>());
                    }
                }
                else
                {
                    for (int i = 0; i < paramList.Count; i++)
                    {
                        if (paramList[i] is Instance instance)
                        {
                            paramList[i] = globalDataList.GatheredInstances[instance.Index];
                        }

                        if (paramList[i] is IMarkupExtension markupExtension)
                        {
                            paramList[i] = markupExtension.ProvideValue(null);
                        }
                    }

                    if (null == xFactoryMethod)
                    {
                        obj = Activator.CreateInstance(type, paramList.ToArray());
                    }
                    else
                    {
                        obj = xFactoryMethod.Invoke(null, paramList.ToArray());
                    }
                }
            }

            if (null != obj)
            {
                globalDataList.GatheredInstances.Add(obj);

                if (globalDataList.Root == null)
                {
                    globalDataList.Root = obj;
                }

                if (obj is BindableObject bindableObject)
                {
                    bindableObject.IsCreateByXaml = true;

                    if (1 == globalDataList.GatheredInstances.Count)
                    {
                        NameScope nameScope = new NameScope();
                        NameScope.SetNameScope(bindableObject, nameScope);
                    }
                }
            }
            else
            {
                throw new Exception($"Can't create instance typeIndex:{typeIndex}");
            }
        }
コード例 #47
0
ファイル: DependencyObject.cs プロジェクト: kangaroo/moon
		internal bool SetNameOnScope (string name, NameScope scope)
		{
			if (name == null)
				throw new ArgumentNullException ("name");
			if (scope == null)
				throw new ArgumentNullException ("scope");
			return NativeMethods.dependency_object_set_name_on_scope (native, name, scope.NativeHandle);
		}
        /// <summary>Turns Spinning on and off</summary>
        /// <param name="shouldSpin">True to enable spinning</param>
        void ControlSpinning(bool shouldSpin)
        {
            if (shouldSpin)
            {
                if (!Spinning)
                {
                    if (spinAnimation != null)
                    {
                        ReBeginSpinningAnimation();
                    }
                    else
                    {
                        INameScope nameScope = NameScope.GetNameScope(this);

                        if (nameScope == null)
                        {
                            nameScope = new NameScope();
                            NameScope.SetNameScope(this, nameScope);
                        }

                        // Create a new animation and storyboard

                        SpinAngle = Angle;

                        spinAnimation                = new DoubleAnimation();
                        spinAnimation.Name           = "BizzySpinnerAnimation";
                        spinAnimation.Duration       = new Duration(TimeSpan.FromSeconds(SpinRate));
                        spinAnimation.RepeatBehavior = RepeatBehavior.Forever;

                        storyboard = new Storyboard();

                        NameScope.SetNameScope(storyboard, nameScope);

                        this.RegisterName("Puppet", this); // name this object 'Puppte' in the NameScope.

                        // Tie the animation to this spinner and the SpinAngleProperty
                        Storyboard.SetTargetName(spinAnimation, "Puppet");
                        Storyboard.SetTargetProperty(spinAnimation, new PropertyPath(BizzySpinner.SpinAngleProperty));

                        storyboard.Children.Add(spinAnimation);

                        ReBeginSpinningAnimation();
                    }

                    SetValue(SpinningPropertyKey, true); // Spinning = true;
                }
            }
            else
            {
                if (spinAnimation != null)
                {
                    if (Spinning)
                    {
                        //
                        // We have to remember the current spin angle.  Why?  Becuase the animation will
                        // reset the SpinAngleProperty back to its base value when it is removed
                        // from the SpinAngleProperty.  The SpinAngleProperty base value is the
                        // animations from value.
                        //
                        double tmp = SpinAngle % OneRotation;

                        storyboard.Stop(this);

                        Angle     = tmp;
                        SpinAngle = tmp;

                        SetValue(SpinningPropertyKey, false);
                    }
                }
            }
        }
コード例 #49
0
        /// <inheritdoc/>
        public override sealed void ApplyTemplate()
        {
            var template = Template;
            var logical = (ILogical)this;

            // Apply the template if it is not the same as the template already applied - except
            // for in the case that the template is null and we're not attached to the logical
            // tree. In that case, the template has probably been cleared because the style setting
            // the template has been detached, so we want to wait until it's re-attached to the
            // logical tree as if it's re-attached to the same tree the template will be the same
            // and we don't need to do anything.
            if (_appliedTemplate != template && (template != null || logical.IsAttachedToLogicalTree))
            {
                if (VisualChildren.Count > 0)
                {
                    foreach (var child in this.GetTemplateChildren())
                    {
                        child.SetValue(TemplatedParentProperty, null);
                    }

                    VisualChildren.Clear();
                }

                if (template != null)
                {
                    Logger.Verbose(LogArea.Control, this, "Creating control template");

                    var child = template.Build(this);
                    var nameScope = new NameScope();
                    NameScope.SetNameScope((Control)child, nameScope);
                    child.SetValue(TemplatedParentProperty, this);
                    RegisterNames(child, nameScope);
                    ((ISetLogicalParent)child).SetParent(this);
                    VisualChildren.Add(child);

                    OnTemplateApplied(new TemplateAppliedEventArgs(nameScope));
                }

                _appliedTemplate = template;
            }
        }
コード例 #50
0
 public TransitioningContentBase()
 {
     NameScope.SetNameScope(this, new NameScope());
 }