Ejemplo n.º 1
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get an area of screen as an array of colors.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <returns>2D array of pixel colors.</returns>
        public static ColorContainer[][] GetPixels(int x, int y, int w = 1, int h = 1)
        {
            Bitmap pixels = Native.API.CopyScreenArea(x, y, w, h);

            //Has to be array of arrays rather than 2D array - silly conversion
            ColorContainer[][] colors = new ColorContainer[w][];
            for (int i = 0; i < w; i++)
            {
                colors[i] = new ColorContainer[h];
            }

            BitmapData data = pixels.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

            int v = data.Stride * h;

            byte[] values = new byte[v];

            Marshal.Copy(data.Scan0, values, 0, v);

            pixels.UnlockBits(data);

            for (int i = 0; i < values.Length; i += 4)
            {
                colors[(i / 4) / w][(i / 4) % h] = new ColorContainer(values[i], values[i + 1], values[i + 2]);
            }

            return(colors);
        }
Ejemplo n.º 3
0
        public MainManager(IPaintingMemoryManager memoryManager)
        {
            this.MemoryManager = memoryManager;

            this.SelectedTool          = Tool.Default;
            this.SelecedColorContainer = ColorContainer.Default;
        }
Ejemplo n.º 4
0
 public PaintingObject(Point position, Size size, ColorContainer colorContainer) : this()
 {
     Position       = position;
     Size           = size;
     Id             = UniqueId;
     ColorContainer = colorContainer;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Get an area of screen as an array of colors.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <returns>2D array of pixel colors.</returns>
        public static ColorContainer[][] GetPixels(int x, int y, int w, int h)
        {
            Bitmap pixels = Native.API.CopyScreenArea(x, y, w, h);

            //Has to be array of arrays rather than 2D array - silly conversion
            ColorContainer[][] colors = new ColorContainer[w][];
            for (int i = 0; i < w; i++)
            {
                colors[i] = new ColorContainer[h];
            }

            BitmapData data = pixels.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

            byte[] values = new byte[data.Stride * h];

            Marshal.Copy(data.Scan0, values, 0, data.Stride * h);

            pixels.UnlockBits(data);

            for (int j = 0; j < data.Height; j++)
            {
                for (int i = 0; i < data.Width; i++)
                {
                    colors[i][j] = new ColorContainer(values[j * data.Width * 4 + i * 4 + 2], values[j * data.Width * 4 + i * 4 + 1], values[j * data.Width * 4 + i * 4]);
                }
            }

            return(colors);
        }
Ejemplo n.º 6
0
        public Window()
        {
            InitializeComponent();

            InfoVersion.Text = Core.Version;

            ConsoleOutput.Font = new System.Drawing.Font(Core.Fonts.Families[0], 10f);

            Package[] installedPackages = Workshop.GetInstalled();

            installedPackages.ToList().ForEach(x =>
            {
                Dictionary <string, string> packageInfo = x.GetInfo();

                PackageInfo p      = new PackageInfo();
                p.NameLabel.Text   = packageInfo["Name"];
                p.AuthorLabel.Text = packageInfo["Authors"];
                p.DescLabel.Text   = packageInfo["Description"];
                p.Package          = x;

                p.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;

                InstalledPackagesList.Controls.Add(p);

                p.RunButton.Click += (o, e) =>
                {
                    x.Run(true);
                };
            });

            var hoverColor = new ColorContainer(0, 0, 0);
            var cursorPos  = new PointContainer(0, 0);

            var timer = new System.Timers.Timer();

            timer.Interval = 1000;
            timer.Elapsed += (s, a) =>
            {
                if (this == null)
                {
                    return;
                }

                cursorPos  = InputWrapper.GetCursorPos();
                hoverColor = ScreenWrapper.GetPixels(cursorPos.X, cursorPos.Y, 1, 1)[0][0];

                Invoke(new Action(() =>
                {
                    if (IsDisposed)
                    {
                        return;
                    }

                    ColorDisplay.Text     = $"R: {hoverColor.R} G: {hoverColor.G} B: {hoverColor.B}";
                    CursorPosDisplay.Text = $"X: {cursorPos.X} Y: {cursorPos.Y}";
                }));
            };
            timer.Start();
        }
Ejemplo n.º 7
0
        public void ConvertsKnownColorToJson()
        {
            var container = new ColorContainer {
                Color = Color.Blue
            };
            var json = JsonConvert.SerializeObject(container);

            Assert.AreEqual("{\"Color\":\"#0000FF\"}", json);
        }
Ejemplo n.º 8
0
        public void ConvertsEmptyColorToJson()
        {
            var container = new ColorContainer {
                Color = Color.Empty
            };
            var json = JsonConvert.SerializeObject(container);

            Assert.AreEqual("{\"Color\":\"\"}", json);
        }
Ejemplo n.º 9
0
    public override void OnInspectorGUI()
    {
        ColorContainer manager = (ColorContainer)target;

        color_data_list.container = manager;
        color_data_list.OnInspectorGUI();

        EditorUtility.SetDirty(target);
    }
        // GET: Colors
        public ActionResult Index()
        {
            //var item = RenderingContext.Current.ContextItem;
            //var listOfColors = new HtmlString(FieldRenderer.Render(item, "Color"));
            var dataSourceId = RenderingContext.Current.Rendering.DataSource;
            var dataSource   = Sitecore.Context.Database.GetItem(dataSourceId);
            var viewModel    = new ColorContainer();

            viewModel.Colors = new List <Item>();
            viewModel.Colors = dataSource.Children;
            return(View(viewModel));
        }
 public void SerializeVectorContainer()
 {
     try
     {
         var obj = new ColorContainer();
         obj.VectorField = new Color(1.25f, 2.5f, 3.75f, 0.25f);
         obj.VectorProperty = new Color(2.25f, 3.5f, 4.25f, 0.5f);
         var data = JsonConvert.SerializeObject(obj);
         Assert.AreEqual("{\"VectorField\":{\"r\":1.25,\"g\":2.5,\"b\":3.75,\"a\":0.25},\"VectorProperty\":{\"r\":2.25,\"g\":3.5,\"b\":4.25,\"a\":0.5}}", data);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.ToString());
     }
 }
    public MyDataContext()
    {
        ColorContainer _cContainer = new ColorContainer();;

        _cContainer.boxStart = Colors.Orange;
        _cContainer.boxEnd   = Colors.Green;
        //note that all items use this _cContainer instance
        _items = new ObservableCollection <ComboboxItem>();
        _items.Add(new ComboboxItem()
        {
            Name = "name1", URL = "url1", CContainer = _cContainer
        });
        _items.Add(new ComboboxItem()
        {
            Name = "name2", URL = "url2", CContainer = _cContainer
        });
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Append RichTextBox with a multi-color text.
        /// </summary>
        /// <param name="textBox">RichTextBox to append to.</param>
        /// <param name="args">Strings prepended by colors ex: Color.Red, "text", Color.Yellow, "text2".</param>
        public static void AppendText(this RichTextBox textBox, params object[] args)
        {
            //params object[] is a very general argument
            //if arg doesn't fit any other overload, it'll run this function - which requires additional precautions
            if (args.Length < 2)
            {
                textBox.AppendText(args[0].ToString());
                return;
            }

            for (int i = 0; i < args.Length; i += 2)
            {
                ColorContainer color = (ColorContainer)args[i];
                textBox.AppendText((String)args[i + 1]);
                textBox.Select(Math.Max(textBox.TextLength - args[i + 1].ToString().Length, 0), args[i + 1].ToString().Length);
                textBox.SelectionColor = Color.FromArgb(color.R, color.G, color.B);
            }
        }
Ejemplo n.º 14
0
    Material GetMaterialForChangeColor(GameObject G, ColorContainer cc)
    {
        Material retorno = null;


        if (cc.meshOrChildren == MainOrChildren.parentObject)
        {
            G = G.transform.parent.gameObject;
        }

        if (cc.meshOrChildren == MainOrChildren.childrenObject)
        {
            retorno = G.GetComponentInChildren <Renderer>().materials[cc.indiceDoMaterialAlvo];
        }
        else if (cc.meshOrChildren == MainOrChildren.mainObject)
        {
            retorno = G.GetComponent <Renderer>().materials[cc.indiceDoMaterialAlvo];
        }

        return(retorno);
    }
Ejemplo n.º 15
0
 void OnEnable()
 {
     color_container = AssetDatabase.LoadAssetAtPath <ColorContainer>("Assets/Character/000_tween.prefab");
     RefreshNames();
 }
Ejemplo n.º 16
0
 public void ConvertsEmptyColorToJson()
 {
     var container = new ColorContainer { Color = Color.Empty };
     var json = JsonConvert.SerializeObject(container);
     Assert.AreEqual("{\"Color\":\"\"}", json);
 }
Ejemplo n.º 17
0
 public void SetSelectedColor(Color color)
 {
     //k jine sirce staci upravit pen size
     SelecedColorContainer = new ColorContainer(new SolidBrush(color), new Pen(color), color);
 }
Ejemplo n.º 18
0
 public PaintingObject(ColorContainer colorContainer) : this()
 {
     ColorContainer = colorContainer;
 }
Ejemplo n.º 19
0
 public abstract PaintingObject GetInstance(Point position, ColorContainer colorContainer);
Ejemplo n.º 20
0
 public ColorDataList(ColorContainer container)
     : base(s_Util, "Colors", true)
 {
     this.container = container;
 }
Ejemplo n.º 21
0
 public override PaintingObject GetInstance(Point position, ColorContainer colorContainer)
 {
     return(new PRectangle(position, new Size(1, 1), colorContainer));
 }
Ejemplo n.º 22
0
 public PRectangle(Point position, Size size, ColorContainer colorContainer) : base(position, size, colorContainer)
 {
     originalStartPosition = new Point(position.X, position.Y);
 }
 public SerializableColorContainerStruct(ColorContainerStruct C)
 {
     coresEditaveis = C.coresEditaveis;
     cor            = new float4(C.cor.r, C.cor.g, C.cor.b, C.cor.a);
 }
Ejemplo n.º 24
0
 public override PaintingObject GetInstance(Point position, Size size, ColorContainer colorContainer)
 {
     return(new PCircle(position, size, colorContainer));
 }
Ejemplo n.º 25
0
 public void ConvertsKnownColorToJson()
 {
     var container = new ColorContainer { Color = Color.Blue };
     var json = JsonConvert.SerializeObject(container);
     Assert.AreEqual("{\"Color\":\"#0000FF\"}", json);
 }