Inheritance: MonoBehaviour
Example #1
0
            //The constructor.
            public Screen()
            {
                //The container is a grid with 1 or 2 row definitions, and 1 column.
                //It may have 2 row definitions when an application bar is visible.
                mPage = new Grid();
                mPage.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
                mPage.RowDefinitions.Add(new RowDefinition { Height = new GridLength( 1, GridUnitType.Star) });
                mView = mPage;

                //Initialize the application bar and set its visibility to false.
                mApplicationBar = new Microsoft.Phone.Shell.ApplicationBar();
                mApplicationBar.IsVisible = false;
                ApplicationBarVisible = false;

                mApplicationBarItemsIndexes = new Dictionary<Object, int>();

                /**
                 * This will add a BackKeyPress event handler to the Application.Current.RootVisual, this is application wide.
                 */
                (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).BackKeyPress += new EventHandler<System.ComponentModel.CancelEventArgs>(BackKeyPressHandler);
                /**
                 * This will add a BackKeyPress event handler to the Application.Current.RootVisual, this is application wide.
                 */
                (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).OrientationChanged += new EventHandler<Microsoft.Phone.Controls.OrientationChangedEventArgs>(OrientationChangedHandler);
            }
    private void UpdateVisibleControls(Grid targetGrid)
    {
        var window = Application.Current.MainWindow as IMainWindow;
        foreach (var locus in window.World.GeneBank.Loci)
        {
            var controls = locus.AlleleManager.Controls;
            if (!locus.isVisibleLocus)
            {
                foreach (var control in controls)
                {
                    control.StackPanel.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                var currentRow = 1;
                foreach (var control in controls)
                {
                    control.UpdateControlValue();

                    var totalRows = targetGrid.RowDefinitions.Count;
                    Grid.SetColumn(control.StackPanel, 0);
                    if (currentRow >= totalRows)
                    {
                        var rd = new RowDefinition { Height = GridLength.Auto };
                        targetGrid.RowDefinitions.Add(rd);
                    }
                    Grid.SetRow(control.StackPanel, currentRow);
                    currentRow++;
                    control.StackPanel.Visibility = Visibility.Visible;
                }
            }
        }
    }
Example #3
0
		public Issue1097 ()
		{
			Grid grid = new Grid {
				RowSpacing = 0,
				ColumnSpacing = 0,
			};

			grid.AddRowDef(count: 2);
			grid.AddColumnDef(count : 2);

			grid.Children.Add(new BoxView() { Color = Color.Red });

			var v2 = new BoxView { Color = Color.Blue };
			Grid.SetColumn(v2, 1);
			grid.Children.Add(v2);

			var v3 = new BoxView { Color = Color.Green };
			Grid.SetRow(v3, 1);
			grid.Children.Add(v3);

			var v4 = new BoxView { Color = Color.Purple };
			Grid.SetRow(v4, 1);
			Grid.SetColumn(v4, 1);
			grid.Children.Add(v4);

			Content = grid;
		}
Example #4
0
	public HeatMapUpdater(int _index,Node[] _nodes,Grid _grid){
		index = _index;
		nodes = _nodes;
		grid = _grid;
		a = new Thread(UpdateHeatMap);
		a.Start();
	}
Example #5
0
    public Vector3 wloc; // 3D location coordinates in Unity's world units

    #endregion Fields

    #region Constructors

    public Square(Grid gr, Vector2 loc, Vector3 wloc)
    {
        this.plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
        plane.name = "Grid plane";
        plane.transform.position = wloc;
        plane.transform.localScale = new Vector3(0.1f, 1.0f, 0.1f);
        plane.transform.Rotate(-90.0f, 0.0f, 0.0f);
        plane.renderer.material.mainTexture = Resources.Load("Textures/Tile2") as Texture;
        plane.renderer.material.color = Color.white;
        colors = new Dictionary<Color, int>();
        colors[Color.red] = 0;
        colors[Color.green] = 0;
        colors[Color.blue] = 0;
        colors[Color.yellow] = 0;
        this.loc = loc;
        this.wloc = wloc;
        objects = new List<GameObject>();
        board = new Square[8];
        int count = 0;
        for(int xof = -1; xof <= 1; xof++) {
            for(int yof = -1; yof <= 1; yof++) {
                int x = (int)loc.x;
                int y = (int)loc.y;
                if(!(xof == 0 && yof == 0)) {
                    if(x+xof >= 0 && x+xof < gr.width && y+yof >= 0 && y+yof < gr.height)
                        board[count] = gr.grid[x+xof, y+yof];
                    count++;
                }
            }
        }
    }
Example #6
0
    public virtual void Init(Grid grid, int x, int y, float scale = 1, Sprite asset = null)
    {
        sfx = AudioManager.instance;

        container = transform.Find("Sprites");
        outline = transform.Find("Sprites/Outline").GetComponent<SpriteRenderer>();
        img = transform.Find("Sprites/Sprite").GetComponent<SpriteRenderer>();
        shadow = transform.Find("Sprites/Shadow").GetComponent<SpriteRenderer>();
        shadow.gameObject.SetActive(false);

        label = transform.Find("Label").GetComponent<TextMesh>();
        label.GetComponent<Renderer>().sortingLayerName = "Ui";
        label.gameObject.SetActive(Debug.isDebugBuild);

        this.grid = grid;
        this.x = x;
        this.y = y;
        this.asset = asset;

        this.walkable = true;

        transform.localPosition = new Vector3(x, y, 0);

        SetAsset(asset);
        SetImages(scale, Vector3.zero, 0);
        SetSortingOrder(0);

        visible = false;
        explored = false;
    }
Example #7
0
 public void Init(Legs legs,Grid grid)
 {
     base.Init(legs);
     this.grid = grid;
     this.auxiliarySteering = new Arrive();
     this.auxiliarySteering.Init(getLegs());
 }
Example #8
0
        public PathFinder(Grid graph, Cell start, Cell goal)
        {
            //  Priority Queue which contains cells that are candidates for examining, lowest priority to the node with the lowest f value
            var frontier = new PriorityQueue<Cell>();
            frontier.Enqueue(start, 0);

            cameFrom[start] = start;
            costSoFar[start] = 0;

            while (frontier.Count > 0)
            {
                var current = frontier.Dequeue();

                // Exit the search if goal have discovered
                if (current.Equals(goal)) { break; }

                // discovers the neighbours
                foreach (var next in graph.Neighbors(current))
                {
                    int newCost = costSoFar[current] + graph.Cost(current, next);

                    if (!costSoFar.ContainsKey(next) || newCost < costSoFar[next])
                    {
                        costSoFar[next] = newCost;

                        // f = g + h
                        int priority = newCost + Heuristic(next, goal);

                        frontier.Enqueue(next, priority);
                        cameFrom[next] = current;
                    }
                }
            }
        }
Example #9
0
    //FOR N_Back!
    public void GenerateGrounds(Grid grid, TerrainChunk tc, int y = 0, 
	                             bool ceiling = false)
    {
        // Generate ground and potholes
        //First and last cannot be a hole.
        for (int i = 0; i < grid.numCellsX; ++i) {
            if (grid.containsObject(i, y)) {
                continue;
            }

            //level is chance that there is a hole! Do not spawnground!
            //int rand = Random.Range (0, 101);

            //if(!(i ==0 || i == grid.numCellsX))
            //{
            if (initCeiling == 0) {
                initCeiling++;
                continue;
            }
            //}

            // Generate random width ground pieces varying from 1-3
            int cap, roll;
            do {
                //cap = Mathf.Min (4, grid.numCellsX - i + 1);
                roll = 3;
            } while (!GenerateWideGround(i, y, roll, grid, tc, ceiling));
        }
    }
Example #10
0
            public override HashSet<Vector> Find(TerrainGrid terrain)
            {
                var interestPoints = new HashSet<Vector>();

                var blocking = new Grid<bool>(terrain.Size);
                foreach (var point in terrain.GetPoints())
                {
                    var terrainType = terrain[point];
                    blocking[point] = TerrainTypes.Blocking.Contains(terrainType);
                }

                blocking = _filters.Close(blocking);

                var areas = _areaFinder.Find(blocking).ToList();
                areas.RemoveAll((area) => area.Count <= 20);
                foreach (var area in areas)
                {
                    var areaList = area.ToList();
                    int xMean = (int)areaList.Average((p) => p.x);
                    int yMean = (int)areaList.Average((p) => p.y);
                    Vector centroid = new Vector(xMean, yMean);
                    interestPoints.Add(centroid);
                }

                return interestPoints;
            }
Example #11
0
        /// <summary>Creates the UI elements for the given HTML node and HTML view.</summary>
        /// <param name="node">The HTML node.</param>
        /// <param name="htmlView">The HTML view.</param>
        /// <returns>The UI elements.</returns>
        public DependencyObject[] CreateControls(HtmlNode node, IHtmlView htmlView)
        {
            var controls = new List<Grid>();
            foreach (var child in node.Children.OfType<HtmlTagNode>().Where(c => c.Name == "li"))
            {
                var grid = new Grid();
                grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(20)});
                grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

                var textBlock = CreateBulletSymbol(htmlView);
                                grid.Children.Add(textBlock);
                Grid.SetColumn(textBlock, 0);

                var panel = new StackPanel();

                child.WrapWithHtmlTag();
                foreach (var c in child.GetChildControls(htmlView).OfType<UIElement>())
                {
                    var frameworkElement = c as FrameworkElement;
                    if (frameworkElement != null)
                        frameworkElement.HorizontalAlignment = HorizontalAlignment.Stretch;

                    panel.Children.Add(c);
                }

                grid.Children.Add(panel);
                Grid.SetColumn(panel, 1);

                controls.Add(grid);
            }

            AdjustMargins(htmlView, controls);
            return controls.OfType<DependencyObject>().ToArray();
        }
Example #12
0
        protected override void Init()
        {
            var label = new Label { Text = "Label" };
            var entry = new Entry { AutomationId = "entry" };
            var grid = new Grid();

            grid.Children.Add(label, 0, 0);
            grid.Children.Add(entry, 1, 0);
            var tableView = new TableView
            {
                Root = new TableRoot
                {
                    new TableSection
                    {
                        new ViewCell
                        {
                            View = grid
                        }
                    }
                }
            };

            Content = new StackLayout
            {
                Children = { tableView }
            };
        }
        public void Calling_AutoGenerateColumns_should_add_columns()
        {
            IGrid<Person> grid = new Grid<Person>(new Person[0], new ViewContext());
            grid.AutoGenerateColumns();

            ((Grid<Person>)grid).Model.Columns.Count.ShouldEqual(2);
        }
Example #14
0
 public void Grid_Key()
 {
     Grid g = new Grid(256, 256);
     Assert.AreEqual("__id__", g.Key);
     g.Key = "key";
     Assert.AreEqual("key", g.Key);
 }
        public void GetVisualParents() {
#endif
            Grid grid = new Grid();
            ContentControl contentControl = new ContentControl();
            TextBox textBox;
            Window.Content = grid;
            grid.Children.Add(contentControl);
            contentControl.ContentTemplate = textBoxTemplate;
#if NETFX_CORE
            await
#endif
            EnqueueShowWindow();
            EnqueueCallback(() => {
                textBox = (TextBox)LayoutHelper.FindElement(contentControl, x => x is TextBox);
                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x is ContentControl).First());
                Assert.AreSame(grid, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x is Grid).First());
                Assert.AreSame(Window, LayoutTreeHelper.GetVisualParents(textBox).Where(x => x.GetType() == Window.GetType()).First());

                Assert.AreSame(contentControl, LayoutTreeHelper.GetVisualParents(textBox, contentControl).Where(x => x is ContentControl).First());
                Assert.IsNull(LayoutTreeHelper.GetVisualParents(textBox, contentControl).Where(x => x is Grid).FirstOrDefault());

                var presenter = LayoutTreeHelper.GetVisualChildren(contentControl).First();
                Assert.IsTrue(new[] { presenter }.SequenceEqual(LayoutTreeHelper.GetVisualParents(textBox, presenter)));
            });
            EnqueueTestComplete();
        }
Example #16
0
        public static bool ColumnJunction(Grid grid)
        {
            Contract.Requires(grid != null);

            var ret = false;
            for (int i = 0; i < Grid.LENGTH; i++)
            {
                var column = grid.Columns[i];
                var bloks = FindPairs(column).Union(FindTriads(column));

                foreach (var block in bloks)
                {
                    int row;
                    if (block.Value.Select(z => (z.Row / 3) * 3).AllEqual(out row))
                    {
                        foreach (var cell in grid.Blocks[row, i].Where(z => z.IsEmpty).Where(z => !block.Value.Contains(z, ReferenceEqualityComparer<Cell>.Default)))
                        {
                            if (cell.RemoveVariants(block.Key))
                            {
                                ret = true;
                            }
                        }
                    }
                }
            }

            return ret;
        }
Example #17
0
        public void Grid_Encode()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\test.xml");
            m.ZoomAll();
            Grid g = new Grid(256, 256);
            var options = new Dictionary<string, object>()
            {
                {"Fields", new List<string>() { "FIPS" } },
                {"Layer", "world" }
            };

            m.Render(g, options);
            Dictionary<string, object> UTFGridDict = g.Encode();

            Assert.AreEqual(UTFGridDict.Keys.Count, 3);

            //Test for keys
            List<string> keyList = (List<string>)UTFGridDict["keys"];
            Assert.AreNotEqual(keyList.Count, 0);

            //Test for data
            Dictionary<string, object> dataDict = (Dictionary<string, object>)UTFGridDict["data"];
            Assert.AreNotEqual(dataDict.Count, 0);

            //data count should equal keys + 1
            Assert.AreEqual(keyList.Count, dataDict.Count + 1);
        }
