Exemple #1
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Events.Clear();
                var events = await DataStore.GetItemsAsync(true); //loading up mock data to be used

                foreach (var evett in events)
                {
                    //    Events.Add(evett);
                    //    Events.Add(evett);
                }
                MockEventData bb  = new MockEventData();
                var           col = await bb.GetColoursAsync(true);

                foreach (var colo in col)
                {
                    Colours.Add(colo);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
 public void FillColours(Color colour)
 {
     for (int i = Colours.Count; i < Vertices.Count; ++i)
     {
         Colours.Add(colour);
     }
 }
        private void PopulateWidthAndColour(Textile selectedTextile)
        {
            Widths.Clear();
            Colours.Clear();

            foreach (var colour in selectedTextile.Colours)
            {
                Colours.Add(colour);
            }
            SelectedColourIndex = 0;

            foreach (var width in selectedTextile.Widths)
            {
                Widths.Add(width);
            }
            SelectedWidthIndex = 0;
        }
Exemple #4
0
    public static void LoadColours() //Loads all saved colours
    {
        //File.Decrypt(Application.dataPath+"/ColourClass"+"/CustomColours.txt");
        string[] lines     = File.ReadAllLines(@"Assets/ColourClass/CustomColours.txt");
        int      lineCount = File.ReadAllLines(@"Assets/ColourClass/CustomColours.txt").Length;

        string[] words;
        foreach (string item in lines)
        {
            words = item.Split(' ');
            string name = words[0];
            byte   r    = byte.Parse(words[1]);
            byte   g    = byte.Parse(words[2]);
            byte   b    = byte.Parse(words[3]);
            byte   a    = byte.Parse(words[4]);
            Colours.Add(new Colour(name, r, g, b, a));
        }
    }
Exemple #5
0
        public static void SwapColours(bool all)
        {
            Colours.Clear();

            if (all)
            {
                foreach (var c in AllColours)
                {
                    Colours.Add(c);
                }
            }
            else
            {
                foreach (var c in AllColours.Take(17).ToList())
                {
                    Colours.Add(c);
                }
            }
        }
Exemple #6
0
 private void AddColour()
 {
     Colours.Add(new ColourViewModel(SelectedColourPicker.ToDrawingColor()));
 }
 private void GetColours()
 {
     Colours.Add(new ColourModel("Alice Blue", Colors.AliceBlue));
     Colours.Add(new ColourModel("Antique White", Colors.AntiqueWhite));
 }
Exemple #8
0
        public static void Main(string[] args)
        {
            if (Directory.Exists(Directory.GetCurrentDirectory() + "/StaticBindings") == false)
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/StaticBindings");
            }

            CreateBindings.DirectoryPath = Directory.GetCurrentDirectory() + "/StaticBindings";
            CreateBindings.Create <Color>();
            CreateBindings.CreateFinalFile();

            //DOML.LinkBindings();
            Console.SetWindowSize((int)(Console.LargestWindowWidth / 1.5f), (int)(Console.LargestWindowHeight / 1.5f));
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            using (StreamReader reader = new StreamReader(File.OpenRead("test.doml"))) {
                int c = reader.Read();
                while (c > 0)
                {
                    Console.Write((char)c);
                    c = reader.Read();
                }
            }
            TopLevelNode topLevel = new Parser().ParseAST(new StreamReader(File.OpenRead("test.doml")));

            topLevel.BasicCodegen(Console.Out, false);
            topLevel.BasicCodegen(Console.Out, true);
            foreach (Instruction instruction in topLevel.GetInstructions())
            {
                Console.Write(instruction.OpCode);
                foreach (object obj in instruction.Parameters)
                {
                    Console.Write(" " + obj);
                }
                Console.WriteLine();
            }

            topLevel.Print(Console.Out);
            Console.Read();
            return;

#if BenchmarkDotNet
            //Summary summary = BenchmarkRunner.Run<AllTests>();
            //Console.Read();
#elif StaticBindings
            if (Directory.Exists(Directory.GetCurrentDirectory() + "/StaticBindings") == false)
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/StaticBindings");
            }

            CreateBindings.DirectoryPath = Directory.GetCurrentDirectory() + "/StaticBindings";
            CreateBindings.Create <Color>("System");
            CreateBindings.CreateFinalFile();
