Ejemplo n.º 1
0
            public void Create(Point seed, Surface src, RectangleRef[] limits, ColorBgra color, float Tolerance, ClusterClearEffectPlugin controller, bool[,] safePoints)
            {
                Ranges.Clear();
                int xL = seed.X;

                while (xL >= 0 && ColorUtils.RGBPercentage(color, src[xL, seed.Y]) <= Tolerance)
                {
                    --xL;
                }
                ++xL;
                int xR   = seed.X + 1;
                int maxR = src.Width;

                while (xR < maxR && ColorUtils.RGBPercentage(color, src[xR, seed.Y]) <= Tolerance)
                {
                    ++xR;
                }
                --xR;
                Ranges.Add(new RectangleRef(xL, seed.Y, xR - xL + 1, 1));

                Stack <ScanRange> scanRanges = new Stack <ScanRange>();

                scanRanges.Push(new ScanRange(xL, xR, seed.Y, 1));
                scanRanges.Push(new ScanRange(xL, xR, seed.Y, -1));
                int       xMin = 0;
                int       xMax = src.Width - 1;
                int       yMin = 0;
                int       yMax = src.Height - 1;
                ScanRange r;
                int       sleft;
                int       sright;

                while (scanRanges.Count != 0)
                {
                    if (controller.IsCancelRequested)
                    {
                        return;
                    }
                    r = scanRanges.Pop();
                    //scan left
                    for (sleft = r.left - 1; sleft >= xMin && ColorUtils.RGBPercentage(color, src[sleft, r.y]) <= Tolerance; --sleft)
                    {
                        safePoints[sleft, r.y] = true;
                    }
                    ++sleft;

                    //scan right
                    for (sright = r.right + 1; sright <= xMax && ColorUtils.RGBPercentage(color, src[sright, r.y]) <= Tolerance; ++sright)
                    {
                        safePoints[sright, r.y] = true;
                    }
                    --sright;
                    Ranges.Add(new RectangleRef(sleft, r.y, sright - sleft, 1));

                    //scan in same direction vertically
                    bool rangeFound = false;
                    int  rangeStart = 0;
                    int  newy       = r.y + r.direction;
                    if (newy >= yMin && newy <= yMax)
                    {
                        xL = sleft;
                        while (xL <= sright)
                        {
                            for (; xL <= sright; ++xL)
                            {
                                if (ColorUtils.RGBPercentage(color, src[xL, newy]) <= Tolerance)
                                {
                                    safePoints[xL, newy] = true;
                                    rangeFound           = true;
                                    rangeStart           = xL++;
                                    break;
                                }
                            }
                            for (; xL <= sright; ++xL)
                            {
                                if (ColorUtils.RGBPercentage(color, src[xL, newy]) > Tolerance)
                                {
                                    break;
                                }
                                safePoints[xL, newy] = true;
                            }
                            if (rangeFound)
                            {
                                rangeFound = false;
                                scanRanges.Push(new ScanRange(rangeStart, xL - 1, newy, r.direction));
                            }
                        }
                    }

                    //scan opposite direction vertically
                    newy = r.y - r.direction;
                    if (newy >= yMin && newy <= yMax)
                    {
                        xL = sleft;
                        while (xL < r.left)
                        {
                            for (; xL < r.left; ++xL)
                            {
                                if (ColorUtils.RGBPercentage(color, src[xL, newy]) <= Tolerance)
                                {
                                    safePoints[xL, newy] = true;
                                    rangeFound           = true;
                                    rangeStart           = xL++;
                                    break;
                                }
                            }
                            for (; xL < r.left; ++xL)
                            {
                                if (ColorUtils.RGBPercentage(color, src[xL, newy]) > Tolerance)
                                {
                                    break;
                                }
                                safePoints[xL, newy] = true;
                            }
                            if (rangeFound)
                            {
                                rangeFound = false;
                                scanRanges.Push(new ScanRange(rangeStart, xL - 1, newy, -r.direction));
                            }
                        }
                        xL = r.right + 1;
                        while (xL <= sright)
                        {
                            for (; xL <= sright; ++xL)
                            {
                                if (ColorUtils.RGBPercentage(color, src[xL, newy]) <= Tolerance)
                                {
                                    safePoints[xL, newy] = true;
                                    rangeFound           = true;
                                    rangeStart           = xL++;
                                    break;
                                }
                            }
                            for (; xL <= sright; ++xL)
                            {
                                if (ColorUtils.RGBPercentage(color, src[xL, newy]) > Tolerance)
                                {
                                    break;
                                }
                                safePoints[xL, newy] = true;
                            }
                            if (rangeFound)
                            {
                                rangeFound = false;
                                scanRanges.Push(new ScanRange(rangeStart, xL - 1, newy, -r.direction));
                            }
                        }
                    }
                }
                CompressRanges();
            }
Ejemplo n.º 2
0
        internal static void Draw2020()
        {
            int   imageSize = 700;
            float radius    = 1.7f; // image radius
            var   viewport  = new Viewport(imageSize, imageSize, -radius, radius, -radius, radius, true);

            int  frameCount  = 40;
            bool isSingleSvg = frameCount == 1;

            for (int fi = 0; fi < frameCount; ++fi)
            {
                double fa = 1.0 * fi / frameCount;

                var image = new Image(viewport);

                if (!isSingleSvg)
                {
                    image.Rectangle(new[] { new Point(-radius, radius), new Point(radius, -radius) })
                    .Add()
                    //.FillStroke(MakeColor(0xFFFFEEFF), Color.Empty);
                    .FillStroke(Color.White, Color.Empty);
                }

                var items = new List <Item> {
                    Item.UnitCircle()
                };

                items = Multiply(items, 4, 0.5, -fa / 4);
                items = Multiply(items, 5, 0.44, fa / 5);       // -> 20

                items = Multiply(items, 5, 0.4, fa / 5);        // -> 100

                var c1 = Item.UnitCircle();
                c1.Transform(c => c * 0.45);
                items.Add(c1);                                  // -> 101

                items = Multiply(items, 4, 0.45, -fa / 4);
                items = Multiply(items, 5, 0.44, fa / 5);       // x 20 -> 2020


                // Draw all items
                foreach (Item item in items)
                {
                    //
                    item.Transform(c => c * MakePhase(0.25));
                    //
                    Complex pos; double r;
                    MakeCircle(item.points, out pos, out r);
                    image.Circle(FromComplex(pos), (float)r)
                    .Add()
                    //.FillStroke(Color.Empty, Color.Red, 0.001f);
                    //.FillStroke(Color.Gray, Color.Black, 0.001f);
                    .FillStroke(ColorUtils.MakeColor(0xFF555555), Color.Empty);
                }

                if (isSingleSvg)
                {
                    // save/open svg
                    string svgPath = "2020.svg";
                    image.WriteSvg(svgPath);
                    Image.Show(svgPath);
                }
                else
                {
#if !NETCOREAPP
                    // save to png
                    string pngPath = String.Format("frames\\2020_{0:00}.png", fi);
                    image.WritePng(pngPath, true);
                    //Image.Show(pngPath);
#endif
                }
            }
        }
