Пример #1
0
 /// <summary>
 /// Opens the selected path in windows explorer
 /// </summary>
 private void ExploreDirectory(string path)
 {
     try
     {
         path = PluginBase.MainForm.ProcessArgString(path);
         if (BridgeManager.Active && BridgeManager.IsRemote(path) && BridgeManager.Settings.UseRemoteExplorer)
         {
             BridgeManager.RemoteOpen(path);
             return;
         }
         Dictionary <string, string> config = ConfigHelper.Parse(configFilename, true).Flatten();
         if (!config.ContainsKey("explorer"))
         {
             config["explorer"] = "explorer.exe /e,\"{0}\"";
         }
         String explorer = PluginBase.MainForm.ProcessArgString(config["explorer"]);
         int    start    = explorer.StartsWith("\"") ? explorer.IndexOf("\"", 2) : 0;
         int    p        = explorer.IndexOf(" ", start);
         if (!path.StartsWith("\""))
         {
             path = "\"" + path + "\"";
         }
         // Start the process...
         ProcessStartInfo psi = new ProcessStartInfo(explorer.Substring(0, p));
         psi.Arguments        = String.Format(explorer.Substring(p + 1), path);
         psi.WorkingDirectory = path;
         ProcessHelper.StartAsync(psi);
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
Пример #2
0
        private void ShellOpenFile(string path)
        {
            if (BridgeManager.Active && BridgeManager.IsRemote(path) && !BridgeManager.AlwaysOpenLocal(path))
            {
                BridgeManager.RemoteOpen(path);
                return;
            }
            ProcessStartInfo psi = new ProcessStartInfo(path);

            psi.WorkingDirectory = Path.GetDirectoryName(path);
            ProcessHelper.StartAsync(psi);
        }
Пример #3
0
        static void Main(string[] args)
        {
            var api = new LocalRPCNode(10332, "http://neoscan.io");

            //var api = new RemoteRPCNode(10332, "http://neoscan.io");
            //var api = new CustomRPCNode();

            Console.WriteLine("Running Bluzelle NEO bridge...");

            // test public address = AHKPx5dZYnwAweQUJQH3UefoswKm6beEz2
            var manager = new BridgeManager(api, new TestSwarm(), "L3Vo5HcJhDoL7s81i4PSDTPfbUpVPrFHQ3V1GwSESkQtF4LW2vvJ", @"..\..\bin\Debug\BluzelleContract.avm");

            manager.Run();
        }
        ////////////////////////////////////////////////////
        //////////////// New in this sample ////////////////
        ////////////////////////////////////////////////////

        /// <summary>
        /// Adds and configures the <see cref="BridgeManager"/>.
        /// </summary>
        private void ConfigureBridges()
        {
            // create a new BridgeManager
            // The graph item styles are responsible for both
            // providing obstacles and drawing bridges,
            // the bridge manager collects the obstacles and
            // updates given edge paths to add bridges.
            // see MySimpleEdgeStyle
            var bridgeManager = new BridgeManager();

            //Convenience class that just queries all model item
            GraphObstacleProvider provider = new GraphObstacleProvider();

            //Register an IObstacleProvider, bridgeManager will query all registered obstacle providers
            //to determine if a bridge must be created
            bridgeManager.AddObstacleProvider(provider);
            //Bind the bridge manager to the GraphControl...
            bridgeManager.CanvasControl = graphControl;
        }
Пример #5
0
        public void HitTest(fsData messageData)
        {
            //Debug.Log("ARKitBridge: HitTest: messageData: " + messageData);

            if (!messageData.IsDictionary)
            {
                return;
            }

            var                 messageDict = messageData.AsDictionary;
            Vector2             screenPoint = BridgeManager.GetVector2(messageDict, "screenPoint");
            ARHitTestResultType resultTypes = BridgeManager.GetEnum <ARHitTestResultType>(messageDict, "resultTypes");
            string              callbackID  = BridgeManager.GetString(messageDict, "callbackID");

            fsData results     = fsData.CreateDictionary();
            var    resultsDict = results.AsDictionary;

            resultsDict["resultTypes"] = messageDict["resultTypes"];

            ARPoint arPoint = new ARPoint();

            arPoint.x = screenPoint.x;
            arPoint.y = screenPoint.y;

            List <ARHitTestResult> hitResults =
                UnityARSessionNativeInterface.GetARSessionNativeInterface().HitTest(arPoint, resultTypes);

            fsData hitTestResults = fsData.Null;

            if (!BridgeManager.ConvertFromList(hitResults, ref hitTestResults))
            {
                Debug.LogError("ARKitBridge: HitTest: error converting List<ARHitTestResult> to json.");
            }
            resultsDict["hitTestResults"] = hitTestResults;

            //Debug.Log("ARKitBridge: HitTest: results: " + results);

            bridgeManager.SendCallbackDataToJS(callbackID, results);
        }
        /// <summary>
        /// Adds and configures the <see cref="BridgeManager"/>.
        /// </summary>
        private void ConfigureBridges()
        {
            bridgeManager = new BridgeManager();

            // we would like to change the custom bridge rendering default,
            // this can be done by decorating the existing default bridge creator
            bridgeManager.DefaultBridgeCreator = new CustomBridgeCreator(bridgeManager.DefaultBridgeCreator);

            //Convenience class that just queries all model item
            GraphObstacleProvider provider = new GraphObstacleProvider();

            //We also want to query nodes for potential obstacles (disabled by default)
            provider.QueryNodes = true;
            //Register an IObstacleProvider, bridgeManager will query all registered obstacle providers
            //to determine if a bridge must be created
            bridgeManager.AddObstacleProvider(provider);
            //Bind the bridge manager to the GraphControl...
            bridgeManager.CanvasControl = graphControl;
            //We register a custom obstacle provider in the node's lookup of group nodes
            // that can be used by bridgeManager (through provider...)
            graphControl.Graph.GetDecorator().NodeDecorator.ObstacleProviderDecorator.SetFactory(
                node => graphControl.Graph.IsGroupNode(node), node => new GroupNodeObstacleProvider(node));

            // Initialize GUI components that configure bridge appearance
            crossingStyleComboBox.ComboBox.DataSource   = Enum.GetValues(typeof(BridgeCrossingStyle));
            crossingStyleComboBox.SelectedItem          = bridgeManager.DefaultBridgeCrossingStyle;
            crossingStyleComboBox.SelectedIndexChanged += crossingStyleComboBox_SelectedIndexChanged;

            crossingPolicyComboBox.ComboBox.DataSource   = Enum.GetValues(typeof(BridgeCrossingPolicy));
            crossingPolicyComboBox.SelectedItem          = bridgeManager.BridgeCrossingPolicy;
            crossingPolicyComboBox.SelectedIndexChanged += crossingPolicyComboBox_SelectedIndexChanged;

            bridgeOrientationComboBox.ComboBox.DataSource   = Enum.GetValues(typeof(BridgeOrientationStyle));
            bridgeOrientationComboBox.SelectedItem          = bridgeManager.DefaultBridgeOrientationStyle;
            bridgeOrientationComboBox.SelectedIndexChanged += bridgeOrientationComboBox_SelectedIndexChanged;

            heightTextBox.Text = bridgeManager.DefaultBridgeHeight.ToString();
            widthTextBox.Text  = bridgeManager.DefaultBridgeWidth.ToString();
        }
Пример #7
0
        public void TestCore()
        {
            var env = new TestEnviroment();

            var test_keypair = KeyPair.GenerateAddress();

            env.api.SendAsset(env.owner_keys, test_keypair.address, "GAS", 1);

            var test_key   = "test_key";
            var test_value = "Hello world!";

            var bridge = new BridgeManager(env.api, env.swarm, env.admin_keys.WIF, contract_script_bytes, env.api.GetBlockHeight());

            var tx = env.api.CallContract(test_keypair, contract_script_hash, "create", new object[] { test_keypair.address.AddressToScriptHash(), test_key, test_value });

            /*Assert.IsNotNull(tx);
             *
             * env.api.WaitForTransaction(test_keypair, tx);
             *
             * // run for a single block
             * bridge.Run(1);
             *
             * env.swarm.Read(env.ui)*/
        }
Пример #8
0
        /// <summary>
        /// Run the Flash IDE with the additional parameters provided
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns>Operation successful</returns>
        static public bool Run(string pathToIDE, string cmdData)
        {
            if (BridgeManager.Active)
            {
                pathToIDE = "Flash";
            }
            else
            {
                if (pathToIDE != null && Directory.Exists(pathToIDE))
                {
                    var exe = Path.Combine(pathToIDE, "Animate.exe");
                    if (!File.Exists(exe))
                    {
                        exe = Path.Combine(pathToIDE, "Flash.exe");
                    }
                    pathToIDE = exe;
                }
                if (pathToIDE == null || !File.Exists(pathToIDE))
                {
                    string       msg    = TextHelper.GetString("Info.ConfigureFlashPath");
                    string       title  = TextHelper.GetString("Info.ConfigurationRequired");
                    DialogResult result = MessageBox.Show(msg, title, MessageBoxButtons.OKCancel);
                    if (result == DialogResult.OK)
                    {
                        PluginBase.MainForm.ShowSettingsDialog("ASCompletion", "Flash");
                    }
                    return(false);
                }
            }

            TimeSpan diff = DateTime.Now.Subtract(lastRun);

            if (diff.Seconds < 1)
            {
                return(false);
            }
            lastRun = DateTime.Now;

            string args = null;

            if (cmdData != null)
            {
                args = PluginBase.MainForm.ProcessArgString(cmdData);
                if (args.IndexOf('"') < 0)
                {
                    args = '"' + args + '"';
                }
            }

            // execution
            ASContext.SetStatusText(TextHelper.GetString("Info.CallingFlashIDE"));
            PluginBase.MainForm.CallCommand("SaveAllModified", null);
            EventManager.DispatchEvent(null, new NotifyEvent(EventType.ProcessStart));

            try
            {
                string file = args.StartsWith('\"') ? args.Substring(1, args.Length - 2) : args;
                if (BridgeManager.Active && BridgeManager.Settings.TargetRemoteIDE &&
                    File.Exists(file) && Path.GetExtension(file) == ".jsfl" && file[0] <= 'H')
                {
                    string   folder = Path.Combine(BridgeManager.Settings.SharedDrive, ".FlashDevelop\\flashide");
                    string[] logs   = Directory.GetFiles(folder, "*.log");
                    foreach (string log in logs)
                    {
                        File.Delete(log);
                    }

                    string shared = Path.Combine(folder, Path.GetFileName(file));
                    File.Copy(file, shared, true);
                    BridgeManager.RemoteOpen(shared);
                    return(true);
                }
            }
            catch { }

            if (args != null)
            {
                ProcessHelper.StartAsync(pathToIDE, args);
            }
            else
            {
                ProcessHelper.StartAsync(pathToIDE);
            }
            return(true);
        }
Пример #9
0
        static void Main(string[] args)
        {
            var settings = new Settings(args);

            Console.WriteLine("Loading Bluzelle contract bytecode...");

            var contractFile = settings.GetValue("avm.path");

            if (!File.Exists(contractFile))
            {
                Console.WriteLine($"The file '{contractFile}' was not found");
                Environment.Exit(-1);
            }

            var contractBytes = File.ReadAllBytes(contractFile);
            var contractHash  = contractBytes.ToScriptHash();

            var api = new CustomRPCNode(settings.GetValue("rpc.host", "localhost"), int.Parse(settings.GetValue("rpc.port", "30333")),
                                        settings.GetValue("neoscan.host", "localhost"), int.Parse(settings.GetValue("neoscan.port", "4000")));

            var lastBlock = api.GetBlockHeight() - 1;

            if (lastBlock < 0)
            {
                lastBlock = 0;
            }

            lastBlock = uint.Parse(settings.GetValue("block", lastBlock.ToString()));

            //var owner_keys = KeyPair.FromWIF("L3Vo5HcJhDoL7s81i4PSDTPfbUpVPrFHQ3V1GwSESkQtF4LW2vvJ");
            var owner_keys = KeyPair.FromWIF("KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr");

            Console.WriteLine("Fetching balances");
            var balances = api.GetAssetBalancesOf("AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y");

            if (balances == null || balances.Count == 0)
            {
                Console.WriteLine("Seems the private net is not currently running..");
                Environment.Exit(-1);
            }

            foreach (var entry in balances)
            {
                Console.WriteLine(entry.Key + " => " + entry.Value);
            }

            Console.WriteLine($"Searching for contract at address {contractHash.ToAddress()}...");

            /*var test = api.InvokeScript(contractHash, new object[] { "test", new object[] { null} });
             * var found = false;
             *
             * if (test != null && test.stack.Length > 0)
             * {
             *  try
             *  {
             *      var testResult = System.Text.Encoding.ASCII.GetString((byte[])test.stack[0]);
             *      found = testResult.Equals("OK");
             *  }
             *  catch
             *  {
             *      // skip
             *  }
             * }
             *
             * if (found)
             * {
             *  Console.WriteLine("Contract found in the NEO chain!");
             * }
             * else
             * {
             *  Console.WriteLine("Contract not found in the NEO chain, deploying...");
             *  var tx = api.DeployContract(owner_keys, contractBytes, new byte[] { 0x07, 0x10 }, 0x05, ContractPropertyState.HasStorage, "Bluzelle", "1.0", "Bluzelle", "*****@*****.**", "Bluzelle contract");
             *  api.WaitForTransaction(owner_keys, tx);
             *
             *  Console.WriteLine("Contract is now deployed!");
             * }
             */

            Console.WriteLine("Starting Bluzelle NEO bridge...");

            //            var swarm = new WSSwarm("ws://192.168.138.134:51010");
            var swarm = new WSSwarm("ws://testnet.bluzelle.com:51010");

            // test public address = AHKPx5dZYnwAweQUJQH3UefoswKm6beEz2
            var manager = new BridgeManager(api, swarm, owner_keys, contractHash, lastBlock);

            manager.Run();
        }
Пример #10
0
 protected override void OnOpen()
 {
     bridgeManager = Main.BridgeManager;
     Log.Level     = LogLevel.Fatal;
     Debug.Log("Open SimulationControlService");
 }