Exemple #1
0
        public static int OptimizeValueOneZero(Stuff[] items, int volumn)
        {
            int length = items.Length, i, j;
            int[,] cache = new int[length + 1, volumn + 1];
            for (i = 1; i <= length; i++)
            {
                for (j = 1; j <= volumn; j++)
                {
                    int old_value = cache[i - 1, j];

                    if (j >= items[i - 1].Weight)
                    {
                        int new_value = items[i - 1].Value;
                        if (i - 2 >= 0 && j - items[i - 2].Value >= 0)
                        {
                            new_value += cache[i - 1, j - items[i - 2].Value];
                        }
                        cache[i, j] = new_value > old_value ? new_value : old_value;
                    }
                    else
                    {
                        cache[i, j] = old_value;
                    }
                }
            }
            return cache[length, volumn];
        }
 protected override void Because_of()
 {
     _source = new Stuff
     {
         Id = 4,
         Name = "Foo",
         RankCode = "Bar"
     };
     _dest = Mapper.Map<Stuff, StuffView>(_source);
 }
Exemple #3
0
    void Start()
    {
        myOtherStuff = myStuff;
        myOtherStuff.bullets = 100;

        int int1 = 5;
        int int2 = int1;
        int2 = 100;

        Debug.Log(myStuff.bullets);
        Debug.Log(int1);
    }
Exemple #4
0
        public static int OptimizeValueDuplicate(Stuff[] items, int volumn)
        {
            int length = items.Length, i, j;
            int[] cache = new int[volumn];

            for (i = 0; i < length; i++)
            {
                for (j = items[i].Weight; j < volumn; j++)
                {
                    int old_value = cache[j];
                    int new_value = items[i].Value;
                    if (j - items[i].Weight>=0)
                    {
                        new_value += cache[j - items[i].Weight];
                    }
                    cache[j] = new_value > old_value ? new_value : old_value;
                }
            }
            return cache[volumn - 1];
        }
Exemple #5
0
        protected PureImage GetTileImageUsingHttp(string url)
        {
            PureImage ret = null;

            WebRequest request = GetRequest(url);

            using (var response = request.GetResponse()) {
                if (CheckTileImageHttpResponse(response))
                {
                    using (Stream responseStream = response.GetResponseStream()) {
                        MemoryStream data = Stuff.CopyStream(responseStream, false);

                        Debug.WriteLine("Response[" + data.Length + " bytes]: " + url);

                        if (data.Length > 0)
                        {
                            ret = GMaps.TileImageProxy.FromStream(data);

                            if (ret != null)
                            {
                                ret.Data          = data;
                                ret.Data.Position = 0;
                            }
                            else
                            {
                                data.Dispose();
                            }
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("CheckTileImageHttpResponse[false]: " + url);
                }
                response.Close();
            }
            return(ret);
        }
Exemple #6
0
        private static void UpdateTfsPath(string localtfspath, int commitid)
        {
            string tfexe = Stuff.GetTFEXEPath();

            if (!Directory.Exists(localtfspath))
            {
                Directory.CreateDirectory(localtfspath);
            }

            var proc = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName         = tfexe,
                    Arguments        = $"vc get . /version:C{commitid} /recursive",
                    UseShellExecute  = false,
                    WorkingDirectory = localtfspath
                }
            };

            proc.Start();
            proc.WaitForExit();
        }
    public override bool Instantiate()
    {
        if (currentCooldown <= 0)
        {
            if (user.tag == "Player")
            {
                Vector3 temp = Stuff.Intersect();
                if (!temp.Equals(Vector3.negativeInfinity))
                {
                    GameObject comet = Instantiate(CometPrefab, temp + new Vector3(0, 20, 0), Quaternion.identity);
                    comet.GetComponent <CometBehaviour>().SetDestination(temp);
                    comet.GetComponent <CometBehaviour>().SetUser(user);

                    StartCoroutine(Cooldown());

                    //rotate player towards cursor
                    StartCoroutine(RotateUser(Quaternion.LookRotation(new Vector3(temp.x - transform.position.x, 0, temp.z - transform.position.z), Vector3.up)));
                }
                return(true);
            }
        }
        return(false);
    }
Exemple #8
0
 private void UpDateData(Stuff s)
 {
     if (lst.Any(prod => prod.Id == s.id))
     {
         foreach (var x in lst)
         {
             if (x.Id == s.id)
             {
                 if (x.Quantity == 0)
                 {
                     MessageBox.Show("QUANTITY = 0!");
                 }
                 else
                 {
                     x.Quantity--;
                     AddToBuyList(s);
                     db.Good.AddOrUpdate(x);
                     DataList.Items.Refresh();
                 }
             }
         }
     }
 }
 public IActionResult Create(Stuff stuff)
 {
     if (ModelState.IsValid)
     {
         try
         {
             string insertQuery = "INSERT INTO stuff (name, id_dep) VALUES (@name, @id_dep)";
             con = new NpgsqlConnection(ConnectionString);
             con.Open();
             con.Execute(insertQuery, stuff);
             return(RedirectToAction(nameof(Index)));
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             con.Close();
         }
     }
     return(View(stuff));
 }
Exemple #10
0
    protected override void Work(Player player, Stuff stuff)
    {
        if (!(stuff is Enemy))
        {
            return;
        }
        var enemy = (Enemy)stuff;

        if (ID == '杖')
        {
            var temp = player.Position;
            player.Position = enemy.Position;
            enemy.Position  = temp;
        }
        if (ID == '吹')
        {
            enemy.Fly(player.direction);
        }
        if (ID == '縛')
        {
            enemy.state = State.Sleep;
        }
    }
 private void tbEquip_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && this.tbEquip.Text.Trim().Length != 0 && this.tbEquipCount.Text.Trim().Length != 0)
     {
         Stuff parSearch = new Stuff();
         //parSearch.strStoreCodePty = this.tbEquip.Text.Trim();
         //DataSet dsEquipResult = Part.GetParts(this.cnConnection, parSearch);
         //if (dsEquipResult.Tables["tabParts"].Rows.Count != 0)
         //{
         //    String strEquipNameCode = dsEquipResult.Tables["tabParts"].Rows[0]["nvcName"].ToString();
         //    String strEquipName = EquipName.GetEquipnameByCode(this.cnConnection, strEquipNameCode);
         //    this.dsEquips.Tables["tabMaintenanceFurnaceEquips"].Rows.Add(-1,this.mfiUpdate.intIDPty, this.tbEquip.Text.Trim(),
         //        Double.Parse(this.tbEquipCount.Text.Trim()),strEquipName);
         //    this.dgvEquips.DataSource = this.dsEquips;
         //    this.dgvEquips.DataMember = "tabMaintenanceFurnaceEquips";
         //}
         //else
         //{
         //    MessageBox.Show("کد اشتباه است.", "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Warning,
         //        MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign);
         //}
     }
 }
