Exemplo n.º 1
0
        public static void Add(FSM fsm, String name, String title, String description, String category)
        {
            if (Tools == null)
            {
                Tools = new Dictionary<string, ToolDescription>();
            }

            Tools[name] = new ToolDescription()
            {
                description = description,
                title = title,
                fsm = fsm,
                category = category
            };
        }
Exemplo n.º 2
0
        public static void Set(String name)
        {
            Trigger("stopped");
            A.Trigger("leave_tool");
            Z.UnlistenAll();

            if (name == "NULL")
            {
                V.TopPanelBackButton = null;
                return;
            }

            ToolDescription desc;
            if (Tools.TryGetValue(name, out desc))
            {
                T.t = desc.fsm;
                T.name = name;
                V.TopPanelBackButton = new BackButton("back");
                A.Trigger("enter_tool");
                Trigger("started");
            }
        }
Exemplo n.º 3
0
        static void Init()
        {
            a = new FSM();
            Tools.Registry.Register();

            a.OnMove("NULL>splash", args => {
                V.Navigate("Splash");
            });

            a.OnMove("splash>login", args =>
            {
                V.Navigate("Login");
            });

            a.OnMove("login_refresh>menu, login>menu, tool>menu", args =>
            {
                Cfg.ReadConfigFile();
                V.Navigate("Menu");
            });

            a.OnTrigger("NULL.view_initialised", args =>
            {
                a.Move("splash");
            });

            a.OnTrigger("splash.initialise", args =>
            {
                Z.Initialise();
            });

            a.OnTrigger("splash.libzano_initialised", args =>
            {
                a.Move("login");
            });

            a.OnTrigger("login.login", args =>
            {
                String email = (String)args[0];
                String pass = (String)args[1];
                ServerConnectivity.Credentials(email, pass);
                ServerConnectivity.Refresh();
                a.Move("login_refresh");
            });

            a.OnTrigger("login.logout", args =>
            {
                U.DeleteAccountFile();
            });

            a.OnTrigger("login.continue", args =>
            {
                a.Move("menu");
            });

            a.OnTrigger("login_refresh.logged_in", args =>
            {
                a.Move("menu");
            });

            a.OnTrigger("menu.enter_tool", args =>
            {
                a.Move("tool");
            });

            a.OnTrigger("tool.leave_tool", args =>
            {
                a.Move("menu");
            });

            a.OnTrigger("tool.connect", args =>
            {
                Internal.Connect.Trigger("connect", args);
            });

            a.OnTrigger("menu.tick", args =>
            {
                /*
                if (tickTimer == 0 || Library.Time() >= tickTimer)
                {
                    if (Z.IsConnected == false && Library.IsConnecting(Z.Handle) == 0 && Internal.Connect.IsConnecting == false)
                    {
                        Console.WriteLine("Testing Zano Connection");
                        tickTimer = Library.Time() + 10000;
                        PeekConnect(Z.Handle);
                        if (hasInternet == false)
                        {
                            V.TopBarConnectionTrigger("connecting");
                        }
                    }
                }
                */
            });

            a.OnTrigger("ANY.peek_connected, ANY.connected", args =>
            {
                hasConnection = true;
                Library.GetSerialNumber(Z.Handle, ref Z.SerialNumber);
                V.TopBarConnectionTrigger("connected", Z.LastBattery, Z.SerialNumberToString(Z.SerialNumber));
            });

            a.OnTrigger("ANY.not_connected, ANY.disconnected", args =>
            {
                if (hasConnection)
                {
                    V.TopBarConnectionTrigger("not_connected");
                }
                hasConnection = false;
            });

            a.OnTrigger("ANY.have_server_connection", args =>
            {
                hasInternet = true;
                V.TopBarConnectionTrigger("internet", LibZano.ServerConnectivity.Name());
            });

            a.OnTrigger("ANY.no_internet", args =>
            {
                hasInternet = false;
                if (Z.IsConnected == false)
                {
                    V.TopBarConnectionTrigger("not_conected");
                }
            });

            a.OnTrigger("ANY.battery", args =>
            {
                if (hasConnection)
                {
                    Library.GetSerialNumber(Z.Handle, ref Z.SerialNumber);
                    V.TopBarConnectionTrigger("connected", Z.LastBattery, Z.SerialNumberToString(Z.SerialNumber));
                }
            });
        }