Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            helper = new DrawingHelper();

            AddHandler(MouseDownEvent, new MouseButtonEventHandler(designer_MouseDown), true);
        }
Example #2
0
 public AccountService(ICacheHandler cache, IMapper mapper, IAccountRepository accountRepository, IAccountRoleRepository accountRoleRepository, IMenuRepository menuRepository, IRoleRepository roleRepository, IButtonRepository buttonRepository, IPermissionRepository permissionRepository, DrawingHelper drawingHelper, ISystemService systemService, IServiceProvider serviceProvider)
 {
     _cache                 = cache;
     _mapper                = mapper;
     _accountRepository     = accountRepository;
     _accountRoleRepository = accountRoleRepository;
     _menuRepository        = menuRepository;
     _roleRepository        = roleRepository;
     _buttonRepository      = buttonRepository;
     _permissionRepository  = permissionRepository;
     _drawingHelper         = drawingHelper;
     _systemService         = systemService;
     _serviceProvider       = serviceProvider;
 }
Example #3
0
 protected override void LoadContent()
 {
     DrawingHelper.Initialize(this.GraphicsDevice);
     spriteBatch = new SpriteBatch(GraphicsDevice);
 }
        private static async Task <bool> GenerateFrames(IEnumerable <DateTimeOffset> keys, List <ParsedGraphInfo> parsedMessageInfos, string basePath, bool drawDots = true)
        {
            List <Task> tasks = new List <Task>();

            for (int i = 2; i <= keys.Count(); i++)
            {
                //if (i % 250 == 0)
                //    await Context.Channel.SendMessageAsync($"Frame gen {i} out of {keys.Count()}");

                var startTime = keys.Take(i).Min();
                var endTime   = keys.Take(i).Max();

                int maxY = GetMaxValue(parsedMessageInfos, endTime);

                var drawInfo = DrawingHelper.GetEmptyGraphics();
                var padding  = DrawingHelper.DefaultPadding;

                padding.Left   = 100; // large numbers
                padding.Bottom = 150; // possible for many labels
                padding.Right  = 150; // add labels for max height

                var labels = DrawingHelper.GetLabels(startTime.DateTime, endTime.DateTime, 0, maxY, 6, 10, " msg");

                var gridSize = new GridSize(drawInfo.Bitmap, padding);

                DrawingHelper.DrawGrid(drawInfo.Canvas, gridSize, padding, labels.XAxisLabels, labels.YAxisLabels, $"Messages count");

                int xOffset  = 0;
                int rowIndex = -4; // workaround to use as many label space as possible

                foreach (var item in parsedMessageInfos)
                {
                    // TODO optimize some lines + move to draw helper
                    var dataPoints = item.Info.Where(j => j.Key <= endTime).OrderBy(i => i.Key).ToDictionary(j => j.Key.DateTime, j => j.Value);

                    // todo add 2. y Axis on the right
                    var dataPointList = DrawingHelper.GetPoints(dataPoints, gridSize, true, startTime.DateTime, endTime.DateTime, false, maxY);

                    var highestPoint = -1f;

                    if (dataPointList.Count > 0)
                    {
                        highestPoint = dataPointList.Min(i => i.Y);
                    }

                    // TODO Do better label name
                    var drawLineInfo = DrawingHelper.DrawLine(drawInfo.Canvas, drawInfo.Bitmap, dataPointList, new SKPaint()
                    {
                        Color = item.Color
                    }, 6, "#" + item.GetName(), rowIndex, xOffset, drawDots, highestPoint, item.Image);                                                                                                                               //new Pen(System.Drawing.Color.LightGreen)

                    if (drawLineInfo.newRow)
                    {
                        rowIndex++;
                        xOffset = drawLineInfo.usedWidth;
                    }
                    else
                    {
                        xOffset += drawLineInfo.usedWidth;
                    }
                }

                tasks.Add(SaveToDisk(basePath, i, drawInfo.Bitmap, drawInfo.Canvas));
            }


            Task.WaitAll(tasks.ToArray());

            return(true);
        }
Example #5
0
        private void Add_Load_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int nodeID = 0, count;

                if (rd_nodeID.IsChecked == true)
                {
                    nodeID = Int32.Parse(_nodeID.Text);
                }
                if (rd_nodeCoord.IsChecked == true)
                {
                    List <Node> nodeList = new List <Node>(MainWindow.nodeList);
                    double      x, y, z;
                    x      = Double.Parse(_nodeX.Text);
                    y      = Double.Parse(_nodeY.Text);
                    z      = Double.Parse(_nodeZ.Text);
                    nodeID = Node.FindNodeByCoordinates(x, y, z, nodeList).ID;
                }

                count = MainWindow.loadList.Count;
                Load load = new Load(count + 1, nodeID);

                if (_loadX.Text != "0")
                {
                    load.SetFx(Double.Parse(_loadX.Text));
                }
                if (_loadY.Text != "0")
                {
                    load.SetFy(Double.Parse(_loadY.Text));
                }
                if (_loadZ.Text != "0")
                {
                    load.SetFz(Double.Parse(_loadZ.Text));
                }
                if (_momentX.Text != "0")
                {
                    load.SetMx(Double.Parse(_momentX.Text));
                }
                if (_momentY.Text != "0")
                {
                    load.SetMy(Double.Parse(_momentY.Text));
                }
                if (_momentZ.Text != "0")
                {
                    load.SetMz(Double.Parse(_momentZ.Text));
                }

                if (rd_fixed.IsChecked == false)
                {
                    load.Status = "increment";
                }

                MainWindow.loadList.Add(load);

                DrawingHelper.DrawLoads(new List <Load>(MainWindow.loadList), false, MainWindow.dispList, Configuration.zoomParam);
                DrawingHelper.DrawMasses(new List <Mass>(MainWindow.massList), false, MainWindow.dispList, Configuration.zoomParam);
            } catch
            {
                MessageBox.Show("An error has occurred and the load case could not be defined. Please check your inputs and try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #6
0
        public void Load(GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator)
        {
            _rectangleTexture = DrawingHelper.CreateRectangleTexture(graphicsDevice, _rectangleWidth, _rectangleHeight,
                                                                     Color.White, Color.Black);
            int radius;

            if (_attachPoint == 0 | _attachPoint == 2)
            {
                radius = _rectangleHeight;
            }
            else
            {
                radius = _rectangleWidth;
            }
            _circleTexture = DrawingHelper.CreateCircleTexture(graphicsDevice, radius, Color.White, Color.Black);

            //body is created as rectangle so that it has the moment of inertia closer to the final shape of the object.
            _angleSpringleverBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _rectangleWidth,
                                                                             _rectangleHeight, 1f);

            _rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _angleSpringleverBody,
                                                                      _rectangleWidth, _rectangleHeight);
            _rectangleGeom.FrictionCoefficient = .5f;
            _rectangleGeom.CollisionGroup      = _collisionGroup;

            Vector2 offset = Vector2.Zero;

            switch (_attachPoint)
            {
            case 0:
            {
                offset = new Vector2(-_rectangleWidth / 2f, 0);       //offset to rectangle to left
                break;
            }

            case 1:
            {
                offset = new Vector2(0, -_rectangleHeight / 2f);       //offset to rectangle to top
                break;
            }

            case 2:
            {
                offset = new Vector2(_rectangleWidth / 2f, 0);       //offset to rectangle to right
                break;
            }

            case 3:
            {
                offset = new Vector2(0, _rectangleHeight / 2f);       //offset to rectangle to bottom
                break;
            }
            }

            _angleSpringleverBody.Position = _position - offset;

            _circleGeom = GeomFactory.Instance.CreateCircleGeom(physicsSimulator, _angleSpringleverBody, radius, 20,
                                                                offset, 0);
            _circleGeom.FrictionCoefficient = .5f;
            _circleGeom.CollisionGroup      = _collisionGroup;

            _revoluteJoint = JointFactory.Instance.CreateFixedRevoluteJoint(physicsSimulator, _angleSpringleverBody,
                                                                            _position);
            physicsSimulator.Add(_revoluteJoint);
            SpringFactory.Instance.CreateFixedAngleSpring(physicsSimulator, _angleSpringleverBody,
                                                          _springConstant, _dampningConstant);
        }
