예제 #1
0
        /// <summary>
        /// The on load end.
        /// </summary>
        /// <param name="eventArgs">
        /// The event args.
        /// </param>
        public void OnFrameLoadEnd(FrameLoadEndEventArgs eventArgs)
        {
            FrameLoadEnd?.Invoke(this, eventArgs);

            // Setup window subclass to intercept message for frameless window dragging
            NativeHost.SetupMessageInterceptor(_browserWindowHandle);
        }
 internal void OnBrowserCreated(object sender, EventArgs e)
 {
     _browserWindowHandle = Browser.GetHost().GetWindowHandle();
     if (_browserWindowHandle != IntPtr.Zero)
     {
         var size = NativeHost.GetWindowClientSize();
         ResizeBrowser(size.Width, size.Height);
     }
 }
        public void LoadServerList()
        {
            _mkt_servers.Add(new ServerAddress {
                Name = "模拟行情", Address = "tcp://ctpsim-front01.gfqh.cn:43213"
            });
            _mkt_servers.Add(new ServerAddress {
                Name = "国泰模拟", Address = "tcp://mn101.ctp.gtja-futures.com:41213"
            });
            _td_servers.Add(new ServerAddress {
                Name = "模拟交易", Address = "tcp://ctpsim-front01.gfqh.cn:43205"
            });
            _td_servers.Add(new ServerAddress {
                Name = "国泰模拟", Address = "tcp://mn101.ctp.gtja-futures.com:41205"
            });

            if (File.Exists(BrokersXmlPath))
            {
                XElement rootElem = XElement.Load(BrokersXmlPath);
                var      serversElemCollection = rootElem.Descendants("Servers");
                var      serversElem           = serversElemCollection.FirstOrDefault();
                var      elemServers           = serversElem.Elements("Server");
                foreach (var elemServ in elemServers)
                {
                    string name         = elemServ.Element("Name").Value;
                    var    tradingItems = GetAddressItems(elemServ.Element("Trading"));
                    FillList(_td_servers, tradingItems, name);
                    var marketItems = GetAddressItems(elemServ.Element("MarketData"));
                    FillList(_mkt_servers, marketItems, name);
                }
            }

            _trade_stations.Add(new ServerAddress {
                Name = "交易服务42", Address = ConfigurationHelper.GetAppSettingValue("42", "180.166.182.12:62248")
            });
            _trade_stations.Add(new ServerAddress {
                Name = "交易服务47", Address = ConfigurationHelper.GetAppSettingValue("47", "180.166.182.12:62249")
            });
            _trade_stations.Add(new ServerAddress {
                Name = "交易服务61(万兆)", Address = ConfigurationHelper.GetAppSettingValue("61", "180.166.182.12:62263")
            });
            _trade_stations.Add(new ServerAddress {
                Name = "国泰君安张江", Address = ConfigurationHelper.GetAppSettingValue("gtja-fm", "180.166.9.91:20205")
            });
            _trade_stations.Add(new ServerAddress {
                Name = "广发飞马", Address = ConfigurationHelper.GetAppSettingValue("gf-fm", "124.74.248.198:30009")
            });

            string localHostIP = NativeHost.GetLocalIP();
            string localPort   = "16181";

            _trade_stations.Add(new ServerAddress {
                Name = "本地服务", Address = string.Format("{0}:{1}",
                                                       localHostIP, localPort)
            });
        }
 internal void ResizeBrowser()
 {
     if (Browser != null)
     {
         _browserWindowHandle = Browser.GetHost().GetWindowHandle();
         if (_browserWindowHandle != IntPtr.Zero)
         {
             var size = NativeHost.GetWindowClientSize();
             ResizeBrowser(size.Width, size.Height);
         }
     }
 }
예제 #5
0
        /// <summary>
        /// Handles the <see cref="E:FrameLoadEnd" /> event.
        /// </summary>
        /// <param name="args">The <see cref="FrameLoadEndEventArgs"/> instance containing the event data.</param>
        void IWebBrowserInternal.OnFrameLoadEnd(FrameLoadEndEventArgs args)
        {
            var handler = FrameLoadEnd;

            if (handler != null)
            {
                handler(this, args);
            }

            // Setup window subclass to intercept message for frameless window dragging
            NativeHost.SetupMessageInterceptor(_browserWindowHandle);
        }
