Esempio n. 1
0
 public Marker(string resourceName)
 {
     // Initialize from XAML and get references to child elements
     _root = XamlReader.Load(Utility.GetXamlResource(resourceName)) as Canvas;
     _background = _root.FindName("Background") as Rectangle;
     _border = _root.FindName("Border") as Rectangle;
     _pulse = _root.FindName("Pulse") as Storyboard;  // May fail
     Content = _root;
 }
Esempio n. 2
0
		public Swoosher()
		{
			System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream( "Next2Friends.Swoosher.Swoosher.xaml" );
			root = (Canvas)this.InitializeFromXaml( new System.IO.StreamReader( s ).ReadToEnd() );

			timer = (Storyboard)root.Resources.FindName( "timer" );
			timer.Completed += OnTick;

			loading = (Loading)root.FindName( "loading" );
			photoCanvas = (Canvas)root.FindName( "photoCanvas" );

			backButton = (Arrow)root.FindName( "backButton" );
			forwardButton = (Arrow)root.FindName( "forwardButton" );
			fullscreenButton = (Arrow)root.FindName( "fullscreenButton" );
			windowedButton = (Arrow)root.FindName( "windowedButton" );
			physicsButton = (Arrow)root.FindName( "physicsButton" );

			Loaded += OnLoaded;
		}
Esempio n. 3
0
        public SortNavigator(Canvas pAssembly)
        {
            _assemblyCanvas = pAssembly;
            _speed = 0;         // no animation by default.
            _moveTimer = _assemblyCanvas.FindName("ScrollTimer") as Storyboard;

            _thumHolder = _assemblyCanvas.FindName("ThumHolder") as Canvas;
            _holderClip = _assemblyCanvas.FindName("HolderClip") as Canvas;
            _btnLeft = _assemblyCanvas.FindName("BtnLeft") as Canvas;
            _btnRight = _assemblyCanvas.FindName("BtnRight") as Canvas;

            _topNaviLeft = _assemblyCanvas.FindName("TopNaviLeft") as Image;
            _topNaviMiddle = _assemblyCanvas.FindName("TopNaviMiddle") as Image;
            _topNaviRight = _assemblyCanvas.FindName("TopNaviRight") as Image;
            _btnLeftImage = _assemblyCanvas.FindName("BtnLeftImage") as Image;
            _btnRightImage = _assemblyCanvas.FindName("BtnRightImage") as Image;
            _dividorA = _assemblyCanvas.FindName("DividorA") as Image;
            _dividorB = _assemblyCanvas.FindName("DividorB") as Image;

            _indexDivider = _assemblyCanvas.FindName("IndexDivider") as TextBlock;
            _indexText1 = _assemblyCanvas.FindName("IndexText1") as TextBlock;
            _indexText2 = _assemblyCanvas.FindName("IndexText2") as TextBlock;

            _btnLeft.Cursor = Cursors.Hand;
            _btnRight.Cursor = Cursors.Hand;

            // Regist hover event
            _btnLeft.MouseEnter += new MouseEventHandler(_btnLeft_MouseEnter);
            _btnLeft.MouseLeave += new EventHandler(_btnLeft_MouseLeave);
            _btnRight.MouseEnter += new MouseEventHandler(_btnRight_MouseEnter);
            _btnRight.MouseLeave += new EventHandler(_btnRight_MouseLeave);

            // Regist click event
            _btnLeft.MouseLeftButtonDown += new MouseEventHandler(_btnLeft_MouseLeftButtonDown);
            _btnLeft.MouseLeftButtonUp += new MouseEventHandler(_btnLeft_MouseLeftButtonUp);
            _btnRight.MouseLeftButtonDown += new MouseEventHandler(_btnRight_MouseLeftButtonDown);
            _btnRight.MouseLeftButtonUp += new MouseEventHandler(_btnRight_MouseLeftButtonUp);

            // download font
            _fontDownloader = new Downloader();
            _fontDownloader.DownloadFailed += new ErrorEventHandler(_fontDownloader_DownloadFailed);
            _fontDownloader.Completed += new EventHandler(_fontDownloader_Completed);
            Uri fontUri = new Uri("Assets/Font/FuturaStd-Heavy.otf", UriKind.RelativeOrAbsolute);
            _fontDownloader.Open("GET", fontUri);
            _fontDownloader.Send();
        }