Exemple #12
0
    public override int[][] GetMoves()
    {
        List <int[]> moves = new List <int[]>();

        for (int d = 0; d < 4; d++)
        {
            for (int d2 = d + 1; d2 < 4; d2++)
            {
                if (d != d2)
                {
                    for (int i = -1; i < 2; i += 2)
                    {
                        for (int i2 = -1; i2 < 2; i2 += 2)
                        {
                            int[][] tryMoves = new int[][] { CalcMove(new int[4]), CalcMove(new int[4]) };

                            for (int m = 0; m < 2; m++)
                            {
                                tryMoves[m][d]  += (2 - m) * i;
                                tryMoves[m][d2] += (1 + m) * i2;
                            }

                            foreach (int[] move in tryMoves)
                            {
                                if (Stuff.WithinBounds(move) && (board.Index(move) == null || board.Index(move).black != black))
                                {
                                    moves.Add(move);
                                }
                            }
                        }
                    }
                }
            }
        }

        return(moves.ToArray());
    }
Exemple #13
0
    public override int[][] GetMoves()
    {
        List <int[]> moves = new List <int[]>();

        for (int x = -1; x < 2; x++)
        {
            for (int y = -1; y < 2; y++)
            {
                for (int z = -1; z < 2; z++)
                {
                    for (int w = -1; w < 2; w++)
                    {
                        int[] move = CalcMove(new int[] { x, y, z, w });
                        if (Stuff.WithinBounds(move) && (board.Index(move) == null || board.Index(move).black != black))
                        {
                            moves.Add(move);
                        }
                    }
                }
            }
        }

        return(moves.ToArray());
    }
        public void TestLmaoToPepe()
        {
            byte[] keyframe1  = TestResources._2389388796_1_Keyframe;
            byte[] keyframe10 = TestResources._2389388796_10_Keyframe;

            var key1Blocks  = LmaoParser.GetBlocksFromLmao(keyframe1);
            var key10Blocks = LmaoParser.GetBlocksFromLmao(keyframe10);

            Assert.IsTrue(key1Blocks.Count == 1904);
            Assert.IsTrue(key10Blocks.Count == 4269);

            var blocks = key10Blocks;

            var groupations  = Stuff.GetRepetitionGroupations(blocks);
            var groupations2 = Stuff.GetRepetitionGroupations(key1Blocks);

            var flattened      = groupations.SelectMany(g => g.Item4).SelectMany(g => g).ToList();
            int flattenedCount = flattened.Sum(b => b.Count);

            Assert.AreEqual(blocks.Count(), flattenedCount);

            //Assert.IsTrue(arrayedGroupations.SelectMany(g => g.SelectMany(gg => gg)).All(g => blocks.Any(b => b == g)));
            //Assert.IsTrue(arrayedGroupations[0].Count() == 4 && arrayedGroupations[2].Count() == 97 && arrayedGroupations[27].Count() == 4 && arrayedGroupations[59].Count() == 23 && arrayedGroupations[140].Count() == 7);
        }