Example #7
0
        private void DrawingOnOnDraw(EventArgs args)
        {
            var heroes          = Config.Main.Updater.Heroes;
            var itemBorderWhite = ItemBorderClr.Value.SelectedIndex == 0;

            foreach (var heroCont in heroes)
            {
                if (!EnableForMainHero && heroCont.IsOwner)
                {
                    continue;
                }
                if (!EnableForAllyHeroes && heroCont.IsAlly)
                {
                    continue;
                }
                var hero = heroCont.Hero;
                if (!hero.IsAlive)
                {
                    continue;
                }
                if (!hero.IsVisible)
                {
                    continue;
                }
                var hpBarPos = HudInfo.GetHPbarPosition(hero);
                var pos      = hpBarPos + new Vector2(ExtraPositionX, ExtraPositionY);
                if (pos.IsZero)
                {
                    continue;
                }
                var copy = pos;
                var size = new Vector2(HudInfo.GetHPBarSizeX(hero) + ExtraSizeX,
                                       HudInfo.GetHpBarSizeY(hero) + ExtraSizeY);
                if (HealthBar)
                {
                    if (!heroCont.IsAlly)
                    {
                        var health = DrawMaxHealth ? $"{hero.Health}/{heroCont.MaxHealth}" : $"{hero.Health}";
                        DrawingHelper.DrawHealthBar(pos, size, health, HealthBarTextSize);
                    }
                }
                if (heroCont.IsOwner)
                {
                    pos  += new Vector2(-1, size.Y);
                    size -= new Vector2(1, 0);
                }
                else
                {
                    pos += new Vector2(0, size.Y - 2);
                }

                if (ManaBars)
                {
                    if (heroCont.IsAlly && ManaBarsForAlly || !heroCont.IsAlly && ManaBarsForEnemy)
                    {
                        var mana = heroCont.Mana;
                        pos = DrawingHelper.DrawManaBar(pos, mana * size.X / heroCont.MaxMana, size,
                                                        new Color(0, 155, 255, 255),
                                                        new Color(0, 0, 0, 255), ((int)mana).ToString(), ManaBarsNumbers,
                                                        ManaBarsSize.Value.Value);
                    }
                    else if (heroCont.IsAlly && !ManaBarsForAlly)
                    {
                        pos += new Vector2(0, size.Y / 2);
                    }
                }

                if (AbilityOverlay)
                {
                    var tempSize    = size.X * AbilitySize / 30f;
                    var abilitySize = new Vector2(tempSize);

                    //IEnumerable<Ability> abilities = heroCont.Abilities;
                    //var enumerable = abilities as Ability[] ?? abilities.ToArray();
                    //var abilityCount = abilities.Count();
                    var abilities    = heroCont.Abilities2.Where(x => x.IsValid && !x.IsHidden).ToList();
                    var abilityCount = abilities.Count;
                    //var extraAbilitites = abilityCount - 4;
                    pos += new Vector2((size.X - tempSize * abilityCount) / 2f, 0);

                    /*if (extraAbilitites > 0)
                     * {
                     *  pos -= new Vector2(abilitySize.X * extraAbilitites / 2f, 0);
                     * }*/

                    /*foreach (var ability in abilities)
                     * {
                     *  if (ability == null || !ability.IsValid || ability.IsHidden)
                     *  {
                     *      heroCont.RefreshAbilities();
                     *      continue;
                     *  }
                     *  pos = DrawAbilityState(pos, ability, abilitySize);
                     * }*/

                    try
                    {
                        foreach (var ability in abilities.OrderBy(x => x.AbilitySlot))
                        {
                            pos = DrawAbilityState(pos, ability, abilitySize);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }

                if (ItemOverlay)
                {
                    var tempSize    = size.X * ItemSize / 30f;
                    var abilitySize = new Vector2(tempSize);
                    var abilities   = ItemDangItems
                        ? heroCont.DangItems
                        : ItemInvisBreakItems
                            ? heroCont.InvisBreakerItems
                            : heroCont.Items;
                    var abilityCount = abilities.Count;
                    //var extraAbilitites = abilityCount - 4;
                    pos  = copy;
                    pos += new Vector2((size.X - tempSize * abilityCount) / 2f, -abilitySize.Y);

                    /*if (extraAbilitites > 0)
                     * {
                     *  //pos -= new Vector2(abilitySize.X * extraAbilitites / 2f, 0);
                     *
                     * }*/

                    foreach (var ability in abilities)
                    {
                        if (ability == null || !ability.IsValid)
                        {
                            continue;
                        }
                        var id = ability.Id;
                        if (id == AbilityId.item_sphere)
                        {
                            if (ability.AbilityState == AbilityState.Ready)
                            {
                                Config.Main.ParticleManager.AddOrUpdate(hero, $"sphere {heroCont.Id}",
                                                                        "particles/items_fx/immunity_sphere_buff.vpcf", ParticleAttachment.RootboneFollow,
                                                                        RestartType.None);
                            }
                            else
                            {
                                Config.Main.ParticleManager.Remove($"sphere {heroCont.Id}");
                            }
                        }
                        pos = DrawItemState(pos, ability, abilitySize, itemBorderWhite ? Color.White : Color.Black);
                    }
                }
            }
        }
Example #8
0
 /// <summary>
 /// Get global bone orientation of a given bone.
 /// </summary>
 /// <param name="boneName"></param>
 /// <returns></returns>
 public Quaternion GetGlobalBoneOrientation(string boneName)
 {
     return(DrawingHelper.UnityToSMPL(_boneNameToTransform[boneName].rotation));
 }
Example #9
0
 public AccountService(ICacheHandler cache, IMapper mapper, IAccountRepository accountRepository, IAccountRoleRepository accountRoleRepository, IMenuRepository menuRepository, IRoleRepository roleRepository, IButtonRepository buttonRepository, IPermissionRepository permissionRepository, DrawingHelper drawingHelper, ISystemService systemService, IServiceProvider serviceProvider, IAccountConfigRepository accountConfigRepository, AdminDbContext dbContext, SystemConfigModel systemConfig)
 {
     _cache                   = cache;
     _mapper                  = mapper;
     _accountRepository       = accountRepository;
     _accountRoleRepository   = accountRoleRepository;
     _menuRepository          = menuRepository;
     _roleRepository          = roleRepository;
     _buttonRepository        = buttonRepository;
     _permissionRepository    = permissionRepository;
     _drawingHelper           = drawingHelper;
     _systemService           = systemService;
     _serviceProvider         = serviceProvider;
     _accountConfigRepository = accountConfigRepository;
     _dbContext               = dbContext;
     _systemConfig            = systemConfig;
 }
Example #10
0
        private bool BlockToDatabase(BlockReference block, Transaction tr)
        {
            try
            {
                Dictionary <string, AttributeReference> attribs = GetBlockAttributes(block, tr);

                if (String.IsNullOrEmpty(attribs["DRAWING-NUMBER"].TextString))
                {
                    PromptResult pr1 = _ed.GetString("Drawing Number:");
                    attribs["DRAWING-NUMBER"].TextString = pr1.StringResult;
                }
                if (String.IsNullOrEmpty(attribs["SHEET"].TextString))
                {
                    PromptResult pr1 = _ed.GetString("Sheet Number:");
                    attribs["SHEET"].TextString = pr1.StringResult;
                }
                if (String.IsNullOrEmpty(attribs["DRAWING-NUMBER"].TextString) ||
                    String.IsNullOrEmpty(attribs["SHEET"].TextString))
                {
                    _ed.WriteMessage("No drawing/sheet number forthcoming, returning.\n");
                    return(false);
                }
                DrawingsDataContext dc      = DBCommon.NewDC;
                Drawing             drawing = GetDrawing(dc, attribs["DRAWING-NUMBER"].TextString, attribs["SHEET"].TextString);

                if (drawing == null)
                {
                    drawing = new Drawing();
                    dc.Drawings.InsertOnSubmit(drawing);
                }

                foreach (var kvp in attribs)
                {
                    if (DrawingHelper.AttributeExists(kvp.Key)) //only save the desired attributes
                    {
                        drawing.SetAttribute(kvp.Key, kvp.Value.TextString);
                    }
                }

                drawing.SheetSize = GetSheetSizeFromBlock(block, tr);

                //TODO: check this
                if (_db.Filename.EndsWith("sv$", StringComparison.OrdinalIgnoreCase))
                {
                    _ed.WriteMessage("File has not been saved since autosave, filename not put into the database.\n");
                }
                else
                {
                    drawing.FileName = _db.Filename;

                    //drawing.Filename = _db.OriginalFileName;
                }
                //If we're putting this in via the CAD, then it must be electronic
                drawing.Electronic = true;

                dc.SubmitChanges();

                if (drawing.Category == DrawingCategory.Undefined)
                {
                    _ed.WriteMessage("WARNING:  Drawing Category is undefined!\n");
                }
                if (drawing.Status == DrawingStatus.Undefined)
                {
                    _ed.WriteMessage("WARNING:  Drawing Status is undefined!\n");
                }
                _ed.WriteMessage("Data successfully written to the database from block " + block.Name + "\n");
                return(true);
            }
            catch (Exception ex)
            {
                _ed.WriteMessage(ex.Message);
                return(false);
            }
        }
        private void Drawing_OnEndScene(EventArgs args)
        {
            foreach (AIHeroClient hero in EntityManager.Heroes.AllHeroes)
            {
                if (!hero.IsHPBarRendered || !hero.HPBarPosition.IsOnScreen() || hero.IsDead || hero.IsMe || (hero.IsAlly && !cooldownTrackerMenu["trackallies"].Cast <CheckBox>().CurrentValue) || (hero.IsEnemy && !cooldownTrackerMenu["trackenemies"].Cast <CheckBox>().CurrentValue))
                {
                    continue;
                }

                //hero.HPBarYOffset = 0.4f;

                Vector2 startVector2 = new Vector2(((int)(hero.HPBarPosition.X + 0.5f)) - 1, ((int)(hero.HPBarPosition.Y + 0.5f)) + 2);

                #region SummmonersBar Block
                DrawingHelper.DrawFilledRectangle(startVector2.X - 14, startVector2.Y, 14, 29, Color.FromArgb(115, 113, 115)); // light gray box
                DrawingHelper.DrawRectangle(startVector2.X - 13, startVector2.Y + 1, 13, 13, Color.Black);                     // 1st outer box
                DrawingHelper.DrawRectangle(startVector2.X - 13, startVector2.Y + 15, 13, 13, Color.Black);                    // 2nd outer box
                #endregion

                foreach (SpellSlot slot in summonerSpellSlots)
                {
                    SpellDataInst spell         = hero.Spellbook.GetSpell(slot);
                    float         time          = spell.CooldownExpires - Game.Time;
                    float         totalCooldown = spell.Cooldown;

                    float percent = (time > 0 && Math.Abs(totalCooldown) > float.Epsilon) ? 1f - (time / totalCooldown) : 1f;

                    if (slot == SpellSlot.Summoner1)
                    {
                        DrawingHelper.DrawFilledRectangle(startVector2.X - 12, startVector2.Y + 2, 11, 11, GetSummonerColor(spell.Name));
                        if (percent < 1f)
                        {
                            Drawing.DrawLine(startVector2.X - 12, startVector2.Y + 2, startVector2.X - 1, startVector2.Y + 13, 1f, Color.Black);
                            Drawing.DrawLine(startVector2.X - 1, startVector2.Y + 1, startVector2.X - 13, startVector2.Y + 13, 1f, Color.Black);

                            Text.TextValue = Math.Floor(time).ToString();
                            Text.Position  = new Vector2(startVector2.X - 21 - (Text.TextValue.Length * 5), startVector2.Y - 1);
                            Text.Draw();
                        }
                    }
                    else
                    {
                        DrawingHelper.DrawFilledRectangle(startVector2.X - 12, startVector2.Y + 16, 11, 11, GetSummonerColor(spell.Name));
                        if (percent < 1f)
                        {
                            Drawing.DrawLine(startVector2.X - 12, startVector2.Y + 16, startVector2.X - 1, startVector2.Y + 27, 1f, Color.Black);
                            Drawing.DrawLine(startVector2.X - 1, startVector2.Y + 15, startVector2.X - 13, startVector2.Y + 27, 1f, Color.Black);

                            Text.TextValue = Math.Floor(time).ToString();
                            Text.Position  = new Vector2(startVector2.X - 21 - (Text.TextValue.Length * 5), startVector2.Y + 15);
                            Text.Draw();
                        }
                    }
                }

                #region SpellBar Block
                Drawing.DrawLine(startVector2.X, startVector2.Y + 18, startVector2.X, startVector2.Y + 29, 1, Color.FromArgb(115, 113, 115));             //left light gray outer line
                Drawing.DrawLine(startVector2.X, startVector2.Y + 28, startVector2.X + 130, startVector2.Y + 28, 1, Color.FromArgb(115, 113, 115));       //bottom light gray outer line
                Drawing.DrawLine(startVector2.X + 130, startVector2.Y + 28, startVector2.X + 134, startVector2.Y + 24, 1, Color.FromArgb(115, 113, 115)); //right diagonal light gray outer line
                Drawing.DrawLine(startVector2.X + 133, startVector2.Y + 24, startVector2.X + 133, startVector2.Y + 17, 1, Color.FromArgb(115, 113, 115)); //right up light gray outer line

                Drawing.DrawLine(startVector2.X + 1, startVector2.Y + 18, startVector2.X + 1, startVector2.Y + 27, 1, Color.FromArgb(74, 69, 74));        //left dark gray middle line
                Drawing.DrawLine(startVector2.X + 1, startVector2.Y + 27, startVector2.X + 130, startVector2.Y + 27, 1, Color.FromArgb(74, 69, 74));      //bottom dark gray middle line
                Drawing.DrawLine(startVector2.X + 130, startVector2.Y + 27, startVector2.X + 133, startVector2.Y + 24, 1, Color.FromArgb(74, 69, 74));    //right diagonal dark gray middle line

                Drawing.DrawLine(startVector2.X + 2, startVector2.Y + 17, startVector2.X + 2, startVector2.Y + 26, 1, Color.Black);                       //left black inner line
                Drawing.DrawLine(startVector2.X + 2, startVector2.Y + 26, startVector2.X + 107, startVector2.Y + 26, 1, Color.Black);                     //bottom black inner line

                Drawing.DrawLine(startVector2.X + 2, startVector2.Y + 17, startVector2.X + 2, startVector2.Y + 18, 1, Color.FromArgb(115, 113, 115));     //Pixel fix light
                Drawing.DrawLine(startVector2.X + 2, startVector2.Y + 18, startVector2.X + 2, startVector2.Y + 19, 1, Color.FromArgb(49, 48, 49));        //Pixel fix dark

                DrawingHelper.DrawRectangle(startVector2.X + 2, startVector2.Y + 19, 106, 8, Color.Black);                                                //SpellBar container
                #endregion

                foreach (SpellSlot slot in spellSlots)
                {
                    SpellDataInst spell         = hero.Spellbook.GetSpell(slot);
                    float         time          = spell.CooldownExpires - Game.Time;
                    float         totalCooldown = spell.Cooldown;

                    int   Xoffset = 0;
                    float length  = 25;
                    switch (slot)
                    {
                    case SpellSlot.Q:
                        Xoffset = 3;
                        break;

                    case SpellSlot.W:
                        Xoffset = 29;
                        break;

                    case SpellSlot.E:
                        Xoffset = 55;
                        break;

                    case SpellSlot.R:
                        Xoffset = 81;
                        length  = 26;
                        break;
                    }

                    SpellState spellState = hero.Spellbook.CanUseSpell(slot);
                    float      percent    = (time > 0 && Math.Abs(totalCooldown) > float.Epsilon) ? 1f - (time / totalCooldown) : 1f;

                    if (spellState != SpellState.NotLearned)
                    {
                        if (percent == 1f)
                        {
                            DrawingHelper.DrawFilledRectangle(startVector2.X + Xoffset, startVector2.Y + 20, length, 6, Color.Green);
                        }
                        else
                        {
                            DrawingHelper.DrawFilledRectangle(startVector2.X + Xoffset, startVector2.Y + 20, length, 6, Color.DarkGray);
                            DrawingHelper.DrawFilledRectangle(startVector2.X + Xoffset, startVector2.Y + 20, length * percent, 6, Color.Orange);
                            Text.TextValue = Math.Floor(time).ToString();
                            Text.Position  = new Vector2(startVector2.X + Xoffset + 13 - (Text.TextValue.Length * 3), startVector2.Y + 29);
                            Text.Draw();
                        }
                    }
                    else
                    {
                        DrawingHelper.DrawFilledRectangle(startVector2.X + Xoffset, startVector2.Y + 20, length, 6, Color.Gray);
                    }
                }

                Drawing.DrawLine(startVector2.X + 28, startVector2.Y + 20, startVector2.X + 28, startVector2.Y + 26, 1, Color.Black); //First Line
                Drawing.DrawLine(startVector2.X + 54, startVector2.Y + 20, startVector2.X + 54, startVector2.Y + 26, 1, Color.Black); //Second Line
                Drawing.DrawLine(startVector2.X + 80, startVector2.Y + 20, startVector2.X + 80, startVector2.Y + 26, 1, Color.Black); // Third Line
            }
        }
    void Update()
    {
        _currentIndex = indexSelector;
        {
            if (_oldIndex != _currentIndex)
            {
                _oldIndex     = _currentIndex;
                indexSelector = Mathf.Clamp(indexSelector, 0, _vertices.Length - 1);
                point.transform.localPosition = _vertices[indexSelector];

                Destroy(_line);
                _line = DrawingHelper.DrawLine(startObject.position, go.position + _vertices[indexSelector], Color.red);

                _worldSpaceMatrix      = go.transform.localToWorldMatrix;
                _worldSpaceMatrix.m03 += _vertices[indexSelector].x;
                _worldSpaceMatrix.m13 += _vertices[indexSelector].y;
                _worldSpaceMatrix.m23 += _vertices[indexSelector].z;

                if (_camera)
                {
                    _viewMatrix       = _camera.worldToCameraMatrix;
                    _projectionMatrix = _camera.projectionMatrix;
                }

                switch (Space)
                {
                case CoordinateSpace.ObjectSpace:
                    currentSpace = _vertices[indexSelector];
                    break;

                case CoordinateSpace.WorldSpace:
                    currentSpace.x = _worldSpaceMatrix.m03;
                    currentSpace.y = _worldSpaceMatrix.m13;
                    currentSpace.z = _worldSpaceMatrix.m23;
                    break;

                case CoordinateSpace.ViewSpace:
                    _viewSpace     = _viewMatrix * _worldSpaceMatrix;
                    currentSpace.x = _viewSpace.m03;
                    currentSpace.y = _viewSpace.m13;
                    currentSpace.z = _viewSpace.m23;
                    break;

                case CoordinateSpace.ProjectionSpace:
                    DestroyCameraLines();
                    DrawNearClippingPlane();
                    _projectionSpace = _projectionMatrix * _viewMatrix * _worldSpaceMatrix;
                    currentSpace.x   = _projectionSpace.m03;
                    currentSpace.y   = _projectionSpace.m13;
                    currentSpace.z   = _projectionSpace.m23;
                    currentSpace.w   = _projectionSpace.m33;
                    break;

                case CoordinateSpace.NormalizedDeviceCoordinateSpace:
                    DestroyCameraLines();
                    DrawNearClippingPlane();
                    _projectionSpace = _projectionMatrix * _viewMatrix * _worldSpaceMatrix;
                    currentSpace.x   = _projectionSpace.m03 / _projectionSpace.m33;
                    currentSpace.y   = _projectionSpace.m13 / _projectionSpace.m33;
                    currentSpace.z   = _projectionSpace.m23 / _projectionSpace.m33;
                    break;

                case CoordinateSpace.TextureSpace:
                    DestroyCameraLines();
                    DrawNearClippingPlane();
                    _projectionSpace = _projectionMatrix * _viewMatrix * _worldSpaceMatrix;
                    currentSpace.x   = (_projectionSpace.m03 / _projectionSpace.m33 + 1) * 0.5f;
                    currentSpace.y   = (_projectionSpace.m13 / _projectionSpace.m33 + 1) * 0.5f;
                    Debug.Log("The graphics API type and driver version used by the graphics device: " + SystemInfo.graphicsDeviceVersion);
                    Debug.Log("Graphics device shader capability level: " + SystemInfo.graphicsShaderLevel);
                    break;
                }
            }
        }
    }
Example #13
0
 private void GameHooks_LoadContent(ContentManager obj)
 {
     gridTexture = TrainerHelper.CreateGrid(Game.GraphicsDevice, 0.1f);
     border      = DrawingHelper.CreateOnePixelTexture(Game.GraphicsDevice, Color.White);
 }
Example #14
0
 public Form1()
 {
     InitializeComponent();
     dh = new DrawingHelper(this);
 }
Example #15
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.DrawString(font != null ? font : CONTENT_MANAGER.defaultfont, (string.IsNullOrEmpty(text)) ? "" : text, AutoSize? Position.ToVector2(): Position.ToVector2() - origin, foregroundColor, Rotation, Vector2.Zero, scale, SpriteEffects.None, LayerDepth.GuiUpper);
     DrawingHelper.DrawRectangle(rect, backgroundColor, true);
     DrawingHelper.DrawRectangle(rect, borderColor, false);
 }
Example #16
0
        private void Canvas_PaintSurface(object sender, SKPaintSurfaceEventArgs e)
        {
            var canvas = e.Surface.Canvas;

            var canvasWidth  = e.Info.Width;
            var canvasHeight = e.Info.Height;

            canvas.Clear();

            var leftMargin   = 5;
            var bottomMargin = 5;

            var recHeight = 250;

            DrawingHelper.DrawBackgroundRectangle(
                canvas,
                canvasWidth,
                recHeight,
                0,
                canvasHeight - recHeight);

            DrawingHelper.DrawText(
                canvas,
                leftMargin,
                canvasHeight - 0 - bottomMargin,
                $"Camera: {Stats.CameraFps} fps ({Stats.CameraMs} ms)");

            DrawingHelper.DrawText(
                canvas,
                leftMargin,
                canvasHeight - 50 - bottomMargin,
                $"Processing: {Stats.ProcessingFps} fps ({Stats.ProcessingMs} ms)");

            DrawingHelper.DrawText(
                canvas,
                leftMargin,
                canvasHeight - 100 - bottomMargin,
                $"YUV2RGB: {Stats.YUV2RGBElapsedMs} ms");

            DrawingHelper.DrawText(
                canvas,
                leftMargin,
                canvasHeight - 150 - bottomMargin,
                $"ResizeAndRotate: {Stats.ResizeAndRotateElapsedMs} ms");

            DrawingHelper.DrawText(
                canvas,
                leftMargin,
                canvasHeight - 200 - bottomMargin,
                $"TFRecognize: {Stats.InterpreterElapsedMs} ms");

            for (var i = 0; i < Stats.NumDetections; i++)
            {
                var score      = Stats.Scores[i];
                var labelIndex = (int)Stats.Labels[i];
                var xmin       = Stats.BoundingBoxes[i * 4 + 0];
                var ymin       = Stats.BoundingBoxes[i * 4 + 1];
                var xmax       = Stats.BoundingBoxes[i * 4 + 2];
                var ymax       = Stats.BoundingBoxes[i * 4 + 3];

                if (!labelIndex.Between(0, labels.Length - 1))
                {
                    continue;
                }
                if (score < MinScore)
                {
                    continue;
                }

                var left   = ymin * canvasWidth;
                var top    = xmin * canvasHeight;
                var right  = ymax * canvasWidth;
                var bottom = xmax * canvasHeight;

                DrawingHelper.DrawBoundingBox(
                    canvas,
                    left,
                    top,
                    right,
                    bottom);

                var label = labels[labelIndex + LabelOffset];
                DrawingHelper.DrawText(canvas, left, bottom, $"{label} - {score}");
            }
        }
Example #17
0
    public override void draw(SpriteBatch s)
    {
        base.draw(s);


        for (int i = 0; i < _playingButtons.Count - 1; i++)
        {
            if (_playingButtons[i]._drawTooltip == true)
            {
                switch (i)
                {
                default:
                    break;

                case 0:
                    s.DrawString(font, "Move units", ToolTipPos, Color.DarkOrange);
                    break;

                case 1:
                    Farm e = new Farm(null, new Vector2(0, 0), BuildingAndUnit.faction.Human);
                    { s.DrawString(font, "Produce Farm, Gold:" + e.GoldCost + "+ Lumber:" + e.LumberCost, ToolTipPos, Color.DarkOrange); }
                    break;

                case 2:
                    WorkerUnit w = new WorkerUnit(null);
                    { s.DrawString(font, "Produce Worker, Gold:" + w.GoldCost + "+ Food:" + w._foodCost, ToolTipPos, Color.DarkOrange); }
                    break;

                case 3:
                    s.DrawString(font, "Stop selected units", ToolTipPos, Color.DarkOrange);
                    break;

                case 4:
                    Barracks B = new Barracks(null, new Vector2(0, 0), BuildingAndUnit.faction.Human);
                    s.DrawString(font, "Barracks, Gold:" + B.GoldCost + "Lumber:" + B.LumberCost, ToolTipPos, Color.DarkOrange);
                    break;

                case 5:
                    BasicMeleeUnit b = new Footman(null, new Vector2(0, 0));
                    s.DrawString(font, "Footman, Gold:" + b.GoldCost + "Lumber:" + b.LumberCost + "Food:" + b.FoodCost, ToolTipPos, Color.DarkOrange);
                    break;

                case 6:
                    s.DrawString(font, "Attack", ToolTipPos, Color.DarkOrange);
                    break;

                case 7:
                    s.DrawString(font, "Chop trees", ToolTipPos, Color.DarkOrange);
                    break;

                case 8:
                    Archer a = new Archer(null, new Vector2(0, 0));
                    s.DrawString(font, "Archer, Gold:" + a.GoldCost + "Lumber:" + a.LumberCost + "Food:" + a.FoodCost, ToolTipPos, Color.DarkOrange);
                    break;

                case 9:
                    s.DrawString(font, " - ", ToolTipPos, Color.Black);
                    break;

                case 10:
                    //Barracks B = new Barracks(null, new Vector2(0, 0), BuildingAndUnit.faction.Human);
                    //s.DrawString(font, "Barracks, Gold:"+ B.GoldCost + "Lumber:" + B.LumberCost , ToolTipPos, Color.DarkOrange);
                    break;

                case 11:
                    s.DrawString(font, "- ", ToolTipPos, Color.Black);
                    break;

                case 12:
                    s.DrawString(font, " - ", ToolTipPos, Color.Black);
                    break;
                }
            }
        }

        _minimap.draw(s);
        s.Draw(_minimapBorder, new Vector2(0, GameEnvironment.getCamera().getScreenSize().Y - 300), Color.White);
        //foreach (BasicMeleeUnit q in hudUnits.OfType<BasicMeleeUnit>())

        if (hudUnits != null)
        {
            int i = 0;
            foreach (BuildingAndUnit e in hudUnits.OfType <BuildingAndUnit>())
            {
                if (e is ProductionBuilding)
                {
                    if ((e as ProductionBuilding)._producingUnit)
                    {
                        DrawingHelper.DrawRectangle(new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, 400, 20), s, Color.SaddleBrown, 2);
                        s.Draw(GameEnvironment.getAssetManager().GetSprite("Sprites/HUD/Healthbar"), new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, (int)(400 * (float)((float)(e as ProductionBuilding)._unitProductionTimer / (float)(e as ProductionBuilding)._unitProductionTime)), 20), Color.White);
                        //DrawingHelper.DrawRectangle(new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 60, (int)(400*(float)((float)(e as ProductionBuilding)._unitProductionTimer / (float)(e as ProductionBuilding)._unitProductionTime)), 20), s, Color.Green, 2);
                    }
                }

                e.Healthbar(s, new Vector2((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 120), 1);
                s.Draw(e.Sprite, new Rectangle((int)GameEnvironment.getCamera().getScreenSize().X / 2 - 350 + i * 64, (int)GameEnvironment.getCamera().getScreenSize().Y - 120, 64, 64), Color.White);
                i++;
                if (i > 9)
                {
                    break;
                }
            }
        }
    }
        private void Add_Boundary_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int    nodeID = 0, count;
                int    nodeNumb = Int32.Parse(_nodeNumb.Text);
                double incX     = Double.Parse(_incX.Text);
                double incY     = Double.Parse(_incY.Text);
                double incZ     = Double.Parse(_incZ.Text);

                for (int i = 0; i < nodeNumb; i++)
                {
                    if (rd_nodeID.IsChecked == true)
                    {
                        nodeID = Int32.Parse(_nodeID.Text);
                    }
                    if (rd_nodeCoord.IsChecked == true)
                    {
                        List <Node> nodeList = new List <Node>(MainWindow.nodeList);
                        double      x, y, z;
                        x      = Double.Parse(_nodeX.Text) + i * incX;
                        y      = Double.Parse(_nodeY.Text) + i * incY;
                        z      = Double.Parse(_nodeZ.Text) + i * incZ;
                        nodeID = Node.FindNodeByCoordinates(x, y, z, nodeList).ID;
                    }

                    count = MainWindow.supportList.Count;
                    Support sup = new Support(count + 1, nodeID);

                    if (chk_xTrans.IsChecked == true)
                    {
                        sup.Set_tX(Double.Parse(_tX.Text));
                    }
                    if (chk_yTrans.IsChecked == true)
                    {
                        sup.Set_tY(Double.Parse(_tY.Text));
                    }
                    if (chk_zTrans.IsChecked == true)
                    {
                        sup.Set_tZ(Double.Parse(_tZ.Text));
                    }
                    if (chk_xRot.IsChecked == true)
                    {
                        sup.Set_rX(Double.Parse(_rX.Text));
                    }
                    if (chk_yRot.IsChecked == true)
                    {
                        sup.Set_rY(Double.Parse(_rY.Text));
                    }
                    if (chk_zRot.IsChecked == true)
                    {
                        sup.Set_rZ(Double.Parse(_rZ.Text));
                    }

                    MainWindow.supportList.Add(sup);
                }
                DrawingHelper.DrawBoundaryConditions(new List <Support>(MainWindow.supportList), false, MainWindow.dispList, 1);
            }
            catch
            {
                MessageBox.Show("An error has occurred and the boundary conditions could not be defined. Please check your inputs and try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public DefaultVerifyCodeProvider(DrawingHelper drawingHelper, ICacheHandler cacheHandler, IConfigProvider configProvider)
 {
     _drawingHelper  = drawingHelper;
     _cacheHandler   = cacheHandler;
     _configProvider = configProvider;
 }
Example #20
0
        private void DrawSingleRecallBar(float X, float Y, Recall recall)
        {
            int opacity = (int)((recallTrackerMenu["opacity"].Cast <Slider>().CurrentValue / 100f) * 255);

            DrawingHelper.DrawRectangle(X, Y, recallbarWidth, recallbarHeight, Color.FromArgb(opacity, Color.Black));
            DrawingHelper.DrawRectangle(X + 1, Y + 1, recallbarWidth - 2, recallbarHeight - 2, Color.FromArgb(opacity, Color.Black));
            DrawingHelper.DrawRectangle(X + 2, Y + 2, recallbarWidth - 4, recallbarHeight - 4, Color.FromArgb(opacity, Color.Gray));

            if (!recall.IsAborted)
            {
                DrawingHelper.DrawFilledRectangle(X + 2, Y + 2, (recallbarWidth - 4) * recall.Percent(), recallbarHeight - 4, Color.FromArgb(opacity, DrawingHelper.Interpolate(Color.Red, Color.LawnGreen, recall.Percent())));
            }
            else
            {
                DrawingHelper.DrawFilledRectangle(X + 2, Y + 2, (recallbarWidth - 4) * recall.Percent(), recallbarHeight - 4, Color.FromArgb(opacity, Color.SlateGray));
            }

            Text.TextValue = recall.Name;
            Text.Position  = new Vector2(X + recallbarWidth + 3, Y);
            Text.Draw();

            Text.Position  = new Vector2(X + recallbarWidth + 6 + Text.Bounding.Width, Y);
            Text.TextValue = "(" + Math.Round(recall.HealthPercent) + "%)";
            Text.Color     = DrawingHelper.Interpolate(Color.Red, Color.LawnGreen, recall.HealthPercent / 100f);
            Text.Draw();

            Text.Color = Color.AntiqueWhite;
        }
Example #21
0
        private void DrawingOnOnDraw(EventArgs args)
        {
            var heroes = Config.Main.Updater.Heroes;
            var size   = new Vector2(_size.X, SizeY);

            foreach (var heroCont in heroes)
            {
                var hero = heroCont.Hero;
                var pos  = GetTopPanelPosition(hero);
                if (pos.IsZero)
                {
                    continue;
                }
                if (HealthBar)
                {
                    pos = DrawingHelper.DrawBar(pos, heroCont.Health * size.X / heroCont.MaxHealth, size,
                                                Color.GreenYellow,
                                                Color.Red);
                }
                if (ManaBar)
                {
                    pos = DrawingHelper.DrawBar(pos, heroCont.Mana * size.X / heroCont.MaxMana, size, Color.Blue,
                                                new Color(155, 155, 155, 155));
                }
                if (VisibleBar)
                {
                    if (heroCont.IsAlly)
                    {
                        var isVisible = hero.IsVisibleToEnemies;
                        if (isVisible)
                        {
                            if (AllyVisibleBarType.Value.SelectedIndex == 0)
                            {
                                pos = DrawingHelper.DrawBar(pos, "visible", new Vector2(size.X, size.Y * 2),
                                                            Color.White);
                            }
                        }
                    }
                    else
                    {
                        var isVisible = hero.IsVisible;
                        if (isVisible)
                        {
                            heroCont.LastTimeUnderVision = Game.RawGameTime;
                        }
                        else
                        {
                            var time = (int)(Game.RawGameTime - heroCont.LastTimeUnderVision) + 1;
                            pos = DrawingHelper.DrawBar(pos, $"in fog {time}", new Vector2(size.X, size.Y * 2),
                                                        Color.White);
                        }
                    }
                }
                if (UltimateBar || UltimateIcon)
                {
                    var ultimate = heroCont.Ultimate;
                    if (UltimateBar)
                    {
                        switch (heroCont.AbilityState)
                        {
                        case AbilityState.OnCooldown:
                            var cdCalc = ultimate.Cooldown - (hero.IsVisible ? 0 : heroCont.TimeInFog);
                            if (cdCalc < 0)
                            {
                                break;
                            }
                            var cd = Math.Min(99, (int)(cdCalc + 1));
                            pos = DrawingHelper.DrawBar(pos, cd.ToString(CultureInfo.InvariantCulture),
                                                        new Vector2(size.X, size.X), ultimate.Texture, Color.White);
                            break;

                        case AbilityState.NotEnoughMana:
                            var mana = Math.Min(99, (int)(ultimate.Ability.ManaCost - heroCont.Mana));
                            pos = DrawingHelper.DrawBar(pos, mana.ToString(CultureInfo.InvariantCulture),
                                                        new Vector2(size.X, size.X), ultimate.Texture, Color.White,
                                                        new Color(100, 100, 255, 100));
                            break;
                        }
                    }

                    if (UltimateIcon && !heroCont.IsAlly)
                    {
                        string path;
                        switch (heroCont.AbilityState)
                        {
                        case AbilityState.OnCooldown:
                            path = "materials/ensage_ui/other/ulti_cooldown.vmat";
                            DrawUltimateIcon(hero, path, size);
                            break;

                        case AbilityState.NotEnoughMana:
                            path = "materials/ensage_ui/other/ulti_nomana.vmat";
                            DrawUltimateIcon(hero, path, size);
                            break;

                        case AbilityState.Ready:
                            path = "materials/ensage_ui/other/ulti_ready.vmat";
                            DrawUltimateIcon(hero, path, size);
                            break;
                        }
                    }
                }


                /*Drawing.DrawRect(pos, size, Color.White);
                 * pos += new Vector2(0, size.Y);
                 * Drawing.DrawRect(pos, size, Color.Blue);*/
            }
        }
Example #22
0
        public void Load(GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator)
        {
            _spiderTexture = DrawingHelper.CreateCircleTexture(graphicsDevice, spiderBodyRadius, Color.White,
                                                               Color.Black);
            _spiderOrigin = new Vector2(_spiderTexture.Width / 2f, _spiderTexture.Height / 2f);

            _upperLegTexture = DrawingHelper.CreateRectangleTexture(graphicsDevice, (int)_upperLegSize.X,
                                                                    (int)_upperLegSize.Y, Color.White, Color.Black);
            _upperLegOrigin = new Vector2(_upperLegTexture.Width / 2f, _upperLegTexture.Height / 2f);

            _lowerLegTexture = DrawingHelper.CreateRectangleTexture(graphicsDevice, (int)_lowerLegSize.X,
                                                                    (int)_lowerLegSize.Y, Color.Red, Color.Black);
            _lowerLegOrigin = new Vector2(_lowerLegTexture.Width / 2f, _lowerLegTexture.Height / 2f);

            //Load bodies
            _spiderBody          = BodyFactory.Instance.CreateCircleBody(physicsSimulator, spiderBodyRadius, 1);
            _spiderBody.Position = _position;
            _spiderBody.IsStatic = false;

            _leftUpperLegBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _upperLegSize.X,
                                                                         _upperLegSize.Y,
                                                                         1);
            _leftUpperLegBody.Position = _spiderBody.Position - new Vector2(spiderBodyRadius, 0) -
                                         new Vector2(_upperLegSize.X / 2, 0);

            _leftLowerLegBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _lowerLegSize.X,
                                                                         _lowerLegSize.Y,
                                                                         1);
            _leftLowerLegBody.Position = _spiderBody.Position - new Vector2(spiderBodyRadius, 0) -
                                         new Vector2(_upperLegSize.X, 0) - new Vector2(_lowerLegSize.X / 2, 0);

            _rightUpperLegBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _upperLegSize.X,
                                                                          _upperLegSize.Y, 1);
            _rightUpperLegBody.Position = _spiderBody.Position + new Vector2(spiderBodyRadius, 0) +
                                          new Vector2(_upperLegSize.X / 2, 0);

            _rightLowerLegBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _lowerLegSize.X,
                                                                          _lowerLegSize.Y, 1);
            _rightLowerLegBody.Position = _spiderBody.Position + new Vector2(spiderBodyRadius, 0) +
                                          new Vector2(_upperLegSize.X, 0) + new Vector2(_lowerLegSize.X / 2, 0);

            //load geometries
            _spiderGeom       = GeomFactory.Instance.CreateCircleGeom(physicsSimulator, _spiderBody, spiderBodyRadius, 14);
            _leftUpperLegGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _leftUpperLegBody,
                                                                         _upperLegSize.X, _upperLegSize.Y);
            _leftLowerLegGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _leftLowerLegBody,
                                                                         _lowerLegSize.X, _lowerLegSize.Y);
            _rightUpperLegGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _rightUpperLegBody,
                                                                          _upperLegSize.X, _upperLegSize.Y);
            _rightLowerLegGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _rightLowerLegBody,
                                                                          _lowerLegSize.X, _lowerLegSize.Y);
            _spiderGeom.CollisionGroup        = _collisionGroup;
            _leftUpperLegGeom.CollisionGroup  = _collisionGroup;
            _leftLowerLegGeom.CollisionGroup  = _collisionGroup;
            _rightUpperLegGeom.CollisionGroup = _collisionGroup;
            _rightLowerLegGeom.CollisionGroup = _collisionGroup;

            //load joints
            JointFactory.Instance.CreateRevoluteJoint(physicsSimulator, _spiderBody,
                                                      _leftUpperLegBody,
                                                      _spiderBody.Position -
                                                      new Vector2(spiderBodyRadius, 0));
            _leftShoulderAngleJoint = JointFactory.Instance.CreateAngleJoint(physicsSimulator, _spiderBody,
                                                                             _leftUpperLegBody);
            _leftShoulderAngleJoint.TargetAngle = -.4f;
            _leftShoulderAngleJoint.MaxImpulse  = 300;

            JointFactory.Instance.CreateRevoluteJoint(physicsSimulator, _spiderBody,
                                                      _rightUpperLegBody,
                                                      _spiderBody.Position +
                                                      new Vector2(spiderBodyRadius, 0));
            _rightShoulderAngleJoint = JointFactory.Instance.CreateAngleJoint(physicsSimulator, _spiderBody,
                                                                              _rightUpperLegBody);
            _rightShoulderAngleJoint.TargetAngle = .4f;
            _leftShoulderAngleJoint.MaxImpulse   = 300;

            JointFactory.Instance.CreateRevoluteJoint(physicsSimulator, _leftUpperLegBody,
                                                      _leftLowerLegBody,
                                                      _spiderBody.Position -
                                                      new Vector2(spiderBodyRadius, 0) -
                                                      new Vector2(_upperLegSize.X, 0));
            _leftKneeAngleJoint = JointFactory.Instance.CreateAngleJoint(physicsSimulator, _leftUpperLegBody,
                                                                         _leftLowerLegBody);
            _leftKneeAngleJoint.TargetAngle = -_kneeTargetAngle;
            _leftKneeAngleJoint.MaxImpulse  = 300;

            JointFactory.Instance.CreateRevoluteJoint(physicsSimulator, _rightUpperLegBody,
                                                      _rightLowerLegBody,
                                                      _spiderBody.Position +
                                                      new Vector2(spiderBodyRadius, 0) +
                                                      new Vector2(_upperLegSize.X, 0));
            _rightKneeAngleJoint = JointFactory.Instance.CreateAngleJoint(physicsSimulator, _rightUpperLegBody,
                                                                          _rightLowerLegBody);
            _rightKneeAngleJoint.TargetAngle = _kneeTargetAngle;
            _rightKneeAngleJoint.MaxImpulse  = 300;
        }
