Пример #1
0
        static void Main(string[] args)
        {
            String file = "test.svg";

            //"iso-8859-1"
            string text = File.ReadAllText(file, Encoding.GetEncoding("utf-8"));

            /*text = Regex.Replace(text, "(<!--(.*?)-->)|(ng-[a-zA-Z0-9-]+=\"[^\"]*\")", "");
             * byte[] bytes = Encoding.Default.GetBytes(text);
             * text = Encoding.UTF8.GetString(bytes);*/
            //File.WriteAllText("loadPodloga2.svg", text);
            SVGImage   image = new SVGImage(Encoding.UTF8.GetBytes(text));
            FileStream sw    = File.Create("svg.pdf");

            image.SaveToPdf(sw);

            image.SaveToPdf("svg2.pdf");
            //System.Drawing.Bitmap i = image.Image(10.0);
            System.Drawing.Bitmap i = image.Image(3000, 3000, false);

            Bitmap   target = new Bitmap(i.Size.Width, i.Size.Height);
            Graphics g      = Graphics.FromImage(target);

            g.Clear(Color.White);
            //g.DrawRectangle(new Pen(new SolidBrush(Color.White)), 0, 0, target.Width, target.Height);
            g.DrawImage(i, 0, 0);
            target.Save("svg.png", ImageFormat.Png);
            i.Save("svg2.png", ImageFormat.Png);
            i.Save("svg.jpeg", ImageFormat.Jpeg);
            i.Save("svg.bmp", ImageFormat.Bmp);
        }
Пример #2
0
    void Start()
    {
        spriteRenderer = GetComponent <SVGImage>();
        if (Switch != null)
        {
            _SwitchConducting = Switch.SwitchConducting;//true;
            if (_SwitchConducting == true)
            {
                spriteRenderer.sprite = close;
                position = DbPos.close;
            }
            else
            {
                spriteRenderer.sprite = open;
                position = DbPos.open;
            }
        }
        else
        {
            _SwitchConducting     = false;
            spriteRenderer.sprite = bad;
            position = DbPos.bad;
        }
        oldSwitchConducting = _SwitchConducting;

        if (Resources.FindObjectsOfTypeAll <OperateDialog>().Length > 0)
        {
            operateDialog = Resources.FindObjectsOfTypeAll <OperateDialog>()[0];
        }
        else
        {
            Debug.Log("cannot find operateDialog");
        }
    }
Пример #3
0
    public void SetBoostImageIcon(int i, String name, bool bought)
    {
        SVGImage image = characterBoards[i].transform.Find(name).GetComponent <SVGImage>();
        Color    newCol;

        if (bought)
        {
            if (ColorUtility.TryParseHtmlString("#FFFFFF", out newCol))
            {
                if (image.color != newCol)
                {
                    image.color = newCol;
                }
            }
        }
        else
        {
            if (ColorUtility.TryParseHtmlString("#5A5A5A", out newCol))
            {
                if (image.color != newCol)
                {
                    image.color = newCol;
                }
            }
        }
    }
Пример #4
0
 public bool FillFromSvg(SVGImage svg)
 {
     try
     {
         float x = ParseSize(svg.X, Dpi.X);
         float y = ParseSize(svg.Y, Dpi.Y);
         float w = ParseSize(svg.Width, Dpi.X);
         float h = ParseSize(svg.Height, Dpi.Y);
         RectangleF = new RectangleF(x, y, w, h);
         _fileName  = svg.HRef;
         _id        = svg.Id;
         try
         {
             _image = Image.FromFile(_fileName);
             return(true);
         }
         catch (Exception ex)
         {
             SVGErr.Log("DrawImageObject", "FillFromSvg", ex.ToString(), SVGErr._LogPriority.Info);
             return(false);
         }
     }
     catch (Exception ex0)
     {
         SVGErr.Log("DrawImageObject", "FillFromSvg", ex0.ToString(), SVGErr._LogPriority.Info);
         return(false);
     }
 }
Пример #5
0
        private static GameObject GetOrCreateProfileOverride(Image portrait)
        {
            GameObject profileOverrideGO = portrait.transform.parent.gameObject.FindFirstChildNamed(ModConsts.GO_Profile_Override);

            if (profileOverrideGO == null)
            {
                Mod.Log.Debug?.Write(" -- CREATING PORTRAIT OVERRIDE NODE");
                profileOverrideGO                      = new GameObject();
                profileOverrideGO.name                 = ModConsts.GO_Profile_Override;
                profileOverrideGO.transform.parent     = portrait.transform.parent;
                profileOverrideGO.transform.localScale = new Vector3(0.5f, 0.5f, 1f);

                Vector3 newPos = portrait.transform.position;
                newPos.x -= 30f;
                newPos.y += 30f;
                profileOverrideGO.transform.position = newPos;

                SVGImage image = profileOverrideGO.GetOrAddComponent <SVGImage>();
                if (image == null)
                {
                    Mod.Log.Warn?.Write(" -- FAILED TO LOAD IMAGE - WILL NRE!");
                }
                image.color   = Color.white;
                image.enabled = true;
            }

            return(profileOverrideGO);
        }