Ejemplo n.º 3
0
        public ModValue(ItemMod mod, FsController fs, int iLvl, Models.BaseItemType baseItem)
        {
            string baseClassName = baseItem.ClassName.ToLower().Replace(' ', '_');

            Record    = fs.Mods.records[mod.RawName];
            AffixType = Record.AffixType;
            AffixText = String.IsNullOrEmpty(Record.UserFriendlyName) ? Record.Key : Record.UserFriendlyName;
            IsCrafted = Record.Domain == ModsDat.ModDomain.Master;
            StatValue = new[] { mod.Value1, mod.Value2, mod.Value3, mod.Value4 };
            Tier      = -1;

            int subOptimalTierDistance = 0;

            List <ModsDat.ModRecord> allTiers;

            if (fs.Mods.recordsByTier.TryGetValue(Tuple.Create(Record.Group, Record.AffixType), out allTiers))
            {
                bool tierFound = false;
                totalTiers = 0;
                var keyRcd = Record.Key.Where(c => char.IsLetter(c)).ToArray <char>();
                foreach (var tmp in allTiers)
                {
                    var keyrcd = tmp.Key.Where(k => char.IsLetter(k)).ToArray <char>();
                    if (!keyrcd.SequenceEqual(keyRcd))
                    {
                        continue;
                    }

                    int baseChance;
                    if (!tmp.TagChances.TryGetValue(baseClassName, out baseChance))
                    {
                        baseChance = -1;
                    }

                    int defaultChance;
                    if (!tmp.TagChances.TryGetValue("default", out defaultChance))
                    {
                        defaultChance = 0;
                    }

                    int tagChance = -1;
                    foreach (var tg in baseItem.Tags)
                    {
                        if (tmp.TagChances.ContainsKey(tg))
                        {
                            tagChance = tmp.TagChances[tg];
                        }
                    }

                    int moreTagChance = -1;
                    foreach (var tg in baseItem.MoreTagsFromPath)
                    {
                        if (tmp.TagChances.ContainsKey(tg))
                        {
                            moreTagChance = tmp.TagChances[tg];
                        }
                    }

                    #region GetOnlyValidMods
                    switch (baseChance)
                    {
                    case 0:
                        break;

                    case -1:         //baseClass name not found in mod tags.
                        switch (tagChance)
                        {
                        case 0:
                            break;

                        case -1:             //item tags not found in mod tags.
                            switch (moreTagChance)
                            {
                            case 0:
                                break;

                            case -1:                //more item tags not found in mod tags.
                                if (defaultChance > 0)
                                {
                                    totalTiers++;
                                    if (tmp.Equals(Record))
                                    {
                                        Tier      = totalTiers;
                                        tierFound = true;
                                    }
                                    if (!tierFound && tmp.MinLevel <= iLvl)
                                    {
                                        subOptimalTierDistance++;
                                    }
                                }
                                break;

                            default:
                                totalTiers++;
                                if (tmp.Equals(Record))
                                {
                                    Tier      = totalTiers;
                                    tierFound = true;
                                }
                                if (!tierFound && tmp.MinLevel <= iLvl)
                                {
                                    subOptimalTierDistance++;
                                }
                                break;
                            }
                            break;

                        default:
                            totalTiers++;
                            if (tmp.Equals(Record))
                            {
                                Tier      = totalTiers;
                                tierFound = true;
                            }
                            if (!tierFound && tmp.MinLevel <= iLvl)
                            {
                                subOptimalTierDistance++;
                            }
                            break;
                        }
                        break;

                    default:
                        totalTiers++;
                        if (tmp.Equals(Record))
                        {
                            Tier      = totalTiers;
                            tierFound = true;
                        }
                        if (!tierFound && tmp.MinLevel <= iLvl)
                        {
                            subOptimalTierDistance++;
                        }
                        break;
                    }
                    #endregion
                }
            }
            double hue = totalTiers == 1 ? 180 : 120 - Math.Min(subOptimalTierDistance, 3) * 40;
            Color = ColorUtils.ColorFromHsv(hue, totalTiers == 1 ? 0 : 1, 1);
        }