Example #18
0
        public WindowImpl(string title)
        {
            Background = Brushes.HotPink;
            UseLayoutRounding = true;
            Title = title;            

            Grid = new Grid()
            {
                UseLayoutRounding = true,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            
            this.AddChild(Grid);

            KeyDownEvents = Observable.FromEvent<KeyEventArgs>(this, "KeyDown").Select(e => e.EventArgs);
            KeyUpEvents = Observable.FromEvent<KeyEventArgs>(this, "KeyUp").Select(e => e.EventArgs);
            MouseMoveEvents = Observable.FromEvent<MouseEventArgs>(this, "MouseMove").Select(e => e.EventArgs.GetPosition(Grid).ToXna());
            MouseDownEvents = Observable.FromEvent<MouseButtonEventArgs>(this, "MouseDown").Select(e => e.EventArgs.GetPosition(Grid).ToXna());
            MouseUpEvents = Observable.FromEvent<MouseButtonEventArgs>(this, "MouseUp").Select(e => e.EventArgs.GetPosition(Grid).ToXna());

            KeyDownEvents.Where(e => e.Key == Key.F).Subscribe(ie => this.Fullscreen = this.Fullscreen == null ? Screen.PrimaryScreen : null);
            
            MaybeFullscreen = null;
            Hwnd = new WindowInteropHelper(this).EnsureHandle();            
            Show();
        }
        public void Calling_AutoGenerateColumns_should_set_gridmodel()
        {
            IGrid<Person> grid = new Grid<Person>(new Person[0], new StringWriter(), new ViewContext());
            grid.AutoGenerateColumns();

            ((Grid<Person>)grid).Model.ShouldBe<AutoColumnGridModel<Person>>();
        }
Example #20
0
    public static void AddPages(TabControl tabControl, string tabName, bool maxSize, params Page[] pages)
    {
        Grid grid = new Grid();
        grid.Width = double.NaN;
        grid.Height = double.NaN;
        grid.Margin = new Thickness(0);
        grid.VerticalAlignment = VerticalAlignment.Top;

        if (maxSize)
        {
            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
            grid.VerticalAlignment = VerticalAlignment.Stretch;
        }

        int index = 0;
        foreach (var item in pages)
        {
            ColumnDefinition col = new ColumnDefinition();
            col.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(col);
            SetPageToGrid(item, grid, 0, index);
            index++;
        }

        TabItem tabItem = new TabItem();
        tabItem.Header = tabName;
        tabItem.Content = grid;
        tabControl.Items.Add(tabItem);
    }
Example #21
0
    public IGrid Create()
    {
        var grid = new Grid();
        grid.Initialize(_setting, _groupFactory);

        return grid;
    }
        public void GridCellInstantiationTest()
        {
            Grid grid;

            // Assert each cell in grid is instantiated and initialized with expected default chemical concentrations
            grid = new Grid(4);
            for (int column = 0; column < grid.Size; column++)
            {
                for (int row = 0; row < grid.Size; row++)
                {
                    Assert.AreEqual(grid[column, row]["A"], 0);
                    Assert.AreEqual(grid[column, row]["B"], 0);
                }
            }

            // Assert each cell in grid is instantiated and initialized with given chemical concentrations
            Cell cell = new Cell
            {
                { "A", 0.25 },
                { "B", 0.75 }
            };
            grid = new Grid(4, cell);
            for (int column = 0; column < grid.Size; column++)
            {
                for (int row = 0; row < grid.Size; row++)
                {
                    Assert.AreEqual(grid[column, row]["A"], 0.25);
                    Assert.AreEqual(grid[column, row]["B"], 0.75);
                }
            }
        }
Example #23
0
        public void Grid_SetsName()
        {
            String actual = new Grid<GridModel>(new GridModel[0]).Name;
            String expected = "Grid";

            Assert.Equal(expected, actual);
        }
Example #24
0
 void Start()
 {
     _root = (Grid)GetComponent<NoesisGUIPanel>().GetContent();
     _root.ManipulationStarting += this.ManipulationStarting;
     _root.ManipulationInertiaStarting += this.ManipulationInertiaStarting;
     _root.ManipulationDelta += this.ManipulationDelta;
 }
Example #25
0
        public void Grid_SetsSource()
        {
            IQueryable<GridModel> expected = new GridModel[2].AsQueryable();
            IQueryable<GridModel> actual = new Grid<GridModel>(expected).Source;

            Assert.Same(expected, actual);
        }
Example #26
0
		protected override void Init ()
		{
			var rootGrid = new Grid {
				RowDefinitions = new RowDefinitionCollection
														  {
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
															 new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) },
														 },
			};


			_mainContent = new ContentView { Content = new ScrollView { Content = new Label { Text = Description } } };
			rootGrid.AddChild (_mainContent, 0, 0);


			var buttons = new StackLayout { Orientation = StackOrientation.Horizontal };

			var button1A = new Button { Text = "View 1A" };
			button1A.Clicked += (sender, args) => ShowView (_view1A);
			buttons.Children.Add (button1A);

			var button1B = new Button { Text = "View 1B" };
			button1B.Clicked += (sender, args) => ShowView (_view1B);
			buttons.Children.Add (button1B);

			var button2 = new Button { Text = "View 2" };
			button2.Clicked += (sender, args) => ShowView (_view2);
			buttons.Children.Add (button2);

			rootGrid.AddChild (buttons, 0, 1);


			Content = rootGrid;
		}
    public void StartLevel()
    {
        m_grid = new DungeonGenerator().Generate(SizeX, SizeY);

        // Change two random floor tiles to stairs
        var position = GetRandomTileOfType(TileType.Floor);
        m_grid[(int)position.x, (int)position.y] = TileType.StairsUp;
        position = GetRandomTileOfType(TileType.Floor);
        m_grid[(int)position.x, (int)position.y] = TileType.StairsDown;

        // Set all tiles
        for (int y = 0; y < m_grid.SizeY; y++)
        {
            for (int x = 0; x < m_grid.SizeX; x++)
            {
                var type = m_grid[x, y];
                if (type == TileType.Empty)
                    m_tileMap.PaintTile(x, y, new Color(0, 0, 0, 0));
                else
                    m_tileMap[x, y] = m_tiles.GetId(type);
            }
        }

        // Move player to stairs
        var stairs = FindTile(TileType.StairsUp);
        var playerBehaviour = GameObject.Find("Player").GetComponent<PlayerBehaviour>();
        playerBehaviour.SetTilePosition((int)stairs.x, (int)stairs.y);
    }
Example #28
0
            public override TerrainGrid Generate(Vector size, FreqDict freqs = null, Random rand = null)
            {
                freqs = freqs ?? _defaultFreqs;
                UpdateFreqs(ref freqs);
                NormalizeFreqs(ref freqs);

                rand = rand ?? new Random();

                var terrain = new Grid<TerrainType>(size);

                var heightGrid = _topographyGenerator.Generate(terrain.Size, rand);
                heightGrid = _filters.OpenClose(heightGrid);
                var sortedPoints = heightGrid.GetPoints().ToList();
                sortedPoints.Sort((lhs, rhs) => (heightGrid[lhs] - heightGrid[rhs]));

                int numTiles = size.x * size.y;
                int numWaterTiles = (int)(numTiles * freqs[TerrainTypes.Water]);
                var waterTiles = sortedPoints.Take(numWaterTiles);
                foreach (var point in waterTiles)
                    terrain[point] = TerrainTypes.Water;

                int numMountainTiles = (int)(numTiles * freqs[TerrainTypes.Mountain]);
                var mountainTiles = sortedPoints.Skip(numTiles - numMountainTiles);
                foreach (var point in mountainTiles)
                    terrain[point] = TerrainTypes.Mountain;

                var landTiles = new HashSet<Vector>(terrain.GetPoints());
                landTiles.ExceptWith(waterTiles);
                landTiles.ExceptWith(mountainTiles);

                AddLandTiles(ref terrain, landTiles.ToList(), freqs, rand);

                return terrain;
            }
    protected void AddDetailGrid(Grid grid)
    {
        DetailGrid detail = new DetailGrid();
        detail.ID = "grid" + level.ToString();
        detail.AutoGenerateColumns = false;
        detail.Serialize = false;
        detail.AllowPageSizeSelection = false;
        detail.AllowPaging = false;
        detail.PageSize = -1;
        detail.AllowAddingRecords = true;
        detail.Width = Unit.Percentage(97);

        detail.ForeignKeys = "CategoryID";

        detail.ClientSideEvents.ExposeSender = true;
        detail.ClientSideEvents.OnClientPopulateControls = "onPopulateControls";
        detail.ClientSideEvents.OnBeforeClientDelete = "onBeforeClientDelete";

        foreach (Column column in grid.Columns)
        {
            Column newColumn = column.Clone() as Column;
            newColumn.SortOrder = SortOrderType.None;
            detail.Columns.Add(newColumn);
        }

        detail.MasterDetailSettings = grid.MasterDetailSettings;

        detail.DataSourceNeeded += Grid1_DataSourceNeeded;
        detail.InsertCommand += Grid1_InsertCommand;
        detail.UpdateCommand += Grid1_UpdateCommand;
        detail.DeleteCommand += Grid1_DeleteCommand;

        grid.DetailGrids.Add(detail);
    }
Example #30
0
 public override void Click(float mouseX, float mouseY, int gridX, int gridY, Grid grid, GridPiece piece)
 {
     if (piece == null)
     {
         grid.AddPiece(new Battery(new ChargeColor(R, G, B)), gridX, gridY);
     }
 }
 public DisplayAdapter(IGameViewModel viewModel)
 {
     myViewModel = viewModel;
     myCanvas    = viewModel.Canvas;
 }
        private void AddPeriod(CIPeriod i, Grid mainGrid, bool addToList)
        {
            mainGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(40)
            });
            Image img = new Image()
            {
                Source        = "close_circle.png",
                HeightRequest = BlankWidth - 10,
                WidthRequest  = BlankWidth - 10,
            };
            var t = new TapGestureRecognizer();

            t.Tapped += (s, e) =>
            {
                DeletePeriod(i, addToList);
            };
            img.GestureRecognizers.Add(t);
            mainGrid.Children.Add(img, 0, rowCount);
            Entry indexEntry = new Entry()
            {
                Text     = i.Index + "",
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Keyboard = Keyboard.Numeric
            };

            mainGrid.Children.Add(indexEntry, 1, rowCount);
            Entry nameEntry = new Entry()
            {
                Text     = i.Name + "",
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
            };

            mainGrid.Children.Add(nameEntry, 2, rowCount);
            Entry intervalEntry = new Entry()
            {
                Text     = Math.Round(i.Interval.TotalMinutes, 2) + "",
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Keyboard = Keyboard.Numeric
            };

            indexEntry.TextChanged += (s, e) =>
            {
                var          entry           = (Entry)s;
                List <Entry> periodToCascade = null;
                try
                {
                    periodToCascade = _addedPeriods.First(_ => _.ElementAt(0).Text == entry.Text && _.ElementAt(1).Text != nameEntry.Text);
                }
                catch { }
                if (entry.Text != "" && periodToCascade != null)
                {
                    var indexToCascade = int.Parse(entry.Text);
                    if (indexToCascade == _addedPeriods.Count)
                    {
                        indexToCascade = 0;
                    }

                    periodToCascade.ElementAt(0).Text = ++indexToCascade + "";
                }
                else if (entry.Text != "" && periodToCascade == null)
                {
                }
            };
            mainGrid.Children.Add(intervalEntry, 3, rowCount++);

            if (_addedPeriods == null)
            {
                _addedPeriods = new List <List <Entry> >();
            }
            List <Entry> addedPeriod = new List <Entry>()
            {
                indexEntry, nameEntry, intervalEntry
            };

            if (true)
            {
                _addedPeriods.Add(addedPeriod);
            }
        }
        private static Grid SingBlock(string name)
        {
            var grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            grid.Cell(0, 0, new Label {
                Content = new TextBlock {
                    FontFamily   = new FontFamily("Arial"),
                    FontSize     = 12,
                    Text         = name,
                    TextWrapping = TextWrapping.Wrap,
                    Width        = 200
                },
            });

            grid.Cell(0, 1, new Label {
                Width               = 100,
                BorderBrush         = Brushes.Black,
                BorderThickness     = new Thickness(0, 0, 0, 1),
                SnapsToDevicePixels = true,
                Margin              = new Thickness(5, 0, 5, 0),
            });
            grid.Cell(1, 1, new Label {
                FontFamily          = new FontFamily("Arial"),
                FontSize            = 9,
                Content             = "(должность)",
                HorizontalAlignment = HorizontalAlignment.Center,
            });

            grid.Cell(0, 2, new Label
            {
                Width               = 87,
                BorderBrush         = Brushes.Black,
                BorderThickness     = new Thickness(0, 0, 0, 1),
                SnapsToDevicePixels = true,
                Margin              = new Thickness(5, 0, 5, 0),
            });
            grid.Cell(1, 2, new Label
            {
                FontFamily          = new FontFamily("Arial"),
                FontSize            = 9,
                Content             = "(подпись)",
                HorizontalAlignment = HorizontalAlignment.Center,
            });

            grid.Cell(0, 3, new Label {
                BorderBrush         = Brushes.Black,
                Width               = 250,
                BorderThickness     = new Thickness(0, 0, 0, 1),
                SnapsToDevicePixels = true,
                Margin              = new Thickness(5, 0, 5, 0),
            });
            grid.Cell(1, 3, new Label {
                FontFamily          = new FontFamily("Arial"),
                FontSize            = 9,
                Content             = "(ф.и.о.)",
                HorizontalAlignment = HorizontalAlignment.Center,
            });
            return(grid);
        }
