Ejemplo n.º 1
0
        public Deposit
        (
            int percent,
            decimal value,
            AccrualsInterval interv,
            int periods
        )
        {
            Percent     = percent;
            Value       = value;
            Interval    = interv;
            StartDate   = DateTime.Now;
            LastAccrual = StartDate;
            switch (interv)
            {
            case AccrualsInterval.minute:
                FinishDate = StartDate.AddMinutes(periods);
                break;

            case AccrualsInterval.month:
                FinishDate = StartDate.AddMonths(periods);
                break;

            case AccrualsInterval.year:
                FinishDate = StartDate.AddYears(periods);
                break;
            }
        }
Ejemplo n.º 2
0
        internal void renderHeaderCols(HtmlTextWriter output)
        {
            for (int i = 0; i < cellCount; i++)
            {
                DateTime from = StartDate.AddMinutes(CellDuration * i);
                //DateTime to = from.AddMinutes(CellDuration);

                string text;

                if (CellDuration < 60) // smaller than hour, use minutes
                {
                    text = String.Format("<span style='color:gray'>{0:00}</span>", from.Minute);
                }
                else if (CellDuration < 1440)// smaller than day, use hours
                {
                    text = TimeFormatter.GetHour(from, TimeFormat, "{0} {1}");
                }
                else // use days
                {
                    text = from.Day.ToString();
                }

                if (i == 0)
                {
                    output.AddAttribute("colspan", "2");
                }
                if (i == cellCount - 1)
                {
                    output.AddStyleAttribute("border-right", "1px solid " + ColorTranslator.ToHtml(BorderColor));
                }
                output.AddStyleAttribute("border-top", "1px solid " + ColorTranslator.ToHtml(BorderColor));
                output.AddStyleAttribute("border-bottom", "1px solid " + ColorTranslator.ToHtml(BorderColor));
                output.AddStyleAttribute("width", (CellWidth) + "px");
                output.AddStyleAttribute("height", (HeaderHeight - 1) + "px");
                output.AddStyleAttribute("overflow", "hidden");
                output.AddStyleAttribute("text-align", "center");
                output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(HourNameBackColor));
                output.AddStyleAttribute("font-family", HourFontFamily);
                output.AddStyleAttribute("font-size", HourFontSize);
                output.AddAttribute("unselectable", "on");
                output.AddStyleAttribute("-khtml-user-select", "none");
                output.AddStyleAttribute("-moz-user-select", "none");
                output.AddStyleAttribute("cursor", "default");
                output.RenderBeginTag("td");

                output.Write("<div unselectable='on' style='height:" + (HeaderHeight - 1) + "px;border-right: 1px solid " + ColorTranslator.ToHtml(HourNameBorderColor) + "; width:" + (CellWidth - 1) + "px;overflow:hidden;'>");
                output.Write(text);
                output.Write("</div>");
                output.RenderEndTag();
            }
        }
Ejemplo n.º 3
0
        private void panelEx_time_MouseMove(object sender, MouseEventArgs e)
        {
            var totalH = (EndDate - StartDate).TotalMinutes;
            var wid    = panelEx_time.Width;
            var div    = wid / totalH;

            var date = StartDate.AddMinutes((int)(e.X / div));


            var newToolTip = date.ToString(CultureInfo.InvariantCulture);

            if (_loginsList1.Exists(a => a.Start < date && a.End > date))
            {
                var start = _loginsList1.Find(a => a.Start <date && a.End> date).Start;
                var end   = _loginsList1.Find(a => a.Start <date && a.End> date).End;
                newToolTip += "\nDN [ " + start + " - " + end + " ]";
            }

            if (_loginsList2.Exists(a => a.Start < date && a.End > date))
            {
                var start = _loginsList2.Find(a => a.Start <date && a.End> date).Start;
                var end   = _loginsList2.Find(a => a.Start <date && a.End> date).End;
                newToolTip += "\nTN [ " + start + " - " + end + " ]";
            }
            if (LineCount == 3)
            {
                if (_loginsList3.Exists(a => a.Start < date && a.End > date))
                {
                    var start = _loginsList3.Find(a => a.Start <date && a.End> date).Start;
                    var end   = _loginsList3.Find(a => a.Start <date && a.End> date).End;
                    newToolTip += "\nDE [ " + start + " - " + end + " ]";
                }
            }

            if (newToolTip != _lastToolTip)
            {
                _lastToolTip = newToolTip;
                toolTip1.SetToolTip(panelEx_time, _lastToolTip);
            }
        }
