public string GetValueOfName(JavaObjectHandle handle)
        {
            AccessibleContextInfo info;

            if (_accessBridge.Functions.GetAccessibleContextInfo(handle.JvmId, handle, out info))
            {
                return(info.name);
            }
            return(null);
        }
        public int GetIntValueOfName(JavaObjectHandle handle)
        {
            string value = GetValueOfName(handle);

            if (string.IsNullOrWhiteSpace(value))
            {
                return(0);
            }

            if (value == ">1000")
            {
                return(1000);
            }

            return(int.Parse(value));
        }
 private void EventsOnPropertyValueChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, string oldValue, string newValue)
 {
 }
 private void EventsOnPropertyVisibleDataChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source)
 {
 }
 // ReSharper disable UnusedMember.Local
 // ReSharper disable UnusedParameter.Local
 private void EventsOnPropertyChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, string property, string oldValue, string newValue)
 {
     // Note: It seems this event is never fired. Maybe this is from older JDKs?
 }
 private void EventsOnMouseExited(int vmId, JavaObjectHandle evt, JavaObjectHandle source)
 {
 }
 private void EventsOnPropertyChildChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, JavaObjectHandle oldChild, JavaObjectHandle newChild)
 {
 }
 private void EventsOnPropertyActiveDescendentChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, JavaObjectHandle oldActiveDescendent, JavaObjectHandle newActiveDescendent)
 {
 }
 private void EventsOnPropertyCaretChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, int oldPosition, int newPosition)
 {
 }
示例#10
0
 private void EventsOnPropertyDescriptionChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, string oldDescription, string newDescription)
 {
 }
示例#11
0
 private void EventsOnPropertyNameChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, string oldName, string newName)
 {
 }
示例#12
0
 private void EventsOnPropertySelectionChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source)
 {
 }
示例#13
0
 private void EventsOnPropertyStateChange(int vmId, JavaObjectHandle evt, JavaObjectHandle source, string oldState, string newState)
 {
 }
 // ReSharper disable once UnusedParameter.Local
 private JOBJECT32 Unwrap(int vmid, JavaObjectHandle objectHandle)
 {
     return(objectHandle.HandleLegacy);
 }
示例#15
0
 // ReSharper disable once UnusedParameter.Local
 private JOBJECT64 Unwrap(int vmid, JavaObjectHandle objectHandle)
 {
     return(objectHandle.Handle);
 }
        public void Collect()
        {
            //fetch process handle by matching window title -- can be made more specific to avoid collision with webbrowsers.
            Process[] processes = Process.GetProcesses();
            foreach (Process proc in processes)
            {
                if (proc.MainWindowTitle.Contains("Puzzle Pirates") && proc.MainWindowTitle.Contains("ocean"))
                {
                    _windowHandle = proc.MainWindowHandle;
                    break;
                }
            }

            if (_windowHandle == null)
            {
                return;
            }

            var window = _accessBridge.CreateAccessibleWindow(_windowHandle);

            var frame = window.GetChildren().First();

            if (frame == null)
            {
                return;
            }

            FindCommodityMarketNode(frame);
            if (_commodityNode == null)
            {
                return;
            }


            var commodityMarket = new CommodityMarket();

            commodityMarket.Island = _currentIsland;
            commodityMarket.Rows   = new List <MarketRow>();

            bool isInventory = false;
            var  parent      = _commodityNode.GetParent().GetParent();

            if (FindNodePropertyValue(parent, "Role") == "scroll pane")
            {
                //get child in scrollpane; should be vp for labels!

                if (((AccessibleContextNode)parent).GetInfo().childrenCount >= 4)
                {
                    var vpChildren = ((AccessibleContextNode)parent).FetchChildNode(3);
                    if (FindNodePropertyValue(vpChildren, "Role") == "viewport")
                    {
                        var panel = ((AccessibleContextNode)vpChildren).FetchChildNode(0);
                        if (FindNodePropertyValue(panel, "Role") == "panel" && ((AccessibleContextNode)panel).GetInfo().childrenCount >= 7)
                        {
                            var    label = ((AccessibleContextNode)panel).FetchChildNode(6);
                            string name  = FindNodePropertyValue(label, "Name");
                            if (FindNodePropertyValue(label, "Name") == "Ye hold")
                            {
                                isInventory = true;
                            }
                        }
                    }
                }
            }

            int incr = 6;

            if (isInventory)
            {
                incr = 7;
            }

            JavaObjectHandle jHandle = _commodityNode.AccessibleContextHandle;
            int JvmId = jHandle.JvmId;

            int m = _commodityNode.GetInfo().childrenCount - incr;

            for (int i = 0; i < m; i += incr)
            {
                commodityMarket.Rows.Add(new MarketRow()
                {
                    Commodity = GetValueOfName(_accessBridge.Functions.GetAccessibleChildFromContext(JvmId, jHandle, i)),
                    Outlet    = GetValueOfName(_accessBridge.Functions.GetAccessibleChildFromContext(JvmId, jHandle, i + 1)),
                    BuyPrice  = GetIntValueOfName(_accessBridge.Functions.GetAccessibleChildFromContext(JvmId, jHandle, i + 2)),
                    WillBuy   = GetIntValueOfName(_accessBridge.Functions.GetAccessibleChildFromContext(JvmId, jHandle, i + 3)),
                    SellPrice = GetIntValueOfName(_accessBridge.Functions.GetAccessibleChildFromContext(JvmId, jHandle, i + 4)),
                    WillSell  = GetIntValueOfName(_accessBridge.Functions.GetAccessibleChildFromContext(JvmId, jHandle, i + 5)),
                    //ye hold would be i+6
                });
            }

            var outputFormat = (string)Properties.Settings.Default["output_format"];

            if (outputFormat == "json")
            {
                var path       = AppDomain.CurrentDomain.BaseDirectory + _currentIsland + "-" + DateTime.Now.ToString("MM-dd-yy H mm ss") + ".json";
                var jsonString = commodityMarket.ToJson();
                File.WriteAllText(path, jsonString);
            }
            else if (outputFormat == "csv")
            {
                var path = AppDomain.CurrentDomain.BaseDirectory + _currentIsland + "-" + DateTime.Now.ToString("MM-dd-yy H mm ss") + ".csv";
                var csv  = commodityMarket.ToCsv();
                File.WriteAllText(path, csv);
            }

            OnFinishCollecting?.Invoke(this, new EventArgs());
        }