Ejemplo n.º 4
0
        protected int ConvertColor(KnownColor knownColor)
        {
            var color = Color.FromKnownColor(knownColor);

            return(ColorUtils.ToColorRef(color));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Execute a known command by name.
        /// </summary>
        /// <param name="command">The command to execute</param>
        /// <param name="confidence">The confidence level (has to be above ConfidenceThreshold value)</param>
        public void ExecuteCommand(string command, double confidence)
        {
            ClearCommandHighlights();

            if (command == null)
            {
                return;            //this is needed, else "command.GetKnownColor" will fail if command==null
            }
            if (confidence >= ConfidenceThreshold)
            {
                switch (command)
                {
                case Commands.CLOSE:
                    RecognitionHighlight(CLOSE);
                    if (!ColorUtils.CloseKnownColorsMessageBox())
                    {
                        Close(); //if the known colors MessageBox isn't open to close it, close the main app window (exit the app)
                    }
                    break;

                case Commands.FORWARD:
                    RecognitionHighlight(FORWARD);
                    TurtlePosition = new Point((playArea.Width + turtleTranslation.X + (displacementAmount * Displacements[CurrentDirection].X)) % playArea.Width,
                                               (playArea.Height + turtleTranslation.Y + (displacementAmount * Displacements[CurrentDirection].Y)) % playArea.Height);
                    break;

                case Commands.BACK:
                    RecognitionHighlight(BACK);
                    TurtlePosition = new Point((playArea.Width + turtleTranslation.X - (displacementAmount * Displacements[CurrentDirection].X)) % playArea.Width,
                                               (playArea.Height + turtleTranslation.Y - (displacementAmount * Displacements[CurrentDirection].Y)) % playArea.Height);
                    break;

                case Commands.LEFT:
                    RecognitionHighlight(LEFT);
                    CurrentDirection = (Direction)(((int)CurrentDirection + 270) % 360); //do not use - 90, do not want to end up with negative numbers (plus can't use Math.Abs on the result of the modulo operation, will end up with wrong number)
                    break;

                case Commands.RIGHT:
                    RecognitionHighlight(RIGHT);
                    CurrentDirection = (Direction)Math.Abs(((int)CurrentDirection + 90) % 360);
                    break;

                case Commands.PENDOWN:
                    RecognitionHighlight(PENDOWN);
                    PenIsDown = true;
                    break;

                case Commands.PENUP:
                    RecognitionHighlight(PENUP);
                    PenIsDown = false;
                    break;

                case Commands.BIGGER:
                    RecognitionHighlight(BIGGER);
                    turtleScale.ScaleX *= ScaleFactor;
                    turtleScale.ScaleY *= ScaleFactor;
                    displacementAmount *= ScaleFactor; //Bigger turtles move in bigger steps
                    penThickness       *= ScaleFactor; //Bigger turtles leave thicker trails
                    break;

                case Commands.SMALLER:
                    RecognitionHighlight(SMALLER);
                    turtleScale.ScaleX /= ScaleFactor;
                    turtleScale.ScaleY /= ScaleFactor;
                    displacementAmount /= ScaleFactor; //Smaller turtles move in smaller steps
                    penThickness       /= ScaleFactor; //Smaller turtles leave thiner trails
                    break;

                case Commands.COLORS:
                    RecognitionHighlight(COLORS);
                    Dispatcher.BeginInvoke(new Action(() => { ColorUtils.ShowKnownColors(); })); //Do not call colorsHyperlink.DoClick() or ColorUtils.ShowKnownColors() directly since the latter uses MessageBox.Show which would block the speech recognition event thread, so we wouldn't be able to then speak the CLOSE command
                    break;

                default:
                    RecognitionHighlight(COLORS);
                    PenColor = command.GetKnownColor();
                    break;
                }
            }
        }
Ejemplo n.º 6
0
 public void updateNameAndColorCode(string strName, string strColorCode)
 {
     this.m_labelName.Text       = strName;
     this.m_panelColor.BackColor = ColorUtils.genColor(strColorCode);
 }
Ejemplo n.º 7
0
 private System.Drawing.Color?GetColor() => ColorUtils.FromColorRef(Point.Color);
Ejemplo n.º 8
0
 public void SetColor(CustomColor color, float intensity = 1)
 {
     _light.color     = ColorUtils.GetColor(color);
     _light.intensity = intensity;
 }
Ejemplo n.º 9
0
        public void Execute(DocumentModifier docMdf)
        {
            List <Item> items = null;

            try
            {
                items = GetItemsFromExcel();
            }
            catch (Exception ex)
            {
                DebugUtils.ShowDebugCatch(ex, "提取Excel中的信息出错");
            }
            if (items != null && items.Count > 0)
            {
                var categories = items.Select(r => r.Category).Distinct().ToArray();
                var paperIdss  = items.Select(r => r.PaperId).Distinct().ToArray();
                var minStation = items.Select(r => r.Start).Min();
                var maxStation = items.Select(r => r.End).Max();

                var paperIds = new Dictionary <string, ObjectIdCollection>();
                foreach (var paperId in paperIdss)
                {
                    paperIds.Add(paperId, new ObjectIdCollection());
                }
                // 以只读方式打开块表   Open the Block table for read
                var acBlkTbl =
                    docMdf.acTransaction.GetObject(docMdf.acDataBase.BlockTableId, OpenMode.ForRead) as BlockTable;

                // 以写方式打开模型空间块表记录   Open the Block table record Model space for write
                var acBlkTblRec =
                    docMdf.acTransaction.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as
                    BlockTableRecord;

                // 绘制基本坐标系与分界线等
                ConstructWorld(docMdf, acBlkTblRec, categories, minStation, maxStation);

                //
                FindIntersections(docMdf, acBlkTblRec, items, categories, paperIds);


                // 将每一个单子中的对象添加到一个组Group中
                var groups = docMdf.acTransaction.GetObject(docMdf.acDataBase.GroupDictionaryId,
                                                            OpenMode.ForWrite) as DBDictionary;

                var colors = ColorUtils.ClassicalExpand(paperIds.Count);
                var ind    = 0;

                foreach (var paperId in paperIds)
                {
                    var gp = new Group(paperId.Key, true);
                    // ProtectionUtils.OverlayDictValue(trans, container, DictKey_Platforms, dbPlatforms);
                    groups.SetAt(paperId.Key, gp);

                    gp.Append(paperId.Value);
                    // gp.Selectable = false; // 默认为 true,如果设置为 false,则即使 PICKSTYLE 系统变量设置为1,这个 group 也不能被作为一个整体进行选择。
                    docMdf.WriteLineIntoDebuger("添加组 ", gp.Name, "成员个数:", gp.GetAllEntityIds().Length.ToString());
                    gp.SetColor(Color.FromColor(colors[ind]));
                    //
                    docMdf.acTransaction.AddNewlyCreatedDBObject(gp, true);
                    ind += 1;
                }
            }
        }
Ejemplo n.º 10
0
        private void eyedropperColorPicker_SelectedColorChanged(object sender, EventArgs e)
        {
            var eyedropper = (EyedropColorPicker)sender;

            txtBGColour.Text = ColorUtils.ColorToHex(eyedropper.SelectedColor);
        }
Ejemplo n.º 11
0
 private void ColorForm_KeyUpDown(object sender, KeyEventArgs e)
 {
     ColorFunctionTemp = ColorUtils.GetColorFunction(ModifierKeys);
 }
Ejemplo n.º 12
0
 private void BgFadeIn(EffectLayer animation_layer)
 {
     layerFadeState = Math.Min(1, layerFadeState + 0.07f);
     animation_layer.Fill(ColorUtils.BlendColors(Color.Empty, Color.Black, layerFadeState));
 }
Ejemplo n.º 13
0
 public CreateProjectButtonColorValueConverter()
     : base(Color.ParseColor("#328fff"), new Color(ColorUtils.SetAlphaComponent(Color.ParseColor("#328fff").ToArgb(), 127)))
 {
 }
Ejemplo n.º 14
0
        public CPULoad(dynamic settings)
        {
            if (settings["color"] != null)
            {
                this.MainColor = (string)settings["color"];
            }
            if (settings["line-width"] != null)
            {
                this.LineWidth = (int)settings["line-width"];
            }
            if (settings["radius"] != null)
            {
                this.Radius = (int)settings["radius"];
            }
            this.panel             = new StackPanel();
            this.panel.Orientation = Orientation.Horizontal;
            var pc        = new PerformanceCounter("Processor Information", "% Processor Time");
            var cat       = new PerformanceCounterCategory("Processor Information");
            var instances = cat.GetInstanceNames();
            var cs        = new Dictionary <string, CounterSample>();
            var actual    = new Dictionary <string, double>();

            var cores = new Dictionary <int, Rectangle>();

            foreach (var s in instances)
            {
                pc.InstanceName = s;
                cs.Add(s, pc.NextSample());
                if (this.isCore(s))
                {
                    cores.Add(this.coreNum(s), null);
                }
            }

            for (int i = 0; i < cores.Count; i++)
            {
                Rectangle rect = new Rectangle();
                rect.Width             = this.LineWidth;
                rect.Height            = 0;
                rect.RadiusX           = this.Radius;
                rect.RadiusY           = this.Radius;
                rect.VerticalAlignment = VerticalAlignment.Bottom;
                rect.Margin            = new Thickness(3, 3, 3, 3);
                if (this.MainColor.Equals("rainbow"))
                {
                    ColorUtils.RGB rgb = ColorUtils.HSLToRGB(new ColorUtils.HSL((int)(360 * ((double)i / cores.Count)), 200, 200));
                    rect.Fill = new SolidColorBrush(Color.FromRgb(rgb.R, rgb.G, rgb.B));
                }
                else if (!this.MainColor.Equals("from-percentage"))
                {
                    rect.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(this.MainColor));
                }
                cores[i] = rect;
                this.panel.Children.Add(rect);
            }

            this.timer          = new Timer();
            this.timer.Interval = 1000;
            this.timer.Elapsed += delegate {
                actual.Clear();
                foreach (var s in instances)
                {
                    pc.InstanceName = s;
                    actual.Add(s, Calculate(cs[s], pc.NextSample()));
                    cs[s] = pc.NextSample();
                }
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate
                {
                    for (int i = 0; i < cores.Count; i++)
                    {
                        try {
                            if (this.MainColor.Equals("from-percentage"))
                            {
                                cores[i].Fill = new SolidColorBrush(this.PercentColor(100 - actual["0," + i]));
                            }
                            cores[i].Height = actual["0," + i] / 100 * 12;
                        } catch { }
                    }
                }));
            };
            this.timer.Start();
        }
        static public string SI_ProceduralDamage(object info)
        {
            Multitype <NetCard, NetSkill, NetBattlefield> data = info as Multitype <NetCard, NetSkill, NetBattlefield>;

            if (data != null)
            {
                return(GameplayUtils.GetDamageFor(data.t1, data.t0).ToString(false));
            }

            Multitype <SkillInstance, Subskill, ClientEntityCharacter> dInfo = info as Multitype <SkillInstance, Subskill, ClientEntityCharacter>;
            SkillInstance         si        = dInfo.t0;
            Subskill              ss        = dInfo.t1;
            ClientEntityCharacter character = dInfo.t2;

            var skillAttributes = si.GetCurrentSkillAttributes()[ss];
            int flags           = skillAttributes.GetFInt("ProceduralFlags").ToInt();

            string st = null;

            FInt  dmgBase = GameplayUtils.GetDamageFor(si, ss, null);
            float addBase = (flags & (int)EActivatorBlocks.Additive) > 0 ?  GameplayUtils.DamageNormalToAdditive(dmgBase) : 0f;

            var a = new FInt(addBase);

            if (ss.challengeTypes == null || character == null)
            {
                if (addBase > 0)
                {
                    st = "x" + dmgBase.ToString(true) + " [+" + a.ToString(true) + "]";
                }
                else
                {
                    st = "x" + dmgBase.ToString(true);
                }
            }
            else
            {
                foreach (var v in ss.challengeTypes)
                {
                    string color = "";
                    switch (v)
                    {
                    case EChallengeType.TypePhysical:
                        color = "XML_COLOR-PHYSICAL";
                        break;

                    case EChallengeType.TypeMental:
                        color = "XML_COLOR-MENTAL";
                        break;

                    case EChallengeType.TypeSpirit:
                        color = "XML_COLOR-SPIRITUAL";
                        break;
                    }

                    if (st == null)
                    {
                        st = "";
                    }
                    else
                    {
                        st += "|";
                    }

                    if (addBase > 0)
                    {
                        st += "x" + dmgBase.ToString(true) + "[+" + a.ToString(true) + "]" +
                              " ( " +
                              ColorUtils.GetColorAsTextTag(color) +
                              GameplayUtils.GetDamageFor(si, ss, character, v, true).ToString(false) +
                              ColorUtils.GetColorAsTextTag("XML_COLOR-NORMAL_FONT") +
                              " )";
                    }
                    else
                    {
                        st += "x" + dmgBase.ToString(true) +
                              " ( " +
                              ColorUtils.GetColorAsTextTag(color) +
                              GameplayUtils.GetDamageFor(si, ss, character, v).ToString(false) +
                              ColorUtils.GetColorAsTextTag("XML_COLOR-NORMAL_FONT") +
                              " )";
                    }
                }
            }
            return(st);
        }