Ejemplo n.º 4
0
        private static DateTime SetDateWithChecks(DateTime obj, int year, int month, int day, int?hour, int?minute, int?second, int?millisecond)
        {
            DateTime StartDate;

            if (year == 0)
            {
                StartDate = new DateTime(obj.Year, 1, 1, 0, 0, 0, 0);
            }
            else
            {
                if (DateTime.MaxValue.Year < year)
                {
                    StartDate = new DateTime(DateTime.MinValue.Year, 1, 1, 0, 0, 0, 0);
                }
                else if (DateTime.MinValue.Year > year)
                {
                    StartDate = new DateTime(DateTime.MaxValue.Year, 1, 1, 0, 0, 0, 0);
                }
                else
                {
                    StartDate = new DateTime(year, 1, 1, 0, 0, 0, 0);
                }
            }

            if (month == 0)
            {
                StartDate = StartDate.AddMonths(obj.Month - 1);
            }
            else
            {
                StartDate = StartDate.AddMonths(month - 1);
            }
            if (day == 0)
            {
                StartDate = StartDate.AddDays(obj.Day - 1);
            }
            else
            {
                StartDate = StartDate.AddDays(day - 1);
            }
            if (!hour.HasValue)
            {
                StartDate = StartDate.AddHours(obj.Hour);
            }
            else
            {
                StartDate = StartDate.AddHours(hour.Value);
            }
            if (!minute.HasValue)
            {
                StartDate = StartDate.AddMinutes(obj.Minute);
            }
            else
            {
                StartDate = StartDate.AddMinutes(minute.Value);
            }
            if (!second.HasValue)
            {
                StartDate = StartDate.AddSeconds(obj.Second);
            }
            else
            {
                StartDate = StartDate.AddSeconds(second.Value);
            }
            if (!millisecond.HasValue)
            {
                StartDate = StartDate.AddMilliseconds(obj.Millisecond);
            }
            else
            {
                StartDate = StartDate.AddMilliseconds(millisecond.Value);
            }

            return(StartDate);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 鼠标弹起事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (_IsMouseDown)
            {
                if (_IsAjustSize)
                {
                    _IsAjustSize = false;
                    var w = e.X - _DragStartLocation.X + DateWidth;
                    if (w < MinDateWidth)
                    {
                        DateWidth = MinDateWidth;
                    }
                    else
                    {
                        DateWidth = (w / 48 + (w % 48 == 0 ? 0 : 1)) * 48;
                    }
                    if (Rows != null)
                    {
                        Rows.IsChanged = true;
                    }
                    AdjustScrollbar();
                    Invalidate();
                }
                else if (_IsDragItem)
                {
                    _IsDragItem = false;
                    //TODO:触发Drag事件
                    Invalidate();
                }
                else if (!_DragStartLocation.IsEmpty && e.X != _DragStartLocation.X && e.Y != _DragStartLocation.Y && _DragStartLocation.X > RowHeaderWidth && _DragStartLocation.Y > ColumnHeight)
                {
                    _DragEndLocation = e.Location;
                    var row = GetRow(_DragStartLocation);
                    if (row != null)
                    {
                        var width = Math.Abs(_DragEndLocation.X - _DragStartLocation.X);
                        if (_DragEndLocation.X < RowHeaderWidth)
                        {
                            width -= RowHeaderWidth - _DragEndLocation.X;
                        }
                        else if (_DragEndLocation.X > ((int)(EndDate.Date - StartDate.Date).TotalDays + 1) * DateWidth + RowHeaderWidth - _HScrollBar.Value)
                        {
                            width = ((int)(EndDate.Date - StartDate.Date).TotalDays + 1) * DateWidth + RowHeaderWidth - _HScrollBar.Value - _DragStartLocation.X;
                        }
                        var start = new Point(Math.Min(_DragStartLocation.X, Math.Max(_DragEndLocation.X, RowHeaderWidth)), row.Top + 1);
                        _SelectionRange = new Rectangle(start, new Size(width, row.Bottom - row.Top - 2));

                        Invalidate();
                        var mw = DateWidth / 24f / 60f;
                        var ts = StartDate.AddMinutes((int)((_DragStartLocation.X - RowHeaderWidth + _HScrollBar.Value) / mw));
                        var te = StartDate.AddMinutes((int)((_DragEndLocation.X - RowHeaderWidth + _HScrollBar.Value) / mw));
                        if (te < ts)
                        {
                            var tt = te;
                            te = ts;
                            ts = tt;
                        }
                        _SelectionTimeRange = new TimeRange {
                            StartTime = ts, EndTime = te
                        };
                        RangeSelected?.Invoke(this, new GanttChartRangeSelectedEventArgs(ts, te));
                    }
                }
            }
            _IsMouseDown       = false;
            _DragStartLocation = Point.Empty;
            _DragEndLocation   = Point.Empty;
        }