예제 #6
0
        public MainWindow()
        {
            _host = new NativeHost();


            _client                         = new Client();
            _client.OnError                += new Action <string>(_client_OnError);
            _client.OnQuoteReceived        += new Action <entity.Quote>(_client_OnQuoteReceived);
            _client.OnPortfolioItemUpdated += new Action <entity.PortfolioItem>(_client_OnPortfolioItemUpdated);
            _client.OnMultiLegOrderUpdated += new Action <trade.MultiLegOrder>(_client_OnMultiLegOrderUpdated);
            _client.OnTradeUpdated         += new Action <trade.Trade>(_client_OnTradeUpdated);

            InitializeComponent();
        }
예제 #7
0
        public void TestCppExceptions()
        {
            var server = GetErrorHandlingServer();

            var serverInterface = (RPC_SERVER_INTERFACE)Marshal.PtrToStructure(server, typeof(RPC_SERVER_INTERFACE));
            var endPointName    = Implementer + DateTime.Now.Ticks + serverInterface.InterfaceId.SyntaxGUID.ToString("N");

            var endpointBindingInfo = new EndpointBindingInfo(RpcProtseq.ncalrpc, null, endPointName);

            NativeHost.StartServer(endpointBindingInfo, server);

            RPC_STATUS status;

            var client = new NativeClient(endpointBindingInfo);

            CallErrorThrowingServer(client.Binding);
        }
예제 #8
0
        public AccountVM()
        {
            AddPortfolioCommand    = new DelegateCommand <AccountVM>(OnAddPortfolio);
            ConnectCommand         = new DelegateCommand <AccountVM>(OnConnectHost);
            DisconnectCommand      = new DelegateCommand <AccountVM>(OnDisconnectHost);
            RemovePortfolioCommand = new DelegateCommand <XamDataGrid>(OnRemovePortfolio);
            DetachCommand          = new DelegateCommand <AccountVM>(OnDetachHost);
            StartAllPortfolioCmd   = new DelegateCommand <AccountVM>(OnStartAllPortfolio);
            StopAllPortfolioCmd    = new DelegateCommand <AccountVM>(OnStopAllPortfolio);

            _host       = new NativeHost();
            AccountInfo = new AccountInfoVM(this);

            EventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>();
            AddressRepo     = ServiceLocator.Current.GetInstance <ServerAddressRepoVM>();

            _clientHandler = new ClientHandlerImpl();
            _client        = new Client(_clientHandler);
            _clientHandler.OnPortfolioUpdated     += new Action <PTEntity.PortfolioUpdateItem>(_clientHandler_OnPortfolioUpdated);
            _clientHandler.OnMultiLegOrderUpdated += new Action <PTEntity.MultiLegOrder>(_client_OnMultiLegOrderUpdated);
            _clientHandler.OnLegOrderUpdated      += new Action <string, string, string, PTEntity.Order>(_client_OnLegOrderUpdated);
            _clientHandler.OnTradeUpdated         += new Action <PTEntity.TradeUpdate>(_client_OnTradeUpdated);
            _clientHandler.OnConnectionClosed     += new Action(_clientHandler_OnConnectionClosed);

            /*
             * _client.OnError += new Action<string>(_client_OnError);
             * _client.OnQuoteReceived += new Action<entity.Quote>(_client_OnQuoteReceived);
             * _client.OnPositionDetialReturn += new Action<trade.PositionDetailInfo>(_client_OnPositionDetialReturn);
             */

            _hedgeFlagItemsSource.Add(new RefDataItem <PTEntity.HedgeFlagType, string>
            {
                Value = PTEntity.HedgeFlagType.SPECULATION, DisplayText = "投机"
            });
            _hedgeFlagItemsSource.Add(new RefDataItem <PTEntity.HedgeFlagType, string>
            {
                Value = PTEntity.HedgeFlagType.ARBITRAGE, DisplayText = "套利"
            });
            _hedgeFlagItemsSource.Add(new RefDataItem <PTEntity.HedgeFlagType, string>
            {
                Value = PTEntity.HedgeFlagType.HEDGE, DisplayText = "套保"
            });
        }