Exemple #15
0
    protected override void Work(Player player, Stuff stuff)
    {
        if (ID == '眼')
        {
            foreach (var trap in floor.Traps)
            {
                trap.isVisible = true;
            }
        }

        if (ID == '草')
        {
            var enemy = floor.GetEnemy(player.Position, player.direction,
                                       new List <TerrainType>()
            {
                TerrainType.wall, TerrainType.breakableWall
            });
            if (enemy == null)
            {
                return;
            }
            enemy.IsAttacked(player);
        }
    }
    // Use this for initialization
    void Start()
    {
        stuffs = new Stuff[transform.childCount];
        var local = Vector3.zero;

        foreach (Transform trans in transform)
        {
            local += trans.GetComponent <MeshFilter> ().mesh.bounds.center;
        }
        center = local / transform.childCount;
        for (int i = 0; i < transform.childCount; i++)
        {
            Stuff stuff = new Stuff();
            stuffs[i] = stuff;

            stuff.transform = transform.GetChild(i);
            stuff.startPos  = stuff.transform.position;
            var oc        = stuff.transform.GetComponent <MeshFilter> ().mesh.bounds.center;
            var direction = oc - center;
            var offset    = direction * radius * 2;
            stuff.endPos       = stuff.startPos + offset;
            stuff.startQuation = stuff.transform.localRotation;
        }
    }
        public object ejecutar(Contexto ctx, Stuff stuff)
        {
            object resEx = Operacion.Validar(exp.ejecutar(ctx, stuff), ctx, stuff, exp.getLinea(), exp.getColumna());

            if (resEx == null)
            {
                return(null);
            }
            if (resEx is Arreglo)
            {
                object resIndice = Operacion.Validar(indice.ejecutar(ctx, stuff), ctx, stuff, indice.getLinea(), indice.getColumna());
                if (resIndice == null)
                {
                    return(null);
                }
                if (resIndice is BigInteger index)
                {
                    Arreglo arr = (Arreglo)resEx;
                    if (index < 0)
                    {
                        stuff.error("Semántico", "'ACCESO ARREGLO', el valor del indice es demasiado pequeño. Encontrado: " + index + ", Minimo: 0.", indice.getLinea(), indice.getColumna(), ctx);
                        return(null);
                    }
                    if (index >= arr.val.Count)
                    {
                        stuff.error("Semántico", "'ACCESO ARREGLO', el valor del indice es demasiado grande. Encontrado: " + index + ", Maximo: " + (arr.val.Count - 1) + ".", indice.getLinea(), indice.getColumna(), ctx);
                        return(null);
                    }
                    return(arr.val.ElementAt((int)index));
                }
                stuff.error("Semántico", "'ACCESO ARREGLO', el tipo del indice es incompatible con esta instruccion. Encontrado: " + Operacion.getTipo(resIndice) + ", Esperado: 'ENTERO'.", indice.getLinea(), indice.getColumna(), ctx);
                return(null);
            }
            stuff.error("Semántico", "'ACCESO ARREGLO', el tipo del operando es incompatible con esta instruccion. Encontrado: " + Operacion.getTipo(resEx) + ", Esperado: 'ARREGLO'.", exp.getLinea(), exp.getColumna(), ctx);
            return(null);
        }
        /// <summary>
        /// Draws the character slightly distorted to give it a hand-written effect, varying each time it's drawn.
        /// </summary>
        /// <param name="at">The location in pixels in the screen the text should be drawn at</param>
        /// <param name="size">The height in pixels characters should have</param>
        public void DrawDistorted(Vec2 at, float size)
        {
            float multX = Stuff.Random(0.033f, 0.05f); // these values are used for distortion
            float multY = Stuff.Random(0.033f, 0.05f);

            float defX = Stuff.Random(6.29f);
            float defY = Stuff.Random(6.29f);

            float bulX = Stuff.Random(0.75f, 1.15f) * 6.29f;
            float bulY = Stuff.Random(0.75f, 1.15f) * 6.29f;

            // for each line group
            for (int i = 0; i < lines.Length; i++)
            {
                Vec2[]  line   = lines[i];
                Point[] points = new Point[line.Length];

                for (int c = 0; c < points.Length; c++)
                {
                    // turns the raw line group data into an array of points on the screen, applying some distortion.
                    // the distortion works by using wave functions, which is better than just adding random values
                    // per vertex position because lines with a lot of vertices will remain being lines and dont get
                    // just completely f****d up. This distortion is uniform across the character.
                    float mx = (float)Math.Sin(line[c].X * bulX + defX) * multX;
                    float my = (float)Math.Sin(line[c].Y * bulY + defY) * multY;

                    float x = at.X + (line[c].X + mx) * size;
                    float y = at.Y + (line[c].Y + my) * size;

                    points[c] = new Point((int)x, (int)y);
                }

                // and now Input handles the mouse moving for us.
                Input.MakeLineGroup(points);
            }
        }
        public string Evaluate(Creative creative, CodeExtractor extractor, CompiledContext context)
        {
            Requires.NonNull(creative, nameof(creative));
            Requires.NonNull(extractor, nameof(extractor));
            Requires.NonNull(context, nameof(context));

            var c = context.Config;

            Requires.Equals(creative.TemplateEngineType, TemplateEngineTypes.DollarString);

            var s = extractor(creative.CreativeSettings) ?? "";

            s = Flatten(s, extractor);
            s = s.Replace("{{", IntermediateOpenSquigleReplacement);

            s = DollarStringIndexerExpr.Replace(s, delegate(Match m)
            {
                var indexerName = m.Groups["IndexerName"].Value;
                var skey        = Stuff.CoalesceStrings(m.Groups["SingleQuoteStringKey"]?.Value, m.Groups["DoubleQuoteStringKey"]?.Value);
                switch (indexerName)
                {
                case "R":
                    var rv = ReusableValueByKey[skey];
                    return(rv?.Value ?? "");
                }
                return("");
            });

            s = DollarStringTokenExpr.Replace(s, delegate(Match m)
            {
                var fieldKey = m.Groups[1].Value.Replace('.', ':');
                return(c[fieldKey]);
            });
            s = s.Replace(IntermediateOpenSquigleReplacement, "{");
            return(s);
        }
        public void Add_CheckReturnsEntity()
        {
            // Arrange
            var entity = new Stuff {
                StuffId = 99, One = "Brand New"
            };

            var stuff = CollectionHelpers.GetStandardStuffList().AsQueryable();

            MockHelpers.SetUpMockStuffSet(_dbContext, stuff, entity);

            var tokenHeader = new System.Collections.Specialized.NameValueCollection();

            tokenHeader.Add("ApiToken", "foo");
            _httpContext.Setup(h => h.Request.Headers).Returns(tokenHeader);

            // Act
            var result = _repository.Add(entity);

            // Assert
            Assert.True(result != null);
            Assert.Equal(entity.StuffId, result.StuffId);
            Assert.Equal("foo", result.EntityOwner);
        }
Exemple #21
0
        public static Stuff GetItem(Guid id)
        {
            Stuff         stuff = null;
            SqlConnection con;

            using (SqlDataReader dr = DataManager.GetDataReader("ESystem_StuffGetById", out con,
                                                                DataManager.CreateParameter("@id", SqlDbType.UniqueIdentifier, id)))
            {
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        stuff = FillDataRecord(dr);
                    }
                }
                else
                {
                    throw new Exception("No Data");
                }

                con.Close();
            }
            return(stuff);
        }
Exemple #22
0
        public void DrawStuff(Stuff stuff)
        {
            try
            {
                SmokeLayer.Clear();
                float startX = MapService.CalculatePointToResolutionX(stuff.StartX);
                float startY = MapService.CalculatePointToResolutionY(stuff.StartY);
                float endX   = MapService.CalculatePointToResolutionX(stuff.EndX);
                float endY   = MapService.CalculatePointToResolutionY(stuff.EndY);

                Bitmap startIcon = null;
                Bitmap endIcon   = null;

                switch (stuff.Type)
                {
                case StuffType.SMOKE:
                    startIcon = GetIconBitmapFromStream("smokegrenade");
                    endIcon   = GetIconBitmapFromStream("smoke");
                    break;

                case StuffType.FLASHBANG:
                    startIcon = GetIconBitmapFromStream("flashbang");
                    endIcon   = GetIconBitmapFromStream("flashbang_exploded");
                    break;

                case StuffType.HE:
                    startIcon = GetIconBitmapFromStream("hegrenade");
                    endIcon   = GetIconBitmapFromStream("he_exploded");
                    break;

                case StuffType.MOLOTOV:
                    startIcon = GetIconBitmapFromStream("molotov");
                    endIcon   = GetIconBitmapFromStream("molotov_burning");
                    break;

                case StuffType.DECOY:
                    startIcon = GetIconBitmapFromStream("decoy");
                    endIcon   = GetIconBitmapFromStream("decoy_screaming");
                    break;
                }

                if (startIcon == null || endIcon == null)
                {
                    return;
                }

                DrawIcon(SmokeLayer, startIcon, new PositionPoint
                {
                    X = startX,
                    Y = startY
                });
                DrawIcon(SmokeLayer, endIcon, new PositionPoint
                {
                    X = endX,
                    Y = endY
                });
                SmokeLayer.DrawLineAa((int)startX, (int)startY, (int)endX, (int)endY, ColorToInt(_colors[0]));

                startIcon.Dispose();
                endIcon.Dispose();
            }
            catch (Exception e)
            {
                Logger.Instance.Log(e);
            }
        }