Example #34
0
    //bool first = true;
    protected override unsafe void OnUpdate()
    {
        var entityManager = World.Active.GetOrCreateManager <EntityManager>();

        for (int danglingEnemyIndex = 0; danglingEnemyIndex < m_DanglingEnemyData.Length; ++danglingEnemyIndex)
        {
            m_PathManager.RemovePath(m_DanglingEnemyData.EnemyStates[danglingEnemyIndex].PathId);
            PostUpdateCommands.RemoveComponent <EnemyState>(m_DanglingEnemyData.Entities[danglingEnemyIndex]);
        }

        s_Start = m_SpawnPointData.SpawnPoint[0].GridIndex;
        s_Goal  = m_GoalPointData.GoalPoint[0].GridIndex;
        s_BlockedTerrainCardinal      = new GridBitfield();
        s_BlockedTerrainIntercardinal = new GridBitfield();
        for (int turretIndex = 0; turretIndex < m_TurretData.Length; ++turretIndex)
        {
            int2 turretGridCoords = Grid.ConvertToGridIndex(m_TurretData.Positions[turretIndex].Value);
            s_BlockedTerrainCardinal[turretGridCoords]      = true;
            s_BlockedTerrainIntercardinal[turretGridCoords] = true;
            if (turretGridCoords.x > 0)
            {
                s_BlockedTerrainIntercardinal[turretGridCoords.x - 1, turretGridCoords.y] = true;
            }
            if (turretGridCoords.x < Grid.NumCells.x - 1)
            {
                s_BlockedTerrainIntercardinal[turretGridCoords.x + 1, turretGridCoords.y] = true;
            }
            if (turretGridCoords.y > 0)
            {
                s_BlockedTerrainIntercardinal[turretGridCoords.x, turretGridCoords.y - 1] = true;
            }
            if (turretGridCoords.y < Grid.NumCells.y - 1)
            {
                s_BlockedTerrainIntercardinal[turretGridCoords.x, turretGridCoords.y + 1] = true;
            }
        }

        // clear out all previous paths to force path-recompute if the tower layour has changed
        if (m_PreviousBlockedTerrain != null && m_PreviousBlockedTerrain != s_BlockedTerrainCardinal)
        {
            m_PathManager.ForcePathRecompute();
        }
        m_PreviousBlockedTerrain = s_BlockedTerrainCardinal;

        for (int trackedEnemyIndex = 0; trackedEnemyIndex < m_TrackedEnemyData.Length; ++trackedEnemyIndex)
        {
            float3 currentPos       = m_TrackedEnemyData.Positions[trackedEnemyIndex].Value;
            int2   currentGridIndex = Grid.ConvertToGridIndex(currentPos);
            float3 target           = HandleLiveEnemy(currentGridIndex, m_TrackedEnemyData.EnemyStates[trackedEnemyIndex]);

            if (currentPos.Equals(target))
            {
                List <float3> path = m_PathManager.GetPath(m_TrackedEnemyData.EnemyStates[trackedEnemyIndex].PathId);
                path.RemoveAt(path.Count - 1);
                target = HandleLiveEnemy(currentGridIndex, m_TrackedEnemyData.EnemyStates[trackedEnemyIndex]);
            }

            float3 delta = Time.deltaTime * m_TrackedEnemyData.Enemies[trackedEnemyIndex].Speed * math.normalize(target - currentPos);

            while (WouldDeltaJumpTarget(currentPos, delta, target))
            {
                float3 toTarget           = target - currentPos;
                float  magDelta           = math.length(delta);
                float  normalizedTimeUsed = math.length(toTarget) / magDelta;
                float  distanceLeft       = (1.0f - normalizedTimeUsed) * magDelta;

                List <float3> path = m_PathManager.GetPath(m_TrackedEnemyData.EnemyStates[trackedEnemyIndex].PathId);
                path.RemoveAt(path.Count - 1);

                if (path.Count == 0)
                {
                    if (m_PlayerData.Player[0].gameState.Equals(GameState.PLAYING))
                    {
                        for (int i = 0; i < m_PlayerData.Player.Length; i++)
                        {
                            var playerData = m_PlayerData.Player[i];
                            playerData.Health--;
                            m_PlayerData.Player[i] = playerData;
                        }
                    }
                    PostUpdateCommands.DestroyEntity(m_TrackedEnemyData.Entities[trackedEnemyIndex]);
                    return;
                }

                currentPos = target;
                target     = path[path.Count - 1];
                delta      = distanceLeft * math.normalize(target - currentPos);
            }

            m_TrackedEnemyData.Positions[trackedEnemyIndex] = new Position {
                Value = currentPos + delta
            };
        }

        for (int newEnemyIndex = 0; newEnemyIndex < m_NewEnemyData.Length; ++newEnemyIndex)
        {
            EnemyState enemyState = new EnemyState {
                PathId = m_PathManager.AddPath()
            };
            PostUpdateCommands.AddComponent(m_NewEnemyData.Entities[newEnemyIndex], enemyState);
        }
    }
Example #35
0
    public PathingSystem()
    {
        Grid.Configure(new int2(24, 20), new float2(1.0f, 1.0f), new float3(0.0f, 0.0f, 0.0f));

        m_PathManager = new PathManager();
    }