Ejemplo n.º 16
0
        public void InitItemData()
        {
            List <PGoods> goodsList = null;
            SysEquipVo    vo;

            if (Repos == GoodsMode.Instance.GOODS_REPOS)
            {
                if (pos == 0)
                {
                    goodsList = Singleton <GoodsMode> .Instance.GetPGoodsByType(GoodsMode.GoodsType.Equip);
                }
                else
                {
                    goodsList = GoodsMode.Instance.GetEquipByPosInBag(this.pos);
                    if (goodsList.Count == 0)
                    {
                        if (grid.gameObject.activeInHierarchy)
                        {
                            grid.SetActive(false);
                        }
                        if (!tips.gameObject.activeInHierarchy)
                        {
                            tips.SetActive(true);
                        }
                        return;
                    }
                }
            }
            else if (Repos == GoodsMode.Instance.EQUIP_REPOS)
            {
                goodsList = Singleton <GoodsMode> .Instance.equipList;
            }
            if (!grid.gameObject.activeInHierarchy)
            {
                grid.SetActive(true);
            }
            if (tips.gameObject.activeInHierarchy)
            {
                tips.SetActive(false);
            }
            int count = goodsList.Count;

            if (count < 10)
            {
                count = 10;
            }
            ItemContainer ic;

            while (itemList.Count < count)
            {
                ic = NGUITools.AddChild(grid.gameObject, item).AddMissingComponent <ItemContainer>();
                ic.gameObject.name = string.Format("{0:D3}", itemList.Count);
                ic.onClick         = ItemOnClick;
                ic.buttonType      = Button.ButtonType.None;
                itemList.Add(ic);
            }
            grid.Reposition();
            int index = 0;

            //默认值初始化
            foreach (ItemContainer container in itemList)
            {
                if (index >= count)
                {
                    container.SetActive(false);
                }
                else
                {
                    Singleton <ItemManager> .Instance.InitItem(container, 1, ItemType.Equip); //空白

                    container.FindInChild <UILabel>("stren").text = string.Empty;
                    container.FindInChild <UILabel>("name").text  = string.Empty;
                    container.FindInChild <UISprite>("highlight").gameObject.SetActive(false);

                    for (int i = 1; i < 6; i++)
                    {
                        ItemManager.Instance.InitItem(container.FindChild("bs" + i), 1, 0);
                    }
                    if (EquipInheritView.Instance.gameObject.activeInHierarchy && this.Repos == GoodsMode.Instance.GOODS_REPOS)
                    {
                        container.FindInChild <UILabel>("pos").text = LanguageManager.GetWord("Equip.Pos" + this.pos);
                    }
                    else if (this.Repos == GoodsMode.Instance.EQUIP_REPOS)
                    {
                        container.FindInChild <UILabel>("pos").text = LanguageManager.GetWord("Equip.Pos" + (index + 1));
                    }
                    else
                    {
                        container.FindInChild <UILabel>("pos").text = string.Empty;
                    }
                    container.Id = 0;
                    container.SetActive(true);
                    index++;
                }
            }
            index = 0;
            List <PGemInHole> gemList;

            foreach (PGoods goods in goodsList)
            {
                vo = BaseDataMgr.instance.GetDataById <SysEquipVo>(goods.goodsId);
                if (Repos == 2)
                {
                    ic = itemList[vo.pos - 1];
                }
                else
                {
                    ic = itemList[index];
                }
                ic.Id = goods.id;
                ic.FindInChild <UILabel>("pos").text = string.Empty;
                ic.enabled = true;
                Singleton <ItemManager> .Instance.InitItem(ic, goods.goodsId, ItemType.Equip);

                ic.FindInChild <UILabel>("stren").text = "+" + goods.equip[0].stren;
                UILabel label = ic.FindInChild <UILabel>("name");
                label.text = vo.name;
                ColorUtils.SetEqNameColor(label, vo.color);

                gemList = goods.equip[0].gemList;
                uint      gemId; //宝石
                SysItemVo itemVo;
                for (int i = 0; i < 5; i++)
                {
                    if (i < gemList.Count)
                    {
                        gemId = gemList[i].gemId;
                    }
                    else
                    {
                        gemId = 1;
                    }
                    ItemManager.Instance.InitItem(ic.FindChild("bs" + (i + 1)), gemId, 0);
                }
                index++;
            }
            vo = null;
        }
        static public string SI_ShieldUpImproved(object info)
        {
            Multitype <NetCard, NetSkill, NetBattlefield> data = info as Multitype <NetCard, NetSkill, NetBattlefield>;

            if (data != null)
            {
                var  ns    = data.t1;
                var  bf    = data.t2;
                FInt value = ns.GetFloatAttribute("TAG-CA_SHIELD");
                if (value == FInt.ZERO)
                {
                    if (bf.ChallengeType == EChallengeType.TypePhysical)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_PHYSICAL");
                    }
                    else if (bf.ChallengeType == EChallengeType.TypeMental)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_MENTAL");
                    }
                    else if (bf.ChallengeType == EChallengeType.TypeMental)
                    {
                        value = ns.GetFloatAttribute("TAG-SHIELDING_SPIRIT");
                    }
                }

                FInt f = GameplayUtils.GetDamageFor(data.t1, data.t0);
                return((value + f).ToInt().ToString());
            }

            Multitype <SkillInstance, Subskill, ClientEntityCharacter> dInfo = info as Multitype <SkillInstance, Subskill, ClientEntityCharacter>;
            SkillInstance         si        = dInfo.t0;
            Subskill              ss        = dInfo.t1;
            ClientEntityCharacter character = dInfo.t2;
            var dataInWorld = si.GetCurrentSkillAttributes()[ss];

            if (dataInWorld.attributes != null && dataInWorld.attributes.Count > 0)
            {
                FInt extra = FInt.ZERO;

                string st = null;
                foreach (var v in ss.challengeTypes)
                {
                    if (character != null)
                    {
                        extra = GameplayUtils.GetDamageFor(si, ss, character, v);
                    }

                    FInt   value = dataInWorld.GetFInt("TAG-CA_SHIELD");
                    string color = "";

                    switch (v)
                    {
                    case EChallengeType.TypePhysical:
                        if (value == FInt.ZERO)
                        {
                            value = dataInWorld.GetFInt("TAG-SHIELDING_PHYSICAL");
                        }
                        color = "XML_COLOR-PHYSICAL";
                        break;

                    case EChallengeType.TypeMental:
                        if (value == FInt.ZERO)
                        {
                            value = dataInWorld.GetFInt("TAG-SHIELDING_MENTAL");
                        }
                        color = "XML_COLOR-MENTAL";
                        break;

                    case EChallengeType.TypeSpirit:
                        if (value == FInt.ZERO)
                        {
                            value = dataInWorld.GetFInt("TAG-SHIELDING_SPIRIT");
                        }
                        color = "XML_COLOR-SPIRITUAL";
                        break;
                    }

                    if (st == null)
                    {
                        st = "";
                    }
                    else
                    {
                        st += "|";
                    }

                    if (extra != FInt.ZERO)
                    {
                        st += ColorUtils.GetColorAsTextTag(color) +
                              extra +
                              ColorUtils.GetColorAsTextTag("XML_COLOR-NORMAL_FONT") +
                              " [+" + value + "]";
                    }
                    else
                    {
                        st += " [+" + value + "]";
                    }
                }
                return(st != null ? st : "");
            }

            return("");
        }