#elif TestBindings
            DOMLBindings.LinkBindings();


            Interpreter interpreter = Parser.GetInterpreterFromText(@"
            // This is a comment
            // Construct a new System.Color
            @ Test        = System.Color ...
            ;             .RGB             = 255, 64, 128 // Implicit 'array'

            @ TheSame     = System.Color ...
            ;             .RGB->Normalised = 1, 0.25, 0.5, // You can have trailing commas

            @ AgainSame   = System.Color ...
            ;             .RGB->Hex        = 0xFF4080
            ;             .Name            = ""OtherName""

            /* Multi Line Comment Blocks are great */
            @ Copy = System.Color...
            ;             .RGB = Test.R, Test.G, Test.B
            ;             .Name = ""Copy""
            ");

            string withComments;
            string withoutComments;

            IRWriter.EmitToLocation(interpreter, Directory.GetCurrentDirectory() + "/CompactOutput.IR", false, false);
            IRWriter.EmitToLocation(interpreter, Directory.GetCurrentDirectory() + "/Output.IR", false, true);

            StringBuilder builder = new StringBuilder();

            IRWriter.EmitToString(interpreter, builder, true);
            withComments = builder.ToString();
            builder.Clear();
            IRWriter.EmitToString(interpreter, builder, false);
            withoutComments = builder.ToString();

            Interpreter c;

            using (StringReader reader = new StringReader(withComments))
            {
                c = Parser.GetInterpreterFromIR(reader);
                c.HandleSafeInstruction(new Instruction());
            }

            using (StringReader reader = new StringReader(withoutComments))
            {
                c = Parser.GetInterpreterFromIR(reader);
                c.HandleSafeInstruction(new Instruction());
            }

            Console.Read();

            return;

            TestDOML.RunStringTest(@"
            // This is a comment
            // Construct a new System.Color
            @ Test        = System.Color ...
            ;             .RGB             = 255, 64, 128 // Implicit 'array'

            @ TheSame     = System.Color ...
            ;             .RGB->Normalised = 1, 0.25, 0.5, // You can have trailing commas

            @ AgainSame   = System.Color ...
            ;             .RGB->Hex        = 0xFF4080
            ;             .Name            = ""OtherName""

            /* Multi Line Comment Blocks are great */
            @ Copy = System.Color...
            ;             .RGB = Test.R, Test.G, Test.B
            ;             .Name = ""Copy""
            ", 5, Config.READ_EMIT);

            Console.Write(Log.HandleLogs);

            Console.Read();
#else
            Log.LogHandler += Log_LogHandler;

            Action <InterpreterRuntime> Set_RGB = (InterpreterRuntime runtime) =>
            {
                if (runtime.Pop(out Colour result))
                {
                    // Handle
                    if (!runtime.Pop(out result.B) || !runtime.Pop(out result.G) || !runtime.Pop(out result.R))
                    {
                        Log.Error("Pops failed");
                        return;
                    }

                    result.R /= 255;
                    result.G /= 255;
                    result.B /= 255;
                }
            };

            Action <InterpreterRuntime> Get_RGB = (InterpreterRuntime runtime) =>
            {
                if (!runtime.Pop(out Colour result) || !runtime.Push(result.R, true) || !runtime.Push(result.G, true) || !runtime.Push(result.B, true))
                {
                    Log.Error("Pushes failed");
                }
            };

            InstructionRegister.RegisterConstructor("System.Color", (InterpreterRuntime runtime) =>
            {
                Colour colour = new Colour();
                Colours.Add(colour);
                if (!runtime.Push(colour, true))
                {
                    Log.Error("Creation failed");
                }
            });

            InstructionRegister.RegisterSetter("RGB", "System.Color", 3, Set_RGB);
            InstructionRegister.RegisterGetter("RGB", "System.Color", 3, Get_RGB);
            InstructionRegister.RegisterSetter("RGB.Normalised", "System.Color", 3, (InterpreterRuntime runtime) =>
            {
                if (runtime.Pop(out Colour result))
                {
                    if (!runtime.Pop(out result.B) || !runtime.Pop(out result.G) || !runtime.Pop(out result.R))
                    {
                        Log.Error("Pops failed");
                    }
                }
            });

            Parser.GetInterpreterFromText(@"
                @ Test = System.Color ... // Comment
                ;      .RGB(Normalised) = 0.5, 0.25, 0.1,
                ").Execute(true);//Emit(Directory.GetCurrentDirectory() + "/Test.doml", true, true);

            /*TestDOML.RunStringTest(@"
             * @ Test = System.Color ... // Comment
             * ;      .RGB(Normalised) = 0.5, 0.25, 0.1,
             * ", 100, Config.ALL);*/

            Colours.ForEach(y => Log.Info($"Colour RGB: {y.R} {y.G} {y.B}"));

            Console.Read();
#endif
        }