Exemple #23
0
        protected PureImage GetTileImageUsingHttp(string url)
        {
            PureImage ret = null;

#if !PocketPC
            WebRequest request = IsSocksProxy ? SocksHttpWebRequest.Create(url) : WebRequest.Create(url);
#else
            WebRequest request = WebRequest.Create(url);
#endif
            if (WebProxy != null)
            {
                request.Proxy = WebProxy;
            }

            if (Credential != null)
            {
                request.PreAuthenticate = true;
                request.Credentials     = Credential;
            }

            if (request is HttpWebRequest)
            {
                var r = request as HttpWebRequest;
                r.UserAgent        = UserAgent;
                r.ReadWriteTimeout = TimeoutMs * 6;
                r.Accept           = requestAccept;
                r.Referer          = RefererUrl;
                r.Timeout          = TimeoutMs;
            }
#if !PocketPC
            else if (request is SocksHttpWebRequest)
            {
                var r = request as SocksHttpWebRequest;

                if (!string.IsNullOrEmpty(UserAgent))
                {
                    r.Headers.Add("User-Agent", UserAgent);
                }

                if (!string.IsNullOrEmpty(requestAccept))
                {
                    r.Headers.Add("Accept", requestAccept);
                }

                if (!string.IsNullOrEmpty(RefererUrl))
                {
                    r.Headers.Add("Referer", RefererUrl);
                }
            }
#endif
            using (var response = request.GetResponse())
            {
                if (CheckTileImageHttpResponse(response))
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        MemoryStream data = Stuff.CopyStream(responseStream, false);

                        Debug.WriteLine("Response[" + data.Length + " bytes]: " + url);

                        if (data.Length > 0)
                        {
                            ret = TileImageProxy.FromStream(data);

                            if (ret != null)
                            {
                                ret.Data          = data;
                                ret.Data.Position = 0;
                            }
                            else
                            {
                                data.Dispose();
                            }
                        }
                        data = null;
                    }
                }
                else
                {
                    Debug.WriteLine("CheckTileImageHttpResponse[false]: " + url);
                }
#if PocketPC
                request.Abort();
#endif
                response.Close();
            }
            return(ret);
        }
Exemple #24
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (list != null)
            {
                list.Clear();
                list = null;
            }
            list       = provider.Projection.GetAreaTileList(area, zoom, 0);
            maxOfTiles = provider.Projection.GetTileMatrixMaxXY(zoom);
            all        = list.Count;

            int countOk    = 0;
            int retryCount = 0;

            if (Shuffle)
            {
                Stuff.Shuffle <GPoint>(list);
            }

            lock (this)
            {
                CachedTiles.Clear();
            }

            for (int i = 0; i < all; i++)
            {
                if (worker.CancellationPending)
                {
                    break;
                }

                GPoint p = list[i];
                {
                    // 参数 for SQLite 离线地图存储
                    // 2017-09-17 by Mark Lee
                    p.gid       = this.gid;
                    p.parentGid = this.parentGid;
                    if (CacheTiles(zoom, p))
                    {
                        if (Overlay != null)
                        {
                            lock (this)
                            {
                                CachedTiles.Enqueue(p);
                            }
                        }
                        countOk++;
                        retryCount = 0;
                    }
                    else
                    {
                        if (++retryCount <= retry) // retry only one
                        {
                            i--;
                            System.Threading.Thread.Sleep(1111);
                            continue;
                        }
                        else
                        {
                            retryCount = 0;
                        }
                    }
                }

                worker.ReportProgress((int)((i + 1) * 100 / all), i + 1);

                if (sleep > 0)
                {
                    System.Threading.Thread.Sleep(sleep);
                }
            }

            e.Result = countOk;

            if (!IsDisposed)
            {
                done.WaitOne();
            }
        }