Ejemplo n.º 18
0
        public override void Render(bool shadow)
        {
            if (Entity.HasComponent <OwnerComponent>())
            {
                return;
            }

            var item     = (Item)Entity;
            var s        = item.Hidden ? Item.UnknownRegion : Sprite;
            var origin   = s.Center;
            var position = CalculatePosition(shadow);
            var angle    = (float)Math.Cos(T * 1.8f) * 0.4f;
            var cursed   = item.Scourged;

            if (!shadow)
            {
                var interact = Entity.TryGetComponent <InteractableComponent>(out var component) &&
                               component.OutlineAlpha > 0.05f;

                if (cursed || interact)
                {
                    var shader = Shaders.Entity;
                    Shaders.Begin(shader);

                    shader.Parameters["flash"].SetValue(cursed ? 1f : component.OutlineAlpha);
                    shader.Parameters["flashReplace"].SetValue(1f);
                    shader.Parameters["flashColor"].SetValue(!cursed ? ColorUtils.White : ColorUtils.Mix(ScourgedColor, ColorUtils.White, component.OutlineAlpha));

                    foreach (var d in MathUtils.Directions)
                    {
                        Graphics.Render(s, position + d, angle, origin);
                    }

                    Shaders.End();
                }
            }

            if (item.Masked)
            {
                Graphics.Color = MaskedColor;
                Graphics.Render(s, position, angle, origin);
                Graphics.Color = ColorUtils.WhiteColor;
            }
            else
            {
                if (!shadow && DebugWindow.ItemShader && !Settings.LowQuality)
                {
                    var shader = Shaders.Item;

                    Shaders.Begin(shader);
                    shader.Parameters["time"].SetValue(T * 0.1f);
                    shader.Parameters["size"].SetValue(FlashSize);
                }

                Graphics.Render(s, position, angle, origin);

                if (!shadow && DebugWindow.ItemShader && !Settings.LowQuality)
                {
                    Shaders.End();
                }
            }
        }