Esempio n. 4
0
		public void ChildNameScope ()
		{
			Canvas b = new Canvas ();
		        Canvas c = (Canvas)XamlReader.Load (@"
<Canvas xmlns=""http://schemas.microsoft.com/client/2007"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
  <Border>
    <Path x:Name=""foo"" Data=""F1 M 10,10 20,20 10,20"" Stroke=""Red""/>
  </Border>
</Canvas>");
			Assert.IsNotNull (c.FindName ("foo"));
			
			b.Children.Add (c);
			
			Assert.IsNull (b.FindName ("foo"));
			Assert.IsNotNull (c.FindName ("foo"));
		}
Esempio n. 5
0
		public void VisualTypes ()
		{
			Canvas c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >

    <Border x:Name=""border"" />
</Canvas>
");
			// just for sanity's sake
			Assert.IsNotNull (c.FindName("border"), "0");

			// Clear the children list and check if that clears the name
			c.Children.Clear();
			Assert.IsNull (c.FindName("border"), "1");


			// try again, this time remove the border and then add it back again
			c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >

    <Border x:Name=""border"" />
</Canvas>
");

			Border b = (Border)c.FindName("border");
			c.Children.Remove (b);

			c.Children.Add (b);

			Assert.IsNotNull (c.FindName("border"), "2");

			// try moving it to a newly created canvas

			c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >

    <Border x:Name=""border"" />
</Canvas>
");

			Canvas c2 = new Canvas ();

			b = (Border)c.FindName("border");
			c.Children.Remove (b);

			c2.Children.Add (b);

			Assert.IsNull (c.FindName("border"), "3");

			Assert.IsNull (c2.FindName("border"), "4");

			// try moving it to a XamlReader.Load'ed canvas

			c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >

    <Border x:Name=""border"" />
</Canvas>
");

			c2 = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" />
");

			b = (Border)c.FindName("border");
			c.Children.Remove (b);

			c2.Children.Add (b);

			Assert.IsNull (c.FindName("border"), "5");

			Assert.IsNotNull (c2.FindName("border"), "6");


			// try adding it in a situation where it'll cause a name conflict

			c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >

    <Border x:Name=""border"" />
</Canvas>
");

			c2 = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >

    <Border x:Name=""border"" />
</Canvas>
");

			b = (Border)c.FindName("border");
			c.Children.Remove (b);

			Assert.Throws <ArgumentException> ( () => c2.Children.Add (b), "7");
		}
Esempio n. 6
0
		public void NonVisualTypes ()
		{
			Canvas c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
  <Canvas.Background>
    <SolidColorBrush x:Name=""brush"" Color=""Green""/>
  </Canvas.Background>
</Canvas>
");

			// just for sanity's sake
			Assert.IsNotNull (c.FindName("brush"), "0");

			Brush b = c.Background;

			// Clear the property and check if that clears the name
			c.ClearValue (Panel.BackgroundProperty);
			Assert.IsNull (c.FindName("brush"), "1");

			// see if the name is reregistered when we add it back
			c.Background = b;

			Assert.IsNotNull (c.FindName("brush"), "2");

			c = (Canvas)XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
  <Canvas.Background>
    <SolidColorBrush x:Name=""brush"" Color=""Green""/>
  </Canvas.Background>
</Canvas>
");
			// setting to null?
			c.Background = null;
			Assert.IsNull (c.FindName("brush"), "3");


			// what happens when we "reparent" a nonvisual type?  does it's name move?
			c = (Canvas)XamlReader.Load (@"<Canvas
						           xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
						           xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
						         <Canvas.Background>
						           <SolidColorBrush x:Name=""brush"" Color=""Green""/>
						         </Canvas.Background>
						       </Canvas>");

			Canvas c2 = new Canvas();

			c2.Background = (Brush)c.FindName("brush");

			// it's still visible in the original canvas
			Assert.IsNotNull (c.FindName ("brush"), "4");

			// but not in the newly created one.
			Assert.IsNull (c2.FindName ("brush"), "5");

			// let's try a XamlReader.Load'ed canvas
			c2 = (Canvas)XamlReader.Load (@"<Canvas
							  xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
							  xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" />");

			c2.Background = (Brush)c.FindName ("brush");

			// it's still visible in the original canvas
			Assert.IsNotNull (c.FindName ("brush"), "6");

			// and it's still not visible in the newly created one.
			Assert.IsNull (c2.FindName ("brush"), "7");


			// let's try removing it from the first tree before adding it to the second
			c = (Canvas)XamlReader.Load (@"<Canvas
						           xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
						           xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
						         <Canvas.Background>
						           <SolidColorBrush x:Name=""brush"" Color=""Green""/>
						         </Canvas.Background>
						       </Canvas>");                                                    

			c2 = (Canvas)XamlReader.Load (@"<Canvas
							  xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
							  xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" />");

			b = c.Background;

			c.ClearValue (Panel.BackgroundProperty);
			c2.Background = b;

			// it's not visible in the original canvas
			Assert.IsNull (c.FindName ("brush"), "8");

			// and now it's visible in the new scope
			Assert.IsNotNull (c2.FindName ("brush"), "9");


			// try removing it from the first tree before adding it to the second when there's a conflict
			c = (Canvas)XamlReader.Load (@"<Canvas
						           xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
						           xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
						         <Canvas.Background>
						           <SolidColorBrush x:Name=""brush"" Color=""Green""/>
						         </Canvas.Background>
						       </Canvas>");                                                    

			Rectangle r;
			r = (Rectangle)XamlReader.Load (@"<Rectangle
							  xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
							  xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
						         <Rectangle.Fill>
						           <SolidColorBrush x:Name=""brush"" Color=""Green""/>
						         </Rectangle.Fill>
						       </Rectangle>");

			
			b = c.Background;

			c.ClearValue (Panel.BackgroundProperty);
			
			Assert.Throws<ArgumentException> ( () => r.Stroke = b, "10" );

			// let's try loading some xaml with name
			// conflicts between 2 non-visual items that
			// are properties of sibling elements.
			Assert.Throws<XamlParseException> (() => XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
  <Canvas>
    <Canvas.Background>
      <SolidColorBrush x:Name=""brush"" Color=""Green""/>
    </Canvas.Background>
  </Canvas>

  <Canvas>
    <Canvas.Background>
      <SolidColorBrush x:Name=""brush"" Color=""Blue""/>
    </Canvas.Background>
  </Canvas>
</Canvas>
"), "11");

			// and also try loading some xaml with name
			// conflicts between 2 non-visual items that
			// are properties of the same element.
			Assert.Throws<XamlParseException> (() => XamlReader.Load (@"
<Canvas
    xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
    xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" >
  <Rectangle>
    <Rectangle.Fill>
      <SolidColorBrush x:Name=""brush"" Color=""Green""/>
    </Rectangle.Fill>

    <Rectangle.Stroke>
      <SolidColorBrush x:Name=""brush"" Color=""Blue""/>
    </Rectangle.Stroke>
  </Rectangle>
</Canvas>
"), "12");
		}
Esempio n. 7
0
		public void BuiltinPropertyFindName ()
		{
			Canvas c = new Canvas ();
			ConcreteFrameworkElement cf1 = new ConcreteFrameworkElement ();

			cf1.Name = "MyName";

			c.Children.Add (cf1);

			Assert.IsNull (c.FindName ("MyName"), "1");
		}
Esempio n. 8
0
        /// <summary>
        /// Constructor for a LayoutManager instance.
        /// </summary>
        /// <param name="pTarget">Target canvas which will hold all photo slices and this manager will take effect on.</param>
        /// <param name="pDataSource">Data source for this manager instance.</param>
        /// <param name="pBtnSortCanvas">Sort layout trigger canvas.</param>
        /// <param name="pBtnRandomCanvas">Random layout trigger canvas.</param>
        /// <param name="pZoomOutTrigger">Zoomout trigter canvas.</param>
        /// <param name="pSortNavi">Sort navigator.</param>
        public LayoutManager(Canvas pTarget, PhotoDataSet pDataSource, Canvas pBtnSortCanvas, Canvas pBtnRandomCanvas, Canvas pZoomOutTrigger, SortNavigator pSortNavi, GenuineSlice pGenuineSlice, TracingIcon pTracingIcon, Image pScreenArrowLeft, Image pScreenArrowRight)
        {
            _target = pTarget;
            _targetShadow = pTarget.FindName("PhotoHolderShadow") as Canvas;
            _sortNavi = pSortNavi;
            _dataSource = pDataSource;
            _zoomOutTrigger = pZoomOutTrigger;
            _btnSort = pBtnSortCanvas;
            _btnSort.Cursor = Cursors.Hand;
            _btnRandom = pBtnRandomCanvas;
            _btnRandom.Cursor = Cursors.Hand;
            _genuineSlice = pGenuineSlice;
            _isSliceRequest = false;
            _tracingMouse = pTracingIcon;
            _screenArrowLeft = pScreenArrowLeft;
            _screenArrowRight = pScreenArrowRight;

            // Generate random & sort params
            GenerateLayoutPostion();
            // Fill thums to thumHolder
            FillThumHolder();

            // Event register.
            _target.MouseLeftButtonUp += new MouseEventHandler(_target_MouseLeftButtonUp);
            _zoomOutTrigger.MouseLeftButtonUp += new MouseEventHandler(_zoomOutTrigger_MouseLeftButtonUp);
            _zoomInStoryboard = _target.FindName("ZoomIn") as Storyboard;
            _zoomOutStoryboard = _target.FindName("ZoomOut") as Storyboard;
            _rotateToAngleStoryboard = _target.FindName("RotateToAngle") as Storyboard;
            _animateToPositionStoryboard = _target.FindName("AnimateToPosition") as Storyboard;
            _zoomInStoryboard.Completed += new EventHandler(_zoomInStoryboard_Completed);
            _zoomOutStoryboard.Completed += new EventHandler(_zoomOutStoryboard_Completed);
            _layoutStandByStoryboard = _target.FindName("LayoutStandBy") as Storyboard;
            _layoutStandByStoryboard.Completed += new EventHandler(_layoutStandByStoryboard_Completed);

            _btnSort.MouseLeftButtonUp += new MouseEventHandler(_btnSort_MouseLeftButtonUp);
            _btnSort.MouseEnter += new MouseEventHandler(_btnSort_MouseEnter);
            _btnSort.MouseLeave += new EventHandler(_btnSort_MouseLeave);
            _btnRandom.MouseLeftButtonUp += new MouseEventHandler(_btnRandom_MouseLeftButtonUp);
            _btnRandom.MouseEnter += new MouseEventHandler(_btnRandom_MouseEnter);
            _btnRandom.MouseLeave += new EventHandler(_btnRandom_MouseLeave);

            _screenArrowLeft.MouseLeftButtonUp += new MouseEventHandler(_screenArrowLeft_MouseLeftButtonUp);
            _screenArrowRight.MouseLeftButtonUp += new MouseEventHandler(_screenArrowRight_MouseLeftButtonUp);

            // By default, enter sorted layout.
            _status = AlbumStatus.Hanging;     // clear status
            Status = AlbumStatus.Sorted;
            _zoomStatus = ZoomStatus.Out;
        }
Esempio n. 9
0
        public void Init(Canvas root)
        {
            Current = this;
            this.content = root;

            // register the scriptable endpoints
            WebApplication.Current.RegisterScriptableObject("page", this);

            game = new Game(root);
            stats = new Stats(root);
            help = new Help(root);

            level = new Level("__empty__", game.world, game.foreground, game.background);

            Canvas gamehost = root.FindName("gamehost") as Canvas;
            gamehost.Children.Add(game);

            Canvas statshost = root.FindName("statshost") as Canvas;
            statshost.Children.Add(stats);

            Canvas helphost = root.FindName("helphost") as Canvas;
            helphost.Children.Add(help);

            continueInfo = root.FindName("continue") as Canvas;

            timer.Attach(root, "game-loop", new Timer.TickDelegate(GameTick), new TimeSpan(TimeSpan.TicksPerSecond/120));

            keyboard.Init(root, new Keyboard.KeyEventDelegate(KeyPress));

            SwitchLevel(levels[currentLevel]);
        }
Esempio n. 10
0
		public Arrow()
		{
			System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream( "Next2Friends.Swoosher.Arrow.xaml" );
			root = (Canvas)this.InitializeFromXaml( new System.IO.StreamReader( s ).ReadToEnd() );
			angle = (RotateTransform)root.FindName( "angle" );
		}
Esempio n. 11
0
        public BoardDisplay()
        {
            // Initialize from XAML and get references to child elements
            _root = XamlReader.Load(Utility.GetXamlResource("SilverlightSudokuHelper.BoardDisplay.xaml")) as Canvas;
            _fadeStoryboard = _root.FindName("FadeStoryboard") as Storyboard;
            _fadeAnimation = _root.FindName("FadeAnimation") as DoubleAnimation;

            // Create the board frame
            _frame = new Rectangle();
            _frame.Fill = new SolidColorBrush { Color = Colors.White };
            _frame.Stroke = new SolidColorBrush { Color = Colors.Black };
            _frame.StrokeThickness = 2;
            _frame.RadiusX = 5;
            _frame.RadiusY = 5;
            _root.Children.Add(_frame);

            // Create the board lines
            _verticalLines = new Line[Board.Size - 1];
            _horizontalLines = new Line[Board.Size - 1];
            for (var i = 0; i < _verticalLines.Length; i++)
            {
                bool majorLine = (0 == ((i + 1) % 3));
                var verticalLine = new Line();
                verticalLine.Stroke = new SolidColorBrush { Color = (majorLine ? Colors.Black : Colors.Gray) };
                verticalLine.StrokeThickness = 2;
                verticalLine.SetValue(Canvas.ZIndexProperty, (majorLine ? 1 : 0));
                _root.Children.Add(verticalLine);
                _verticalLines[i] = verticalLine;
                var horizontalLine = new Line();
                horizontalLine.Stroke = new SolidColorBrush { Color = (majorLine ? Colors.Black : Colors.Gray) };
                horizontalLine.StrokeThickness = 2;
                horizontalLine.SetValue(Canvas.ZIndexProperty, (majorLine ? 1 : 0));
                _root.Children.Add(horizontalLine);
                _horizontalLines[i] = horizontalLine;
            }

            // Create the selection marker
            _marker = new Marker("SilverlightSudokuHelper.MarkerSelection.xaml");
            _root.Children.Add(_marker);
            _markerPosition = new Point(4, 4);

            // Create the conflict marker
            _conflict = new Marker("SilverlightSudokuHelper.MarkerConflict.xaml");
            _root.Children.Add(_conflict);

            // Create the value and candidate text blocks
            _values = new TextBlock[Board.Size, Board.Size];
            _candidates = new TextBlock[Board.Size, Board.Size, 9];
            for (var y = 0; y < Board.Size; y++)
            {
                for (var x = 0; x < Board.Size; x++)
                {
                    var value = new TextBlock { FontFamily = FontFamily };
                    _root.Children.Add(value);
                    _values[x, y] = value;
                    for (var z = 0; z < 9; z++)
                    {
                        var candidate = new TextBlock { FontFamily = FontFamily, Foreground = new SolidColorBrush { Color = Colors.Gray } };
                        _root.Children.Add(candidate);
                        _candidates[x, y, z] = candidate;
                    }
                }
            }

            // Handle the Loaded event to do layout
            Loaded += new RoutedEventHandler(HandleLoaded);

            // Attach the constructed object to make it visible
            Content = _root;
        }