Пример #6
0
        public static DrawObject Create(SVGImage svg)
        {
            try
            {
                DrawImageObject dobj;
                if (string.IsNullOrEmpty(svg.Id))
                {
                    dobj = new DrawImageObject(svg.HRef, ParseSize(svg.X, Dpi.X),
                                               ParseSize(svg.Y, Dpi.Y),
                                               ParseSize(svg.Width, Dpi.X),
                                               ParseSize(svg.Height, Dpi.Y));
                }
                else
                {
                    var di = new DrawImageObject();
                    if (!di.FillFromSvg(svg))
                    {
                        return(null);
                    }
                    dobj = di;
                }

                return(dobj);
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawImageObject", "Create", ex.ToString(), SVGErr._LogPriority.Info);
                return(null);
            }
        }
    public static void Postfix(
        MechComponentRef ___componentRef,
        SVGImage ___icon,
        LocalizableText ___nameText,
        LocalizableText ___bonusTextA,
        LocalizableText ___bonusTextB
        )
    {
        try
        {
            // support no icon
            ___icon.gameObject.SetActive(!string.IsNullOrEmpty(___componentRef.Def.Description.Icon));

            // support no name
            ___nameText.gameObject.SetActive(!string.IsNullOrEmpty(___componentRef.Def.Description.UIName));

            // support null besides empty string
            ___bonusTextA.gameObject.SetActive(!string.IsNullOrEmpty(___componentRef.Def.BonusValueA));
            ___bonusTextB.gameObject.SetActive(!string.IsNullOrEmpty(___componentRef.Def.BonusValueB));
        }
        catch (Exception e)
        {
            Control.Logger.Error.Log(e);
        }
    }
Пример #8
0
    // Function to set the weather mode
    public void SetWeather(SVGImage bg_btn, WeatherClip clip)
    {
        hasWeather = thisScenario.SetWeatherVideo(clip); // Returns true if video found
        UpdateStartButton();

        SetSelectedButton(parent_weathertoggles, bg_btn);
    }
Пример #9
0
    private void checkIfRezeptIsDone()
    {
        foreach (Transform child in panels_left[0].transform)
        {
            //wenn der Pfeil erreicht ist, sind die Zutaten alle erledigt
            if (child.tag == "Pfeil")
            {
                finishRezept();
                return;
            }

            Image image = child.GetComponent <Image> ();
            if (image != null)
            {
                var tempColor = image.color;
                if (tempColor.a != 0.2f)
                {
                    return;
                }
            }

            SVGImage image2 = child.GetComponent <SVGImage> ();
            if (image2 != null)
            {
                var tempColor = image2.color;
                if (tempColor.a != 0.2f)
                {
                    return;
                }
            }
        }
    }
Пример #10
0
        void DrawSolutionIcon(CairoContextEx cr, double x, double y, double width, double height)
        {
            string image;
            int    img_index = (int)SolutionIcon;

            switch (SolutionIcon)
            {
            case SolutionType.CorrectAnswer:
                image = "gtk-ok.svg";
                break;

            case SolutionType.InvalidAnswer:
                image = "gtk-stop.svg";
                break;

            case SolutionType.Tip:
                image = "gtk-info.svg";
                break;

            default:
                return;
            }

            // In memory games, the image gets painted several dozen times
            if (images [img_index] == null)
            {
                images [img_index] = new SVGImage(System.Reflection.Assembly.GetExecutingAssembly(), image);
            }

            cr.DrawImage(images [img_index], x + icon_margin, y, width, height);
        }
Пример #11
0
 void SetActiveTab(SVGImage image)
 {
     foreach (SVGImage ri in images)
     {
         ri.sprite = tabClosed;
     }
     image.sprite = tabOpen;
 }