Ejemplo n.º 19
0
        public uint getColor32(ushort colorIndex)
        {
            var cl32 = (Color32)(getColor(colorIndex));

            return(ColorUtils.toColor(cl32.r, cl32.g, cl32.b));
        }
Ejemplo n.º 20
0
 public void BelowMin()
 {
     Assert.AreEqual(0.25f, ColorUtils.Clamp(0, 0.25f, 1));
 }
Ejemplo n.º 21
0
        public override IImage ApplyTool(IImage target)
        {
            var value = GetValueFromParameter(ParameterName.Contrast, -MaxValue, MaxValue, DefaultValue);

            if (value - Math.Floor(value) > 0)
            {
                throw new Exception("The number must not have any decimal value");
            }
            _contrastCorrectionFactor = (MaxValue + 4) * (value + MaxValue) / (MaxValue * (MaxValue + 4 - value));
            var pixels    = target.ImageRGB;
            var newPixels = new int[target.Height, target.Width];

            for (var i = 0; i < target.Height; i++)
            {
                for (var j = 0; j < target.Width; j++)
                {
                    newPixels[i, j] = pixels[i, j];
                    newPixels[i, j] = ColorUtils.SetBlue(newPixels[i, j],
                                                         (int)(_contrastCorrectionFactor * (ColorUtils.GetBlue(pixels[i, j]) - Translation) + Translation));
                    newPixels[i, j] = ColorUtils.SetGreen(newPixels[i, j],
                                                          (int)(_contrastCorrectionFactor * (ColorUtils.GetGreen(pixels[i, j]) - Translation) + Translation));
                    newPixels[i, j] = ColorUtils.SetRed(newPixels[i, j],
                                                        (int)(_contrastCorrectionFactor * (ColorUtils.GetRed(pixels[i, j]) - Translation) + Translation));
                }
            }

            return(new Image(newPixels));
        }
