예제 #1
0
        public TriggerPoint Add(DayOfWeek day, int hour, Color color, string toolTip)
        {
            TriggerPoint triggerPoint = new TriggerPoint(day, hour, color, toolTip);

            this.Add(triggerPoint);
            return(triggerPoint);
        }
예제 #2
0
        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);
        }
예제 #3
0
        private void OnMouseDoubleClick(object sender, MouseEventArgs e)
        {
            MouseEventHandler handler = OnTriggerPointDoubleClick;

            _selectedTriggerPoint = GetSelectedTriggerPoint(e.Location);
            if (null != handler && null != _selectedTriggerPoint)
            {
                handler(this, e);
            }
        }
예제 #4
0
        private void toolTipTimer_Tick(object sender, EventArgs e)
        {
            TriggerPoint triggerPoint = GetSelectedTriggerPoint(_lastMouseLocation);

            if (null != triggerPoint)
            {
                string toolTipText = triggerPoint.ToolTip;
                ShowTooltip(toolTipText, _lastMouseLocation);
                _toolTipTimer.Stop();
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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();
        }
예제 #7
0
        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)
            {
            }
        }
예제 #8
0
파일: WeekView.cs 프로젝트: huizh/xenadmin
        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;
        }
예제 #9
0
파일: WeekView.cs 프로젝트: huizh/xenadmin
 public TriggerPoint Add(DayOfWeek day, int hour, Color color, string toolTip)
 {
     TriggerPoint triggerPoint = new TriggerPoint(day, hour, color, toolTip);
     this.Add(triggerPoint);
     return triggerPoint;
 }
예제 #10
0
파일: WeekView.cs 프로젝트: huizh/xenadmin
 public TriggerPoint Add(TriggerPoint triggerPoint)
 {
     _triggerPoints.Add(triggerPoint.SortKey, triggerPoint);
     return triggerPoint;
 }
예제 #11
0
파일: WeekView.cs 프로젝트: huizh/xenadmin
        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);
            }
        }
예제 #12
0
파일: WeekView.cs 프로젝트: huizh/xenadmin
        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)
            {
            }

        }
예제 #13
0
파일: WeekView.cs 프로젝트: huizh/xenadmin
 private void OnMouseDoubleClick(object sender, MouseEventArgs e)
 {
     MouseEventHandler handler = OnTriggerPointDoubleClick;
     _selectedTriggerPoint = GetSelectedTriggerPoint(e.Location);
     if (null != handler && null != _selectedTriggerPoint)
     {
         handler(this, e);
     }
 }
예제 #14
0
 public TriggerPoint Add(TriggerPoint triggerPoint)
 {
     _triggerPoints.Add(triggerPoint.SortKey, triggerPoint);
     return(triggerPoint);
 }
예제 #15
0
        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);
            }
        }
예제 #16
0
파일: WeekView.cs 프로젝트: huizh/xenadmin
 public TriggerPoint AddTriggerPoint(TriggerPoint triggerPoint)
 {
     _triggerPoints.Add(triggerPoint);
     this.Refresh();
     return _triggerPoints.List[triggerPoint.SortKey];
 }
예제 #17
0
        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();
        }
예제 #18
0
 public TriggerPoint AddTriggerPoint(TriggerPoint triggerPoint)
 {
     _triggerPoints.Add(triggerPoint);
     this.Refresh();
     return(_triggerPoints.List[triggerPoint.SortKey]);
 }