Example #23
0
 private void DrawGenome()
 {
     DrawingHelper.DrawGenome(_networkGraphGraphics, CurrentPlayer);
 }
Example #24
0
 public AccountService(LoginInfo loginInfo, ICacheHandler cache, IMapper mapper, IUnitOfWork <AdminDbContext> uow, IAccountRepository accountRepository, IAccountRoleRepository accountRoleRepository, IMenuRepository menuRepository, IRoleRepository roleRepository, IButtonRepository buttonRepository, IPermissionRepository permissionRepository, DrawingHelper drawingHelper, ILogger <AccountService> logger, ISystemService systemService)
 {
     _loginInfo             = loginInfo;
     _cache                 = cache;
     _mapper                = mapper;
     _uow                   = uow;
     _accountRepository     = accountRepository;
     _accountRoleRepository = accountRoleRepository;
     _menuRepository        = menuRepository;
     _roleRepository        = roleRepository;
     _buttonRepository      = buttonRepository;
     _permissionRepository  = permissionRepository;
     _drawingHelper         = drawingHelper;
     _systemService         = systemService;
 }
Example #25
0
        public async Task CreateMoviePlace(bool stacked, int groupByHour, int fps, bool drawDots)
        {
            var author = Context.Message.Author;

            if (author.Id != Program.ApplicationSetting.Owner)
            {
                Context.Channel.SendMessageAsync("You aren't allowed to run this command", false);
                return;
            }

            // Get users that havent pinged the role in the last 72h
            var sqlQuery = @"
    SELECT 
        HOUR(PlacedDateTime), 
        DATE(PlacedDateTime), 
        COUNT(*)
    FROM 
        PlaceBoardHistory 
    GROUP BY 
        HOUR(PlacedDateTime),
        DATE(PlacedDateTime)
    ORDER BY
        DATE(PlacedDateTime),
        HOUR(PlacedDateTime)";

            Stopwatch watch = new Stopwatch();

            watch.Start();


            List <GraphEntryInfo> messageTimes = new List <GraphEntryInfo>();



            var queryResult = await SQLHelper.GetQueryResults(null, sqlQuery, true, 10_000_000, true, true);


            Context.Channel.SendMessageAsync($"Retrieved data in {watch.ElapsedMilliseconds}ms");


            var parsedInfo = new ParsedGraphInfo()
            {
                ChannelId   = 1,
                Info        = new Dictionary <DateTimeOffset, int>(),
                ChannelName = "eth-place-bots",
                Color       = new SKColor(255, 0, 0)
            };

            var firstDateTime = DateTimeOffset.MaxValue;
            var lastDateTime  = DateTimeOffset.MinValue;


            foreach (var item in queryResult.Data)
            {
                int      hours    = Convert.ToInt32(item[0]);
                DateTime dateTime = Convert.ToDateTime(item[1]);
                int      count    = Convert.ToInt32(item[2]);

                var key = new DateTimeOffset(dateTime).AddHours(hours);
                parsedInfo.Info.Add(key, count);

                if (firstDateTime > key)
                {
                    firstDateTime = key;
                }
                if (lastDateTime < key)
                {
                    lastDateTime = key;
                }
            }


            double maxFrames = 600;

            int bound = (int)((lastDateTime - firstDateTime).TotalMinutes / maxFrames);

            Context.Channel.SendMessageAsync($"Group by {bound} minutes, Total mins {(lastDateTime - firstDateTime).TotalMinutes}");



            Context.Channel.SendMessageAsync($"Total frames {parsedInfo.Info.Count()}");

            //int val = 0;
            //foreach (var group in groups)
            //{
            //    val += group.Value;
            //    dataPointsSpam.Add(group.TimeStamp.DateTime, val);
            //}

            (string basePath, string baseOutputPath) = MovieHelper.CleanAndCreateMovieFolders();


            if (stacked)
            {
                var values = parsedInfo.Info.OrderBy(i => i.Key);
                int val    = 0;

                foreach (var info in values)
                {
                    val += info.Value;
                    parsedInfo.Info[info.Key] = val;
                }
            }

            try
            {
                List <Task> tasks = new List <Task>();

                for (int i = 2; i <= parsedInfo.Info.Count; i++)
                {
                    if (i % 250 == 0)
                    {
                        Context.Channel.SendMessageAsync($"Frame gen {i} out of {parsedInfo.Info.Count}");
                    }

                    var startTime = parsedInfo.Info.Keys.Take(i).Min();
                    var endTime   = parsedInfo.Info.Keys.Take(i).Max();

                    int maxY = 0;

                    // TODO calculate the rolling info


                    foreach (var info in parsedInfo.Info)
                    {
                        // only consider until this key
                        if (info.Key > endTime)
                        {
                            continue;
                        }

                        if (maxY < info.Value)
                        {
                            maxY = info.Value;
                        }
                    }


                    var drawInfo = DrawingHelper.GetEmptyGraphics();
                    var padding  = DrawingHelper.DefaultPadding;

                    padding.Left = 150; // large numbers

                    var labels = DrawingHelper.GetLabels(startTime.DateTime, endTime.DateTime, 0, maxY, 6, 10, " msg");

                    var gridSize = new GridSize(drawInfo.Bitmap, padding);

                    DrawingHelper.DrawGrid(drawInfo.Canvas, gridSize, padding, labels.XAxisLabels, labels.YAxisLabels, $"Messages count");

                    // TODO optimize some lines + move to draw helper
                    var dataPoints = parsedInfo.Info.Where(j => j.Key <= endTime).OrderBy(i => i.Key).ToDictionary(j => j.Key.DateTime, j => j.Value);

                    // todo add 2. y Axis on the right
                    var dataPointList = DrawingHelper.GetPoints(dataPoints, gridSize, true, startTime.DateTime, endTime.DateTime, false, maxY);

                    var highestPoint = -1f;

                    if (dataPoints.Count() > 0)
                    {
                        highestPoint = dataPointList.Min(i => i.Y);
                    }

                    DrawingHelper.DrawLine(drawInfo.Canvas, drawInfo.Bitmap, dataPointList, new SKPaint()
                    {
                        Color = parsedInfo.Color
                    }, 6, "#" + parsedInfo.ChannelName, 0, 0, drawDots, highestPoint);                                                                                                                  //new Pen(System.Drawing.Color.LightGreen)

                    tasks.Add(MovieHelper.SaveToDisk(basePath, i, drawInfo.Bitmap, drawInfo.Canvas));
                }

                await Context.Channel.SendMessageAsync("Finished processing, waiting for SaveToDisk");

                Task.WaitAll(tasks.ToArray());

                await Context.Channel.SendMessageAsync("Saving finished. Starting FFMpeg");

                int random = new Random().Next(1_000_000_000);
                //GlobalFFOptions.Configure(options => options.BinaryFolder = Program.Settings.FFMpegPath);
                Xabe.FFmpeg.FFmpeg.SetExecutablesPath(Program.ApplicationSetting.FFMpegPath);

                var    files    = Directory.GetFiles(Path.Combine(basePath)).ToList().OrderBy(i => i);
                string fileName = Path.Combine(baseOutputPath, $"movie_{random}.mp4");

                var conversion = new Conversion();
                conversion.SetInputFrameRate(fps);
                conversion.BuildVideoFromImages(files);
                conversion.SetFrameRate(fps);
                conversion.SetPixelFormat(PixelFormat.rgb24);
                conversion.SetOutput(fileName);
                conversion.OnProgress += Conversion_OnProgress;

                await conversion.Start();


                //var imageInfos = Directory.GetFiles(Path.Combine(basePath)).ToList().OrderBy(i => i).Select(i => ImageInfo.FromPath(i)).ToArray();
                //FFMpeg.JoinImageSequence(fileName, frameRate: 30, imageInfos);

                await Context.Channel.SendFileAsync(fileName);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while creating movie");
                await Context.Channel.SendMessageAsync(ex.ToString());
            }
        }