Пример #12
0
        /// <summary>
        /// 它创建了一个新的SVG图像元素。
        /// </summary>
        public SVGImage AddImage(SVGUnit parent, ref SVGUnit last)
        {
            SVGImage img = new SVGImage(this);

            AddElement(parent, img, ref last);

            return(img);
        }
        static bool Prefix(SGDifficultyIndicatorWidget __instance, List <UIColorRefTracker> ___pips, UIColor ___activeColor, ref int difficulty)
        {
            Traverse difficultySetter = Traverse.Create(__instance).Property("Difficulty");

            difficultySetter.SetValue(difficulty);
            __instance.Reset();
            float f = ((float)(difficulty) % 10) / 2f;

            if (!DCECore.settings.useDiffRungs)
            {
                f = Mathf.Min((float)difficulty / 2f, 5f);
            }
            else
            {
                if ((difficulty % 10) == 0 && difficulty != 0)
                {
                    f = 5f;
                }
            }

            int   index;
            Color color;
            bool  customColor = DCECore.settings.getRungColor(Math.Max((difficulty - 1) / 10, 0), out color);

            for (index = 0; index < Mathf.FloorToInt(f); ++index)
            {
                UIColorRefTracker pip = ___pips[index];
                pip.GetComponent <SVGImage>().fillAmount = 1f;

                if (customColor)
                {
                    pip.SetUIColor(UIColor.Custom);
                    pip.OverrideWithColor(color);
                }
                else
                {
                    pip.SetUIColor(___activeColor);
                }
            }
            if ((double)index >= (double)f)
            {
                return(false);
            }
            UIColorRefTracker pip1      = ___pips[index];
            SVGImage          component = pip1.GetComponent <SVGImage>();

            if (customColor)
            {
                pip1.SetUIColor(UIColor.Custom);
                pip1.OverrideWithColor(color);
            }
            else
            {
                pip1.SetUIColor(___activeColor);
            }
            component.fillAmount = f - (float)index;
            return(false);
        }
Пример #14
0
 private static IEnumerator FadeToAlpha(SVGImage image, float alpha)
 {
     image.color = new Color(image.color.r, image.color.g, image.color.b, 0);
     while (image.color.a < alpha)
     {
         image.color = new Color(image.color.r, image.color.g, image.color.b, image.color.a + Time.deltaTime * 2.0f);
         yield return(null);
     }
 }
Пример #15
0
 // Use this for initialization
 void Start()
 {
     animalSVGImage = gameObject.GetComponent(typeof(SVGImage)) as SVGImage;
     animalOpenEye  = animalSVGImage.vectorGraphics;
     isClosed       = false;
     open           = firstBlink;
     close          = 0.2f;
     timer          = open;
 }
Пример #16
0
 private static IEnumerator FadeToZeroAlpha(SVGImage image)
 {
     image.color = new Color(image.color.r, image.color.g, image.color.b, 1);
     while (image.color.a > 0.0f)
     {
         image.color = new Color(image.color.r, image.color.g, image.color.b, image.color.a - Time.deltaTime * 2.0f);
         yield return(null);
     }
 }
Пример #17
0
    public void SetBoostImageCircle(SVGImage circle, bool bought)
    {
        Color newCol;

        SVGImage image           = circle.transform.Find("Boost Image").GetComponent <SVGImage>();
        Image    backgroundImage = circle.transform.parent.GetComponent <Image>();

        if (bought)
        {
            if (ColorUtility.TryParseHtmlString("#EAEAEA", out newCol))
            {
                if (circle.color != newCol)
                {
                    circle.color = newCol;
                }
            }
            if (ColorUtility.TryParseHtmlString("#FFFFFF", out newCol))
            {
                if (image.color != newCol)
                {
                    image.color = newCol;
                }
            }
            if (ColorUtility.TryParseHtmlString("#FFFFFF", out newCol))
            {
                if (backgroundImage.color != newCol)
                {
                    backgroundImage.color = newCol;
                }
            }
        }
        else
        {
            if (ColorUtility.TryParseHtmlString("#686868", out newCol))
            {
                if (circle.color != newCol)
                {
                    circle.color = newCol;
                }
            }
            if (ColorUtility.TryParseHtmlString("#5A5A5A", out newCol))
            {
                if (image.color != newCol)
                {
                    image.color = newCol;
                }
            }
            if (ColorUtility.TryParseHtmlString("#C8C8C8", out newCol))
            {
                if (backgroundImage.color != newCol)
                {
                    backgroundImage.color = newCol;
                }
            }
        }
    }
Пример #18
0
        public static void ResetDrawBackgroundCache()
        {
            if (image == null)
            {
                return;
            }

            image.Dispose();
            image = null;
        }
Пример #19
0
        static void UpdateIcon(GameObject icon, bool enable, bool isPlayerPositive)
        {
            if (enable)
            {
                SVGImage image = icon.GetComponent <SVGImage>();
                image.color = isPlayerPositive ? Mod.Config.Icons.PlayerPositiveMarkColor : Mod.Config.Icons.PlayerNegativeMarkColor;
            }

            icon.SetActive(enable);
        }