Ejemplo n.º 22
0
 public void AboveMax()
 {
     Assert.AreEqual(0.75f, ColorUtils.Clamp(1, 0, 0.75f));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Execute initialization tasks.
        /// </summary>
        protected void Init()
        {
            ShowPenColor();

            // This requires that a Kinect is connected at the time of app startup.
            // To make the app robust against plug/unplug,
            // Microsoft recommends using KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser).
            if (KinectV1Utils.StartKinectSensor() == null)
            {
                statusBarText.Text   = Properties.Resources.NoKinectReady;
                imgKinect.Visibility = Visibility.Hidden;
            }
            else
            {
                statusBarText.Text   = Properties.Resources.KinectReady;
                imgKinect.Visibility = Visibility.Visible;
            }

            speechSynthesis = new SpeechSynthesis();

            speechRecognition = new SpeechRecognitionKinectV1();                          //will fallback to same engine used by SpeechRecognition class automatically if it can't find Kinect V1 sensor

            speechRecognition.LoadGrammar(Properties.Resources.SpeechGrammar_en, "Main"); //could use SpeechGrammar_en.Create() to generate the grammar programmatically instead of loading it from an XML (resource) file
            speechRecognition.LoadGrammar(SpeechRecognitionUtils.CreateGrammarFromNames(ColorUtils.GetKnownColorNames(), "en", "Colors"));

            //setup recognition event handlers
            speechRecognition.Recognized    += SpeechRecognition_Recognized;
            speechRecognition.NotRecognized += SpeechRecognition_NotRecognized;

            // For long recognition sessions (a few hours or more), it may be beneficial to turn off adaptation of the acoustic model.
            // This will prevent recognition accuracy from degrading over time.
            //// speechRecognition.AcousticModelAdaptation = false;

            speechRecognition.Start(); //start speech recognition (set to keep on firing speech recognition events, not just once)
        }
Ejemplo n.º 24
0
 public void WithinRange()
 {
     Assert.AreEqual(0.5f, ColorUtils.Clamp(0.5f, 0, 1));
 }
Ejemplo n.º 25
0
 public static void SystemColorVector3Uniform(Shader shader, System.Drawing.Color color, string name)
 {
     shader.SetVector3(name, ColorUtils.Vector4FromColor(color).Xyz);
 }
Ejemplo n.º 26
0
        private static bool BuildObjectMesh(Tile tile, string name,
                                            double[] vertices,
                                            int[] triangles,
                                            int[] colors,
                                            double[] uvs,
                                            int[] uvMap,
                                            out Vector3[] worldPoints,
                                            out Color[] unityColors,
                                            out Vector2[] unityUvs,
                                            out Vector2[] unityUvs2,
                                            out Vector2[] unityUvs3)
        {
            long id;

            if (!ShouldLoad(tile, name, out id))
            {
                worldPoints = null;
                unityColors = null;;
                unityUvs    = null;
                unityUvs2   = null;
                unityUvs3   = null;
                return(false);
            }

            int uvCount    = uvs.Length;
            int colorCount = colors.Length;

            worldPoints = new Vector3[vertices.Length / 3];
            for (int i = 0; i < vertices.Length; i += 3)
            {
                worldPoints[i / 3] = tile.Projection
                                     .Project(new GeoCoordinate(vertices[i + 1], vertices[i]), vertices[i + 2]);
            }

            unityColors = new Color[colorCount];
            for (int i = 0; i < colorCount; ++i)
            {
                unityColors[i] = ColorUtils.FromInt(colors[i]);
            }

            if (uvCount > 0)
            {
                unityUvs  = new Vector2[uvCount / 2];
                unityUvs2 = new Vector2[uvCount / 2];
                unityUvs3 = new Vector2[uvCount / 2];

                var textureMapper = CreateTextureAtlasMapper(unityUvs, unityUvs2, unityUvs3, uvs, uvMap);
                for (int i = 0; i < uvCount; i += 2)
                {
                    unityUvs[i / 2] = new Vector2((float)uvs[i], (float)uvs[i + 1]);
                    textureMapper.SetUvs(i / 2, i);
                }
            }
            else
            {
                unityUvs  = new Vector2[worldPoints.Length];
                unityUvs2 = new Vector2[worldPoints.Length];
                unityUvs3 = new Vector2[worldPoints.Length];
            }

            tile.Register(id);

            return(true);
        }
Ejemplo n.º 27
0
        protected override void DoInit()
        {
            base.DoInit();

            animator             = GetComponent <SpriteAnimator> ();
            animator.loopCount   = 0;
            animator.playOnStart = false;
            render        = GetComponent <SpriteRenderer> ();
            startAngulars = transform.eulerAngles;
            colors        = new Color[] { Color.yellow, ColorUtils.HexToColor("E18624FF"), ColorUtils.HexToColor("9A9EE8FF") };
        }
Ejemplo n.º 28
0
    void Update()
    {
        if (rotateDelay > 0)
        {
            rotateDelay--;
        }

        if (Input.touchCount > 0)
        {
            if (Input.touchCount == 1)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    //check for intersection, will also need to see if top piece, also global is holding
                    if (false)
                    {
                        snapped = false;

                        Vector3 curScreenPoint = new Vector3(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y, 0);
                        Vector3 curPosition    = Camera.main.ScreenToWorldPoint(curScreenPoint);

                        float newX = Mathf.Clamp(curPosition.x - localMouseXY.x, -13, 13);
                        float newY = Mathf.Clamp(curPosition.y - localMouseXY.y, -10, 5);

                        transform.position = new Vector3(newX, newY, -1);


                        GameObject           background           = GameObject.FindGameObjectWithTag("BackgroundEffect");
                        BackgroundController backgroundController = background.GetComponent <BackgroundController>();

                        backgroundController.setColor(ColorUtils.lightenColor(backColor, 0.2f));

                        if (rotateDelay != 0)
                        {
                            DestroyIcons();
                        }
                        else if (displayedRotationIconBottom == null && displayedRotationIconTop == null)
                        {
                            DisplayIcons();
                        }
                    }
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Ended && isHolding)
                {
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Moved && isHolding)
                {
                    gameObject.SendMessage("OnMouseUp");
                    isHolding = false;
                }

                rotating = false;
            }
            else if (Input.touchCount == 2)
            {
                if (isHolding)
                {
                    if (!rotating)
                    {
                        startVector = Input.GetTouch(1).position - Input.GetTouch(0).position;
                    }
                    else
                    {
                        var currVector  = Input.GetTouch(1).position - Input.GetTouch(0).position;
                        var angleOffset = Vector2.Angle(startVector, currVector);
                        var LR          = Vector3.Cross(startVector, currVector);

                        if (angleOffset > 30)
                        {
                            if (LR.z > 0)
                            {
                                // Anticlockwise turn equal to angleOffset.
                                rotateCounterClockwise();
                            }
                            else if (LR.z < 0)
                            {
                                // Clockwise turn equal to angleOffset.
                                rotateClockwise();
                            }
                        }
                    }
                }
            }
        }
        else
        {
            rotating  = false;
            isHolding = false;
        }
    }
