/// <summary> /// Windows下的鼠标事件 /// </summary> /// <param name="var">变量</param> /// <returns>状态</returns> public double WinMouseEvent(CVariable var) { INativeBase native = m_chart.Native; WinformControlHostEx host = native.Host as WinformControlHostEx; if (host != null) { SIZE displaySize = native.DisplaySize; int dx = 0, dy = 0, data = 0; int vlen = var.m_parameters.Length; String eventID = ""; if (vlen >= 1) { eventID = m_indicator.GetText(var.m_parameters[0]); } if (vlen >= 2) { dx = (int)m_indicator.GetValue(var.m_parameters[1]); } if (vlen >= 3) { dy = (int)m_indicator.GetValue(var.m_parameters[2]); } if (vlen >= 4) { data = (int)m_indicator.GetValue(var.m_parameters[3]); } host.MouseEvent(eventID, dx, dy, data); } return(1); }
/// <summary> /// 创建指标 /// </summary> /// <param name="text">脚本</param> /// <param name="parameters">参数</param> /// <returns>指标ID</returns> public static int CreateIndicatorExtern(String text, String parameters) { try { if (m_native == null) { m_native = NativeHandler.CreateNative(); } if (m_chart == null) { m_chart = new ChartAEx(); m_chart.Native = m_native; } m_serialNumber++; CTable dataSource = m_chart.Native.CreateTable(); dataSource.AddColumn(KeyFields.CLOSE_INDEX); dataSource.AddColumn(KeyFields.HIGH_INDEX); dataSource.AddColumn(KeyFields.LOW_INDEX); dataSource.AddColumn(KeyFields.OPEN_INDEX); dataSource.AddColumn(KeyFields.VOL_INDEX); dataSource.AddColumn(KeyFields.AMOUNT_INDEX); CIndicator indicator = SecurityDataHelper.CreateIndicator(m_chart, dataSource, text, parameters); m_indicators[m_serialNumber] = indicator; indicator.OnCalculate(0); } catch (Exception ex) { Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace); } return(m_serialNumber); }
/// <summary> /// 加载 /// </summary> /// <param name="name">名称</param> public void LoadXml(String name) { if (name == "PlanWindow") { DataCenter.ExportService = new ExportService(); DataCenter.PlanService = new PlanService(); m_xml = new PlanWindow(); DataCenter.PlanWindow = m_xml as PlanWindow; } m_xml.CreateNative(); m_native = m_xml.Native; m_native.Paint = new GdiPlusPaintEx(); m_host = new WinHostEx(); m_host.Native = m_native; m_native.Host = m_host; m_host.HWnd = Handle; m_native.AllowScaleSize = true; m_native.DisplaySize = new SIZE(ClientSize.Width, ClientSize.Height); m_xml.ResetScaleSize(GetClientSize()); m_xml.Script = new GaiaScript(m_xml); m_xml.Native.ResourcePath = DataCenter.GetAppPath() + "\\config"; m_xml.Load(DataCenter.GetAppPath() + "\\config\\" + name + ".html"); m_host.ToolTip = new ToolTipA(); m_host.ToolTip.Font = new FONT("SimSun", 20, true, false, false); (m_host.ToolTip as ToolTipA).InitialDelay = 250; m_native.Update(); Invalidate(); }
/// <summary> /// 创建方法 /// </summary> /// <param name="indicator">指标</param> /// <param name="id">ID</param> /// <param name="name">名称</param> /// <param name="native">XML对象</param> public CFunctionEx(CIndicator indicator, int id, String name, INativeBase native) { m_indicator = indicator; m_ID = id; m_name = name; m_native = native; }
/// <summary> /// 重置缩放尺寸 /// </summary> /// <param name="clientSize">客户端大小</param> public void ResetScaleSize(SIZE clientSize) { INativeBase native = Native; if (native != null) { ControlHost host = native.Host; SIZE nativeSize = native.DisplaySize; List <ControlA> controls = native.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { WindowFrameA frame = controls[i] as WindowFrameA; if (frame != null) { WindowEx window = frame.GetControls()[0] as WindowEx; if (window != null && !window.AnimateMoving) { POINT location = window.Location; if (location.x < 10 || location.x > nativeSize.cx - 10) { location.x = 0; } if (location.y < 30 || location.y > nativeSize.cy - 30) { location.y = 0; } window.Location = location; } } } native.ScaleSize = new SIZE((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor)); native.Update(); } }
/// <summary> /// 创建控件 /// </summary> /// <param name="node">节点</param> /// <param name="type">类型</param> /// <returns>控件</returns> public override ControlA CreateControl(XmlNode node, String type) { INativeBase native = Native; if (type == "barragediv") { return(new BarrageDiv()); } else if (type == "column" || type == "th") { return(new GridColumnEx()); } else if (type == "ribbonbutton") { return(new RibbonButton()); } else if (type == "windowex") { return(new WindowEx()); } ControlA control = base.CreateControl(node, type); if (control != null) { control.Font.m_fontFamily = "微软雅黑"; if (control is CheckBoxA) { (control as CheckBoxA).ButtonBackColor = CDraw.PCOLORS_BACKCOLOR8; } } return(control); }
/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="e">参数</param> private void MainWindow_Loaded(object sender, RoutedEventArgs e) { //创建管理器 m_host = new WPFHost(); //注册消息 WindowInteropHelper helper = new WindowInteropHelper(this); m_host.WindowHwnd = helper.Handle; HwndSource hwndSource = HwndSource.FromHwnd(m_host.WindowHwnd); hwndSource.AddHook(new HwndSourceHook(WndProc)); //启动服务 DataCenter.StartService(); //创建方法库 m_chart = new OwChart(); m_chart.CreateNative(); m_native = m_chart.Native; m_wpfPaint = new WPFPaint(); m_native.Paint = m_wpfPaint; m_native.Host = m_host; m_host.Render = new Render(m_native); m_native.DisplaySize = new SIZE(525, 350); AddChild(m_host.Render); m_host.Container = m_host.Render; m_host.Native = m_native; m_chart.Load(WPFHost.GetAppPath() + "\\config\\MainFrame.xml"); m_host.Render.Chart = m_chart; m_chart.ShowLoginWindow(); }
/// <summary> /// 窗体关闭事件 /// </summary> /// <param name="e"></param> protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e); List <ControlA> controls = m_native.GetControls(); List <ControlA> removeControls = new List <ControlA>(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { removeControls.Add(controls[i]); } for (int i = 0; i < controlsSize; i++) { m_native.RemoveMirror(removeControls[i]); } removeControls.Clear(); if (m_native != null) { m_native.Dispose(); m_native = null; } if (m_window != null) { WindowXmlEx window = m_window; m_window = null; window.Close(); } }
/// <summary> /// 添加 /// </summary> private void Add() { INativeBase native = Native; int divsSize = m_divs.Count; for (int i = 0; i < divsSize; i++) { SandBoxCandleDiv div = m_divs[i]; if (!div.Moving) { int clientX = native.ClientX(div); int clientY = native.ClientY(div); int direction = 0; if (clientY < 100) { direction = 1; clientY += 150; } else { clientY -= 150; } m_window.RemoveControl(div); div.Parent = null; m_native.AddControl(div); POINT newLocation = new POINT(clientX, clientY); div.Direction = direction; div.Location = newLocation; div.Moving = true; } } CreateNextData(true); CreatePreView(); m_native.Invalidate(); }
/// <summary> /// 添加镜像 /// </summary> /// <param name="native">库</param> /// <param name="target">目标</param> public void AddMirror(INativeBase native, ControlA target) { if (target.Parent == null || (target.Location.x == 0 && target.Location.y == 0)) { ClientSize = new Size(target.Size.cx, target.Size.cy); } else { ClientSize = new Size(target.Parent.Size.cx, target.Parent.Size.cy); } if (m_native == null) { m_native = NativeHandler.CreateNative(); m_native.MirrorMode = MirrorMode.Shadow; m_native.Paint = new GdiPlusPaintEx(); m_native.Host = new WinHostEx(); m_native.Host.Native = m_native; m_native.ResourcePath = WinHostEx.GetAppPath() + "\\config"; m_host = m_native.Host as WinHostEx; m_host.HWnd = Handle; //设置尺寸 m_native.AllowScaleSize = true; m_native.DisplaySize = new SIZE(ClientSize.Width, ClientSize.Height); ResetScaleSize(GetClientSize()); } m_native.AddMirror(native, target); m_native.Invalidate(); }
static void Main(string[] args) { INativeBase native = NativeHandler.CreateNative(); String script = "TEST(100);TEST(100);TEST(100);"; CIndicator indicator = CFunctionEx.CreateIndicator(script, native); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); for (int i = 0; i < 1000000; i++) { CMathElement ce = new CMathElement(); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); Console.ReadLine(); string appPath = DataCenter.GetAppPath(); string fileName = appPath + "\\test.js"; if (args != null && args.Length > 0) { fileName = appPath + "\\" + args[0]; } DataCenter.StartService(fileName); }
/// <summary> /// 创建界面(添加) /// </summary> /// <param name="native">方法库</param> public EditWindow(INativeBase native) { Load(native, "EditWindow", "collection"); //注册点击事件 RegisterEvents(m_window); //获取值 m_btnCancel = GetButton("btnCancel"); m_btnGo = GetButton("btnGo"); m_btnSelectDeveloper = GetButton("btnSelectDeveloper"); m_btnSubmit = GetButton("btnSubmit"); m_chbDeveloperPass = GetCheckBox("cbDeveloperPass"); m_chbCloseTask = GetCheckBox("cbCloseTask"); m_chbDeveloperReceive = GetCheckBox("cbDeveloperReceive"); m_chbTestPass = GetCheckBox("cbTestPass"); m_chbProductPass = GetCheckBox("cbProductPass"); m_chbPublished = GetCheckBox("cbPublished"); m_chbPublished = GetCheckBox("cbPublished"); m_chbWaitPublish = GetCheckBox("cbWaitPublish"); m_cmbCategory = GetComboBox("cbCategory"); m_cmbGroup = GetComboBox("cbGroup"); //组的联动 m_cmbGroup.RegisterEvent(new ControlEvent(SelectedIndexChangedEvent), EVENTID.SELECTEDINDEXCHANGED); m_cmbHurry = GetComboBox("cbHurry"); m_dtpEnd = GetDatePicker("dtpEnd"); m_dtpStart = GetDatePicker("dtpStart"); m_rtbDescription = GetTextBox("rtbDescription"); m_txtBranches = GetTextBox("rtbBranches"); m_txtCreater = GetTextBox("txtCreater"); m_txtDeveloper = GetTextBox("txtDeveloper"); m_txtHttpPath = GetTextBox("txtHttpPath"); m_txtJiraID = GetTextBox("txtJiraID"); m_txtRelativeGroup = GetTextBox("txtRelativeGroup"); m_txtTitle = GetTextBox("txtTitle"); }
/// <summary> /// 创建界面 /// </summary> /// <param name="native">方法库</param> public SearchWindow(INativeBase native) { Load(native, "SearchWindow", "collection"); //注册点击事件 RegisterEvents(m_window); this.m_searchTable = GetGrid("dgvTable"); }
/// <summary> /// 执行秒表方法 /// </summary> /// <param name="timerID">秒表ID</param> public void OnTimer(int timerID) { if (m_timerID == timerID) { INativeBase native = Native; ChartA chart = m_chart.Chart; CTable dataSource = chart.DataSource; int divsSize = m_divs.Count; bool painting = false; int cx = native.ClientX(m_window); int cy = native.ClientY(m_window); List <SandBoxCandleDiv> removeDivs = new List <SandBoxCandleDiv>(); for (int i = 0; i < divsSize; i++) { SandBoxCandleDiv div = m_divs[i]; //判断是否需要重绘 if (div.Moving) { painting = true; } //执行秒表 if (m_divs[i].OnTimer()) { SecurityData data = div.Data; int rowIndex = dataSource.GetRowIndex(data.m_date); int[] fields = new int[7]; fields[0] = KeyFields.CLOSE_INDEX; fields[1] = KeyFields.HIGH_INDEX; fields[2] = KeyFields.LOW_INDEX; fields[3] = KeyFields.OPEN_INDEX; fields[4] = KeyFields.VOL_INDEX; fields[5] = KeyFields.AMOUNT_INDEX; fields[6] = KeyFields.AVGPRICE_INDEX; //插入数据 SecurityDataHelper.InsertLatestData(m_chart.Chart, dataSource, m_chart.Indicators, fields, data); removeDivs.Add(div); } } //移除控件 int removeDivsSize = removeDivs.Count; if (removeDivsSize > 0) { for (int i = 0; i < removeDivsSize; i++) { SandBoxCandleDiv div = removeDivs[i]; m_native.RemoveControl(div); m_divs.Remove(div); div.Dispose(); } removeDivs.Clear(); m_chart.Chart.Update(); } //重绘 if (painting) { m_native.Invalidate(); } } }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public MasterWindow(INativeBase native) { Load(native, "MasterWindow", "masterWindow"); RegisterEvents(m_window); m_gridMasters = GetGrid("gridMasters"); m_gridMasters.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindMasters(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public BSStockWindow(INativeBase native) { Load(native, "BSStockWindow", "bsStockWindow"); RegisterEvents(m_window); m_gridBSStocks = GetGrid("gridBSStocks"); m_gridBSStocks.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindCodes(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public BusinessCardWindow(INativeBase native) { Load(native, "BusinessCardWindow", "businessCardWindow"); RegisterEvents(m_window); m_gridBusinessCards = GetGrid("gridBusinessCards"); m_gridBusinessCards.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindCards(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public SelectStaffWindow(INativeBase native) { Load(native, "SelectStaffWindow", "selectStaffWindow"); RegisterEvents(m_window); m_gridResult = GetGrid("gridResult"); m_gridStaffs = GetGrid("gridStaffs"); BindStaffs(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public RemoteWindow(INativeBase native) { Load(native, "RemoteWindow", "remoteWindow"); RegisterEvents(m_window); m_gridRemotes = GetGrid("gridRemotes"); m_gridRemotes.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindServers(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public FollowWindow(INativeBase native) { Load(native, "FollowWindow", "followWindow"); RegisterEvents(m_window); m_gridFollows = GetGrid("gridFollows"); m_gridFollows.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindFollows(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public ClueWindow(INativeBase native) { Load(native, "ClueWindow", "clueWindow"); RegisterEvents(m_window); m_gridClues = GetGrid("gridClues"); m_gridClues.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindClues(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public StaffWindow(INativeBase native) { Load(native, "StaffWindow", "staffWindow"); RegisterEvents(m_window); m_gridStaffs = GetGrid("gridStaffs"); m_gridStaffs.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindStaffs(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public GitWindow(INativeBase native) { Load(native, "GitWindow", "gitWindow"); RegisterEvents(m_window); m_gridGit = GetGrid("gridGits"); m_gridGit.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindGits(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public ProjectWindow(INativeBase native) { Load(native, "ProjectWindow", "projectWindow"); RegisterEvents(m_window); m_gridProjects = GetGrid("gridProjects"); m_gridProjects.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); m_gridProjects.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); BindProjects(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public AwardWindow(INativeBase native) { Load(native, "AwardWindow", "awardWindow"); RegisterEvents(m_window); m_gridAwards = GetGrid("gridAwards"); m_gridAwards.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); m_gridAwards.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); BindAwards(); }
/// <summary> /// 重置缩放尺寸 /// </summary> /// <param name="clientSize">客户端大小</param> public void ResetScaleSize(SIZE clientSize) { INativeBase native = Native; if (native != null) { native.ScaleSize = new SIZE((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor)); native.Update(); } }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public LevelWindow(INativeBase native) { Load(native, "LevelWindow", "levelWindow"); RegisterEvents(m_window); m_chartLevels = GetChart("chartLevels"); m_chartLevels.HScalePixel = 20; m_chartLevels.HScaleFieldText = "日期"; CTable dataSource = m_chartLevels.DataSource; dataSource.AddColumn(0); dataSource.AddColumn(1); dataSource.AddColumn(2); dataSource.AddColumn(3); dataSource.AddColumn(4); CDiv div = m_chartLevels.AddDiv(); div.BackColor = COLOR.ARGB(255, 255, 255); div.LeftVScale.ScaleColor = COLOR.ARGB(50, 105, 217); div.HScale.ScaleColor = COLOR.ARGB(50, 105, 217); div.HGrid.GridColor = COLOR.ARGB(50, 105, 217); div.HGrid.LineStyle = 2; PolylineShape ps = new PolylineShape(); ps.FieldName = 0; ps.FieldText = "开发"; ps.FillColor = COLOR.ARGB(100, 50, 105, 217); ps.Color = COLOR.ARGB(50, 105, 217); div.AddShape(ps); PolylineShape ps2 = new PolylineShape(); ps2.FieldName = 3; ps2.FieldText = "研发"; ps2.FillColor = COLOR.ARGB(100, 255, 80, 80); ps2.Color = COLOR.ARGB(255, 80, 80); div.AddShape(ps2); PolylineShape ps3 = new PolylineShape(); ps3.FieldName = 4; ps3.FieldText = "规范"; ps3.FillColor = COLOR.ARGB(100, 80, 255, 80); ps3.Color = COLOR.ARGB(80, 255, 80); div.AddShape(ps3); PolylineShape psTop = new PolylineShape(); psTop.FieldName = 1; div.AddShape(psTop); PolylineShape psBottom = new PolylineShape(); psBottom.FieldName = 2; div.AddShape(psBottom); m_gridLevels = GetGrid("gridLevels"); m_gridLevels.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindLevels(); BindChart(); }
/// <summary> /// 创建登录窗体 /// </summary> /// <param name="native">方法库</param> public LoginWindow(INativeBase native) { Load(native, "LoginWindow", "windowLogin"); m_invokeEvent = new ControlInvokeEvent(Invoke); m_window.RegisterEvent(m_invokeEvent, EVENTID.INVOKE); //注册点击事件 RegisterEvents(m_window); m_loginService = DataCenter.LoginService; m_loginDataCallBackEvent = new ListenerMessageCallBack(LoginDataCallBack); m_loginService.RegisterListener(m_loginRequestID, m_loginDataCallBackEvent); }
/// <summary> /// 创建聊天窗体 /// </summary> /// <param name="native">方法库</param> public ChatWindow(INativeBase native) { Load(native, "ChatWindow", "windowChat"); m_invokeEvent = new ControlInvokeEvent(Invoke); m_window.RegisterEvent(m_invokeEvent, EVENTID.INVOKE); //注册点击事件 RegisterEvents(m_window); m_chatService = DataCenter.ChatService; m_chatDataCallBackEvent = new ListenerMessageCallBack(ChatDataCallBack); m_chatService.RegisterListener(m_chatService.RequestID, m_chatDataCallBackEvent); }
/// <summary> /// 以动画形式隐藏 /// </summary> public void AnimateHide() { m_animateType = 1; INativeBase native = Native; ControlHost host = native.Host; m_animateDirection = m_rd.Next(0, 4); StartTimer(m_timerID, 10); m_animateMoving = true; host.AllowOperate = false; }