Пример #20
0
 //public void initializeStuff(Transform uicharge, TextMeshProUGUI uichargetext, SVGImage fillcolorsvgimg){
 public void initializeStuff(GameObject uicharge, GameObject uichargetext)
 {
     chargePercent     = 0.0f;
     energyGradientMat = gameObject.GetComponent <Image>().material;
     UICharge          = uicharge.GetComponent <RectTransform>();
     UIChargeText      = uichargetext.GetComponent <TextMeshProUGUI>();
     FillColor         = uicharge.GetComponent <SVGImage>();
     //tint = FillColor.GetComponent<Material>();
     print(UICharge + " " + UIChargeText + " " + FillColor);
 }
Пример #21
0
    public bool UseSvgImg()
    {
        Init();
        SVGImage sr = this.GetComponent <SVGImage>();

        if (sr != null)
        {
            this.SetImg(sr);
        }
        return(sr != null);
    }
Пример #22
0
 public static void Postfix(MechComponentRef ___componentRef, SVGImage ___icon)
 {
     try
     {
         ___icon.gameObject.SetActive(!string.IsNullOrEmpty(___componentRef.Def.Description.Icon));
     }
     catch (Exception e)
     {
         Control.mod.Logger.LogError(e);
     }
 }
Пример #23
0
    // Called when a button is selected to change all buttons to standard color
    private void SetSelectedButton(Transform parent, SVGImage selectedBtn)
    {
        SVGImage[] backgrounds = parent.GetComponentsInChildren <SVGImage>();

        foreach (SVGImage item in backgrounds)
        {
            item.color = normal_color;
        }

        selectedBtn.color = selected_color;
    }
Пример #24
0
    public void DeterminePreviewColor(GameObject preview, int highestLevel)
    {
        BuildingPreview buildingPreview = preview.GetComponent <BuildingPreview>();

        if (buildingPreview)
        {
            SVGImage svgImage1 = preview.transform.Find("Ground").GetComponent <SVGImage>();
            SVGImage svgImage2 = preview.transform.Find("Structure").GetComponent <SVGImage>();
            svgImage1.color = buildingPreview.index <= highestLevel ? Color.white : new Color(0, 0, 0, 0.7f);
            svgImage2.color = buildingPreview.index <= highestLevel ? Color.white : new Color(0, 0, 0, 0.7f);
        }
    }
Пример #25
0
        private void Start()
        {
            viewComponent = GetComponent <SVGImage>();

            if (viewPlay == null || viewPause == null)
            {
                DebugLog.LogRed("There`s no sprite in ButtonPause.cs");
                return;
            }

            UpdateState();
        }
 void Awake()
 {
     mimic = GetComponent <SVGImage>();
     if (mimic != null)
     {
         NormalColor = mimic.color;
     }
     else
     {
         Debug.Log("cannot find SVG Image");
     }
 }
Пример #27
0
    void Awake()
    {
        Joystick         = GameObject.FindGameObjectWithTag("Joystick");
        MovementJoystick = ((CNJoystick)Joystick.GetComponent(typeof(CNJoystick)));

        fireButton       = GameObject.Find("Fire Button").GetComponent <Button> ();
        jumpButton       = GameObject.Find("Jump Button").GetComponent <Button> ();
        drinkButton      = GameObject.Find("Drink Button").GetComponent <Button> ();
        drinkButtonGO    = GameObject.Find("Drink Button");
        drinkButtonImage = drinkButtonGO.GetComponentInChildren <SVGImage> ();

        equipSFX = this.gameObject.GetComponent <AudioSource> ();
    }
 public static void setSpriteOrHide(this SVGImage image, Sprite sprite)
 {
     if (sprite == null)
     {
         image.sprite  = sprite;
         image.enabled = false;
     }
     else
     {
         image.enabled = true;
         image.sprite  = sprite;
     }
 }
 // Token: 0x06013CC1 RID: 81089 RVA: 0x00509D40 File Offset: 0x00507F40
 static void Reset(UIColor ___defaultColor, List <UIColorRefTracker> ___pips)
 {
     if (___defaultColor == UIColor.Custom)
     {
         return;
     }
     foreach (UIColorRefTracker uicolorRefTracker in ___pips)
     {
         uicolorRefTracker.SetUIColor(___defaultColor);
         SVGImage component = uicolorRefTracker.GetComponent <SVGImage>();
         if (component != null)
         {
             component.fillAmount = 0f;
         }
     }
 }
Пример #30
0
    private void Start()
    {
        _soundManager = SoundManager29.Instance;

        _camera = Camera.main;

        _originalRot = _bottle.transform.eulerAngles.z;

        _bottleBatter = _bottle.transform.GetChild(0).GetChild(0).gameObject;

        _originalScale = _batters[0].localScale;

        _readyFlapjack = _batters[2].GetComponent <SVGImage>();

        _startRoutine = StartCoroutine(WaitForPlayerInput());
    }