public TriggerPoint Add(DayOfWeek day, int hour, Color color, string toolTip) { TriggerPoint triggerPoint = new TriggerPoint(day, hour, color, toolTip); this.Add(triggerPoint); return(triggerPoint); }
public TriggerPoint GetNextTriggerPoint(TriggerPoint triggerPoint) { TriggerPoint firstTriggerPoint = null; TriggerPoint nextTriggerPoint = null; int currentIndex = _triggerPoints.IndexOfKey(triggerPoint.SortKey); foreach (int key in _triggerPoints.Keys) { if (null == firstTriggerPoint) { firstTriggerPoint = _triggerPoints[key]; } if (key > triggerPoint.SortKey) { nextTriggerPoint = _triggerPoints[key]; break; } } if (null == nextTriggerPoint) { nextTriggerPoint = firstTriggerPoint; } return(nextTriggerPoint); }
private void OnMouseDoubleClick(object sender, MouseEventArgs e) { MouseEventHandler handler = OnTriggerPointDoubleClick; _selectedTriggerPoint = GetSelectedTriggerPoint(e.Location); if (null != handler && null != _selectedTriggerPoint) { handler(this, e); } }
private void toolTipTimer_Tick(object sender, EventArgs e) { TriggerPoint triggerPoint = GetSelectedTriggerPoint(_lastMouseLocation); if (null != triggerPoint) { string toolTipText = triggerPoint.ToolTip; ShowTooltip(toolTipText, _lastMouseLocation); _toolTipTimer.Stop(); } }
private TriggerPoint GetSelectedTriggerPoint(Point point) { TriggerPoint triggerPoint = null; foreach (KeyValuePair <RectangleF, TriggerPoint> pair in _taskMap) { if (pair.Key.Contains(_lastMouseLocation)) { triggerPoint = pair.Value; } } return(triggerPoint); }
private void PopulateListView() { weekView1.ClearTriggerPoints(); lvTaskList.Items.Clear(); //foreach (int key in _scheduledTasks.SortedTaskList.Keys) foreach (int key in _scheduledTasks.VirtualTaskList.Keys) { //WlbScheduledTask task = _scheduledTasks.SortedTaskList[key]; WlbScheduledTask task = _scheduledTasks.VirtualTaskList[key]; WlbScheduledTask parentTask = _scheduledTasks.TaskList[_scheduledTasks.VirtualTaskList[key].TaskId.ToString()]; DateTime localExecuteTime; WlbScheduledTask.WlbTaskDaysOfWeek localDaysOfWeek; WlbScheduledTask.GetLocalTaskTimes((task.DaysOfWeek), task.ExecuteTime, out localDaysOfWeek, out localExecuteTime); ListViewItem item = new ListViewItem(); item.Text = key.ToString(); item.SubItems.Add(GetTaskOptMode(task) == WlbPoolPerformanceMode.MaximizeDensity ? Messages.WLB_OPT_MODE_MAXIMIZEDENSITY : Messages.WLB_OPT_MODE_MAXIMIZEPERFORMANCE); item.SubItems.Add(GetTaskDayOfWeek(localDaysOfWeek, parentTask.DaysOfWeek)); item.SubItems.Add(GetTaskExecuteTime(localExecuteTime)); item.SubItems.Add(task.Enabled ? Messages.YES : Messages.NO); item.Tag = task; lvTaskList.Items.Add(item); //} //foreach (WlbScheduledTask task in _scheduledTasks.VirtualTaskList.Values) //{ if (task.Enabled) { //DateTime localExecuteTime; //WlbScheduledTask.WlbTaskDaysOfWeek localDaysOfWeek; WlbScheduledTask.GetLocalTaskTimes((task.DaysOfWeek), task.ExecuteTime, out localDaysOfWeek, out localExecuteTime); string toolTipText = string.Format("Change to {0} mode at {1} on {2}", WlbScheduledTask.GetTaskOptMode(task), WlbScheduledTask.GetTaskExecuteTime(localExecuteTime), WlbScheduledTask.DaysOfWeekL10N(localDaysOfWeek)); TriggerPoint triggerPoint = new TriggerPoint(); triggerPoint.Day = WlbScheduledTask.ConvertFromWlbTaskDayOfWeek(localDaysOfWeek); triggerPoint.Hour = localExecuteTime.Hour; triggerPoint.Color = GetTaskOptMode(task) == WlbPoolPerformanceMode.MaximizePerformance ? Color.Blue : Color.Green; triggerPoint.ToolTip = toolTipText; triggerPoint.Tag = task.TaskId; weekView1.AddTriggerPoint(triggerPoint); } } lvTaskList.Sort(); EnableButtons(); }
private void DrawTriggerPoints(Graphics graphics) { try { _taskMap.Clear(); foreach (TriggerPoint triggerPoint in _triggerPoints.List.Values) { DrawTriggerPoint(graphics, triggerPoint); } // unless the first trigger starts at Sunday 12a, we need to fill in the beginning of the bar // with the "end" of the last trigger of the week, so insert a fake trigger at Sunday 12a. // Also, if there is only one trigger defined, we need to add the same fake Sunday trigger if (_triggerPoints.List.Count > 0) { TriggerPoint firstTriggerPoint = _triggerPoints.List.Values[0]; TriggerPoint lastTriggerPoint = _triggerPoints.List.Values[_triggerPoints.List.Values.Count - 1]; if (firstTriggerPoint.Hour > 0 || _triggerPoints.List.Keys.Count == 1) { TriggerPoint fillerTriggerPoint = new TriggerPoint(); fillerTriggerPoint.Day = DayOfWeek.Sunday; fillerTriggerPoint.Hour = 0; fillerTriggerPoint.Color = lastTriggerPoint.Color; fillerTriggerPoint.ToolTip = lastTriggerPoint.ToolTip; fillerTriggerPoint.Tag = lastTriggerPoint.Tag; fillerTriggerPoint.IsSelected = lastTriggerPoint.IsSelected; DrawTriggerPoint(graphics, fillerTriggerPoint); } } } catch (Exception) { } }
public TriggerPoint GetNextTriggerPoint(TriggerPoint triggerPoint) { TriggerPoint firstTriggerPoint = null; TriggerPoint nextTriggerPoint = null; int currentIndex = _triggerPoints.IndexOfKey(triggerPoint.SortKey); foreach (int key in _triggerPoints.Keys) { if (null == firstTriggerPoint) { firstTriggerPoint = _triggerPoints[key]; } if (key > triggerPoint.SortKey) { nextTriggerPoint = _triggerPoints[key]; break; } } if (null == nextTriggerPoint) { nextTriggerPoint = firstTriggerPoint; } return nextTriggerPoint; }
public TriggerPoint Add(DayOfWeek day, int hour, Color color, string toolTip) { TriggerPoint triggerPoint = new TriggerPoint(day, hour, color, toolTip); this.Add(triggerPoint); return triggerPoint; }
public TriggerPoint Add(TriggerPoint triggerPoint) { _triggerPoints.Add(triggerPoint.SortKey, triggerPoint); return triggerPoint; }
private void DrawTriggerPoint(Graphics graphics, TriggerPoint triggerPoint) { int lineX = (int)this.Margin.Left + (int)triggerPoint.Day * (int)_dayWidth + (int)triggerPoint.Hour * (int)_hourWidth; int lineY1 = (int)_barLineY - (_barHeight / 2) + _barPadding.Top; int lineY2 = (int)_barLineY + (_barHeight / 2) - _barPadding.Bottom; TriggerPoint nextTriggerPoint = _triggerPoints.GetNextTriggerPoint(triggerPoint); bool isLastTriggerPoint = (nextTriggerPoint.SortKey <= triggerPoint.SortKey); //If this is the last trigger point, we need to draw up to the end of the control int barWidth; if (isLastTriggerPoint) { barWidth = (int)this.Margin.Left + (int)_gridWidth - lineX; } else //otherwise, draw up to the beginning of the next trigger { barWidth = (this.Margin.Left + (int)nextTriggerPoint.Day * (int)_dayWidth + nextTriggerPoint.Hour * (int)_hourWidth) - lineX; } //Draw the main bar with Gradient RectangleF triggerRectangle = new RectangleF(lineX, lineY1, barWidth, (lineY2 - lineY1)); graphics.Clip = new Region(triggerRectangle); graphics.SmoothingMode = SmoothingMode.AntiAlias; Color barColor; if (_highlightType == WeekView.HighlightType.Bar && triggerPoint.IsSelected) { barColor = _hightlightColor; } else { barColor = triggerPoint.Color; } using (GraphicsPath outerPath = GetRoundedPath(triggerRectangle, 2)) { using (LinearGradientBrush brush = new LinearGradientBrush(triggerRectangle, barColor, ControlPaint.LightLight(barColor), LinearGradientMode.Vertical)) { graphics.FillPath(brush, outerPath); } } //Draw the second gradient to make it shiny RectangleF shinyRectangle = new RectangleF(triggerRectangle.X + _barPadding.Left, triggerRectangle.Y + _barPadding.Top, triggerRectangle.Width - (_barPadding.Left + _barPadding.Right), triggerRectangle.Height * 0.49f); using (GraphicsPath innerPath = GetRoundedPath(shinyRectangle, 2)) { int alphaTop = 120, alphaBottom = 30; Color topColor = Color.FromArgb(alphaTop, Color.White); Color bottomColor = Color.FromArgb(alphaBottom, Color.White); shinyRectangle = new RectangleF(shinyRectangle.X, shinyRectangle.Y, shinyRectangle.Width, shinyRectangle.Height + 1); // + _barPadding.Top + _barPadding.Bottom + 1); using (LinearGradientBrush lighterBrush = new LinearGradientBrush(shinyRectangle, topColor, bottomColor, LinearGradientMode.Vertical)) { graphics.FillPath(lighterBrush, innerPath); } } //Draw hightlight for selected TriggerPoint if (_highlightType == HighlightType.Box && triggerPoint.IsSelected) { Rectangle highlightRectangle = new Rectangle(lineX, lineY1, barWidth - 1, (lineY2 - lineY1) - 1); using (Pen highlightPen = new Pen(_hightlightColor)) { graphics.DrawRectangle(highlightPen, highlightRectangle); } } if (!_taskMap.ContainsKey(triggerRectangle)) { _taskMap.Add(triggerRectangle, triggerPoint); } }
public TriggerPoint Add(TriggerPoint triggerPoint) { _triggerPoints.Add(triggerPoint.SortKey, triggerPoint); return(triggerPoint); }
public TriggerPoint AddTriggerPoint(TriggerPoint triggerPoint) { _triggerPoints.Add(triggerPoint); this.Refresh(); return _triggerPoints.List[triggerPoint.SortKey]; }
public TriggerPoint AddTriggerPoint(TriggerPoint triggerPoint) { _triggerPoints.Add(triggerPoint); this.Refresh(); return(_triggerPoints.List[triggerPoint.SortKey]); }