/// <summary> /// 鼠标抬起方法 /// </summary> /// <param name="touchInto">触摸信息</param> public override void onTouchUp(FCTouchInfo touchInto) { m_point2 = Native.TouchPoint; base.onTouchUp(touchInto); if (!IsDragging) { FCView divDesigner = Parent; if (m_resizePoint != -1) { FCRect nowRect = convertBoundsToPRect(Bounds); //移动控件 int targetsSize = m_targets.Count; if (targetsSize > 0) { m_designerDiv.saveUndo(); for (int i = 0; i < targetsSize; i++) { FCView target = m_targets[i]; FCPoint oldLocation = target.Location; FCSize oldSize = target.Size; oldLocation.x += nowRect.left - m_startRect.left; oldLocation.y += nowRect.top - m_startRect.top; oldSize.cx += (nowRect.right - nowRect.left) - (m_startRect.right - m_startRect.left); oldSize.cy += (m_startRect.top - m_startRect.bottom) - (nowRect.top - nowRect.bottom); if (oldSize.cx < 4) { oldSize.cx = 4; } else if (oldSize.cy < 4) { oldSize.cy = 4; } m_xml.setProperty(target, "location", FCStr.convertPointToStr(oldLocation)); m_xml.setProperty(target, "size", FCStr.convertSizeToStr(oldSize)); target.update(); } } m_designerDiv.Designer.refreshProperties(); } else { if (m_targets.Count == 1) { if (Math.Abs(m_point1.x - m_point2.x) > 5 && Math.Abs(m_point1.y - m_point2.y) > 5) { //获取选中控件 FCView target = m_targets[0]; FCRect moveRect = getRectangle(pointToControl(m_point1), pointToControl(m_point2)); List <FCView> newTargets = new List <FCView>(); List <FCView> subControls = target.getControls(); int left = 0, top = 0, right = 0, bottom = 0, idx = 0; int subControlsSize = subControls.Count; for (int i = 0; i < subControlsSize; i++) { FCView subControl = subControls[i]; FCRect bounds = subControl.Bounds; FCRect tempRect = new FCRect(); if (Native.Host.getIntersectRect(ref tempRect, ref moveRect, ref bounds) > 0) { newTargets.Add(subControl); if (idx == 0) { left = bounds.left; top = bounds.top; right = bounds.right; bottom = bounds.bottom; } else { if (left > bounds.left) { left = bounds.left; } if (top > bounds.top) { top = bounds.top; } if (right < bounds.right) { right = bounds.right; } if (bottom < bounds.bottom) { bottom = bounds.bottom; } } idx++; } } if (newTargets.Count > 0) { FCPoint p1 = target.pointToNative(new FCPoint(left, top)); FCPoint p2 = target.pointToNative(new FCPoint(right, bottom)); p1 = divDesigner.pointToControl(p1); p2 = divDesigner.pointToControl(p2); Bounds = convertPRectToBounds(new FCRect(p1.x, p1.y, p2.x, p2.y)); clearTargets(); addTargets(newTargets); m_designerDiv.Designer.refreshProperties(newTargets); } } } } } refreshStatusBar(); m_resizePoint = -1; Cursor = FCCursors.Arrow; FCNative native = Native; native.Host.setCursor(FCCursors.Arrow); native.update(); native.invalidate(); }
/// <summary> /// 创建内部控件 /// </summary> /// <param name="parent">父控件</param> /// <param name="clsid">类型ID</param> /// <returns>控件</returns> public override FCView createInternalControl(FCView parent, String clsid) { //日历控件 FCCalendar calendar = parent as FCCalendar; if (calendar != null) { if (clsid == "datetitle") { return(new DateTitle(calendar)); } else if (clsid == "headdiv") { HeadDiv headDiv = new HeadDiv(calendar); headDiv.Width = parent.Width; headDiv.Dock = FCDockStyle.Top; return(headDiv); } else if (clsid == "lastbutton") { return(new ArrowButton(calendar)); } else if (clsid == "nextbutton") { ArrowButton nextBtn = new ArrowButton(calendar); nextBtn.ToLast = false; return(nextBtn); } } //分割层 FCSplitLayoutDiv splitLayoutDiv = parent as FCSplitLayoutDiv; if (splitLayoutDiv != null) { if (clsid == "splitter") { FCButton splitter = new FCButton(); splitter.Size = new FCSize(5, 5); return(splitter); } } //滚动条 FCScrollBar scrollBar = parent as FCScrollBar; if (scrollBar != null) { if (clsid == "addbutton") { FCButton addButton = new FCButton(); addButton.Size = new FCSize(15, 15); return(addButton); } else if (clsid == "backbutton") { return(new FCButton()); } else if (clsid == "scrollbutton") { FCButton scrollButton = new FCButton(); scrollButton.AllowDrag = true; return(scrollButton); } else if (clsid == "reducebutton") { FCButton reduceButton = new FCButton(); reduceButton.Size = new FCSize(15, 15); return(reduceButton); } } //页夹 FCTabPage tabPage = parent as FCTabPage; if (tabPage != null) { if (clsid == "headerbutton") { FCButton button = new FCButton(); button.AllowDrag = true; FCSize size = new FCSize(100, 20); button.Size = size; return(button); } } //下拉列表 FCComboBox comboBox = parent as FCComboBox; if (comboBox != null) { if (clsid == "dropdownbutton") { FCButton dropDownButton = new FCButton(); dropDownButton.DisplayOffset = false; int width = comboBox.Width; int height = comboBox.Height; FCPoint location = new FCPoint(width - 16, 0); dropDownButton.Location = location; FCSize size = new FCSize(16, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { FCComboBoxMenu comboBoxMenu = new FCComboBoxMenu(); comboBoxMenu.ComboBox = comboBox; comboBoxMenu.Popup = true; FCSize size = new FCSize(100, 200); comboBoxMenu.Size = size; return(comboBoxMenu); } } //日期选择 FCDateTimePicker datePicker = parent as FCDateTimePicker; if (datePicker != null) { if (clsid == "dropdownbutton") { FCButton dropDownButton = new FCButton(); dropDownButton.DisplayOffset = false; int width = datePicker.Width; int height = datePicker.Height; FCPoint location = new FCPoint(width - 16, 0); dropDownButton.Location = location; FCSize size = new FCSize(16, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { FCMenu dropDownMenu = new FCMenu(); dropDownMenu.Padding = new FCPadding(1); dropDownMenu.Popup = true; FCSize size = new FCSize(200, 200); dropDownMenu.Size = size; return(dropDownMenu); } } //数字选择 FCSpin spin = parent as FCSpin; if (spin != null) { if (clsid == "downbutton") { FCButton downButton = new FCButton(); downButton.DisplayOffset = false; FCSize size = new FCSize(16, 16); downButton.Size = size; return(downButton); } else if (clsid == "upbutton") { FCButton upButton = new FCButton(); upButton.DisplayOffset = false; FCSize size = new FCSize(16, 16); upButton.Size = size; return(upButton); } } //容器层 FCDiv div = parent as FCDiv; if (div != null) { if (clsid == "hscrollbar") { FCHScrollBar hScrollBar = new FCHScrollBar(); hScrollBar.Visible = false; hScrollBar.Size = new FCSize(15, 15); return(hScrollBar); } else if (clsid == "vscrollbar") { FCVScrollBar vScrollBar = new FCVScrollBar(); vScrollBar.Visible = false; vScrollBar.Size = new FCSize(15, 15); return(vScrollBar); } } //表格 FCGrid grid = parent as FCGrid; if (grid != null) { if (clsid == "edittextbox") { return(new FCTextBox()); } } return(null); }
/// <summary> /// 创建菜单项 /// </summary> /// <param name="text">文字</param> public FCMenuItem(String text) { Font = new FCFont("宋体", 12, false, false, false); Size = new FCSize(200, 25); Text = text; }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintForeground(FCPaint paint, FCRect clipRect) { String text = Text; //绘制文字 if (text != null && text.Length > 0) { int width = Width, height = Height; if (width > 0 && height > 0) { FCFont font = Font; FCSize tSize = paint.textSize(text, font); long linkColor = getPaintingLinkColor(); FCPoint tPoint = new FCPoint((width - tSize.cx) / 2, (height - tSize.cy) / 2); FCPadding padding = Padding; switch (m_textAlign) { case FCContentAlignment.BottomCenter: tPoint.y = height - tSize.cy; break; case FCContentAlignment.BottomLeft: tPoint.x = padding.left; tPoint.y = height - tSize.cy - padding.bottom; break; case FCContentAlignment.BottomRight: tPoint.x = width - tSize.cx - padding.right; tPoint.y = height - tSize.cy - padding.bottom; break; case FCContentAlignment.MiddleLeft: tPoint.x = padding.left; break; case FCContentAlignment.MiddleRight: tPoint.x = width - tSize.cx - padding.right; break; case FCContentAlignment.TopCenter: tPoint.y = padding.top; break; case FCContentAlignment.TopLeft: tPoint.x = padding.left; tPoint.y = padding.top; break; case FCContentAlignment.TopRight: tPoint.x = width - tSize.cx - padding.right; tPoint.y = padding.top; break; } FCRect tRect = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy); if (AutoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom)) { if (tRect.right > clipRect.right) { tRect.right = clipRect.right; } if (tRect.bottom > clipRect.bottom) { tRect.bottom = clipRect.bottom; } paint.drawTextAutoEllipsis(text, linkColor, font, tRect); } else { paint.drawText(text, linkColor, font, tRect); } //画下划线 FCNative native = Native; if (m_linkBehavior == FCLinkBehavior.AlwaysUnderLine || (m_linkBehavior == FCLinkBehavior.HoverUnderLine && (this == native.PushedControl || this == native.HoveredControl))) { paint.drawLine(linkColor, 1, 0, tPoint.x, tPoint.y + tSize.cy, tPoint.x + tSize.cx, tPoint.y + tSize.cy); } } } }
/// <summary> /// 创建菜单项 /// </summary> public FCMenuItem() { Font = new FCFont("宋体", 12, false, false, false); Size = new FCSize(200, 25); }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪矩形</param> public override void onPaintForeground(FCPaint paint, FCRect clipRect) { int width = Width, height = Height; if (width > 0 && height > 0) { int right = width; int midY = height / 2; String text = Text; int tRight = 0; long textColor = getPaintingTextColor(); if (text != null && text.Length > 0) { FCFont font = Font; FCSize tSize = paint.textSize(text, font); FCRect tRect = new FCRect(); tRect.left = 10; tRect.top = midY - tSize.cy / 2 + 2; tRect.right = tRect.left + tSize.cx; tRect.bottom = tRect.top + tSize.cy; paint.drawText(text, textColor, font, tRect); tRight = tRect.right + 4; } //绘制选中 if (m_checked) { FCRect eRect = new FCRect(tRight, height / 2 - 4, tRight + 8, height / 2 + 4); paint.fillEllipse(textColor, eRect); } //画子菜单的提示箭头 if (m_items.size() > 0) { FCPoint point1 = new FCPoint(), point2 = new FCPoint(), point3 = new FCPoint(); FCMenu menu = m_parentMenu; if (m_parentItem != null) { menu = m_parentItem.DropDownMenu; } FCLayoutStyle layoutStyle = menu.LayoutStyle; //横向 if (layoutStyle == FCLayoutStyle.LeftToRight || layoutStyle == FCLayoutStyle.RightToLeft) { point1.x = right - 25; point1.y = midY - 2; point2.x = right - 14; point2.y = midY - 2; point3.x = right - 20; point3.y = midY + 4; } //纵向 else { point1.x = right - 15; point1.y = midY; point2.x = right - 25; point2.y = midY - 5; point3.x = right - 25; point3.y = midY + 5; } FCPoint[] points = new FCPoint[] { point1, point2, point3 }; paint.fillPolygon(textColor, points); } } }
/// <summary> /// 重置日期图层 /// </summary> /// <param name="state">状态</param> public virtual void onResetDiv(int state) { if (m_calendar != null) { int size = 0; CMonth thisMonth = m_calendar.Month; CMonth lastMonth = m_calendar.getLastMonth(thisMonth.Year, thisMonth.Month); CMonth nextMonth = m_calendar.getNextMonth(thisMonth.Year, thisMonth.Month); int left = 0; int headHeight = m_calendar.HeadDiv.Height; int top = headHeight; int width = m_calendar.Width; int height = m_calendar.Height; height -= m_calendar.TimeDiv.Height; int dayButtonHeight = height - top; if (dayButtonHeight < 1) { dayButtonHeight = 1; } int subH = 0, toY = 0; ArrayList <DayButton> dayButtons = new ArrayList <DayButton>(); if (m_am_Direction == 1) { subH = (6 - (m_am_ClickRowTo - m_am_ClickRowFrom)) * (dayButtonHeight / 6); toY = -height + subH + headHeight; toY = toY * m_am_Tick / m_am_TotalTick; if (state == 1) { thisMonth = nextMonth; lastMonth = m_calendar.getLastMonth(thisMonth.Year, thisMonth.Month); nextMonth = m_calendar.getNextMonth(thisMonth.Year, thisMonth.Month); } } else if (m_am_Direction == 2) { subH = (6 - (m_am_ClickRowFrom - m_am_ClickRowTo)) * (dayButtonHeight / 6); toY = height - subH - headHeight; toY = toY * m_am_Tick / m_am_TotalTick; if (state == 1) { thisMonth = lastMonth; lastMonth = m_calendar.getLastMonth(thisMonth.Year, thisMonth.Month); nextMonth = m_calendar.getNextMonth(thisMonth.Year, thisMonth.Month); } } if (state == 0) { dayButtons = m_dayButtons; } else if (state == 1) { dayButtons = m_dayButtons_am; } int dheight = dayButtonHeight / 6; HashMap <int, CDay> days = thisMonth.Days; CDay firstDay = days.get(1); int startDayOfWeek = (int)new DateTime(firstDay.Year, firstDay.Month, firstDay.Day).DayOfWeek; int buttonSize = dayButtons.size(); for (int i = 0; i < buttonSize; i++) { if (i == 35) { dheight = height - top; } DayButton dayButton = dayButtons.get(i); int vOffSet = 0; if (state == 1) { if (m_am_Tick > 0) { dayButton.Visible = true; if (m_am_Direction == 1) { vOffSet = toY + dayButtonHeight; } else if (m_am_Direction == 2) { vOffSet = toY - dayButtonHeight; } } else { dayButton.Visible = false; continue; } } else { vOffSet = toY; } if ((i + 1) % 7 == 0) { FCPoint dp = new FCPoint(left, top + vOffSet); FCSize ds = new FCSize(width - left, dheight); dayButton.Bounds = new FCRect(dp.x, dp.y, dp.x + ds.cx, dp.y + ds.cy); left = 0; if (i != 0 && i != size - 1) { top += dheight; } } else { FCPoint dp = new FCPoint(left, top + vOffSet); FCSize ds = new FCSize(width / 7 + ((i + 1) % 7) % 2, dheight); dayButton.Bounds = new FCRect(dp.x, dp.y, dp.x + ds.cx, dp.y + ds.cy); left += ds.cx; } CDay cDay = null; dayButton.InThisMonth = false; if (i >= startDayOfWeek && i <= startDayOfWeek + days.size() - 1) { cDay = days.get(i - startDayOfWeek + 1); dayButton.InThisMonth = true; } else if (i < startDayOfWeek) { cDay = lastMonth.Days.get(lastMonth.Days.size() - startDayOfWeek + i + 1); } else if (i > startDayOfWeek + days.size() - 1) { cDay = nextMonth.Days.get(i - startDayOfWeek - days.size() + 1); } int day = cDay.Day; dayButton.Day = cDay; if (state == 0 && dayButton.Day != null && dayButton.Day == m_calendar.SelectedDay) { dayButton.Selected = true; } else { dayButton.Selected = false; } } } }
/// <summary> /// 创建按钮 /// </summary> public WindowButton() { TextColor = FCDraw.FCCOLORS_LINECOLOR; Size = new FCSize(150, 150); }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintForeground(FCPaint paint, FCRect clipRect) { String text = Text; //绘制文字 if (text != null && text.Length > 0) { int width = Width, height = Height; if (width > 0 && height > 0) { FCFont font = Font; FCSize tSize = paint.textSize(text, font); FCPoint tPoint = new FCPoint((width - tSize.cx) / 2, (height - tSize.cy) / 2); FCPadding padding = Padding; switch (m_textAlign) { case FCContentAlignment.BottomCenter: tPoint.y = height - tSize.cy; break; case FCContentAlignment.BottomLeft: tPoint.x = padding.left; tPoint.y = height - tSize.cy - padding.bottom; break; case FCContentAlignment.BottomRight: tPoint.x = width - tSize.cx - padding.right; tPoint.y = height - tSize.cy - padding.bottom; break; case FCContentAlignment.MiddleLeft: tPoint.x = padding.left; break; case FCContentAlignment.MiddleRight: tPoint.x = width - tSize.cx - padding.right; break; case FCContentAlignment.TopCenter: tPoint.y = padding.top; break; case FCContentAlignment.TopLeft: tPoint.x = padding.left; tPoint.y = padding.top; break; case FCContentAlignment.TopRight: tPoint.x = width - tSize.cx - padding.right; tPoint.y = padding.top; break; } FCRect tRect = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy); long textColor = getPaintingTextColor(); if (AutoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom)) { if (tRect.right > clipRect.right) { tRect.right = clipRect.right; } if (tRect.bottom > clipRect.bottom) { tRect.bottom = clipRect.bottom; } paint.drawTextAutoEllipsis(text, textColor, font, tRect); } else { paint.drawText(text, textColor, font, tRect); } } } }
/// <summary> /// 消息处理 /// </summary> /// <param name="m">消息</param> /// <returns>是否处理</returns> public virtual int onMessage(ref Message m) { if (m_native != null) { if (m.Msg == WM_IME_SETCONTEXT && m.WParam.ToInt32() == 1) { ImmAssociateContext(m_hWnd, m_hImc); } if (m.Msg == m_pInvokeMsgID) { onInvoke(m.WParam.ToInt32()); } switch (m.Msg) { case WM_CHAR: { if (m_allowOperate) { KeyEventArgs e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | Control.ModifierKeys); char key = (char)e.KeyData; if (m_native.onChar(key)) { return(1); } } break; } case WM_KEYDOWN: case WM_SYSKEYDOWN: { if (m_allowOperate) { KeyEventArgs e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | Control.ModifierKeys); char key = (char)e.KeyData; bool handle = m_native.onPreviewKeyEvent(FCEventID.KEYDOWN, key); if (handle) { return(1); } else { m_native.onKeyDown(key); } } break; } case WM_KEYUP: case WM_SYSKEYUP: { if (m_allowOperate) { KeyEventArgs e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | Control.ModifierKeys); char key = (char)e.KeyData; m_native.onKeyUp(key); } break; } case WM_ERASEBKGND: return(1); case WM_IME_CHAR: { if (m_allowOperate) { if (m.WParam.ToInt32() == PM_REMOVE) { FCView control = m_native.FocusedControl; if (control != null) { StringBuilder str = new StringBuilder(); int size = ImmGetCompositionString(m_hImc, GCS_COMPSTR, null, 0); size += sizeof(Char); ImmGetCompositionString(m_hImc, GCS_RESULTSTR, str, size); } } } break; } case WM_LBUTTONDBLCLK: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 2; m_native.onMouseDown(newTouchInfo); m_native.onDoubleClick(newTouchInfo); } break; } case WM_LBUTTONDOWN: { if (m_allowOperate) { activeMirror(); FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseDown(newTouchInfo); } break; } case WM_LBUTTONUP: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseUp(newTouchInfo); } break; } case WM_MOUSEMOVE: { if (m_allowOperate) { if ((int)m.WParam == 1) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseMove(newTouchInfo); } else if ((int)m.WParam == 2) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseMove(newTouchInfo); } else { FCTouchInfo newTouchInfo = new FCTouchInfo(); m_native.onMouseMove(newTouchInfo); } } break; } case WM_MOUSEWHEEL: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_delta = (int)m.WParam; m_native.onMouseWheel(newTouchInfo); } break; } case WM_PAINT: { FCSize displaySize = m_native.DisplaySize; FCRect paintRect = new FCRect(0, 0, displaySize.cx, displaySize.cy); onPaint(paintRect); break; } case WM_RBUTTONDBLCLK: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 2; m_native.onMouseDown(newTouchInfo); m_native.onDoubleClick(newTouchInfo); } break; } case WM_RBUTTONDOWN: { if (m_allowOperate) { activeMirror(); FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseDown(newTouchInfo); } break; } case WM_RBUTTONUP: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseUp(newTouchInfo); } break; } case WM_TIMER: { if (m.HWnd == m_hWnd) { int timerID = (int)m.WParam; m_native.onTimer(timerID); } break; } } } return(0); }
/// <summary> /// 创建按钮 /// </summary> public FCButton() { FCSize size = new FCSize(60, 20); Size = size; }
/// <summary> /// 重置日期图层 /// </summary> /// <param name="state">状态</param> public virtual void onResetDiv(int state) { if (m_calendar != null) { int thisStartYear = m_startYear; int lastStartYear = m_startYear - 12; int nextStartYear = m_startYear + 12; int left = 0; int headHeight = m_calendar.HeadDiv.Height; int top = headHeight; int width = m_calendar.Width; int height = m_calendar.Height; height -= m_calendar.TimeDiv.Height; int yearButtonHeight = height - top; if (yearButtonHeight < 1) { yearButtonHeight = 1; } int toY = 0; ArrayList <YearButton> yearButtons = new ArrayList <YearButton>(); if (m_am_Direction == 1) { toY = yearButtonHeight * m_am_Tick / m_am_TotalTick; if (state == 1) { thisStartYear = nextStartYear; lastStartYear = thisStartYear - 12; nextStartYear = thisStartYear + 12; } } else if (m_am_Direction == 2) { toY = -yearButtonHeight * m_am_Tick / m_am_TotalTick; if (state == 1) { thisStartYear = lastStartYear; lastStartYear = thisStartYear - 12; nextStartYear = thisStartYear + 12; } } if (state == 0) { yearButtons = m_yearButtons; } else if (state == 1) { yearButtons = m_yearButtons_am; } int dheight = yearButtonHeight / 3; int buttonSize = yearButtons.size(); for (int i = 0; i < buttonSize; i++) { if (i == 8) { dheight = height - top; } YearButton yearButton = yearButtons.get(i); yearButton.Year = thisStartYear + i; int vOffSet = 0; if (state == 1) { if (m_am_Tick > 0) { yearButton.Visible = true; if (m_am_Direction == 1) { vOffSet = toY - yearButtonHeight; } else if (m_am_Direction == 2) { vOffSet = toY + yearButtonHeight; } } else { yearButton.Visible = false; continue; } } else { vOffSet = toY; } if ((i + 1) % 4 == 0) { FCPoint dp = new FCPoint(left, top + vOffSet); FCSize ds = new FCSize(width - left, dheight); yearButton.Bounds = new FCRect(dp.x, dp.y, dp.x + ds.cx, dp.y + ds.cy); left = 0; if (i != 0 && i != buttonSize - 1) { top += dheight; } } else { FCPoint dp = new FCPoint(left, top + vOffSet); FCSize ds = new FCSize(width / 4 + ((i + 1) % 4) % 2, dheight); yearButton.Bounds = new FCRect(dp.x, dp.y, dp.x + ds.cx, dp.y + ds.cy); left += ds.cx; } } } }
/// <summary> /// 重绘方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="rect">矩形</param> /// <param name="clipRect">裁剪矩形</param> /// <param name="isAlternate">是否交替行</param> public override void onPaint(FCPaint paint, FCRect rect, FCRect clipRect, bool isAlternate) { int clipW = clipRect.right - clipRect.left; int clipH = clipRect.bottom - clipRect.top; FCGrid grid = Grid; FCGridRow row = Row; if (clipW > 0 && clipH > 0 && grid != null && Column != null && row != null && TargetColumn != null) { int width = rect.right - rect.left; int height = rect.bottom - rect.top; int scrollH = 0; FCHScrollBar hscrollBar = grid.HScrollBar; if (hscrollBar != null && hscrollBar.Visible) { scrollH = hscrollBar.Pos; } FCFont font = null; long backColor = FCColor.None; long textColor = FCColor.None; bool autoEllipsis = m_tree.AutoEllipsis; FCGridCellStyle style = Style; if (style != null) { if (style.AutoEllipsis) { autoEllipsis = style.AutoEllipsis; } backColor = style.BackColor; if (style.Font != null) { font = style.Font; } textColor = style.TextColor; } FCGridRowStyle rowStyle = grid.RowStyle; if (isAlternate) { FCGridRowStyle alternateRowStyle = grid.AlternateRowStyle; if (alternateRowStyle != null) { rowStyle = alternateRowStyle; } } if (rowStyle != null) { bool selected = false; ArrayList <FCGridRow> selectedRows = grid.SelectedRows; int selectedRowsSize = selectedRows.size(); for (int i = 0; i < selectedRowsSize; i++) { if (selectedRows[i] == row) { selected = true; break; } } if (backColor == FCColor.None) { //选中 if (selected) { backColor = rowStyle.SelectedBackColor; } //悬停 else if (Row == Grid.HoveredRow) { backColor = rowStyle.HoveredBackColor; } //普通 else { backColor = rowStyle.BackColor; } } if (font == null) { font = rowStyle.Font; } if (textColor == FCColor.None) { //选中 if (selected) { textColor = rowStyle.SelectedTextColor; } //悬停 else if (Row == Grid.HoveredRow) { textColor = rowStyle.HoveredTextColor; } //普通 else { textColor = rowStyle.TextColor; } } } //绘制背景 paint.fillRect(backColor, rect); FCRect headerRect = TargetColumn.Bounds; headerRect.left += Grid.HorizontalOffset - scrollH; headerRect.top += Grid.VerticalOffset - scrollH; int left = headerRect.left; //绘制复选框 if (m_tree.CheckBoxes) { int cw = m_tree.CheckBoxSize.cx; int ch = m_tree.CheckBoxSize.cy; FCRect checkBoxRect = new FCRect(); checkBoxRect.left = left; checkBoxRect.top = rect.top + (height - ch) / 2; checkBoxRect.right = checkBoxRect.left + cw; checkBoxRect.bottom = checkBoxRect.top + ch; onPaintCheckBox(paint, checkBoxRect); left += cw + 10; } //绘制折叠展开的标志 int nw = m_tree.NodeSize.cx; int nh = m_tree.NodeSize.cy; if (m_nodes.size() > 0) { FCRect nodeRect = new FCRect(); nodeRect.left = left; nodeRect.top = rect.top + (height - nh) / 2; nodeRect.right = nodeRect.left + nw; nodeRect.bottom = nodeRect.top + nh; onPaintNode(paint, nodeRect); } left += nw + 10; m_indent = left; String text = getPaintText(); //绘制文字 if (text != null) { FCSize tSize = paint.textSize(text, font); FCRect tRect = new FCRect(); tRect.left = left; tRect.top = rect.top + (row.Height - tSize.cy) / 2; tRect.right = tRect.left + tSize.cx; tRect.bottom = tRect.top + tSize.cy; if (autoEllipsis && (tRect.right < clipRect.right || tRect.bottom < clipRect.bottom)) { if (tRect.right < clipRect.right) { tRect.right = clipRect.right; } if (tRect.bottom < clipRect.bottom) { tRect.bottom = clipRect.bottom; } paint.drawTextAutoEllipsis(text, textColor, font, tRect); } else { paint.drawText(text, textColor, font, tRect); } } } onPaintControl(paint, rect, clipRect); }
/// <summary> /// 秒表方法 /// </summary> /// <param name="timerID">秒表ID</param> public override void onTimer(int timerID) { base.onTimer(timerID); if (m_timerID == timerID) { FCNative native = Native; FCHost host = native.Host; FCSize nativeSize = native.DisplaySize; int x = Left, y = Top, width = Width, height = Height; if (m_animateType == 0) { int xSub = nativeSize.cx / 4; int ySub = nativeSize.cy / 4; int mx = (nativeSize.cx - width) / 2; int my = (nativeSize.cy - height) / 2; float opacity = Opacity; opacity += 0.1F; if (opacity > 1) { opacity = 1; } Opacity = opacity; bool stop = false; switch (m_animateDirection) { //从左向右 case 0: if (x + xSub >= mx) { x = mx; stop = true; } else { x += xSub; } break; //从右向左 case 1: if (x - xSub <= mx) { x = mx; stop = true; } else { x -= xSub; } break; //从上往下 case 2: if (y + ySub >= my) { y = my; stop = true; } else { y += ySub; } break; //从下往上 case 3: if (y - ySub <= my) { y = my; stop = true; } else { y -= ySub; } break; } if (stop) { Opacity = 1; m_animateMoving = false; stopTimer(m_timerID); host.AllowOperate = true; } } else { int xSub = nativeSize.cx / 4; int ySub = nativeSize.cy / 4; float opacity = Opacity; opacity -= 0.1F; if (opacity < 0) { opacity = 0; } Opacity = opacity; bool stop = false; switch (m_animateDirection) { //从右向左 case 0: if (x - xSub <= -width) { x = 0; stop = true; } else { x -= xSub; } break; //从左向右 case 1: if (x + xSub >= nativeSize.cx) { x = 0; stop = true; } else { x += xSub; } break; //从下往上 case 2: if (y - ySub <= -height) { y = 0; stop = true; } else { y -= ySub; } break; //从上往下 case 3: if (y + ySub >= nativeSize.cy) { y = 0; stop = true; } else { y += ySub; } break; } if (stop) { Opacity = 0; m_animateMoving = false; stopTimer(m_timerID); host.AllowOperate = true; hide(); } } FCPoint location = new FCPoint(x, y); Location = location; native.invalidate(); } }
/// <summary> /// 大小转换为字符 /// </summary> /// <param name="size">大小</param> /// <returns>字符</returns> public static String convertSizeToStr(FCSize size) { return(String.Format("{0},{1}", size.cx, size.cy)); }