예제 #9
0
        public void TestCallback()
        {
            var server = GetExplicitWithCallbacksServer();

            var endPointName = Implementer + DateTime.Now.Ticks;

            var serverInterface = (RPC_SERVER_INTERFACE)Marshal.PtrToStructure(server, typeof(RPC_SERVER_INTERFACE));

            var endpointBindingInfo = new EndpointBindingInfo(RpcProtseq.ncalrpc, null, endPointName);

            NativeHost.StartServer(endpointBindingInfo, server);



            RPC_STATUS status;


            var client = new NativeClient(endpointBindingInfo);

            CallExplicitWithCallbacksServer(client.Binding);
        }
예제 #10
0
        public void LoadServerList()
        {
            _mkt_servers.Add(new ServerAddress {
                Name = "模拟行情", Address = "tcp://ctpsim-front01.gfqh.cn:43213"
            });
            _td_servers.Add(new ServerAddress {
                Name = "模拟交易", Address = "tcp://ctpsim-front01.gfqh.cn:43205"
            });

            if (File.Exists(BrokersXmlPath))
            {
                XElement rootElem = XElement.Load(BrokersXmlPath);
                var      serversElemCollection = rootElem.Descendants("Servers");
                var      serversElem           = serversElemCollection.FirstOrDefault();
                var      elemServers           = serversElem.Elements("Server");
                foreach (var elemServ in elemServers)
                {
                    string name         = elemServ.Element("Name").Value;
                    var    tradingItems = GetAddressItems(elemServ.Element("Trading"));
                    FillList(_td_servers, tradingItems, name);
                    var marketItems = GetAddressItems(elemServ.Element("MarketData"));
                    FillList(_mkt_servers, marketItems, name);
                }
            }

            _trade_stations.Add(new ServerAddress {
                Name = "交易服务42", Address = ConfigurationHelper.GetAppSettingValue("42", "116.228.246.94:62248")
            });
            _trade_stations.Add(new ServerAddress {
                Name = "交易服务47", Address = ConfigurationHelper.GetAppSettingValue("47", "116.228.246.94:62249")
            });

            string localHostIP = NativeHost.GetLocalIP();
            string localPort   = "16181";

            _trade_stations.Add(new ServerAddress {
                Name = "本地服务", Address = string.Format("{0}:{1}",
                                                       localHostIP, localPort)
            });
        }
예제 #11
0
        public AccountVM()
        {
            AddPortfolioCommand    = new DelegateCommand <AccountVM>(OnAddPortfolio);
            ConnectCommand         = new DelegateCommand <AccountVM>(OnConnectHost);
            DisconnectCommand      = new DelegateCommand <AccountVM>(OnDisconnectHost);
            RemovePortfolioCommand = new DelegateCommand <XamDataGrid>(OnRemovePortfolio);
            DetachCommand          = new DelegateCommand <AccountVM>(OnDetachHost);

            _host = new NativeHost();

            EventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>();
            AddressRepo     = ServiceLocator.Current.GetInstance <ServerAddressRepoVM>();

            _client                         = new Client();
            _client.OnError                += new Action <string>(_client_OnError);
            _client.OnQuoteReceived        += new Action <entity.Quote>(_client_OnQuoteReceived);
            _client.OnPortfolioItemUpdated += new Action <entity.PortfolioItem>(_client_OnPortfolioItemUpdated);
            _client.OnMultiLegOrderUpdated += new Action <trade.MultiLegOrder>(_client_OnMultiLegOrderUpdated);
            _client.OnLegOrderUpdated      += new Action <string, string, string, trade.Order>(_client_OnLegOrderUpdated);
            _client.OnTradeUpdated         += new Action <trade.Trade>(_client_OnTradeUpdated);
            _client.OnPositionDetialReturn += new Action <trade.PositionDetailInfo>(_client_OnPositionDetialReturn);
        }
 internal void ResizeBrowser(int width, int height)
 {
     NativeHost?.ResizeBrowser(_browserWindowHandle, width, height);
 }
예제 #13
0
 public virtual void SetTitle(string title)
 {
     NativeHost?.SetWindowTitle(title);
 }