Exemple #25
0
        public MainWindow()
        {
            InitializeComponent();

            // add your custom map db provider
            //MySQLPureImageCache ch = new MySQLPureImageCache();
            //ch.ConnectionString = @"server=sql2008;User Id=trolis;Persist Security Info=True;database=gmapnetcache;password=trolis;";
            //MainMap.Manager.SecondaryCache = ch;

            // set your proxy here if need
            //GMapProvider.IsSocksProxy = true;
            //GMapProvider.WebProxy = new WebProxy("127.0.0.1", 1080);
            //GMapProvider.WebProxy.Credentials = new NetworkCredential("*****@*****.**", "bilgeada");
            // or
            //GMapProvider.WebProxy = WebRequest.DefaultWebProxy;
            //

            // set cache mode only if no internet avaible
            if (!Stuff.PingNetwork("pingtest.com"))
            {
                MainMap.Manager.Mode = AccessMode.CacheOnly;
                MessageBox.Show("No internet connection available, going to CacheOnly mode.",
                                "GMap.NET - Demo.WindowsPresentation",
                                MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }

            GoogleMapProvider.Instance.ApiKey = Stuff.GoogleMapsApiKey;

            // config map
            MainMap.MapProvider = GMapProviders.OpenStreetMap;
            MainMap.Position    = new PointLatLng(54.6961334816182, 25.2985095977783);

            //// 20200313 (jokubokla): Demo of the new Sweden Map with Mercator instead of SWEREF99
            //MainMap.MapProvider = GMapProviders.SwedenMapAlternative;
            //MainMap.Position = new PointLatLng(58.406298501604, 15.5825614929199); // Linköping
            //MainMap.MinZoom = 1;
            //MainMap.MaxZoom = 15;
            //MainMap.Zoom = 11;
            //TextBoxGeo.Text = "Linköping";

            //MainMap.ScaleMode = ScaleModes.Dynamic;

            // map events
            MainMap.OnPositionChanged   += MainMap_OnCurrentPositionChanged;
            MainMap.OnTileLoadComplete  += MainMap_OnTileLoadComplete;
            MainMap.OnTileLoadStart     += MainMap_OnTileLoadStart;
            MainMap.OnMapTypeChanged    += MainMap_OnMapTypeChanged;
            MainMap.MouseMove           += MainMap_MouseMove;
            MainMap.MouseLeftButtonDown += MainMap_MouseLeftButtonDown;
            MainMap.MouseEnter          += MainMap_MouseEnter;

            // get map types
            ComboBoxMapType.ItemsSource       = GMapProviders.List;
            ComboBoxMapType.DisplayMemberPath = "Name";
            ComboBoxMapType.SelectedItem      = MainMap.MapProvider;

            // acccess mode
            ComboBoxMode.ItemsSource  = Enum.GetValues(typeof(AccessMode));
            ComboBoxMode.SelectedItem = MainMap.Manager.Mode;

            // get cache modes
            CheckBoxCacheRoute.IsChecked = MainMap.Manager.UseRouteCache;
            CheckBoxGeoCache.IsChecked   = MainMap.Manager.UseGeocoderCache;

            // setup zoom min/max
            SliderZoom.Maximum = MainMap.MaxZoom;
            SliderZoom.Minimum = MainMap.MinZoom;

            // get position
            TextBoxLat.Text = MainMap.Position.Lat.ToString(CultureInfo.InvariantCulture);
            TextBoxLng.Text = MainMap.Position.Lng.ToString(CultureInfo.InvariantCulture);

            // get marker state
            CheckBoxCurrentMarker.IsChecked = true;

            // can drag map
            CheckBoxDragMap.IsChecked = MainMap.CanDragMap;

#if DEBUG
            CheckBoxDebug.IsChecked = true;
#endif

            //validator.Window = this;

            // set current marker
            currentMarker = new GMapMarker(MainMap.Position);
            {
                currentMarker.Shape  = new CustomMarkerRed(this, currentMarker, "custom position marker");
                currentMarker.Offset = new Point(-15, -15);
                currentMarker.ZIndex = int.MaxValue;
                MainMap.Markers.Add(currentMarker);
            }

            //if(false)
            {
                // add my city location for demo
                GeoCoderStatusCode status;

                var city = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius", out status);
                if (city != null && status == GeoCoderStatusCode.OK)
                {
                    var it = new GMapMarker(city.Value);
                    {
                        it.ZIndex = 55;
                        it.Shape  = new CustomMarkerDemo(this, it, "Welcome to Lithuania! ;}");
                    }
                    MainMap.Markers.Add(it);

                    #region -- add some markers and zone around them --

                    //if(false)
                    {
                        var objects = new List <PointAndInfo>();
                        {
                            string area = "Antakalnis";
                            var    pos  = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius, " + area, out status);
                            if (pos != null && status == GeoCoderStatusCode.OK)
                            {
                                objects.Add(new PointAndInfo(pos.Value, area));
                            }
                        }
                        {
                            string area = "Senamiestis";
                            var    pos  = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius, " + area, out status);
                            if (pos != null && status == GeoCoderStatusCode.OK)
                            {
                                objects.Add(new PointAndInfo(pos.Value, area));
                            }
                        }
                        {
                            string area = "Pilaite";
                            var    pos  = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius, " + area, out status);
                            if (pos != null && status == GeoCoderStatusCode.OK)
                            {
                                objects.Add(new PointAndInfo(pos.Value, area));
                            }
                        }
                        AddDemoZone(8.8, city.Value, objects);
                    }

                    #endregion
                }

                if (MainMap.Markers.Count > 1)
                {
                    MainMap.ZoomAndCenterMarkers(null);
                }
            }

            // perfromance test
            timer.Interval = TimeSpan.FromMilliseconds(44);
            timer.Tick    += timer_Tick;

            // transport demo
            transport.DoWork                    += transport_DoWork;
            transport.ProgressChanged           += transport_ProgressChanged;
            transport.WorkerSupportsCancellation = true;
            transport.WorkerReportsProgress      = true;
        }
Exemple #26
0
        protected PureImage GetTileImageUsingHttp(string url)
        {
            PureImage ret = null;

            var request = IsSocksProxy ? SocksHttpWebRequest.Create(url) :
                          WebRequestFactory != null?WebRequestFactory(this, url) : WebRequest.Create(url);

            if (WebProxy != null)
            {
                request.Proxy = WebProxy;
            }

            if (Credential != null)
            {
                request.PreAuthenticate = true;
                request.Credentials     = Credential;
            }

            if (!string.IsNullOrEmpty(_authorization))
            {
                request.Headers.Set("Authorization", _authorization);
            }

            if (request is HttpWebRequest r)
            {
                r.UserAgent        = UserAgent;
                r.ReadWriteTimeout = TimeoutMs * 6;
                r.Accept           = requestAccept;
                if (!string.IsNullOrEmpty(RefererUrl))
                {
                    r.Referer = RefererUrl;
                }

                r.Timeout = TimeoutMs;
            }
            else
            {
                if (!string.IsNullOrEmpty(UserAgent))
                {
                    request.Headers.Add("User-Agent", UserAgent);
                }

                if (!string.IsNullOrEmpty(requestAccept))
                {
                    request.Headers.Add("Accept", requestAccept);
                }

                if (!string.IsNullOrEmpty(RefererUrl))
                {
                    request.Headers.Add("Referer", RefererUrl);
                }
            }

            InitializeWebRequest(request);

            using (var response = request.GetResponse())
            {
                if (CheckTileImageHttpResponse(response))
                {
                    using (var responseStream = response.GetResponseStream())
                    {
                        var data = Stuff.CopyStream(responseStream, false);

                        Debug.WriteLine("Response[" + data.Length + " bytes]: " + url);

                        if (data.Length > 0)
                        {
                            ret = TileImageProxy.FromStream(data);

                            if (ret != null)
                            {
                                ret.Data          = data;
                                ret.Data.Position = 0;
                            }
                            else
                            {
                                data.Dispose();
                            }
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("CheckTileImageHttpResponse[false]: " + url);
                }

                response.Close();
            }

            return(ret);
        }
        public PartInsert()
        {
            InitializeComponent();

            this.stInsert = new Stuff();
        }
Exemple #28
0
    public OverlappingModel(string name, int N, int width, int height, bool periodicInput, bool periodicOutput, int symmetry, int ground)
        : base(width, height)
    {
        this.N   = N;
        periodic = periodicOutput;

        var bitmap = new Bitmap($"samples/{name}.png");
        int SMX = bitmap.Width, SMY = bitmap.Height;

        byte[,] sample = new byte[SMX, SMY];
        colors         = new List <Color>();

        for (int y = 0; y < SMY; y++)
        {
            for (int x = 0; x < SMX; x++)
            {
                Color color = bitmap.GetPixel(x, y);

                int i = 0;
                foreach (var c in colors)
                {
                    if (c == color)
                    {
                        break;
                    }
                    i++;
                }

                if (i == colors.Count)
                {
                    colors.Add(color);
                }
                sample[x, y] = (byte)i;
            }
        }

        int  C = colors.Count;
        long W = Stuff.Power(C, N * N);

        byte[] pattern(Func <int, int, byte> f)
        {
            byte[] result = new byte[N * N];
            for (int y = 0; y < N; y++)
            {
                for (int x = 0; x < N; x++)
                {
                    result[x + y * N] = f(x, y);
                }
            }
            return(result);
        };

        byte[] patternFromSample(int x, int y) => pattern((dx, dy) => sample[(x + dx) % SMX, (y + dy) % SMY]);

        byte[] rotate(byte[] p) => pattern((x, y) => p[N - 1 - y + x * N]);

        byte[] reflect(byte[] p) => pattern((x, y) => p[N - 1 - x + y * N]);

        long index(byte[] p)
        {
            long result = 0, power = 1;

            for (int i = 0; i < p.Length; i++)
            {
                result += p[p.Length - 1 - i] * power;
                power  *= C;
            }
            return(result);
        };

        byte[] patternFromIndex(long ind)
        {
            long residue = ind, power = W;

            byte[] result = new byte[N * N];

            for (int i = 0; i < result.Length; i++)
            {
                power /= C;
                int count = 0;

                while (residue >= power)
                {
                    residue -= power;
                    count++;
                }

                result[i] = (byte)count;
            }

            return(result);
        };

        Dictionary <long, int> weights  = new Dictionary <long, int>();
        List <long>            ordering = new List <long>();

        for (int y = 0; y < (periodicInput ? SMY : SMY - N + 1); y++)
        {
            for (int x = 0; x < (periodicInput ? SMX : SMX - N + 1); x++)
            {
                byte[][] ps = new byte[8][];

                ps[0] = patternFromSample(x, y);
                ps[1] = reflect(ps[0]);
                ps[2] = rotate(ps[0]);
                ps[3] = reflect(ps[2]);
                ps[4] = rotate(ps[2]);
                ps[5] = reflect(ps[4]);
                ps[6] = rotate(ps[4]);
                ps[7] = reflect(ps[6]);

                for (int k = 0; k < symmetry; k++)
                {
                    long ind = index(ps[k]);
                    if (weights.ContainsKey(ind))
                    {
                        weights[ind]++;
                    }
                    else
                    {
                        weights.Add(ind, 1);
                        ordering.Add(ind);
                    }
                }
            }
        }

        T            = weights.Count;
        this.ground  = (ground + T) % T;
        patterns     = new byte[T][];
        base.weights = new float[T];

        int counter = 0;

        foreach (long w in ordering)
        {
            patterns[counter]     = patternFromIndex(w);
            base.weights[counter] = weights[w];
            counter++;
        }

        bool agrees(byte[] p1, byte[] p2, int dx, int dy)
        {
            int xmin = dx < 0 ? 0 : dx, xmax = dx < 0 ? dx + N : N, ymin = dy < 0 ? 0 : dy, ymax = dy < 0 ? dy + N : N;

            for (int y = ymin; y < ymax; y++)
            {
                for (int x = xmin; x < xmax; x++)
                {
                    if (p1[x + N * y] != p2[x - dx + N * (y - dy)])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        };

        propagator = new int[4][][];
        for (int d = 0; d < 4; d++)
        {
            propagator[d] = new int[T][];
            for (int t = 0; t < T; t++)
            {
                List <int> list = new List <int>();
                for (int t2 = 0; t2 < T; t2++)
                {
                    if (agrees(patterns[t], patterns[t2], DX[d], DY[d]))
                    {
                        list.Add(t2);
                    }
                }
                propagator[d][t] = new int[list.Count];
                for (int c = 0; c < list.Count; c++)
                {
                    propagator[d][t][c] = list[c];
                }
            }
        }
    }
 // Use this for initialization
 private void Start()
 {
     stuff = new Stuff();
     map   = new int[size, size];
     GenerateMap();
 }
    override protected void CreateChildren()
    {
        base.CreateChildren();

        #region Top label

        Label label = new TitleLabel {
            Left = 20, Top = 20, StyleName = "title"
        };
        AddChild(label);

        new TextRotator
        {
            Delay = 5, // 5 seconds delay
            Lines = new[]
            {
                "Absolute Layout Demo 2",
                "Created with eDriven.Gui"/*,
                                           * "Author: Danko Kozar"*/
            },
            Callback = delegate(string line) { label.Text = line; }
        }
        .Start();

        #endregion

        #region Bottom label

        Label label2 = new Label
        {
            HorizontalCenter = 0,
            Bottom           = 20,
            Text             = "[GuiInspector: Ctrl + click = sticky, Ctrl + Return toggles inspector, Ctrl + arrows for walking the DOM]"
        };
        label2.SetStyle("labelStyle", BlueLabelStyle.Instance);
        AddChild(label2);

        #endregion

        Button btn1 = new Button
        {
            Left         = 100,
            Top          = 100,
            Width        = 300,
            Height       = 300,
            FocusEnabled = false,
            Text         = @"Left = 100,
Top = 100,
Width = 300,
Height = 300",
            Tooltip      = @"This is the tooltip
Nice, eh? :)",
            SkinClass    = typeof(ButtonSkin5),
            Icon         = ImageLoader.Instance.Load("Icons/star_big")
        };
        AddChild(btn1);

        Button btn2 = new Button
        {
            Left         = 500,
            Right        = 100,
            Top          = 100,
            MinWidth     = 300,
            Height       = 300,
            FocusEnabled = false,
            Text         = @"Left = 400,
Right = 100,
Top = 100,
MinWidth = 300,
Height = 300",
            Tooltip      = @"This is the tooltip of the second button
(this one is constrained in width, so resizes with screen width)",
            SkinClass    = typeof(ButtonSkin5),
            Icon         = ImageLoader.Instance.Load("Icons/star_big")
        };
        AddChild(btn2);

        Button btn3 = new Button
        {
            Left         = 100,
            Top          = 500,
            Bottom       = 100,
            Width        = 300,
            MinHeight    = 300,
            FocusEnabled = false,
            Text         = @"Left = 100,
Top = 500,
Bottom = 100,
Width = 300,
MinHeight = 300",
            Tooltip      = @"This is the tooltip of the third button
(this one is constrained in height, so resizes with screen height)",
            SkinClass    = typeof(ButtonSkin5),
            Icon         = ImageLoader.Instance.Load("Icons/star_big")
        };
        AddChild(btn3);

        Stuff btn4 = new Stuff
        {
            Left      = 500,
            Right     = 100,
            Top       = 500,
            Bottom    = 100,
            MinWidth  = 300,
            MinHeight = 300
        };
        AddChild(btn4);
    }
Exemple #31
0
 public MainWindow()
 {
     InitializeComponent();
     gridControl.ItemsSource = Stuff.GetStuff();
 }
 public MyService(Stuff stuff)      // injected stuff
 {
 }
Exemple #33
0
        public override void OnInitialized()
        {
            if (!init)
            {
                try
                {
                    string key = ClientKey;

                    // to avoid registration stuff, default key
                    if (TryGetDefaultKey && string.IsNullOrEmpty(ClientKey))
                    {
                        //old: Vx8dmDflxzT02jJUG8bEjMU07Xr9QWRpPTeRuAZTC1uZFQdDCvK/jUbHKdyHEWj4LvccTPoKofDHtzHsWu/0xuo5u2Y9rj88
                        key = Stuff.GString(
                            "Jq7FrGTyaYqcrvv9ugBKv4OVSKnmzpigqZtdvtcDdgZexmOZ2RugOexFSmVzTAhOWiHrdhFoNCoySnNF3MyyIOo5u2Y9rj88");
                    }

                    #region -- try get sesion key --

                    if (!string.IsNullOrEmpty(key))
                    {
                        string keyResponse = GMaps.Instance.UseUrlCache
                            ? Cache.Instance.GetContent("BingLoggingServiceV1" + key,
                                                        CacheType.UrlCache,
                                                        TimeSpan.FromHours(TTLCache))
                            : string.Empty;

                        if (string.IsNullOrEmpty(keyResponse))
                        {
                            // Bing Maps WPF Control
                            // http://dev.virtualearth.net/webservices/v1/LoggingService/LoggingService.svc/Log?entry=0&auth={0}&fmt=1&type=3&group=MapControl&name=WPF&version=1.0.0.0&session=00000000-0000-0000-0000-000000000000&mkt=en-US

                            keyResponse = GetContentUsingHttp(string.Format(
                                                                  "http://dev.virtualearth.net/webservices/v1/LoggingService/LoggingService.svc/Log?entry=0&fmt=1&type=3&group=MapControl&name=AJAX&mkt=en-us&auth={0}&jsonp=microsoftMapsNetworkCallback",
                                                                  key));

                            if (!string.IsNullOrEmpty(keyResponse) && keyResponse.Contains("ValidCredentials"))
                            {
                                if (GMaps.Instance.UseUrlCache)
                                {
                                    Cache.Instance.SaveContent("BingLoggingServiceV1" + key,
                                                               CacheType.UrlCache,
                                                               keyResponse);
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(keyResponse) && keyResponse.Contains("sessionId") &&
                            keyResponse.Contains("ValidCredentials"))
                        {
                            // microsoftMapsNetworkCallback({"sessionId" : "xxx", "authenticationResultCode" : "ValidCredentials"})

                            SessionId = keyResponse.Split(',')[0].Split(':')[1].Replace("\"", string.Empty)
                                        .Replace(" ", string.Empty);
                            Debug.WriteLine("GMapProviders.BingMap.SessionId: " + SessionId);
                        }
                        else
                        {
                            Debug.WriteLine("BingLoggingServiceV1: " + keyResponse);
                        }
                    }

                    #endregion

                    // supporting old road

                    if (TryCorrectVersion && DisableDynamicTileUrlFormat)
                    {
                        #region -- get the version --

                        string url  = @"http://www.bing.com/maps";
                        string html = GMaps.Instance.UseUrlCache
                            ? Cache.Instance.GetContent(url, CacheType.UrlCache, TimeSpan.FromDays(TTLCache))
                            : string.Empty;

                        if (string.IsNullOrEmpty(html))
                        {
                            html = GetContentUsingHttp(url);

                            if (!string.IsNullOrEmpty(html))
                            {
                                if (GMaps.Instance.UseUrlCache)
                                {
                                    Cache.Instance.SaveContent(url, CacheType.UrlCache, html);
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(html))
                        {
                            #region -- match versions --

                            var reg = new Regex("tilegeneration:(\\d*)", RegexOptions.IgnoreCase);
                            var mat = reg.Match(html);
                            if (mat.Success)
                            {
                                var gc    = mat.Groups;
                                int count = gc.Count;
                                if (count == 2)
                                {
                                    string ver = gc[1].Value;
                                    string old = GMapProviders.BingMap.Version;
                                    if (ver != old)
                                    {
                                        GMapProviders.BingMap.Version          = ver;
                                        GMapProviders.BingSatelliteMap.Version = ver;
                                        GMapProviders.BingHybridMap.Version    = ver;
                                        GMapProviders.BingOSMap.Version        = ver;
#if DEBUG
                                        Debug.WriteLine("GMapProviders.BingMap.Version: " + ver + ", old: " + old +
                                                        ", consider updating source");
                                        if (Debugger.IsAttached)
                                        {
                                            Thread.Sleep(5555);
                                        }
#endif
                                    }
                                    else
                                    {
                                        Debug.WriteLine("GMapProviders.BingMap.Version: " + ver + ", OK");
                                    }
                                }
                            }

                            #endregion
                        }

                        #endregion
                    }

                    init = true; // try it only once
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("TryCorrectBingVersions failed: " + ex);
                }
            }
        }
Exemple #34
0
    public OverlappingModel(string name, int N, int width, int height, bool periodicInput, bool periodicOutput, int symmetry, int ground)
        : base(width, height)
    {
        this.N   = N;
        periodic = periodicOutput;

        var bitmap = new Bitmap($"samples/{name}.png");
        int SMX = bitmap.Width, SMY = bitmap.Height;

        byte[,] sample = new byte[SMX, SMY];
        colors         = new List <Color>();

        // samples the color space and assigns a unique index to each color
        // palletization
        for (int y = 0; y < SMY; y++)
        {
            for (int x = 0; x < SMX; x++)
            {
                Color color = bitmap.GetPixel(x, y);

                int i = 0;
                foreach (var c in colors)
                {
                    if (c == color)
                    {
                        break;
                    }
                    i++;
                }

                if (i == colors.Count)
                {
                    colors.Add(color);
                }
                sample[x, y] = (byte)i;
            }
        }

        int C = colors.Count;
        // N = search space
        long W = Stuff.Power(C, N * N);

        byte[] pattern(Func <int, int, byte> f)
        {
            byte[] result = new byte[N * N];
            for (int y = 0; y < N; y++)
            {
                for (int x = 0; x < N; x++)
                {
                    result[x + y * N] = f(x, y);
                }
            }
            return(result);
        };

        byte[] patternFromSample(int x, int y) =>
        pattern((dx, dy) =>
                sample[(x + dx) % SMX, (y + dy) % SMY]);

        byte[] rotate(byte[] p) => pattern((x, y) => p[N - 1 - y + x * N]);

        byte[] reflect(byte[] p) => pattern((x, y) => p[N - 1 - x + y * N]);

        // assigns an index to a pattern based on its bits?
        // i think this is a hash
        long index(byte[] p)
        {
            long result = 0, power = 1;

            for (int i = 0; i < p.Length; i++)
            {
                result += p[p.Length - 1 - i] * power;
                power  *= C;
            }
            return(result);
        };

        // index is a reversible hash
        // pulls out the bit pattern
        byte[] patternFromIndex(long ind)
        {
            long residue = ind, power = W;

            byte[] result = new byte[N * N];

            for (int i = 0; i < result.Length; i++)
            {
                power /= C;
                int count = 0;

                while (residue >= power)
                {
                    residue -= power;
                    count++;
                }

                result[i] = (byte)count;
            }

            return(result);
        };

        Dictionary <long, int> weights  = new Dictionary <long, int>();
        List <long>            ordering = new List <long>();

        for (int y = 0; y < (periodicInput ? SMY : SMY - N + 1); y++)
        {
            for (int x = 0; x < (periodicInput ? SMX : SMX - N + 1); x++)
            {
                byte[][] ps = new byte[8][];

                ps[0] = patternFromSample(x, y);
                ps[1] = reflect(ps[0]);
                ps[2] = rotate(ps[0]);
                ps[3] = reflect(ps[2]);
                ps[4] = rotate(ps[2]);
                ps[5] = reflect(ps[4]);
                ps[6] = rotate(ps[4]);
                ps[7] = reflect(ps[6]);

                for (int k = 0; k < symmetry; k++)
                {
                    long ind = index(ps[k]);
                    if (weights.ContainsKey(ind))
                    {
                        weights[ind]++;
                    }
                    else
                    {
                        weights.Add(ind, 1);
                        ordering.Add(ind);
                    }
                }
            }
        }

        // weights are every possible pattern + reflections + rotations
        // BUT IT IS WEIGHTED BY HOW OFTEN IT OCCURS IN THE SOURCE IMAGE
        numberOfOptionsT = weights.Count;
        this.ground      = (ground + numberOfOptionsT) % numberOfOptionsT;
        patterns         = new byte[numberOfOptionsT][];
        base.weights     = new double[numberOfOptionsT];

        int counter = 0;

        foreach (long w in ordering)
        {
            patterns[counter]     = patternFromIndex(w);
            base.weights[counter] = weights[w];
            counter++;
        }

        // can one pattern be overlaid on the other
        bool agrees(byte[] p1, byte[] p2, int dx, int dy)
        {
            int xmin = dx < 0 ? 0 : dx
            , xmax   = dx < 0 ? dx + N : N
            , ymin   = dy < 0 ? 0 : dy
            , ymax   = dy < 0 ? dy + N : N;

            for (int y = ymin; y < ymax; y++)
            {
                for (int x = xmin; x < xmax; x++)
                {
                    if (p1[x + N * y] != p2[x - dx + N * (y - dy)])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        };

        // ?
        propagator = new int[4][][];
        // d = cardinal direction delta
        for (int d = 0; d < 4; d++)
        {
            propagator[d] = new int[numberOfOptionsT][];
            for (int t = 0; t < numberOfOptionsT; t++)
            {
                List <int> list = new List <int>();

                // where do the patterns agree?
                for (int t2 = 0; t2 < numberOfOptionsT; t2++)
                {
                    if (agrees(patterns[t], patterns[t2], DX[d], DY[d]))
                    {
                        list.Add(t2);
                    }
                }
                propagator[d][t] = new int[list.Count];

                for (int c = 0; c < list.Count; c++)
                {
                    propagator[d][t][c] = list[c];
                }
            }
        }
    }
    override protected void CreateChildren()
    {
        base.CreateChildren();

        #region Top label

        Label label = new TitleLabel {Left = 20, Top = 20, StyleName = "title"};
        AddChild(label);

        new TextRotator
        {
            Delay = 5, // 5 seconds delay
            Lines = new[]
            {
                "Absolute Layout Demo 2",
                "Created with eDriven.Gui"/*,
                "Author: Danko Kozar"*/
            },
            Callback = delegate(string line) { label.Text = line; }
        }
            .Start();

        #endregion

        #region Bottom label

        Label label2 = new Label
        {
            HorizontalCenter = 0,
            Bottom = 20,
            Text = "[GuiInspector: Ctrl + click = sticky, Ctrl + Return toggles inspector, Ctrl + arrows for walking the DOM]"
        };
        label2.SetStyle("labelStyle", BlueLabelStyle.Instance);
        AddChild(label2);

        #endregion

        Button btn1 = new Button
        {
            Left = 100,
            Top = 100,
            Width = 300,
            Height = 300,
            FocusEnabled = false,
            Text = @"Left = 100,
Top = 100,
Width = 300,
Height = 300",
            Tooltip = @"This is the tooltip
Nice, eh? :)",
            SkinClass = typeof(ButtonSkin5),
            Icon = ImageLoader.Instance.Load("Icons/star_big")
        };
        AddChild(btn1);

        Button btn2 = new Button
        {
            Left = 500,
            Right = 100,
            Top = 100,
            MinWidth = 300,
            Height = 300,
            FocusEnabled = false,
            Text = @"Left = 400,
Right = 100,
Top = 100,
MinWidth = 300,
Height = 300",
            Tooltip = @"This is the tooltip of the second button
(this one is constrained in width, so resizes with screen width)",
            SkinClass = typeof(ButtonSkin5),
            Icon = ImageLoader.Instance.Load("Icons/star_big")
        };
        AddChild(btn2);

        Button btn3 = new Button
        {
            Left = 100,
            Top = 500,
            Bottom = 100,
            Width = 300,
            MinHeight = 300,
            FocusEnabled = false,
            Text = @"Left = 100,
Top = 500,
Bottom = 100,
Width = 300,
MinHeight = 300",
            Tooltip = @"This is the tooltip of the third button
(this one is constrained in height, so resizes with screen height)",
            SkinClass = typeof(ButtonSkin5),
            Icon = ImageLoader.Instance.Load("Icons/star_big")
        };
        AddChild(btn3);

        Stuff btn4 = new Stuff
        {
            Left = 500,
            Right = 100,
            Top = 500,
            Bottom = 100,
            MinWidth = 300,
            MinHeight = 300
        };
        AddChild(btn4);
    }