Example #36
0
        public static void Launcher(Grid grid, int px, int py, int sx, int sy, string header, JObject data)
        {
            Microsoft.AppCenter.Analytics.Analytics.TrackEvent("Create Launcher Widget");

            try
            {
                Models.Sitemap.Widget3      item = data.ToObject <Models.Sitemap.Widget3>();
                Dictionary <string, string> widgetKeyValuePairs = Helpers.SplitCommand(item.Label);
                CrossLogger.Current.Debug("Launcher", "Label: " + widgetKeyValuePairs["label"]);

                //Master Grid for Widget
                Grid Widget_Grid = new Grid
                {
                    RowDefinitions = new RowDefinitionCollection {
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        },
                        new RowDefinition {
                            Height = new GridLength(2, GridUnitType.Star)
                        },
                    },
                    ColumnDefinitions = new ColumnDefinitionCollection {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                    },
                    RowSpacing        = 0,
                    ColumnSpacing     = 0,
                    BackgroundColor   = App.Config.CellColor,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Padding           = new Thickness(0, 0, 0, 10),
                };

                //Header
                Widget_Grid.Children.Add(new Forms9Patch.Label
                {
                    Text                    = header.Replace("\"", " "),
                    FontSize                = 100,
                    TextColor               = App.Config.TextColor,
                    BackgroundColor         = App.Config.CellColor,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Start,
                    LineBreakMode           = LineBreakMode.NoWrap,
                    Lines                   = 1,
                    AutoFit                 = Forms9Patch.AutoFit.Width,
                }, 0, 0);

                //Circle
                SvgCachedImage svg = new SvgCachedImage
                {
                    DownsampleToViewSize = false,
                    Aspect = Aspect.AspectFit,
                    BitmapOptimizations = false,
                    Source = SvgImageSource.FromSvgString(@"<svg viewBox=""0 0 100 100""><circle cx=""50"" cy=""50"" r=""50"" fill=""" + App.Config.ValueColor.ToHex().ToString() + @""" /></svg>"),
                };
                Widget_Grid.Children.Add(svg, 0, 1);

                //Image
                Widget_Grid.Children.Add(new Image
                {
                    Source            = widgetKeyValuePairs["icon"],
                    Aspect            = Aspect.AspectFit,
                    BackgroundColor   = Color.Transparent,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                }, 0, 1);

                //Button must be last to be added to work
                Button launcherButton = new Button
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    BackgroundColor   = Color.Transparent,
                    StyleId           = widgetKeyValuePairs["url"] //StyleID is not used on buttons
                };
                Widget_Grid.Children.Add(launcherButton, 0, 1, 0, 2);

                launcherButton.Clicked += OnLauncherButtonClicked;
                CrossLogger.Current.Debug("Launcher", "Button ID: " + launcherButton.Id + " created.");

                grid.Children.Add(Widget_Grid, px, px + sx, py, py + sy);
            }
            catch (Exception ex)
            {
                CrossLogger.Current.Error("Launcher", "Widgets.Launcher crashed: " + ex.ToString());
                Error(grid, px, py, sx, sy, ex.ToString());
            }
        }
        public void DrawField(List <IMapEntity> mapEntities, int totalRows, int totalColumns, ref IMapEntity[,] fieldMap)
        {
            mySubject = null;
            myCanvas.Children.Clear();
            myCanvas.RowDefinitions.Clear();
            myCanvas.ColumnDefinitions.Clear();

            Dictionary <IMapEntity, int> countMapping = new Dictionary <IMapEntity, int>();

            mapEntities.ForEach(entity => countMapping.Add(entity, 0));

            for (int i = 0; i < totalRows; i++)
            {
                myCanvas.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
            }
            for (int i = 0; i < totalColumns; i++)
            {
                myCanvas.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
            }
            Random random             = new Random();
            int    mapEntityToPick    = 0;
            int    lastEntityPicked   = 0;
            int    totalEntitiesTypes = mapEntities.Count;

            for (int x = 0; x < totalColumns; x++)
            {
                for (int y = 0; y < totalRows; y++)
                {
                    var cell = new ContentControl();

                    if (x == 0 && y == 0)
                    {
                        cell.Content = new EmptyMapEnity();
                    }
                    else
                    {
                        lastEntityPicked = mapEntityToPick;
                        do
                        {
                            mapEntityToPick = random.Next(0, mapEntities.Count + 3);
                        } while (lastEntityPicked == mapEntityToPick);

                        lastEntityPicked = mapEntityToPick;

                        if (mapEntityToPick < mapEntities.Count)
                        {
                            var entityToCopy = mapEntities.ElementAt(mapEntityToPick);

                            int entityAddCount = countMapping[entityToCopy];

                            if ((entityToCopy.Multiplicity == MapEntityMultiplicity.Multiple || entityAddCount < 1))
                            {
                                while (entityToCopy.Multiplicity != MapEntityMultiplicity.Single && !IsCountUnderDistributionWeight(entityAddCount, entityToCopy.DistributionWeight, totalRows * totalColumns))
                                {
                                    var tempMapEntityIndex = random.Next(0, mapEntities.Count);
                                    var tempEntity         = mapEntities.ElementAt(tempMapEntityIndex);
                                    if (lastEntityPicked == tempMapEntityIndex || tempEntity.Multiplicity == MapEntityMultiplicity.Single)
                                    {
                                        continue;
                                    }
                                    entityToCopy    = tempEntity;
                                    entityAddCount  = countMapping[entityToCopy];
                                    mapEntityToPick = tempMapEntityIndex;
                                }
                                ;

                                cell.Content = new DataBoundMapEntity
                                {
                                    Description         = entityToCopy.Description,
                                    DisplayText         = entityToCopy.DisplayText,
                                    Icon                = entityToCopy.Icon,
                                    ScoringWeight       = entityToCopy.ScoringWeight,
                                    Row                 = y,
                                    Column              = x,
                                    IsMoveAllowedOnThis = entityToCopy.IsMoveAllowedOnThis
                                };

                                countMapping[entityToCopy]++;
                            }
                            else
                            {
                                cell.Content = new EmptyMapEnity();
                            }
                        }
                        else
                        {
                            cell.Content = new EmptyMapEnity();
                        }
                    }

                    Grid.SetRow(cell, x);
                    Grid.SetColumn(cell, y);
                    myCanvas.Children.Add(cell);
                    fieldMap[x, y] = cell.Content as IMapEntity;
                }
            }
        }
        // Themes
        private void loadTheme(int themeID)
        {
            switch (themeID)
            {
            case 0:     // Light
            {
                bgColor    = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                bgColor2   = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                textColor  = new SolidColorBrush(Color.FromRgb(24, 24, 24));
                textColor2 = new SolidColorBrush(Color.FromRgb(10, 10, 10));
                break;
            }

            case 1:     // Dark
            {
                bgColor    = new SolidColorBrush(Color.FromRgb(24, 24, 24));
                bgColor2   = new SolidColorBrush(Color.FromRgb(61, 61, 61));
                textColor  = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                textColor2 = new SolidColorBrush(Color.FromRgb(179, 179, 179));
                break;
            }
            }

            // Set colors
            mainGrid.Background       = bgColor;
            menuGrid.Background       = bgColor;
            bodyGrid.Background       = bgColor;
            footerGrid.Background     = bgColor;
            songTitleLabel.Foreground = textColor;
            artistLabel.Foreground    = textColor2;
            if (correctMarkBtnFlag.Visibility == Visibility.Collapsed)
            {
                correctMarkBtnText.Foreground = textColor2;
            }
            correctMarkDescriptionLabel.Foreground = textColor;
            correctMarkDescriptionBtn.Foreground   = textColor;
            versionLabel.Foreground       = textColor2;
            smallerFontBtnText.Foreground = textColor2;
            biggerFontBtnText.Foreground  = textColor2;
            fontSizeText.Foreground       = textColor2;
            if (!Properties.Settings.Default.boldFont)
            {
                boldFontBtnText.Foreground = textColor2;
            }
            if (themeID == 0)
            {
                darkModeBtnText.Foreground = textColor2;
            }
            if (!Properties.Settings.Default.topMost)
            {
                topModeBtnText.Foreground = textColor2;
            }
            if (!Properties.Settings.Default.launchFlag)
            {
                launchFlagBtnText.Foreground = textColor2;
            }
            settingsBtnText.Foreground  = textColor2;
            focusModeBtnText.Foreground = textColor2;
            countLabel.Foreground       = textColor2;
            gradient0.Color             = bgColor.Color;
            gradient1.Color             = Color.FromArgb(0, bgColor.Color.R, bgColor.Color.G, bgColor.Color.B);
            gradient2.Color             = Color.FromArgb(0, bgColor.Color.R, bgColor.Color.G, bgColor.Color.B);
            gradient3.Color             = bgColor.Color;
            gradient4.Color             = bgColor2.Color;
            gradient5.Color             = bgColor.Color;

            foreach (ListViewItem s in lyricsView.Items)
            {
                Grid g = (Grid)s.Content;

                foreach (UIElement u in g.Children)
                {
                    TextBox t = (TextBox)u;
                    t.Foreground = textColor;
                }
            }

            // Save settings
            Properties.Settings.Default.theme = themeID;
            Properties.Settings.Default.Save();
        }
Example #39
0
 public WeatherForecast(Grid root, Config config) : base(root, "Weather", config, 250, 120, new Thickness(10, 10, 10, 10), HorizontalAlignment.Center, VerticalAlignment.Bottom, TimeSpan.FromMinutes(10))
 {
     httpClient = new HttpClient();
 }
        private void addToLyricsView(string s, bool error = false, bool topCenter = true)
        {
            ListViewItem lContainer = new ListViewItem();

            lContainer.Style               = (Style)Application.Current.FindResource("ListViewContainerStyle");
            lContainer.IsEnabled           = true;
            lContainer.HorizontalAlignment = HorizontalAlignment.Center;

            if (s.Contains("\r\n") && s.Length > 4)
            {
                if (s.Substring(s.Length - 2, 2) == "\r\n")
                {
                    s = s.Substring(0, s.Length - 2);
                }
            }

            Grid lGrid = new Grid();

            lGrid.Width = this.ActualWidth - 50;
            TextBox lString = new TextBox();

            lString.Style           = Properties.Settings.Default.boldFont ? (Style)Application.Current.FindResource("BoldFont") : (Style)Application.Current.FindResource("BookFont");
            lString.Foreground      = textColor;
            lString.FontSize        = Properties.Settings.Default.textSize;
            lString.FontStretch     = FontStretches.UltraExpanded;
            lString.IsReadOnly      = true;
            lString.Background      = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            lString.BorderThickness = new Thickness(0);
            lString.TextAlignment   = TextAlignment.Center;
            lString.Text            = s;
            lString.TextWrapping    = TextWrapping.WrapWithOverflow;
            lString.Padding         = new Thickness(20, 0, 20, 0);

            if (error)
            {
                lString.Text = "I can't find the lyrics, sorry.";
                TextBox emoji = new TextBox();
                emoji.Style           = (Style)Application.Current.FindResource("IconFont");
                emoji.FontSize        = Properties.Settings.Default.textSize + 40;
                emoji.Text            = "";
                emoji.IsReadOnly      = true;
                emoji.Background      = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                emoji.BorderThickness = new Thickness(0);
                emoji.Foreground      = textColor;
                emoji.FontStretch     = FontStretches.UltraExpanded;
                emoji.TextAlignment   = TextAlignment.Center;
                emoji.Padding         = new Thickness(20, 25, 20, 0);

                lGrid.Children.Add(lString);
                lGrid.Children.Add(emoji);
            }
            else
            {
                lGrid.Children.Add(lString);
            }

            lContainer.Content = lGrid;

            if (topCenter)
            {
                lyricsView.VerticalAlignment = VerticalAlignment.Top;
            }
            else
            {
                lyricsView.VerticalAlignment = VerticalAlignment.Center;
            }

            lyricsView.Items.Add(lContainer);
        }
Example #41
0
        public void GetEmployeesAccessMasterGridEditActiveSlaveGridThreeSlaveGrids()
        {
            Grid mastergrid = new Grid();

            mastergrid.DataSourceId        = "Employees";
            mastergrid.ID                  = "test";
            mastergrid.Page                = Testpage;
            mastergrid.CurrentId           = "3";
            mastergrid["Photo"].Visibility = Visibility.None; //HtmlForm is required for File columns.
            mastergrid.Mode                = Mode.Edit;
            mastergrid.ConnectionString    = ConnectionAccessOleDb;
            Testpage.Controls.Add(mastergrid);

            Grid slavegrid = new Grid();

            slavegrid.DataSourceId     = "EmployeeTerritories";
            slavegrid.ID               = "test2";
            slavegrid.Page             = Testpage;
            slavegrid.MasterGrid       = "test";
            slavegrid.ConnectionString = ConnectionAccessOleDb;
            Testpage.Controls.Add(slavegrid);

            Grid slavegrid2 = new Grid();

            slavegrid2.DataSourceId     = "EmployeeTerritories";
            slavegrid2.ID               = "test3";
            slavegrid2.Page             = Testpage;
            slavegrid2.MasterGrid       = "test";
            slavegrid2.ConnectionString = ConnectionAccessOleDb;
            Testpage.Controls.Add(slavegrid2);

            Grid slavegrid3 = new Grid();

            slavegrid3.DataSourceId     = "EmployeeTerritories";
            slavegrid3.ID               = "test3";
            slavegrid3.Page             = Testpage;
            slavegrid3.MasterGrid       = "test";
            slavegrid3.ConnectionString = ConnectionAccessOleDb;
            Testpage.Controls.Add(slavegrid3);


            mastergrid.RaisePostBackEvent("SlaveGridClick!test2");

            StringBuilder  sb         = new StringBuilder();
            StringWriter   sw         = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);

            mastergrid.RenderControl(gridwriter);

            sb         = new StringBuilder();
            sw         = new StringWriter(sb);
            gridwriter = new HtmlTextWriter(sw);
            slavegrid.RenderControl(gridwriter);


            Assert.AreEqual(mastergrid.MasterTable.Rows.Count, 1);
            Assert.Greater(slavegrid.MasterTable.Rows.Count, 1);
            Assert.IsTrue(slavegrid.MasterTable.GotDataSourceSchema);
            Assert.IsFalse(slavegrid2.MasterTable.GotDataSourceSchema);
            Assert.IsFalse(slavegrid3.MasterTable.GotDataSourceSchema);
            Assert.IsTrue(mastergrid.ActiveMenuSlaveGrid != null &&
                          mastergrid.ActiveMenuSlaveGrid.ID.Equals(slavegrid.ID));
        }
Example #42
0
        public async override void update()
        {
            try
            {
                if (state)
                {
                    Debug.WriteLine("Weather Forecast UPDATE");
                    Grid     grid     = new Grid();
                    Forecast forecast = await getForecast();

                    //Image
                    Image       image  = new Image();
                    BitmapImage bimage = new BitmapImage(new Uri("ms-appx:///Assets/" + forecast.icon + ".png"));
                    image.Source = bimage;
                    image.RenderTransformOrigin = new Point(0.5, 0.5);
                    image.Width  = 50;
                    image.Height = 50;
                    image.Margin = new Thickness(0, 30, 0, 50);

                    TextBlock temp2 = new TextBlock();
                    temp2.Text       = forecast.temp.Substring(0, 2) + "º";
                    temp2.FontSize   = 30;
                    temp2.FontWeight = FontWeights.Bold;
                    temp2.Foreground = new SolidColorBrush(Colors.White);
                    temp2.Margin     = new Thickness(150, 40, 0, 0);

                    TextBlock tb = new TextBlock();
                    tb.Text                = "\t" + forecast.sunrise.Hour + ":" + forecast.sunrise.Minute + "\t" + forecast.sunset.Hour + ":" + forecast.sunset.Minute;
                    tb.FontSize            = 14;
                    tb.Foreground          = new SolidColorBrush(Colors.White);
                    tb.HorizontalAlignment = HorizontalAlignment.Center;
                    tb.Margin              = new Thickness(0, 80, 0, 0);

                    Image       sunrise  = new Image();
                    BitmapImage _sunrise = new BitmapImage(new Uri("ms-appx:///Assets/SunSet.png"));
                    sunrise.Source = _sunrise;
                    sunrise.RenderTransformOrigin = new Point(0.5, 0.5);
                    sunrise.Width  = 14;
                    sunrise.Height = 14;
                    sunrise.Margin = new Thickness(0, 57, 55, 0);

                    Image              sunset  = new Image();
                    BitmapImage        _sunset = new BitmapImage(new Uri("ms-appx:///Assets/SunSet.png"));
                    CompositeTransform ts      = new CompositeTransform();
                    ts.Rotation                  = Convert.ToDouble(180);
                    sunset.RenderTransform       = ts;
                    sunset.Source                = _sunset;
                    sunset.RenderTransformOrigin = new Point(0.5, 0.5);
                    sunset.Width                 = 14;
                    sunset.Height                = 14;
                    sunset.Margin                = new Thickness(55, 57, 0, 0);

                    /*
                     * //Temp
                     * TextBlock temp = new TextBlock();
                     * temp.Text = "Min: " + forecast.minTemp + "  --  Max: " + forecast.maxTemp;
                     * temp.FontSize = 10;
                     * temp.Foreground = new SolidColorBrush(Colors.White);
                     * temp.Margin = new Thickness(105, 0, 0, 0);
                     *
                     *
                     *
                     * //WindSpeed
                     * Image wind = new Image();
                     * BitmapImage windbimage = new BitmapImage(new Uri("ms-appx:///Assets/wind.png"));
                     * CompositeTransform ts = new CompositeTransform();
                     * ts.Rotation = Convert.ToDouble(forecast.windDir);
                     * wind.Source = windbimage;
                     * wind.RenderTransform = ts;
                     * wind.RenderTransformOrigin = new Point(0.5, 0.5);
                     * wind.Width = 50;
                     * wind.Height = 50;
                     * wind.Margin = new Thickness(100, 50, 0, 0);
                     *
                     * TextBlock temp3 = new TextBlock();
                     * temp2.Text = "Location: " + forecast.location;
                     * temp2.FontSize = 10;
                     * temp2.Foreground = new SolidColorBrush(Colors.White);
                     * temp2.Margin = new Thickness(0,100, 0, 0);
                     *
                     * grid.Children.Add(temp);
                     * grid.Children.Add(temp2);
                     * grid.Children.Add(temp3);
                     * grid.Children.Add(wind);
                     */

                    grid.Children.Add(tb);
                    grid.Children.Add(temp2);
                    grid.Children.Add(image);
                    grid.Children.Add(sunset);
                    grid.Children.Add(sunrise);
                    clearWidget();
                    addToWidget(grid);
                }
                else
                {
                    clearWidget();
                }

                //Debug.WriteLine("Weather Forecast: " + Marshal.SizeOf(grid));
            }
            catch (Exception e)
            {
                Debug.WriteLine("You probly dont have internet");
            }
        }
Example #43
0
    void Update()
    {
        if (Input.GetKey("up") && Time.time - lastSlide >= maxSlideSpeed)
        {
            transform.Rotate(0, 0, -90);
            if (!isValidPosition())
            {
                // undo move if invalid.
                transform.Rotate(0, 0, 90);
            }
            else
            {
                updateGrid();
            }
            lastSlide = Time.time;
        }
        if (Input.GetKey("left") && Time.time - lastSlide >= maxSlideSpeed)
        {
            transform.position += Vector3.left;

            if (!isValidPosition())
            {
                // undo move if invalid.
                transform.position += Vector3.right;
            }
            else
            {
                updateGrid();
            }
            lastSlide = Time.time;
        }

        if (Input.GetKey("right") && Time.time - lastSlide >= maxSlideSpeed)
        {
            transform.position += Vector3.right;
            if (!isValidPosition())
            {
                // undo move if invalid.
                transform.position += Vector3.left;
            }
            else
            {
                updateGrid();
            }
            lastSlide = Time.time;
        }

        if (Input.GetKey("down") || Time.time - lastFall >= gravityTickSpeed)
        {
            transform.position += new Vector3(0, -1, 0);
            if (!isValidPosition())
            {
                // undo move if invalid.
                transform.position += new Vector3(0, 1, 0);
                Grid.destroyFullRows();

                // piece is done. Turn off update loop
                enabled = false;
                spawner.spawnNext();
            }
            else
            {
                updateGrid();
            }
            lastFall = Time.time;
        }
    }
        public void UpdateForNewPosition()
        {
            const int duration = 400;

            this.UpdatePieceSizes();

            Storyboard animation = new Storyboard();

            animation.Duration = TimeSpan.FromMilliseconds(duration + 25);
            this.Resources.Add("tmpTimline" + this.currentAnimation++, animation);

            for (int i = 0; i < this.position.PieceList.Length; i++)
            {
                byte oldPieceLocation = 0xFF;
                if (this.oldPieceList != null)
                {
                    oldPieceLocation = this.oldPieceList[i];
                }

                byte newPieceLocation = this.position.PieceList[i];

                Piece oldPiece = oldPieceLocation != 0xFF ? this.pieces[this.oldBoard[oldPieceLocation]] : null;
                Piece newPiece = newPieceLocation != 0xFF ? this.pieces[this.position.Board[newPieceLocation]] : null;

                if (oldPieceLocation != newPieceLocation)
                {
                    if (newPieceLocation == 0xFF)
                    {
                        // Piece was captured
                        DoubleAnimation opacityAnimation = new DoubleAnimation();
                        Storyboard.SetTarget(opacityAnimation, oldPiece);
                        Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
                        opacityAnimation.Duration = TimeSpan.FromMilliseconds(duration);
                        opacityAnimation.To       = 0;

                        animation.Children.Add(opacityAnimation);
                    }
                    else if (oldPieceLocation == 0xFF)
                    {
                        // Piece was created (game reset, undo)

                        DoubleAnimation opacityAnimation = new DoubleAnimation();
                        Storyboard.SetTarget(opacityAnimation, newPiece);
                        Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
                        opacityAnimation.Duration = TimeSpan.FromMilliseconds(duration);
                        opacityAnimation.To       = 1;

                        Grid.SetRow(newPiece, SquareHelper.GetRow(newPieceLocation));
                        Grid.SetColumn(newPiece, SquareHelper.GetColumn(newPieceLocation));

                        animation.Children.Add(opacityAnimation);
                    }
                    else
                    {
                        if (oldPiece == newPiece)
                        {
                            // Piece just moved
                            Grid.SetRow(newPiece, SquareHelper.GetRow(newPieceLocation));
                            Grid.SetColumn(newPiece, SquareHelper.GetColumn(newPieceLocation));

                            DoubleAnimation yAnimation = new DoubleAnimation();
                            Storyboard.SetTarget(yAnimation, ((TransformGroup)newPiece.RenderTransform).Children[0]);
                            Storyboard.SetTargetProperty(yAnimation, new PropertyPath("Y"));

                            yAnimation.Duration = TimeSpan.FromMilliseconds(duration);
                            yAnimation.From     = (SquareHelper.GetRow(oldPieceLocation) - SquareHelper.GetRow(newPieceLocation)) * 100;
                            yAnimation.To       = 0;

                            animation.Children.Add(yAnimation);

                            DoubleAnimation xAnimation = new DoubleAnimation();
                            Storyboard.SetTarget(xAnimation, ((TransformGroup)newPiece.RenderTransform).Children[0]);
                            Storyboard.SetTargetProperty(xAnimation, new PropertyPath("X"));

                            xAnimation.Duration = TimeSpan.FromMilliseconds(duration);
                            xAnimation.From     = (SquareHelper.GetColumn(oldPieceLocation) - SquareHelper.GetColumn(newPieceLocation)) * 100;
                            xAnimation.To       = 0;

                            animation.Children.Add(xAnimation);
                        }
                        else
                        {
                            // Promotion
                            DoubleAnimation opacityAnimation = new DoubleAnimation();
                            Storyboard.SetTarget(opacityAnimation, newPiece);
                            Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
                            opacityAnimation.Duration = TimeSpan.FromMilliseconds(duration);
                            opacityAnimation.To       = 1;

                            Grid.SetRow(newPiece, SquareHelper.GetRow(newPieceLocation));
                            Grid.SetColumn(newPiece, SquareHelper.GetColumn(newPieceLocation));

                            animation.Children.Add(opacityAnimation);

                            opacityAnimation = new DoubleAnimation();
                            Storyboard.SetTarget(opacityAnimation, oldPiece);
                            Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
                            opacityAnimation.Duration = TimeSpan.FromMilliseconds(duration);
                            opacityAnimation.To       = 0;

                            animation.Children.Add(opacityAnimation);
                        }
                    }
                }
                else
                {
                    // TODO: what should be done here?
                }
            }

            // Workaround layout bug.
            this.LayoutRoot.Width--;
            this.LayoutRoot.Height++;

            animation.Completed += this.OnAnimationCompleted;
            animation.Begin();

            this.oldBoard     = new List <byte>(this.position.Board);
            this.oldPieceList = new List <byte>(this.position.PieceList);
            this.oldPieces    = new List <Piece>(this.pieces);
        }
Example #45
0
        /*This function creates and displays a node cluster on the screen
         * Parameters
         * Int16[,] NodeProp- Node locations
         * int top - Top or y coordinate of the cluster location on screen
         * int left - Left or x coordinate of the cluster location on screen
         * int fontsize - font size of text to be displayed on the nodes of the cluster (only valid for nodes in selected/zoomed states or the title nodes)
         * bool zoomed - whether a node is zoomed or not (used for animatin code)
         */
        public void displayCluster(Int16[,] NodeProp, int top, int left, int fontsize, bool zoomed)
        {
            //Due to the layout of a cluster on screen, currently we are only adding the first 7 nodes to a cluster. nCnt now stores the number of nodes inside this cluster.
            int nCnt = nodes.Count < 7 ? nodes.Count : 7;

            //Close all the media (if any) being played in other node
            MainWindow.mp.Stop();
            MainWindow.mp.Close();

            Ellipse   ellipse;
            TextBlock txt;
            Grid      grid;

            for (int i = 0; i < nCnt; i++)
            {
                //Create the ellipse to represent the node and display its content
                ellipse                 = new Ellipse();
                ellipse.Height          = NodeProp[i, 2];
                ellipse.Width           = NodeProp[i, 2];
                ellipse.StrokeThickness = 0;
                BrushConverter bc    = new BrushConverter();
                Brush          brush = (Brush)bc.ConvertFrom(nodes.ElementAt(i).color);

                // store node's name in Textblock
                txt = new TextBlock();
                txt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                txt.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                txt.TextTrimming        = TextTrimming.CharacterEllipsis;

                if (i == 0)
                {
                    txt.FontSize = fontsize + 7;
                }
                else
                {
                    txt.FontSize = fontsize;
                    ellipse.Fill = brush;
                    txt.Margin   = new Thickness(15, 10, 15, 10);
                }
                txt.Foreground   = (Brush)bc.ConvertFrom(nodes.ElementAt(i).textColor);
                txt.FontWeight   = System.Windows.FontWeights.Bold;
                txt.TextWrapping = System.Windows.TextWrapping.Wrap;
                txt.Text         = nodes.ElementAt(i).name;
                //Don't display the node name if it is in shrinked or default state. This is because the text will be unreadable
                if ((nodes.ElementAt(i).state == "shrinked" || nodes.ElementAt(i).state == "default") && ellipse.Width < 100)
                {
                    txt.Visibility = System.Windows.Visibility.Hidden;
                }

                // Assign values to Labels for storing node's parent ID,
                //node's state, node's name, node's type,node's subject/discipline, and the node's fill color for the ellipse.
                Label lbl = new Label();
                lbl.Content    = nodes.ElementAt(i).nodeID;
                lbl.Visibility = System.Windows.Visibility.Hidden;
                Label lbl1 = new Label();
                lbl1.Content    = nodes.ElementAt(i).state;
                lbl1.Visibility = System.Windows.Visibility.Hidden;
                Label lbl2 = new Label();
                lbl2.Content    = nodes.ElementAt(i).name;
                lbl2.Visibility = System.Windows.Visibility.Hidden;
                Label lbl3 = new Label();
                lbl3.Content    = nodes.ElementAt(i).type;
                lbl3.Visibility = System.Windows.Visibility.Hidden;
                Label lbl4 = new Label();
                lbl4.Content    = nodes.ElementAt(i).subject;
                lbl4.Visibility = System.Windows.Visibility.Hidden;
                Label lbl5 = new Label();
                lbl5.Content    = nodes.ElementAt(i).color;
                lbl5.Visibility = System.Windows.Visibility.Hidden;

                //Add the children to the node grid. Each node grid consists of ellipse to show content, Textblock to store textual content, Labels for storing node's parent ID,
                //node's state, node's name, node's type,node's subject/discipline, and the node's fill color for the ellipse.
                grid        = new Grid();
                grid.Height = NodeProp[i, 2];
                grid.Width  = NodeProp[i, 2];
                grid.Children.Add(ellipse);
                grid.Children.Add(txt);
                grid.Children.Add(lbl);
                grid.Children.Add(lbl1);
                grid.Children.Add(lbl2);
                grid.Children.Add(lbl3);
                grid.Children.Add(lbl4);
                grid.Children.Add(lbl5);
                grid.MouseLeftButtonDown  += new MouseButtonEventHandler(MainWindow.node_leftClick);
                grid.MouseRightButtonDown += new MouseButtonEventHandler(MainWindow.node_rightClick);
                grid.HorizontalAlignment   = System.Windows.HorizontalAlignment.Stretch;
                grid.VerticalAlignment     = System.Windows.VerticalAlignment.Stretch;

                //Add this node grid to the Paint Canvas and assign it a location
                MainWindow.PaintCanvas.Children.Add(grid);
                Canvas.SetLeft(grid, NodeProp[i, 1] + left);
                Canvas.SetTop(grid, NodeProp[i, 0] + top);


                //this code adds animation on a cluster node by zooming them gradually to the designated size
                DoubleAnimation da = new DoubleAnimation(1.5, new Duration(TimeSpan.FromSeconds(2)));
                ScaleTransform  sc = new ScaleTransform();
                grid.RenderTransform       = sc;
                grid.RenderTransformOrigin = new Point(0.5, 0.5);

                if (!zoomed)
                {
                    da.AutoReverse = true;
                }

                sc.BeginAnimation(ScaleTransform.ScaleXProperty, da);
                sc.BeginAnimation(ScaleTransform.ScaleYProperty, da);
            }
        }
Example #46
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="grid">表格实例</param>
 /// <param name="dataItem">行对应的数据源(在回发时为null)</param>
 /// <param name="rowIndex">行序号</param>
 public GridRow(Grid grid, object dataItem, int rowIndex)
 {
     _grid     = grid;
     _dataItem = dataItem;
     _rowIndex = rowIndex;
 }
Example #47
0
        /// <summary>
        /// Updates an active batched anim controller.
        /// </summary>
        /// <param name="instance">The controller to update.</param>
        /// <param name="dt">The time since the last update.</param>
        private static void UpdateActive(KBatchedAnimController instance, float dt)
        {
            Transform transform;
            var       batch   = instance.batch;
            var       visType = instance.visibilityType;
            bool      visible = instance.IsVisible();

            // Check if moved, do this even if offscreen as it may move the anim on screen
            if (batch != null && (transform = instance.transform).hasChanged)
            {
                var      lastChunk = instance.lastChunkXY;
                Vector3  pos = transform.position, posWithOffset = pos + instance.Offset;
                float    z = pos.z;
                Vector2I cellXY;
                bool     always = visType == KAnimControllerBase.VisibilityType.Always;
                transform.hasChanged = false;
                // If this is the only anim in the batch, and the Z coordinate changed,
                // override the Z in the batch
                if (batch.group.maxGroupSize == 1 && instance.lastPos.z != z)
                {
                    batch.OverrideZ(z);
                }
                instance.lastPos = posWithOffset;
                // This is basically GetCellXY() with less accesses to __instance.transform
                if (Grid.CellSizeInMeters == 0.0f)
                {
                    // Handle out-of-game
                    cellXY = new Vector2I((int)posWithOffset.x, (int)posWithOffset.y);
                }
                else
                {
                    cellXY = Grid.PosToXY(posWithOffset);
                }
                if (!always && lastChunk != KBatchedAnimUpdater.INVALID_CHUNK_ID &&
                    KAnimBatchManager.CellXYToChunkXY(cellXY) != lastChunk)
                {
                    // Re-register in a different batch
                    instance.DeRegister();
                    instance.Register();
                }
                else if (visible || always)
                {
                    // Only set dirty if it is on-screen now - changing visible sets dirty
                    // If it moved into a different chunk, Register sets dirty
                    instance.SetDirty();
                }
            }
            // If it has a batch, and is active
            if (instance.batchGroupID != KAnimBatchManager.NO_BATCH)
            {
                var   anim = instance.curAnim;
                var   mode = instance.mode;
                bool  force = instance.forceRebuild, stopped = instance.stopped;
                float t = instance.elapsedTime, increment = dt * instance.playSpeed;
                // Suspend updates if: not currently suspended, not force update, and one
                // of (paused, stopped, no anim, one time and finished with no more to play)
                if (!instance.suspendUpdates && !force && (mode == KAnim.PlayMode.Paused ||
                                                           stopped || anim == null || (mode == KAnim.PlayMode.Once && (t > anim.
                                                                                                                       totalTime || anim.totalTime <= 0f) && instance.animQueue.Count == 0)))
                {
                    instance.SuspendUpdates(true);
                }
                if (visible || force)
                {
                    var aem    = instance.aem;
                    var handle = instance.eventManagerHandle;
                    instance.curAnimFrameIdx = instance.GetFrameIdx(t, true);
                    // Trigger anim event manager if time advanced more than 0.01s
                    if (handle.IsValid() && aem != null)
                    {
                        float elapsedTime = aem.GetElapsedTime(handle);
                        if (Math.Abs(t - elapsedTime) > 0.01f)
                        {
                            aem.SetElapsedTime(handle, t);
                        }
                    }
                    instance.UpdateFrame(t);
                    // Time can be mutated by UpdateFrame
                    if (!stopped && mode != KAnim.PlayMode.Paused)
                    {
                        instance.SetElapsedTime(instance.elapsedTime + increment);
                    }
                    instance.forceRebuild = false;
                }
                else if (visType == KAnimControllerBase.VisibilityType.OffscreenUpdate &&
                         !stopped && mode != KAnim.PlayMode.Paused)
                {
                    // If invisible, only advance if offscreen update is enabled
                    instance.SetElapsedTime(t + increment);
                }
            }
        }
        private void StyleRadioButtons()
        {
            switch ((ALMIntegration.eALMType)WorkSpace.Instance.Solution.AlmType)
            {
            case ALMIntegration.eALMType.QC:
                QCRadioButton.IsChecked  = true;
                QCRadioButton.FontWeight = FontWeights.ExtraBold;
                QCRadioButton.Foreground = (SolidColorBrush)FindResource("$SelectionColor_Pink");
                RQMLoadConfigPackageButton.Visibility = Visibility.Collapsed;
                DownloadPackageLink.Visibility        = Visibility.Collapsed;
                Grid.SetColumnSpan(ServerURLTextBox, 2);
                ExampleURLHint.Content = "Example: http://server:8080/almbin";
                if (!isServerDetailsCorrect)
                {
                    ServerURLTextBox.IsEnabled  = true;
                    ServerURLTextBox.IsReadOnly = false;
                }
                else
                {
                    ServerURLTextBox.IsEnabled  = false;
                    ServerURLTextBox.IsReadOnly = true;
                }
                ServerURLTextBox.Cursor     = null;
                RQMRadioButton.FontWeight   = FontWeights.Regular;
                RQMRadioButton.Foreground   = Brushes.Black;
                RQMRadioButton.IsChecked    = false;
                RallyRadioButton.FontWeight = FontWeights.Regular;
                RallyRadioButton.Foreground = Brushes.Black;
                RallyRadioButton.IsChecked  = false;
                RestAPICheckBox.Visibility  = Visibility.Visible;
                JiraRadioButton.IsChecked   = false;
                JiraRadioButton.FontWeight  = FontWeights.Regular;
                JiraRadioButton.Foreground  = Brushes.Black;
                break;

            case ALMIntegration.eALMType.RQM:
                RQMRadioButton.IsChecked              = true;
                RQMRadioButton.FontWeight             = FontWeights.ExtraBold;
                RQMRadioButton.Foreground             = (SolidColorBrush)FindResource("$SelectionColor_Pink");
                RQMLoadConfigPackageButton.Visibility = Visibility.Visible;
                DownloadPackageLink.Visibility        = Visibility.Visible;
                Grid.SetColumnSpan(ServerURLTextBox, 1);
                SetLoadPackageButtonContent();
                ServerURLTextBox.IsReadOnly = true;
                ServerURLTextBox.IsEnabled  = false;
                ServerURLTextBox.Cursor     = Cursors.Arrow;
                QCRadioButton.FontWeight    = FontWeights.Regular;
                QCRadioButton.Foreground    = Brushes.Black;
                QCRadioButton.IsChecked     = false;
                RallyRadioButton.FontWeight = FontWeights.Regular;
                RallyRadioButton.Foreground = Brushes.Black;
                RallyRadioButton.IsChecked  = false;
                RestAPICheckBox.Visibility  = Visibility.Hidden;
                JiraRadioButton.IsChecked   = false;
                JiraRadioButton.FontWeight  = FontWeights.Regular;
                JiraRadioButton.Foreground  = Brushes.Black;
                break;

            case ALMIntegration.eALMType.RALLY:
                RallyRadioButton.IsChecked            = true;
                RallyRadioButton.FontWeight           = FontWeights.ExtraBold;
                RallyRadioButton.Foreground           = (SolidColorBrush)FindResource("$SelectionColor_Pink");
                RQMLoadConfigPackageButton.Visibility = Visibility.Collapsed;
                DownloadPackageLink.Visibility        = Visibility.Collapsed;
                Grid.SetColumnSpan(ServerURLTextBox, 2);
                ExampleURLHint.Content = "Example: http://server:8080/almbin";
                if (!isServerDetailsCorrect)
                {
                    ServerURLTextBox.IsEnabled  = true;
                    ServerURLTextBox.IsReadOnly = false;
                }
                else
                {
                    ServerURLTextBox.IsEnabled  = false;
                    ServerURLTextBox.IsReadOnly = true;
                }
                ServerURLTextBox.Cursor    = null;
                QCRadioButton.FontWeight   = FontWeights.Regular;
                QCRadioButton.Foreground   = Brushes.Black;
                QCRadioButton.IsChecked    = false;
                RQMRadioButton.FontWeight  = FontWeights.Regular;
                RQMRadioButton.Foreground  = Brushes.Black;
                RQMRadioButton.IsChecked   = false;
                RestAPICheckBox.Visibility = Visibility.Hidden;
                JiraRadioButton.IsChecked  = false;
                JiraRadioButton.FontWeight = FontWeights.Regular;
                JiraRadioButton.Foreground = Brushes.Black;
                break;

            case ALMIntegration.eALMType.Jira:
                JiraRadioButton.IsChecked             = true;
                JiraRadioButton.FontWeight            = FontWeights.ExtraBold;
                JiraRadioButton.Foreground            = (SolidColorBrush)FindResource("$SelectionColor_Pink");
                RQMLoadConfigPackageButton.Visibility = Visibility.Visible;
                DownloadPackageLink.Visibility        = Visibility.Visible;
                Grid.SetColumnSpan(ServerURLTextBox, 2);
                SetLoadJiraPackageButtonContent();
                if (!isServerDetailsCorrect)
                {
                    ServerURLTextBox.IsEnabled  = true;
                    ServerURLTextBox.IsReadOnly = false;
                }
                else
                {
                    ServerURLTextBox.IsEnabled  = false;
                    ServerURLTextBox.IsReadOnly = true;
                }
                ServerURLTextBox.Cursor     = null;
                QCRadioButton.FontWeight    = FontWeights.Regular;
                QCRadioButton.Foreground    = Brushes.Black;
                QCRadioButton.IsChecked     = false;
                RQMRadioButton.FontWeight   = FontWeights.Regular;
                RQMRadioButton.Foreground   = Brushes.Black;
                RQMRadioButton.IsChecked    = false;
                RestAPICheckBox.Visibility  = Visibility.Hidden;
                RallyRadioButton.IsChecked  = false;
                RallyRadioButton.FontWeight = FontWeights.Regular;
                RallyRadioButton.Foreground = Brushes.Black;
                break;
            }
        }
        private void AnchoringWithOffsetCoercion(bool reduceAnchorOffset)
        {
            using (ScrollPresenterTestHooksHelper scrollPresenterTestHooksHelper = new ScrollPresenterTestHooksHelper(
                       enableAnchorNotifications: true,
                       enableInteractionSourcesNotifications: true,
                       enableExpressionAnimationStatusNotifications: false))
            {
                ScrollPresenter scrollPresenter                     = null;
                Border          anchorElement                       = null;
                AutoResetEvent  scrollPresenterLoadedEvent          = new AutoResetEvent(false);
                AutoResetEvent  scrollPresenterViewChangedEvent     = new AutoResetEvent(false);
                AutoResetEvent  scrollPresenterAnchorRequestedEvent = new AutoResetEvent(false);

                // This test validates that the ScrollPresenter accounts for maximum vertical offset (based on viewport and content extent)
                // when calculating the vertical offset shift for anchoring. The vertical offset cannot exceed content extent - viewport.

                RunOnUIThread.Execute(() =>
                {
                    Log.Comment("Visual tree setup");
                    anchorElement = new Border
                    {
                        Width             = 100,
                        Height            = 100,
                        Background        = new SolidColorBrush(Colors.Red),
                        Margin            = new Thickness(0, 600, 0, 0),
                        VerticalAlignment = VerticalAlignment.Top
                    };

                    Grid grid = new Grid();
                    grid.Children.Add(anchorElement);
                    grid.Width      = 200;
                    grid.Height     = 1000;
                    grid.Background = new SolidColorBrush(Colors.Gray);

                    scrollPresenter = new ScrollPresenter
                    {
                        Content = grid,
                        Width   = 200,
                        Height  = 200
                    };

                    scrollPresenter.Loaded += (object sender, RoutedEventArgs e) =>
                    {
                        Log.Comment("ScrollPresenter.Loaded event handler");
                        scrollPresenterLoadedEvent.Set();
                    };

                    scrollPresenter.ViewChanged += delegate(ScrollPresenter sender, object args)
                    {
                        Log.Comment("ViewChanged - HorizontalOffset={0}, VerticalOffset={1}, ZoomFactor={2}",
                                    sender.HorizontalOffset, sender.VerticalOffset, sender.ZoomFactor);
                        Log.Comment("ViewChanged - CurrentAnchor is " + (sender.CurrentAnchor == null ? "null" : "non-null"));
                        if ((reduceAnchorOffset && sender.VerticalOffset == 400) ||
                            (!reduceAnchorOffset && sender.VerticalOffset == 500))
                        {
                            scrollPresenterViewChangedEvent.Set();
                        }
                    };

                    scrollPresenter.AnchorRequested += delegate(ScrollPresenter sender, ScrollingAnchorRequestedEventArgs args)
                    {
                        Log.Comment("AnchorRequested - Forcing the red Border to be the ScrollPresenter anchor.");
                        args.AnchorElement = anchorElement;
                        scrollPresenterAnchorRequestedEvent.Set();
                    };

                    Log.Comment("Setting window content");
                    Content = scrollPresenter;
                });

                WaitForEvent("Waiting for ScrollPresenter.Loaded event", scrollPresenterLoadedEvent);
                IdleSynchronizer.Wait();

                ScrollTo(scrollPresenter, 0.0, 600.0, ScrollingAnimationMode.Disabled, ScrollingSnapPointsMode.Ignore);

                RunOnUIThread.Execute(() =>
                {
                    Verify.AreEqual(600, scrollPresenter.VerticalOffset);

                    Log.Comment("ScrollPresenter.Content height is reduced by 300px. ScrollPresenter.VerticalOffset is expected to be reduced by 100px (600 -> 500).");
                    (scrollPresenter.Content as Grid).Height = 700;
                    if (reduceAnchorOffset)
                    {
                        Log.Comment("Tracked element is shifted up by 200px within the ScrollPresenter.Content (600 -> 400). Anchoring is expected to reduce the VerticalOffset by half of that (500 -> 400).");
                        anchorElement.Margin = new Thickness(0, 400, 0, 0);
                    }
                    scrollPresenterViewChangedEvent.Reset();
                });

                WaitForEvent("Waiting for ScrollPresenter.ViewChanged event", scrollPresenterViewChangedEvent);
                WaitForEvent("Waiting for ScrollPresenter.AnchorRequested event", scrollPresenterAnchorRequestedEvent);
                IdleSynchronizer.Wait();

                RunOnUIThread.Execute(() =>
                {
                    Verify.AreEqual(reduceAnchorOffset ? 400 : 500, scrollPresenter.VerticalOffset);

                    Log.Comment("ScrollPresenter CurrentAnchor is " + (scrollPresenter.CurrentAnchor == null ? "null" : "non-null"));
                    Verify.IsNotNull(scrollPresenter.CurrentAnchor);
                });
            }
        }
Example #50
0
 public Background(Grid grid)
 {
     _stars = new List <Star>();
     _grid  = grid;
 }
Example #51
0
        // Method create board
        private void CreateBoard()
        {
            // Create grid for the gameboard
            #region gridBoard
            Grid gridBoard = new Grid
            {
                Name = "GameBoard",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top,
                Height     = 1000,
                Width      = 1000,
                Background = new SolidColorBrush(Colors.MintCream),
                Margin     = new Thickness(5),
            };
            gridBoard.SetValue(Grid.RowProperty, 2);
            gridBoard.SetValue(Grid.ColumnProperty, 2);
            gridBoard.RowDefinitions.Add(new RowDefinition());
            gridBoard.RowDefinitions.Add(new RowDefinition());
            gridBoard.RowDefinitions.Add(new RowDefinition());
            gridBoard.ColumnDefinitions.Add(new ColumnDefinition());
            gridBoard.ColumnDefinitions.Add(new ColumnDefinition());
            gridBoard.RowDefinitions[0].Height   = new GridLength(100);
            gridBoard.RowDefinitions[2].Height   = new GridLength(400);
            gridBoard.ColumnDefinitions[1].Width = new GridLength(250);

            // Frame the grid
            frame = new Border()
            {
                BorderBrush     = new SolidColorBrush(Colors.Black),
                BorderThickness = new Thickness(2)
            };
            frame.SetValue(Grid.RowSpanProperty, 3);
            frame.SetValue(Grid.ColumnSpanProperty, 2);
            gridBoard.Children.Add(frame);

            parentGrid.Children.Add(gridBoard);
            #endregion

            // Create grid for the answer pegs
            #region answerGrid
            Grid answerGrid = new Grid
            {
                Name = "AnswerGrid",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = 100,
                Width  = 1000,
                Margin = new Thickness(5)
            };
            answerGrid.SetValue(Grid.RowProperty, 0);
            answerGrid.SetValue(Grid.ColumnSpanProperty, 2);
            answerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            answerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            answerGrid.ColumnDefinitions.Add(new ColumnDefinition());
            answerGrid.ColumnDefinitions.Add(new ColumnDefinition());

            // Frame the grid
            frame = new Border()
            {
                BorderBrush     = new SolidColorBrush(Colors.Black),
                BorderThickness = new Thickness(2)
            };
            frame.SetValue(Grid.ColumnSpanProperty, _columns);
            answerGrid.Children.Add(frame);

            PlaceAnswerPegs(answerGrid); // place answer pegs
            gridBoard.Children.Add(answerGrid);
            #endregion

            // Create grid for the display pegs
            #region displayGrid
            Grid displayGrid = new Grid
            {
                Name = "DisplayGrid",
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = 1000,
                Width  = 1000,
                Margin = new Thickness(5)
            };
            displayGrid.SetValue(Grid.RowProperty, 1);
            displayGrid.SetValue(Grid.ColumnProperty, 0);

            for (i = 0; i < _rows; i++)
            {
                displayGrid.RowDefinitions.Add(new RowDefinition());
                displayGrid.RowDefinitions[i].Height = new GridLength(90);
                for (j = 0; j < _columns; j++)
                {
                    displayGrid.ColumnDefinitions.Add(new ColumnDefinition());
                    displayGrid.ColumnDefinitions[j].Width = new GridLength(180);
                } // for j
            }     // for i

            // Frame the grid
            frame = new Border()
            {
                BorderBrush     = new SolidColorBrush(Colors.Black),
                BorderThickness = new Thickness(2)
            };
            frame.SetValue(Grid.RowSpanProperty, _rows);
            frame.SetValue(Grid.ColumnSpanProperty, _columns);
            displayGrid.Children.Add(frame);

            PlaceEmptyPegs(displayGrid); // Place empty pegs
            gridBoard.Children.Add(displayGrid);
            #endregion

            // Create grid for the feedback pegs
            #region feedbackGrid
            Grid feedbackGrid = new Grid
            {
                Name = "FeedbackGrid",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = 1000,
                Width  = 1000,
                Margin = new Thickness(5)
            };
            feedbackGrid.SetValue(Grid.RowProperty, 1);
            feedbackGrid.SetValue(Grid.ColumnProperty, 2);
            for (i = 0; i < _rows; i++)
            {
                feedbackGrid.RowDefinitions.Add(new RowDefinition());
                feedbackGrid.RowDefinitions[i].Height = new GridLength(90);
            } // for i

            // Frame the grid
            frame = new Border()
            {
                BorderBrush     = new SolidColorBrush(Colors.Black),
                BorderThickness = new Thickness(2)
            };
            frame.SetValue(Grid.RowSpanProperty, _rows);
            feedbackGrid.Children.Add(frame);

            PlaceEmptyFeedbackPegs(feedbackGrid); // Place empty feedback pegs
            gridBoard.Children.Add(feedbackGrid);
            #endregion

            // Create grid for the choose pegs
            #region chooseGrid
            Grid chooseGrid = new Grid
            {
                Name = "ChooseGrid",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top,
                Height = 1000,
                Width  = 1000,
                Margin = new Thickness(5)
            };
            chooseGrid.SetValue(Grid.RowProperty, 2);
            chooseGrid.SetValue(Grid.ColumnSpanProperty, 2);
            chooseGrid.RowDefinitions.Add(new RowDefinition());
            chooseGrid.RowDefinitions.Add(new RowDefinition());
            chooseGrid.RowDefinitions[0].Height = new GridLength(100);
            chooseGrid.RowDefinitions[1].Height = new GridLength(100);
            for (i = 0; i < _columns; i++)
            {
                chooseGrid.ColumnDefinitions.Add(new ColumnDefinition());
            } // for

            // Frame the grid
            frame = new Border()
            {
                BorderBrush     = new SolidColorBrush(Colors.Black),
                BorderThickness = new Thickness(2)
            };
            frame.SetValue(Grid.RowSpanProperty, 2);
            frame.SetValue(Grid.ColumnSpanProperty, _columns);
            chooseGrid.Children.Add(frame);

            PlaceChoosePegs(chooseGrid); // Place choose pegs
            gridBoard.Children.Add(chooseGrid);
            #endregion
        } // CreateBoard()
Example #52
0
        public EventDialog(Campaign campaign, Event evt, Timestamp timestamp, String title, String player, Window owner = null)
        {
            InitializeComponent();
            this.evt       = evt;
            this.timestamp = timestamp;
            this.campaign  = campaign;
            this.Title     = title;
            if (owner != null)
            {
                this.Owner = owner;
            }
            bool             canEdit = this.evt.canEdit(player);
            ColumnDefinition cd;
            RowDefinition    rd;
            Label            lbl;
            Grid             g;

            if (this.timestamp != null)
            {
                this.parentGrp.Header = "Date/Time";
                if (this.evt.duration == null)
                {
                    this.evt.duration = new TimeSpan(this.timestamp.calendar, 0);
                }
                cd       = new ColumnDefinition();
                cd.Width = GridLength.Auto;
                this.parentGrid.ColumnDefinitions.Add(cd);
                this.parentGrid.ColumnDefinitions.Add(new ColumnDefinition());
                cd       = new ColumnDefinition();
                cd.Width = GridLength.Auto;
                this.parentGrid.ColumnDefinitions.Add(cd);
                this.parentGrid.ColumnDefinitions.Add(new ColumnDefinition());
                rd        = new RowDefinition();
                rd.Height = GridLength.Auto;
                this.parentGrid.RowDefinitions.Add(rd);
                Button startBut = new Button();
                startBut.Content = "Start:";
                startBut.Click  += this.setStart;
                Grid.SetRow(startBut, 0);
                Grid.SetColumn(startBut, 0);
                this.parentGrid.Children.Add(startBut);
                this.startBox            = new TextBox();
                this.startBox.IsReadOnly = true;
                this.startBox.Text       = (this.timestamp - this.evt.duration).toString(true, true);
                Grid.SetRow(this.startBox, 0);
                Grid.SetColumn(this.startBox, 1);
                this.parentGrid.Children.Add(this.startBox);
                Button endBut = new Button();
                endBut.Content = "End:";
                endBut.Click  += this.setEnd;
                Grid.SetRow(endBut, 0);
                Grid.SetColumn(endBut, 2);
                this.parentGrid.Children.Add(endBut);
                this.endBox            = new TextBox();
                this.endBox.IsReadOnly = true;
                this.endBox.Text       = this.timestamp.toString(true, true);
                Grid.SetRow(this.endBox, 0);
                Grid.SetColumn(this.endBox, 3);
                this.parentGrid.Children.Add(this.endBox);
                rd        = new RowDefinition();
                rd.Height = GridLength.Auto;
                this.parentGrid.RowDefinitions.Add(rd);
                Button durBut = new Button();
                durBut.Content = "Duration:";
                durBut.Click  += this.setDuration;
                Grid.SetRow(durBut, 1);
                Grid.SetColumn(durBut, 0);
                this.parentGrid.Children.Add(durBut);
                this.durBox            = new TextBox();
                this.durBox.IsReadOnly = true;
                this.durBox.Text       = this.evt.duration.toString(true);
                Grid.SetRow(this.durBox, 1);
                Grid.SetColumn(this.durBox, 1);
                Grid.SetColumnSpan(this.durBox, 3);
                this.parentGrid.Children.Add(this.durBox);
                if (!canEdit)
                {
                    startBut.IsEnabled = false;
                    endBut.IsEnabled   = false;
                    durBox.IsEnabled   = false;
                }
            }
            else
            {
                this.parentGrp.Header = "Parent";
                this.parentGrid.ColumnDefinitions.Add(new ColumnDefinition());
                rd        = new RowDefinition();
                rd.Height = GridLength.Auto;
                this.parentGrid.RowDefinitions.Add(rd);
                lbl = new Label();
                if (this.evt != null)
                {
                    lbl.Content = this.evt.parent.parent.title;
                }
                else
                {
                    lbl.Content = "Event is in vault";
                }
                Grid.SetRow(lbl, 0);
                Grid.SetColumn(lbl, 0);
                this.parentGrid.Children.Add(lbl);
            }
            g         = new Grid();
            rd        = new RowDefinition();
            rd.Height = GridLength.Auto;
            this.parentGrid.RowDefinitions.Add(rd);
            cd       = new ColumnDefinition();
            cd.Width = GridLength.Auto;
            g.ColumnDefinitions.Add(cd);
            g.ColumnDefinitions.Add(new ColumnDefinition());
            rd        = new RowDefinition();
            rd.Height = GridLength.Auto;
            g.RowDefinitions.Add(rd);
            Button tsBut = new Button();

            tsBut.Content = "Timestamp:";
/////
//
            //button click handler
//
/////
            Grid.SetRow(tsBut, 0);
            Grid.SetColumn(tsBut, 0);
            g.Children.Add(tsBut);
            this.tsBox            = new TextBox();
            this.tsBox.IsReadOnly = true;
            this.tsBox.Text       = this.evt.timestamp.ToLocalTime().ToString();
            Grid.SetRow(this.tsBox, 0);
            Grid.SetColumn(this.tsBox, 1);
            g.Children.Add(this.tsBox);
            Grid.SetRow(g, this.parentGrid.RowDefinitions.Count);
            Grid.SetColumn(g, 0);
            Grid.SetColumnSpan(g, this.parentGrid.ColumnDefinitions.Count);
            this.parentGrid.Children.Add(g);
/////
//
            //this.descGrid:
            //[notes label] if this.evt.canViewNotes(player)
            //[notes box] if this.evt.canViewNotes(player) (deal with notesBox if not canEdit)
            //anything dynamic for this.resGrid
//
/////
            this.viewersLst.Items.SortDescriptions.Add(new SortDescription("", ListSortDirection.Ascending));
            if (this.evt.viewers == null)
            {
                this.viewersLst.Items.Add("<Everyone>");
            }
            else
            {
                foreach (String p in this.evt.viewers)
                {
                    this.viewersLst.Items.Add(this.getPlayer(p));
                }
            }
            this.viewersLst.Items.Refresh();
            this.editorsLst.Items.SortDescriptions.Add(new SortDescription("", ListSortDirection.Ascending));
            if (this.evt.editors == null)
            {
                this.editorsLst.Items.Add("<Everyone>");
            }
            else
            {
                foreach (String p in this.evt.editors)
                {
                    this.editorsLst.Items.Add(this.getPlayer(p));
                }
            }
            this.editorsLst.Items.Refresh();
            if (!canEdit)
            {
                tsBut.IsEnabled          = false;
                this.titleBox.IsReadOnly = true;
                this.descBox.IsReadOnly  = true;
/////
//
                //disable results edit stuff
//
/////
                this.virtBox.IsEnabled = false;
/////
//
                //disable other edit stuff
//
/////
                this.okBut.Visibility  = Visibility.Hidden;
                this.cancelBut.Content = "Done";
            }
            if ((!this.evt.canAssign(player)) && (!this.evt.canClaim(player)))
            {
                this.ownerBut.IsEnabled = false;
            }
            if (!this.evt.canSetPermissions(player))
            {
                this.viewerAddBut.IsEnabled  = false;
                this.viewerRemBut.IsEnabled  = false;
                this.viewerAllBut.IsEnabled  = false;
                this.viewerNoneBut.IsEnabled = false;
                this.editorAddBut.IsEnabled  = false;
                this.editorRemBut.IsEnabled  = false;
                this.editorAllBut.IsEnabled  = false;
                this.editorNoneBut.IsEnabled = false;
            }
        }
Example #53
0
        } // CreateBoard()

        #region Place Pegs on Boards Methods
        // Method place pegs that user can choose
        private void PlaceChoosePegs(Grid chooseGrid)
        {
            // Variables
            Ellipse    choosePeg;
            StackPanel stackPanel;

            // For loop 2 rows and 4 columns
            for (i = 0; i < 2; i++)
            {
                for (j = 0; j < _columns; j++)
                {
                    stackPanel = new StackPanel()
                    {
                        Height = 80,
                        Width  = 80,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center,
                    };

                    choosePeg = new Ellipse
                    {
                        Height = 80,
                        Width  = 80,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment   = VerticalAlignment.Center,
                        Stroke          = new SolidColorBrush(Colors.Black),
                        StrokeThickness = 2
                    };

                    // each pegs different colors
                    if (i == 0)
                    {
                        switch (j)
                        {
                        case 0:
                            choosePeg.Name = "red";
                            choosePeg.Fill = new SolidColorBrush(Colors.Red);
                            break;

                        case 1:
                            choosePeg.Name = "orange";
                            choosePeg.Fill = new SolidColorBrush(Colors.Orange);
                            break;

                        case 2:
                            choosePeg.Name = "yellow";
                            choosePeg.Fill = new SolidColorBrush(Colors.Yellow);
                            break;

                        case 3:
                            choosePeg.Name = "green";
                            choosePeg.Fill = new SolidColorBrush(Colors.Green);
                            break;
                        } // switch
                    }     // if
                    else
                    {
                        switch (j)
                        {
                        case 0:
                            choosePeg.Name = "blue";
                            choosePeg.Fill = new SolidColorBrush(Colors.Blue);
                            break;

                        case 1:
                            choosePeg.Name = "indigo";
                            choosePeg.Fill = new SolidColorBrush(Colors.Indigo);
                            break;

                        case 2:
                            choosePeg.Name = "violet";
                            choosePeg.Fill = new SolidColorBrush(Colors.Violet);
                            break;

                        case 3:
                            choosePeg.Name = "pink";
                            choosePeg.Fill = new SolidColorBrush(Colors.Pink);
                            break;
                        } // switch
                    }     // else

                    // Tapped event
                    choosePeg.Tapped += Choose_Tapped;

                    // Add to parent
                    stackPanel.Children.Add(choosePeg);
                    stackPanel.SetValue(Grid.RowProperty, i);
                    stackPanel.SetValue(Grid.ColumnProperty, j);
                    chooseGrid.Children.Add(stackPanel);
                } // for j
            }     // for i
        }         // PlaceChoosePegs()
Example #54
0
        }     // FeedbackPegs()

        // Method Game Over
        private void GameOver()
        {
            // Variables
            Grid       gameOverGrid;
            StackPanel stackPanel;
            TextBlock  textBlock;
            Button     restartBtn;
            Ellipse    answerPeg;

            // Reveal answer pegs
            for (i = 0; i < _columns; i++)
            {
                answerPeg = FindName("questionPeg " + (i + 1).ToString()) as Ellipse;
                switch (i)
                {
                case 0:
                    answerPeg.Fill = answerPeg1.Fill;
                    break;

                case 1:
                    answerPeg.Fill = answerPeg2.Fill;
                    break;

                case 2:
                    answerPeg.Fill = answerPeg3.Fill;
                    break;

                case 3:
                    answerPeg.Fill = answerPeg4.Fill;
                    break;
                } // switch
            }     // for

            gameOverGrid = new Grid()
            {
                Name = "GameOverGrid",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top,
                Height     = 1000,
                Width      = 1000,
                Background = new SolidColorBrush(Colors.MintCream),
                Margin     = new Thickness(5)
            };
            gameOverGrid.RowDefinitions.Add(new RowDefinition());
            gameOverGrid.SetValue(Grid.RowProperty, 2);
            gameOverGrid.SetValue(Grid.ColumnProperty, 0);

            stackPanel = new StackPanel()
            {
                Height = 1000,
                Width  = 1000,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };

            textBlock = new TextBlock()
            {
                Height              = 500,
                Width               = 500,
                Foreground          = new SolidColorBrush(Colors.Red),
                FontSize            = 20,
                TextAlignment       = TextAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            if (win)
            {
                textBlock.Text = "Game Over! You Win!";
            }
            else
            {
                textBlock.Text = "Game Over! You Lose!";
            } // if

            restartBtn = new Button()
            {
                Content             = "Play Again",
                Tag                 = "restart",
                Margin              = new Thickness(10),
                Width               = 150,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top
            };

            restartBtn.Click += Button_Click;

            stackPanel.Children.Add(textBlock);
            stackPanel.Children.Add(restartBtn);
            stackPanel.SetValue(Grid.RowProperty, 0);
            gameOverGrid.Children.Add(stackPanel);
            parentGrid.Children.Add(gameOverGrid);
        } // GameOver()
Example #55
0
        private void GenerateButton(AppSelectorData AppSelectorData, int index)
        {
            btnGrid = new Grid()
            {
                Margin  = new Thickness(0),
                Padding = new Thickness(0)
            };
            if (this.ShowMessages && this.MainOrientation == Orientation.Vertical)
            {
                btnGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.5, GridUnitType.Star)
                });
                btnGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.5, GridUnitType.Star)
                });
                btnGrid.ColumnSpacing = WIDTH_GRID_COLUMNSPACING;
            }

            ImagePair images = new ImagePair()
            {
                //ID = i,
                Selected = new Image()
                {
                    Width = this.ButtonWidth,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                },
                NotSelected = new Image()
                {
                    Width = this.ButtonWidth,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Opacity             = 1.0
                }
            };

            if (!string.IsNullOrEmpty(AppSelectorData.Source_NotSelectedImage))
            {
                images.NotSelected.Source = new BitmapImage()
                {
                    UriSource = new Uri(AppSelectorData.Source_NotSelectedImage), DecodePixelWidth = (int)this.ButtonWidth
                };
            }
            else if (!string.IsNullOrEmpty(AppSelectorData.SourceSVG_NotSelectedImage))
            {
                images.NotSelected.Source = new SvgImageSource(new Uri(AppSelectorData.SourceSVG_NotSelectedImage));
            }

            if (!string.IsNullOrEmpty(AppSelectorData.Source_SelectedImage))
            {
                images.Selected.Source = new BitmapImage()
                {
                    UriSource = new Uri(AppSelectorData.Source_SelectedImage), DecodePixelWidth = (int)this.ButtonWidth
                };
            }
            else if (!string.IsNullOrEmpty(AppSelectorData.SourceSVG_SelectedImage))
            {
                images.Selected.Source = new SvgImageSource(new Uri(AppSelectorData.SourceSVG_SelectedImage));
            }
            //images.Selected.Source
            Grid.SetRow(images.NotSelected, 0);
            Grid.SetColumn(images.NotSelected, 0);
            btnGrid.Children.Add(images.NotSelected);
            Grid.SetRow(images.Selected, 0);
            Grid.SetColumn(images.Selected, 0);
            btnGrid.Children.Add(images.Selected);

            if (this.MainOrientation == Orientation.Vertical && this.ShowMessages)
            {
                TextBlockEx tbMessage = new TextBlockEx()
                {
                    Name              = "Text",
                    Text              = AppSelectorData.Message,
                    TextStyle         = TextStyles.AppSelectorText,
                    FontSize          = 20,
                    Opacity           = 1,
                    VerticalAlignment = VerticalAlignment.Center,
                    TextStyleBold     = TextStyles.AppSelectorTextBold
                                        //TextStyleBold = (IsListView ? TextStyles.AppSelectorTextDarkBold: TextStyles.AppSelectorTextBold)
                };

                if (index == 0)
                {
                    tbMessage.ShowBoldText(true);
                }

                Grid.SetRow(tbMessage, 0);
                Grid.SetColumn(tbMessage, 1);// kk this isnt working just yet.
                btnGrid.Children.Add(tbMessage);
            }
            if (!AppSelectorData.IsClearButton)
            {
                this.ImagePairs.Add(index, images);
            }

            HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center;

            // if we need to show messages then align left
            if (this.MainOrientation == Orientation.Vertical && this.ShowMessages)
            {
                horizontalAlignment = HorizontalAlignment.Left;
            }

            AppSelectorButton sbButton = new AppSelectorButton()
            {
                ID                  = index,
                Background          = new SolidColorBrush(Colors.Transparent),
                HorizontalAlignment = horizontalAlignment,
                VerticalAlignment   = VerticalAlignment.Center,
                Content             = btnGrid
            };

            //if (!IsListView)
            //{
            //    sbButton.Background = new SolidColorBrush(Colors.Transparent);
            //}
            //else
            //{
            //    sbButton.NormalBackground = (index % 2 == 0 ? BackGroundWhiteAcrylic : BackGroundGrayAcrylic);
            //    if (index == 0)
            //    {
            //        sbButton.Background = new SolidColorBrush(Colors.Blue);
            //    }
            //    else
            //    {
            //        sbButton.Background = sbButton.NormalBackground;
            //    }

            //}

            //only set the dimensions of the button if the control variables are passed in
            // and the orientation is correct
            if (this.ButtonHeight > 0)
            {
                sbButton.Height = this.ButtonHeight;
            }

            // if u need to show messages, dont set the width b/c theres no way to figure out the width
            // if there is text
            if (this.ButtonWidth > 0 && (!this.ShowMessages && !(this.MainOrientation == Orientation.Vertical)))
            {
                sbButton.Width = this.ButtonWidth;
            }
            if (null != _buttonStyle)
            {
                sbButton.Style = _buttonStyle;
            }
            ;

            if (AppSelectorData.IsClearButton)
            {// these buttons get their own handler and dont change the selection of the app selector
                sbButton.AddHandler(PointerReleasedEvent, new PointerEventHandler(Selector_ClearButtonClick), true);
            }
            else
            {
                sbButton.AddHandler(PointerReleasedEvent, new PointerEventHandler(Selector_ButtonClick), true);
            }
            btnGrid.PointerEntered += pointerEntered;


            if (this.MainOrientation == Orientation.Horizontal)
            {
                Grid.SetRow(sbButton, 0);
                Grid.SetColumn(sbButton, index);
            }
            else // vertical
            {
                Grid.SetColumn(sbButton, 0);
                Grid.SetRow(sbButton, index);
            }
            if (!AppSelectorData.IsClearButton)
            {// clear button is not a part of the regular buttons
                this.Buttons.Add(sbButton);
            }
            _layoutRoot.Children.Add(sbButton);
            _buttonList.Add(sbButton);
        }
Example #56
0
        }     // PlaceEmptyFeedbackPegs

        // Method place answer pegs into the board
        private void PlaceAnswerPegs(Grid answerGrid)
        {
            // Variables
            Ellipse    questionPeg;
            StackPanel stackPanel;
            // Image brush for the ellipse texture
            ImageBrush ellipseBackground = new ImageBrush();

            ellipseBackground.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/questionMark.png", UriKind.Absolute));

            // For loop 4 columns
            for (i = 0; i < _columns; i++)
            {
                stackPanel = new StackPanel()
                {
                    Height = 80,
                    Width  = 80,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                };

                questionPeg = new Ellipse
                {
                    Name   = "questionPeg " + (i + 1).ToString(),
                    Height = 80,
                    Width  = 80,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Stroke          = new SolidColorBrush(Colors.Black),
                    StrokeThickness = 2,
                    Fill            = ellipseBackground
                };

                // Create answer pegs with while loop prevent duplicate colors
                if (i == 0)
                {
                    answerPeg1 = CreateAnswerPegs(i);
                }
                else if (i == 1)
                {
                    answerPeg2 = CreateAnswerPegs(i);
                    while (((SolidColorBrush)answerPeg2.Fill).Color == ((SolidColorBrush)answerPeg1.Fill).Color)
                    {
                        answerPeg2 = CreateAnswerPegs(i);
                    }
                }
                else if (i == 2)
                {
                    answerPeg3 = CreateAnswerPegs(i);
                    while (((SolidColorBrush)answerPeg3.Fill).Color == ((SolidColorBrush)answerPeg2.Fill).Color ||
                           ((SolidColorBrush)answerPeg3.Fill).Color == ((SolidColorBrush)answerPeg1.Fill).Color)
                    {
                        answerPeg3 = CreateAnswerPegs(i);
                    }
                }
                else
                {
                    answerPeg4 = CreateAnswerPegs(i);
                    while (((SolidColorBrush)answerPeg4.Fill).Color == ((SolidColorBrush)answerPeg3.Fill).Color ||
                           ((SolidColorBrush)answerPeg4.Fill).Color == ((SolidColorBrush)answerPeg2.Fill).Color ||
                           ((SolidColorBrush)answerPeg4.Fill).Color == ((SolidColorBrush)answerPeg1.Fill).Color)
                    {
                        answerPeg4 = CreateAnswerPegs(i);
                    }
                } // if..else..if

                // Add to parent
                stackPanel.Children.Add(questionPeg);
                stackPanel.SetValue(Grid.ColumnProperty, i);
                answerGrid.Children.Add(stackPanel);
            } // for i
        }     // PlaceAnswerPegs()
 public void Init(ref Grid display)
 {
     _count = 0;
     _state = RacerState.Select;
     Layout(ref display);
 }
Example #58
0
        private void GenerateButton(ImagePair imagePair, int i, int position)
        {
            Grid grid = new Grid()
            {
                Margin  = new Thickness(0),
                Padding = new Thickness(0)
            };

            if (this.ShowMessages && this.MainOrientation == Orientation.Vertical)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.5, GridUnitType.Star)
                });
                grid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(.5, GridUnitType.Star)
                });
                grid.ColumnSpacing = WIDTH_GRID_COLUMNSPACING;
            }

            Grid.SetRow(imagePair.NotSelected, 0);
            Grid.SetColumn(imagePair.NotSelected, 0);
            grid.Children.Add(imagePair.NotSelected);
            Grid.SetRow(imagePair.Selected, 0);
            Grid.SetColumn(imagePair.Selected, 0);
            grid.Children.Add(imagePair.Selected);

            HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center;

            // if we need to show messages then align left
            if (this.MainOrientation == Orientation.Vertical && this.ShowMessages && !string.IsNullOrWhiteSpace(imagePair.Message))
            {
                horizontalAlignment = HorizontalAlignment.Left;
                TextBlockEx tbMessage = new TextBlockEx()
                {
                    Name              = "TheText",
                    Text              = imagePair.Message,
                    TextStyle         = TextStyles.AppSelectorText,
                    FontSize          = 20,
                    Opacity           = 1,
                    VerticalAlignment = VerticalAlignment.Center,
                    TextStyleBold     = TextStyles.AppSelectorTextBold
                };

                if (i == 0)
                {
                    tbMessage.ShowBoldText(true);
                }

                Grid.SetRow(tbMessage, 0);
                Grid.SetColumn(tbMessage, 1);// kk this isnt working just yet.
                grid.Children.Add(tbMessage);
            }

            AppSelectorButton sbButton = new AppSelectorButton()
            {
                ID = i,
                HorizontalAlignment = horizontalAlignment,
                VerticalAlignment   = VerticalAlignment.Center,
                Content             = grid
            };

            //if (!IsListView)
            //{
            //    sbButton.Background = new SolidColorBrush(Colors.Transparent);
            //}
            //else
            //{
            //    sbButton.NormalBackground = (i % 2 == 0 ? BackGroundWhiteAcrylic : BackGroundGrayAcrylic);
            //    if (i == 0)
            //    {
            //        sbButton.Background = new SolidColorBrush(Colors.Blue);
            //    }
            //    else
            //    {
            //        sbButton.Background = sbButton.NormalBackground;
            //    }

            //}

            //only set the dimensions of the button if the control variables are passed in
            // and the orientation is correct
            if (this.ButtonHeight > 0)
            {
                sbButton.Height = this.ButtonHeight;
            }

            // if u need to show messages, dont set the width b/c theres no way to figure out the width
            // if there is text
            if (this.ButtonWidth > 0 && (!this.ShowMessages && !(this.MainOrientation == Orientation.Vertical)))
            {
                sbButton.Width = this.ButtonWidth;
            }
            if (null != _buttonStyle)
            {
                sbButton.Style = _buttonStyle;
            }
            ;

            if (imagePair.IsClearButton)
            {// these buttons get their own handler and dont change the selection of the app selector
                sbButton.AddHandler(PointerReleasedEvent, new PointerEventHandler(Selector_ClearButtonClick), true);
            }
            else
            {
                sbButton.AddHandler(PointerReleasedEvent, new PointerEventHandler(Selector_ButtonClick), true);
            }
            grid.PointerEntered += pointerEntered;


            if (this.MainOrientation == Orientation.Horizontal)
            {
                Grid.SetRow(sbButton, 0);
                Grid.SetColumn(sbButton, position);
            }
            else // vertical
            {
                Grid.SetColumn(sbButton, 0);
                Grid.SetRow(sbButton, position);
            }
            if (!imagePair.IsClearButton)
            {// clear button is not a part of the regular buttons
                this.Buttons.Add(sbButton);
            }
            _layoutRoot.Children.Add(sbButton);
            _buttonList.Add(sbButton);
        }
 /// <summary>
 /// When the commands text is clicked, switch to the commands CommandGrid panel in UI.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Commands_Click(object sender, RoutedEventArgs e)
 {
     lastPanel.Visibility = Visibility.Collapsed;
     lastPanel            = Commands;
     Commands.Visibility  = Visibility.Visible;
 }
Example #60
0
        private void RenderUI()
        {
            // get the layout base (a canvas here)
            _layoutRoot = (Grid)this.GetTemplateChild("LayoutRoot");


            // if we can't get the layout root, we can't do anything
            if (null == _layoutRoot)
            {
                return;
            }

            // update the grid
            _layoutRoot.Name = "AppSelectorGrid";



            // must construct additional columns or rows based on orientation and number
            // keep 1.0 so it creates a ratio (double) for the width/height definitions
            // coloring book will pass in image pairs, otherwise its a regular URI count from a normal app selector
            int iButtonCount = this.ImagePairs.Count > 0 ? this.ImagePairs.Count + 1: URIs.Count;

            double ratio = 1.0 / iButtonCount;

            if (this.MainOrientation == Orientation.Horizontal)
            {
                _layoutRoot.ColumnSpacing = WIDTH_GRID_COLUMNSPACING;
                _layoutRoot.RowDefinitions.Add(new RowDefinition());
                for (int i = 0; i < iButtonCount; i++)
                {
                    _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(ratio, GridUnitType.Star)
                    });
                }
            }
            else
            {
                //_layoutRoot.RowSpacing = (!IsListView ? WIDTH_GRID_ROWSPACING: 0);
                _layoutRoot.RowSpacing = WIDTH_GRID_ROWSPACING;
                _layoutRoot.ColumnDefinitions.Add(new ColumnDefinition());
                for (int i = 0; i < iButtonCount; i++)
                {
                    _layoutRoot.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(ratio, GridUnitType.Star)
                    });
                }
            }

            // create the button style
            //if (IsListView)
            //{
            //    _buttonStyle = StyleHelper.GetApplicationStyle("ListViewButton");
            //}
            //else
            //{
            _buttonStyle = StyleHelper.GetApplicationStyle("AppSelectorButton");
            //}

            // JN loop this area to create images and buttons based on list
            int index = 0;

            if (this.ImagePairs.Count != 0)
            {// hubris! dont add clearbutton image pair unless it has a value. should only have a value on colorbook
                if (this.ClearButtonImagePair != null)
                {
                    GenerateButton(this.ClearButtonImagePair, 0, 0);
                    index = 1;
                }
                else
                {
                    index = 0;
                }

                for (int i = 0; i < this.ImagePairs.Count; i++, index++)
                {
                    GenerateButton(this.ImagePairs[i], i, index);
                }
            }
            else
            {
                for (int i = 0; i < this.URIs.Count; i++)
                {
                    GenerateButton(this.URIs[i], i);
                }
            }


            if (this.ShowSelectedLine)
            {
                selectedLine.StrokeThickness = 5;
                double LineRightMargin  = StyleHelper.GetApplicationDouble("AppSelectorLineBottomMargin");
                double LineBottomMargin = StyleHelper.GetApplicationDouble("AppSelectorLineBottomMargin");

                if (this.MainOrientation == Orientation.Vertical)
                {
                    selectedLine.X1 = -LineRightMargin;
                    selectedLine.Y1 = VERTICAL_LINE_OFFSET;

                    selectedLine.X2 = -LineRightMargin;
                    selectedLine.Y2 = this.ButtonHeight + VERTICAL_LINE_OFFSET;
                }
                if (this.MainOrientation == Orientation.Horizontal)
                {
                    selectedLine.X1 = 3;
                    selectedLine.Y1 = this.ButtonHeight + 5 + LineBottomMargin;

                    selectedLine.X2 = this.ButtonWidth + 4;// border thickness for some reason 2 on both sides
                    selectedLine.Y2 = this.ButtonHeight + 5 + LineBottomMargin;
                }

                SolidColorBrush SelectedLineColor = RadiatingButton.GetSolidColorBrush("#FF0078D4");

                selectedLine.Stroke = SelectedLineColor;
                selectedLine.Fill   = SelectedLineColor;
                _layoutRoot.Children.Add(selectedLine);

                this.SelectedButton = this.Buttons[0];// set the first button as the selected button for line moving

                // need sine easing
                SineEase sineEaseIn = new SineEase()
                {
                    EasingMode = EasingMode.EaseIn
                };
                // set this once here and forget it.
                this.selectedLine.RenderTransform = this.translateTransform;
                Duration duration = new Duration(new TimeSpan(0, 0, 0, 0, 400));
                daAnimation = new DoubleAnimation()
                {
                    Duration       = duration,
                    EasingFunction = sineEaseIn
                };

                this.storyboard.Children.Add(daAnimation);
                Storyboard.SetTarget(daAnimation, this.translateTransform);
                if (this.MainOrientation == Orientation.Horizontal)
                {
                    Storyboard.SetTargetProperty(daAnimation, "X");
                }
                if (this.MainOrientation == Orientation.Vertical)
                {
                    Storyboard.SetTargetProperty(daAnimation, "Y");
                }
            }

            // set up animations
            _storyboardFadeIn  = AnimationHelper.CreateEasingAnimation(_layoutRoot, "Opacity", 0.0, 0.0, 1.0, this.DurationInMilliseconds, this.StaggerDelayInMilliseconds, false, false, new RepeatBehavior(1d));
            _storyboardFadeOut = AnimationHelper.CreateEasingAnimation(_layoutRoot, "Opacity", 1.0, 1.0, 0.0, this.DurationInMilliseconds, this.StaggerDelayInMilliseconds, false, false, new RepeatBehavior(1d));

            this.UpdateUI();
        }