Ejemplo n.º 29
0
        //private static void StartWindow()
        //{
        //    var displayDevice = DisplayDevice.Default;
        //    window = new Window(1280, 720, "Test")
        //    {
        //        Location = new Point(0, 0),
        //        Background = Color.Green
        //    };
        //    window.Run();
        //}

        private static void StartWindow()
        {
            var t = new Thread(() =>
            {
                window = new Window(1920, 1080, "Test");
                window.Show();
            });

            t.Start();
            while (null == window)
            {
                Thread.CurrentThread.Join(250);
            }
            var root = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Background  = ColorUtils.FromRgbA(.1f, .1f, .1f, 1f)
            };

            window.RootElement = root;
            var stackPanel = new StackPanel
            {
                Size       = window.Size.AsFloat().Multiply(0.5f),
                Background = ColorUtils.FromRgbA(.2f, .2f, .2f, 1f),
                Margin     = 16f
            };
            var labelMargins = new Thickness(8f);

            stackPanel.AddChild(new ContentControl
            {
                ContentString = "Left Aligned",
                Foreground    = Color.Green,
                Background    = Color.Black,
                Margin        = labelMargins,
                Padding       = 16f
            },
                                new ContentControl
            {
                Foreground          = Color.Green,
                Background          = Color.Black,
                Margin              = labelMargins,
                HorizontalAlignment = Alignment.End,
                ContentString       = "Right Aligned"
            },
                                new ContentControl
            {
                ContentString       = "Centered",
                Margin              = labelMargins,
                HorizontalAlignment = Alignment.Center,
                Foreground          = Color.Green,
                Background          = Color.Black
            },
                                stretchedControl = new ContentControl
            {
                ContentString       = "Stretched",
                Margin              = labelMargins,
                HorizontalAlignment = Alignment.Stretch,
                Foreground          = Color.Green,
                Background          = Color.Black
            },
                                textBox = new TextBox
            {
                //Font = UIElement.DefaultFont,
                FontSize      = 48,
                Foreground    = Color.Black,
                Background    = Color.White,
                Size          = new SizeF(800, 400),
                Text          = "Default Text",
                Margin        = 8f,
                AcceptsReturn = true
            });
            canvas = new Canvas
            {
                Background = ColorUtils.FromRgbA(.3f, .3f, .3f, 1f),
                Margin     = 16f
            };
            canvas.AddChild(new ContentControl
            {
                Size          = new SizeF(120f, 10f),
                ContentString = "This content will not fit inside the control, yet it is not clipped.",
                Background    = new Color(128, 64, 64, 255)
            });
            root.AddChild(stackPanel, canvas);
        }
Ejemplo n.º 30
0
        private void Processing()
        {
            // Prevent Zoom Tolerance
            float Zoom = setting.Zoom;

            // ViewSize
            Size vSize = new Size(100, 100);

            // View Half Size
            Size vhSize = new Size(vSize.Width / 2, vSize.Height / 2);

            // Capture Size
            Size scSize = new Size(SelectOdd(vSize.Width / Zoom), SelectOdd(vSize.Height / Zoom));

            // ZoomBuffer Size
            Size zbSize = new Size((int)(scSize.Width * Zoom), (int)(scSize.Height * Zoom));

            // Remain Size
            Size rmSize = zbSize - vSize;

            // Capture Area
            Point mPt = Mouse.Position;

            if (IsActivated && IntersectWith(this.Bounds, mPt))
            {
                if (mInWorkArea)
                {
                    return;
                }
                else
                {
                    mInWorkArea = true;
                }

                mPt = this.Location;
            }
            else
            {
                mInWorkArea = false;
            }

            Rectangle area = new Rectangle(mPt.X - scSize.Width / 2, mPt.Y - scSize.Height / 2, scSize.Width, scSize.Height);

            // Capture
            Bitmap buffer = ScreenCapture.Capture(area);

            // Picked Color
            Color pColor = buffer.GetPixel(area.Width / 2, area.Height / 2);

            // ViewBox Processing
            Bitmap view = new Bitmap(vSize.Width, vSize.Height);

            using (Graphics g = Graphics.FromImage(view))
            {
                Point dPos = new Point(-rmSize.Width / 2, -rmSize.Height / 2);

                g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                g.DrawImage(buffer, new Rectangle(dPos, zbSize));

                // Grid Processing
                if (setting.ShowGrid && Zoom >= 2f)
                {
                    using (SolidBrush sb = new SolidBrush(Color.FromArgb(100, Color.White)))
                    {
                        using (Pen p = new Pen(sb))
                        {
                            int z = (int)Zoom;

                            for (int x = dPos.X; x <= vSize.Width; x += z)
                            {
                                if (x >= 0)
                                {
                                    g.DrawLine(p, new PointF(x, 0), new PointF(x, vSize.Height));
                                }
                            }

                            for (int y = dPos.Y; y <= vSize.Height; y += z)
                            {
                                if (y >= 0)
                                {
                                    g.DrawLine(p, new PointF(0, y), new PointF(vSize.Width, y));
                                }
                            }
                        }
                    }
                }

                // CrossLine Processing
                for (int x = 0; x < vSize.Width; x++)
                {
                    Color px = view.GetPixel(x, vhSize.Height);

                    view.SetPixel(x, vhSize.Height, ColorUtils.Invert(px));
                }

                for (int y = 0; y < vSize.Height; y++)
                {
                    Color px = view.GetPixel(vhSize.Width, y);

                    view.SetPixel(vhSize.Width, y, ColorUtils.Invert(px));
                }
            }

            buffer.Dispose();

            SetPickedColor(pColor);

            CrossThreading.UIInvoke(() =>
            {
                ldcPlate.BaseColor = pColor;

                viewBox.Image?.Dispose();
                viewBox.Image = view;
            });
        }