Example #26
0
        private void Add_Element_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double _length, _height, _thickness, _sizeX, _sizeY, _xIni, _yIni, _zIni;
                int    _mat, _layers, signLength, signHeight;
                _length    = Double.Parse(txt_length.Text);
                _height    = Double.Parse(txt_height.Text);
                _thickness = Double.Parse(txt_thickness.Text);
                _sizeX     = Double.Parse(txt_sizeLength.Text);
                _sizeY     = Double.Parse(txt_sizeHeight.Text);
                _mat       = Int32.Parse(txt_mat.Text);
                _xIni      = Double.Parse(txt_xIni.Text);
                _yIni      = Double.Parse(txt_yIni.Text);
                _zIni      = Double.Parse(txt_zIni.Text);
                _layers    = Int32.Parse(txt_layer.Text);

                Vector3D _iniVec, _lengthVec, _heightVec;
                _iniVec = new Vector3D(_xIni, _yIni, _zIni);

                //gets the sign of the length of the element
                if (_length < 0)
                {
                    signLength = -1;
                }
                else
                {
                    signLength = 1;
                }

                //gets the sign of the height of the element
                if (_height < 0)
                {
                    signHeight = -1;
                }
                else
                {
                    signHeight = 1;
                }

                //sets the length direction and height direction in terms of vectors
                if (rd_xLeng.IsChecked == true)
                {
                    _lengthVec = new Vector3D(1, 0, 0);
                }
                else if (rd_yLeng.IsChecked == true)
                {
                    _lengthVec = new Vector3D(0, 1, 0);
                }
                else
                {
                    _lengthVec = new Vector3D(0, 0, 1);
                }

                if (rd_xHeight.IsChecked == true)
                {
                    _heightVec = new Vector3D(1, 0, 0);
                }
                else if (rd_yHeight.IsChecked == true)
                {
                    _heightVec = new Vector3D(0, 1, 0);
                }
                else
                {
                    _heightVec = new Vector3D(0, 0, 1);
                }

                double eleNumberDir1 = Math.Abs(_length) / _sizeX;
                double eleNumberDir2 = Math.Abs(_height) / _sizeY;

                double nodeNumberDir1 = eleNumberDir1 * 2 + 1;
                double nodeNumberDir2 = eleNumberDir2 * 2 + 1;
                int    count          = MainWindow.nodeList.Count;

                //Create the nodes
                for (int i = 0; i < nodeNumberDir2; i++)     //Iterate over height
                {
                    for (int j = 0; j < nodeNumberDir1; j++) //iterate over length (the order is reversed so that the numbering comes in rows instead of columns
                    {
                        double xPos, yPos, zPos;
                        xPos = _iniVec.X + signLength * j * _lengthVec.X * (_sizeX / 2) + signHeight * i * _heightVec.X * (_sizeY / 2);
                        yPos = _iniVec.Y + signLength * j * _lengthVec.Y * (_sizeX / 2) + signHeight * i * _heightVec.Y * (_sizeY / 2);
                        zPos = _iniVec.Z + signLength * j * _lengthVec.Z * (_sizeX / 2) + signHeight * i * _heightVec.Z * (_sizeY / 2);
                        if (Node.FindNodeByCoordinates(xPos, yPos, zPos, new List <Node>(MainWindow.nodeList)) == null)
                        {
                            Node n = new Node(count + 1, new Point3D(xPos, yPos, zPos));
                            MainWindow.nodeList.Add(n);
                            MainWindow.myModel3DGroup.Children.Add(DrawingHelper.Draw3DCube(Configuration.nodeSize * Configuration.zoomParam, n.Point, Configuration.nodeColor));
                            count++;
                        }
                    }

                    /* this is for the 8-node element
                     * if (i % 2 == 0) //divide by 2 to know in which row of the nodes we are, if it is on the row with 3 nodes per element or on the row with 2 nodes per element
                     * {
                     *  for (int j = 0; j < nodeNumberDir1; j++) //iterate over length (the order is reversed so that the numbering comes in rows instead of columns
                     *  {
                     *      double xPos, yPos, zPos;
                     *      xPos = _iniVec.X + j * _lengthVec.X * (_size / 2) + i * _heightVec.X * (_size / 2);
                     *      yPos = _iniVec.Y + j * _lengthVec.Y * (_size / 2) + i * _heightVec.Y * (_size / 2);
                     *      zPos = _iniVec.Z + j * _lengthVec.Z * (_size / 2) + i * _heightVec.Z * (_size / 2);
                     *      Node n = new Node(count + 1, new Point3D(xPos, yPos, zPos));
                     *      MainWindow.nodeList.Add(n);
                     *      MainWindow.myModel3DGroup.Children.Add(DrawingHelper.Draw3DCube(nodeSize, n.Point, Colors.Black));
                     *      count++;
                     *  }
                     * } else
                     * {
                     *  for (int j = 0; j < nodeNumberDir1 - eleNumberDir1; j++) //iterate over the row of nodes that has lower number of nodess on the 8-node element model
                     *  {
                     *      double xPos, yPos, zPos;
                     *      xPos = _iniVec.X + j * _lengthVec.X * (_size) + i * _heightVec.X * (_size / 2);
                     *      yPos = _iniVec.Y + j * _lengthVec.Y * (_size) + i * _heightVec.Y * (_size / 2);
                     *      zPos = _iniVec.Z + j * _lengthVec.Z * (_size) + i * _heightVec.Z * (_size / 2);
                     *      Node n = new Node(count + 1, new Point3D(xPos, yPos, zPos));
                     *      MainWindow.nodeList.Add(n);
                     *      MainWindow.myModel3DGroup.Children.Add(DrawingHelper.Draw3DCube(nodeSize, n.Point, Colors.Black));
                     *      count++;
                     *  }
                     * }
                     */
                }

                List <Node> nodeList = new List <Node>(MainWindow.nodeList);

                List <Material> materialList = new List <Material>(MainWindow.materialList);

                //Create the Elements
                int countEle = MainWindow.shellList.Count;
                for (int i = 0; i < eleNumberDir2; i++) //for each element
                {
                    for (int j = 0; j < eleNumberDir1; j++)
                    {
                        Vector3D pos = _iniVec;
                        Node     n1  = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos += _sizeX * signLength * _lengthVec;
                        Node n2 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos += _sizeY * signHeight * _heightVec;
                        Node n3 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos -= _sizeX * signLength * _lengthVec;
                        Node n4 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos = pos - _sizeY * signHeight * _heightVec + (_sizeX / 2) * signLength * _lengthVec;
                        Node n5 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos = pos + (_sizeX / 2) * signLength * _lengthVec + (_sizeY / 2) * signHeight * _heightVec;
                        Node n6 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos = pos - (_sizeX / 2) * signLength * _lengthVec + (_sizeY / 2) * signHeight * _heightVec;
                        Node n7 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos = pos - (_sizeX / 2) * signLength * _lengthVec - (_sizeY / 2) * signHeight * _heightVec;
                        Node n8 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);
                        pos = pos + (_sizeX / 2) * signLength * _lengthVec;
                        Node n9 = Node.FindNodeByCoordinates(pos.X, pos.Y, pos.Z, nodeList);

                        //adds an element to the element list
                        ShellElement ele = new ShellElement(countEle + 1, n1, n2, n3, n4, n5, n6, n7, n8, n9, _thickness, _layers, materialList[_mat - 1]);
                        countEle++;
                        MainWindow.shellList.Add(ele);

                        //draws the element on the viewModel3D in the mainWindow
                        MainWindow.myModel3DGroup.Children.Add(DrawingHelper.Draw3DPanel(ele, Configuration.shellEleColor, false, MainWindow.dispList, Configuration.zoomParam));

                        _iniVec += _sizeX * signLength * _lengthVec;
                    }
                    _iniVec.X = _xIni;
                    _iniVec.Y = _yIni;
                    _iniVec.Z = _zIni;

                    _iniVec += (i + 1) * _sizeY * signHeight * _heightVec;
                }
            }
            catch
            {
                MessageBox.Show("An error has occurred and the shell elements could not be created. Please check your inputs and try again", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #27
0
        public async Task Progress()
        {
            var author = Context.Message.Author;

            if (author.Id != Program.ApplicationSetting.Owner)
            {
                Context.Channel.SendMessageAsync("You aren't allowed to run this command", false);
                return;
            }

            (string basePath, string baseOutputPath) = MovieHelper.CleanAndCreateMovieFolders();

            SKRect rect = new SKRect(100, 100, 200, 200);

            var arcPaint = new SKPaint()
            {
                Color = new SKColor(255, 0, 0)
            };

            List <Task> tasks = new List <Task>();

            // draw empty rectabgle
            int frame = 0;

            // Spawn the border
            for (int i = 0; i < 10; i++)
            {
                var drawInfo = DrawingHelper.GetEmptyGraphics(505, 200);


                drawInfo.Canvas.DrawRect(70, 25, 365, 100, new SKPaint()
                {
                    Color = new SKColor(255, 0, 0, (byte)(20 * i + 30)), IsStroke = true, Style = SKPaintStyle.Stroke, StrokeWidth = 4
                });

                tasks.Add(MovieHelper.SaveToDisk(basePath, frame, drawInfo.Bitmap, drawInfo.Canvas));
                frame++;
            }

            // Standstill
            for (int i = 0; i < 5; i++)
            {
                var drawInfo = DrawingHelper.GetEmptyGraphics(505, 200);

                drawInfo.Canvas.DrawRect(70, 25, 365, 100, new SKPaint()
                {
                    Color = new SKColor(255, 0, 0, 255), IsStroke = true, Style = SKPaintStyle.Stroke, StrokeWidth = 4
                });

                tasks.Add(MovieHelper.SaveToDisk(basePath, frame, drawInfo.Bitmap, drawInfo.Canvas));
                frame++;
            }

            int dayOfTheYear = 60; Math.Min(DateTime.Now.DayOfYear, 365); // dont handle leap years for now TODO

            for (int i = 0; i < dayOfTheYear + 10; i++)
            {
                var drawInfo = DrawingHelper.GetEmptyGraphics(505, 200);

                for (int j = 0; j < Math.Min(i, 10); j++)
                {
                    drawInfo.Canvas.DrawRect(70, 23, Math.Min(i - j, dayOfTheYear), 100, new SKPaint()
                    {
                        Color = new SKColor(0, 255, 0, 25), Style = SKPaintStyle.Fill
                    });

                    if (j == i)
                    {
                        break;
                    }
                }

                // border
                drawInfo.Canvas.DrawRect(70, 25, 365, 100, new SKPaint()
                {
                    Color = new SKColor(255, 0, 0, 255), IsStroke = true, Style = SKPaintStyle.Stroke, StrokeWidth = 4
                });

                tasks.Add(MovieHelper.SaveToDisk(basePath, frame, drawInfo.Bitmap, drawInfo.Canvas));
                frame++;
            }


            /*            for (int i = 0; i < 180; i++)
             *  {
             *      var drawInfo = DrawingHelper.GetEmptyGraphics(500, 500);
             *
             *      using (SKPath path = new SKPath())
             *      {
             *          path.AddArc(rect, 0, i);
             *          drawInfo.Canvas.DrawPath(path, arcPaint);
             *
             *          tasks.Add(SaveToDisk(basePath, i, drawInfo.Bitmap, drawInfo.Canvas));
             *      }
             *  }*/

            int random = new Random().Next(1_000_000_000);

            var    files    = Directory.GetFiles(Path.Combine(basePath)).ToList().OrderBy(i => i);
            string fileName = Path.Combine(baseOutputPath, $"movie_{random}.gif");

            try
            {
                using (var collection = new MagickImageCollection())
                {
                    int i = 0;
                    foreach (var file in files)
                    {
                        collection.Add(file);
                        collection[i].AnimationDelay = 1; // in this example delay is 1000ms/1sec

                        if (i == 0)
                        {
                            collection[i].AnimationIterations = 0;
                        }

                        //collection[i].Flip();
                        i++;
                    }

                    // Optionally reduce colors
                    var settings = new QuantizeSettings();

                    //settings.Colors = 256;
                    //collection.Quantize(settings);

                    // Optionally optimize the images (images should have the same size).
                    //collection.Optimize();

                    // Save gif
                    collection.Write(fileName, MagickFormat.Gif);
                }
            }
            catch (Exception ex)
            {
            }

            await Context.Channel.SendFileAsync(fileName);
        }
Example #28
0
        private void DrawingOnOnDraw(EventArgs args)
        {
            var heroes          = Config.Main.Updater.Heroes;
            var itemBorderWhite = ItemBorderClr.Value.SelectedIndex == 0;

            foreach (var heroCont in heroes)
            {
                var hero = heroCont.Hero;
                if (!hero.IsAlive)
                {
                    continue;
                }
                if (!hero.IsVisible)
                {
                    continue;
                }
                var pos = HudInfo.GetHPbarPosition(hero);
                if (pos.IsZero)
                {
                    continue;
                }
                var copy = pos;
                var size = new Vector2(HudInfo.GetHPBarSizeX(hero), HudInfo.GetHpBarSizeY(hero));
                if (heroCont.IsOwner)
                {
                    pos  += new Vector2(-1, size.Y);
                    size -= new Vector2(1, 0);
                }
                else
                {
                    pos += new Vector2(0, size.Y - 2);
                }
                if (ManaBars)
                {
                    if (heroCont.IsAlly && ManaBarsForAlly || !heroCont.IsAlly && ManaBarsForEnemy)
                    {
                        var mana = heroCont.Mana;
                        pos = DrawingHelper.DrawManaBar(pos, mana * size.X / heroCont.MaxMana, size,
                                                        new Color(0, 155, 255, 255),
                                                        new Color(0, 0, 0, 255), ((int)mana).ToString(), ManaBarsNumbers,
                                                        ManaBarsSize.Value.Value);
                    }
                }

                if (AbilityOverlay)
                {
                    var tempSize    = size.X * AbilitySize / 30f;
                    var abilitySize = new Vector2(tempSize);

                    //IEnumerable<Ability> abilities = heroCont.Abilities;
                    //var enumerable = abilities as Ability[] ?? abilities.ToArray();
                    //var abilityCount = abilities.Count();
                    var abilities    = heroCont.Abilities2.Where(x => x.IsValid && !x.IsHidden).ToList();
                    var abilityCount = abilities.Count;
                    //var extraAbilitites = abilityCount - 4;
                    pos += new Vector2((size.X - tempSize * abilityCount) / 2f, 0);

                    /*if (extraAbilitites > 0)
                     * {
                     *  pos -= new Vector2(abilitySize.X * extraAbilitites / 2f, 0);
                     * }*/

                    /*foreach (var ability in abilities)
                     * {
                     *  if (ability == null || !ability.IsValid || ability.IsHidden)
                     *  {
                     *      heroCont.RefreshAbilities();
                     *      continue;
                     *  }
                     *  pos = DrawAbilityState(pos, ability, abilitySize);
                     * }*/

                    try
                    {
                        foreach (var ability in abilities.OrderBy(x => x.AbilitySlot))
                        {
                            pos = DrawAbilityState(pos, ability, abilitySize);
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }

                if (ItemOverlay)
                {
                    var tempSize     = size.X * ItemSize / 30f;
                    var abilitySize  = new Vector2(tempSize);
                    var abilities    = ItemDangItems ? heroCont.DangItems : heroCont.Items;
                    var abilityCount = abilities.Count;
                    //var extraAbilitites = abilityCount - 4;
                    pos  = copy;
                    pos += new Vector2((size.X - tempSize * abilityCount) / 2f, -abilitySize.Y);

                    /*if (extraAbilitites > 0)
                     * {
                     *  //pos -= new Vector2(abilitySize.X * extraAbilitites / 2f, 0);
                     *
                     * }*/

                    foreach (var ability in abilities)
                    {
                        if (ability == null || !ability.IsValid)
                        {
                            continue;
                        }
                        pos = DrawItemState(pos, ability, abilitySize, itemBorderWhite ? Color.White : Color.Black);
                    }
                }
            }
        }
 public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
 {
     for (int i = 0; i < 4; i++)
     {
         Vector2 offset = new Vector2((float)(Math.Sin(Main.GameUpdateCount * 0.125f) + 1f) * 1.125f, 0f).RotatedBy(MathHelper.PiOver2 * i);
         offset.Y = 2;
         spriteBatch.WorldDraw(Azercadmium.extraTexture[7], npc.Center + offset, npc.frame, ColorHelper.EmberGladesColor2 * 0.88f, npc.rotation, new Vector2(40, 30), npc.scale, DrawingHelper.DirectionToSpriteEffects(-npc.spriteDirection));
     }
 }
Example #30
0
        public static void CleanCurrentStrucure()
        {
            //cleans the current LISTs of objects in the project (nodes, elements, materials, sections, etc.)
            if (MainWindow.materialList != null)
            {
                MainWindow.materialList.Clear();
            }
            if (MainWindow.nodeList != null)
            {
                MainWindow.nodeList.Clear();
            }
            if (MainWindow.springList != null)
            {
                MainWindow.springList.Clear();
            }
            if (MainWindow.shellList != null)
            {
                MainWindow.shellList.Clear();
            }
            if (MainWindow.loadList != null)
            {
                MainWindow.loadList.Clear();
            }
            if (MainWindow.massList != null)
            {
                MainWindow.massList.Clear();
            }
            if (MainWindow.supportList != null)
            {
                MainWindow.supportList.Clear();
            }
            if (MainWindow.dispList != null)
            {
                MainWindow.dispList.Clear();
            }
            if (MainWindow.seriesDispList != null)
            {
                MainWindow.seriesDispList.Clear();
            }
            if (MainWindow.seriesLoadList != null)
            {
                MainWindow.seriesLoadList.Clear();
            }
            if (MainWindow.modalDispList != null)
            {
                MainWindow.modalDispList.Clear();
            }
            if (MainWindow.natFreqs != null)
            {
                MainWindow.natFreqs.Clear();
            }
            if (MainWindow.deformed)
            {
                MainWindow.deformed = false;
            }
            if (MainWindow.analysis != null)
            {
                MainWindow.analysis.Clear();
            }
            if (MainWindow.seismicLoad != null)
            {
                MainWindow.seismicLoad.Clear();
            }
            if (MainWindow.impulseLoad != null)
            {
                MainWindow.impulseLoad.Clear();
            }

            MainWindow.iteration       = 1;
            MainWindow.scale           = 1;
            MainWindow.numberLoadSteps = 0;

            //cleans the current 3D elements on screen
            DrawingHelper.ClearScreen(ref MainWindow.myModel3DGroup);
        }
Example #31
0
    public PoseUpdater(Transform transform, string bonePrefix, Utlis.AvatarType avatarType, bool smooth = false)
    {
        useSmooth   = smooth;
        _avatarType = avatarType;
        //targetMeshRenderer = transform.GetComponent<SkinnedMeshRenderer>();

        _boneNamePrefix       = bonePrefix;
        _boneNameToJointIndex = new Dictionary <string, int>();
        _boneneameToSMPLbone  = new Dictionary <string, string>();

        if (_avatarType == Utlis.AvatarType.RocketBox)
        {
            _boneNameToJointIndex.Add("Pelvis", 0);
            _boneNameToJointIndex.Add("L Thigh", 1);
            _boneNameToJointIndex.Add("R Thigh", 2);
            _boneNameToJointIndex.Add("Spine", 3);
            _boneNameToJointIndex.Add("L Calf", 4);
            _boneNameToJointIndex.Add("R Calf", 5);
            _boneNameToJointIndex.Add("Spine1", 6);
            _boneNameToJointIndex.Add("L Foot", 7);
            _boneNameToJointIndex.Add("R Foot", 8);
            _boneNameToJointIndex.Add("Spine2", 9);
            _boneNameToJointIndex.Add("L Toe0", 10);
            _boneNameToJointIndex.Add("R Toe0", 11);
            _boneNameToJointIndex.Add("Neck", 12);
            _boneNameToJointIndex.Add("L Clavicle", 13);
            _boneNameToJointIndex.Add("R Clavicle", 14);
            _boneNameToJointIndex.Add("Head", 15);
            _boneNameToJointIndex.Add("L UpperArm", 16);
            _boneNameToJointIndex.Add("R UpperArm", 17);
            _boneNameToJointIndex.Add("L Forearm", 18);
            _boneNameToJointIndex.Add("R Forearm", 19);
            _boneNameToJointIndex.Add("L Hand", 20);
            _boneNameToJointIndex.Add("R Hand", 21);
            //_boneNameToJointIndex.Add("L_Hand", 22);
            //_boneNameToJointIndex.Add("R_Hand", 23);


            _boneneameToSMPLbone.Add("Pelvis", "Pelvis");
            _boneneameToSMPLbone.Add("L Thigh", "L_Hip");
            _boneneameToSMPLbone.Add("R Thigh", "R_Hip");
            _boneneameToSMPLbone.Add("Spine", "Spine1");
            _boneneameToSMPLbone.Add("L Calf", "L_Knee");
            _boneneameToSMPLbone.Add("R Calf", "R_Knee");
            _boneneameToSMPLbone.Add("Spine1", "Spine2");
            _boneneameToSMPLbone.Add("L Foot", "L_Ankle");
            _boneneameToSMPLbone.Add("R Foot", "R_Ankle");
            _boneneameToSMPLbone.Add("Spine2", "Spine3");
            _boneneameToSMPLbone.Add("L Toe0", "L_Foot");
            _boneneameToSMPLbone.Add("R Toe0", "R_Foot");
            _boneneameToSMPLbone.Add("Neck", "Neck");
            _boneneameToSMPLbone.Add("L Clavicle", "L_Collar");
            _boneneameToSMPLbone.Add("R Clavicle", "R_Collar");
            _boneneameToSMPLbone.Add("Head", "Head");
            _boneneameToSMPLbone.Add("L UpperArm", "L_Shoulder");
            _boneneameToSMPLbone.Add("R UpperArm", "R_Shoulder");
            _boneneameToSMPLbone.Add("L Forearm", "L_Elbow");
            _boneneameToSMPLbone.Add("R Forearm", "R_Elbow");
            _boneneameToSMPLbone.Add("L Hand", "L_Wrist");
            _boneneameToSMPLbone.Add("R Hand", "R_Wrist");
        }


        leftArmIndexList = new List <int>()
        {
            13, 16, 18, 20
        };
        rightArmIndexList = new List <int>()
        {
            14, 17, 19, 21
        };
        leftLegIndexList = new List <int>()
        {
            1, 4, 7, 10
        };
        rightLegIndexList = new List <int>()
        {
            2, 5, 8, 11
        };
        torsoIndexList = new List <int>()
        {
            0, 3, 6, 9, 12, 15
        };


        _boneNameToTransform = new Dictionary <string, Transform>();
        initBoneOrientation  = new Dictionary <string, Quaternion>();
        foreach (var item in _boneNameToJointIndex)
        {
            var       _boneName = _boneNamePrefix + item.Key;
            Transform t         = transform.FindChildRecursive(_boneName);
            if (t != null)
            {
                _boneNameToTransform.Add(item.Key, t);
                initBoneOrientation.Add(item.Key, t.localRotation);
            }
            else
            {
                Debug.Log(_boneName + "can't find gameobject");
            }
        }

        //testing interpolate
        curBoneOrientation  = new Dictionary <string, Quaternion>();
        nextBoneOrientation = new Dictionary <string, Quaternion>();

        this.jointRotationsQueue = new Queue <Dictionary <string, Quaternion> >();


        // create cylinders to draw rotation axes if required
        _drawingHelper = new DrawingHelper();


        //debug
        DrawBoneOrientations();
    }