/* ----------------------------------------------------------------- */
        /// SetPowerSetting
        /* ----------------------------------------------------------------- */
        private void SetPowerSetting(XmlNode root, XmlDocument doc, ScheduleItem src)
        {
            PowerSetting item = src.ACValues;
            XmlElement parent = doc.CreateElement(XML_POWER_SETTING);

            XmlElement monitor = doc.CreateElement(XML_MONITOR_TIMEOUT);
            monitor.InnerText = item.MonitorTimeout.ToString();
            parent.AppendChild(monitor);

            XmlElement disk = doc.CreateElement(XML_DISK_TIMEOUT);
            disk.InnerText = item.DiskTimeout.ToString();
            parent.AppendChild(disk);

            XmlElement standby = doc.CreateElement(XML_STANDBY_TIMEOUT);
            standby.InnerText = item.StandByTimeout.ToString();
            parent.AppendChild(standby);

            XmlElement hibernation = doc.CreateElement(XML_HIBERNATION_TIMEOUT);
            hibernation.InnerText = item.HibernationTimeout.ToString();
            parent.AppendChild(hibernation);

            XmlElement processor = doc.CreateElement(XML_PROCESSOR_POLICY);
            processor.InnerText = ((int)item.ThrottlePolicy).ToString();
            processor.SetAttribute("min", item.MinThrottle.ToString());
            processor.SetAttribute("max", item.MaxThrottle.ToString());
            parent.AppendChild(processor);

            XmlElement dim = doc.CreateElement(XML_DIM_TIMEOUT);
            dim.InnerText = item.DimTimeout.ToString();
            parent.AppendChild(dim);

            XmlElement brightness = doc.CreateElement(XML_BRIGHTNESS);
            brightness.InnerText = item.Brightness.ToString();
            parent.AppendChild(brightness);

            XmlElement dim_brightness = doc.CreateElement(XML_DIM_BRIGHTNESS);
            dim_brightness.InnerText = item.DimBrightness.ToString();
            parent.AppendChild(dim_brightness);

            root.AppendChild(parent);
        }
        /* ----------------------------------------------------------------- */
        /// Load
        /* ----------------------------------------------------------------- */
        public bool Load(string path)
        {
            XmlDocument doc = new XmlDocument();
            try {
                doc.Load(path);
                XmlElement root = doc.DocumentElement;
                if (!root.HasChildNodes) return true;
                for (XmlNode child = root.FirstChild; child != null; child = child.NextSibling) {
                    if (child.Name == XML_DEFAULT_SETTING) this._default = this.GetScheduleItem(child);
                    else if (child.Name == XML_SCHEDULE) this.LoadSchedule(child);
                }
            }
            catch (Exception /* err */) {
                return false;
            }

            return true;
        }
 /* ----------------------------------------------------------------- */
 /// GetScheduleItem
 /* ----------------------------------------------------------------- */
 private ScheduleItem GetScheduleItem(XmlNode root)
 {
     ScheduleItem dest = new ScheduleItem();
     for (XmlNode child = root.FirstChild; child != null; child = child.NextSibling) {
         if (child.Name == XML_FIRST_TIME && child.HasChildNodes) dest.First = DateTime.Parse(child.ChildNodes[0].Value);
         else if (child.Name == XML_LAST_TIME && child.HasChildNodes) dest.Last = DateTime.Parse(child.ChildNodes[0].Value);
         else if (child.Name == XML_PROFILE && child.HasChildNodes) dest.ProfileName = child.ChildNodes[0].Value;
         else if (child.Name == XML_POWER_SETTING && child.HasChildNodes) dest.ACValues = this.GetPowerSetting(child);
     }
     return dest;
 }
Beispiel #4
0
        /* ----------------------------------------------------------------- */
        /// AddSchedule
        /* ----------------------------------------------------------------- */
        private void AddSchedule(string key, ScheduleItem value)
        {
            if (!this._schedule.ContainsKey(key)) {
                if (value.ProfileName == CUBEPOWER_PROFILENAME || this._setting.Scheme.Find(value.ProfileName) == null) {
                    value.ProfileName = CUSTOM_PROFILE;
                }

                ListViewItem item = new ListViewItem();
                item.Text = key;
                item.SubItems.Add(value.ProfileName);
                item.SubItems.Add(Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.MonitorTimeout)));
                item.SubItems.Add(Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.DiskTimeout)));
                item.SubItems.Add(Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.StandByTimeout)));
                item.SubItems.Add(Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.HibernationTimeout)));
                if (Environment.OSVersion.Version.Major > 5) {
                    string description = String.Format("{0}% - {1}%", value.ACValues.MinThrottle, value.ACValues.MaxThrottle);
                    item.SubItems.Add(description);
                }
                else item.SubItems.Add(Appearance.PowerThrottlePolicyString(value.ACValues.ThrottlePolicy));
                item.SubItems.Add(Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.DimTimeout)));
                item.SubItems.Add(value.ACValues.Brightness + "%");
                item.SubItems.Add(value.ACValues.DimBrightness + "%");
                this.ScheduleListView.Items.Add(item);
                this._schedule.Add(key, value);
                this.ValidateSchedule();
            }
        }
Beispiel #5
0
 private void UpdateSchedule(string key, ScheduleItem value, ListViewItem dest)
 {
     if (dest == null) this.AddSchedule(key, value);
     else {
         if (this._schedule.ContainsKey(key)) this._schedule[key] = value;
         else this._schedule.Add(key, value);
         dest.Text = key;
         dest.SubItems[1].Text = value.ProfileName;
         dest.SubItems[2].Text = Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.MonitorTimeout));
         dest.SubItems[3].Text = Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.DiskTimeout));
         dest.SubItems[4].Text = Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.StandByTimeout));
         dest.SubItems[5].Text = Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.HibernationTimeout));
         if (Environment.OSVersion.Version.Major > 5) {
             dest.SubItems[6].Text =String.Format("{0}% - {1}%", value.ACValues.MinThrottle, value.ACValues.MaxThrottle);
         }
         else dest.SubItems[6].Text = Appearance.PowerThrottlePolicyString(value.ACValues.ThrottlePolicy);
         dest.SubItems[7].Text = Appearance.ExpireTypeString(Translator.SecondToExpireType(value.ACValues.DimTimeout));
         dest.SubItems[8].Text = value.ACValues.Brightness + "%";
         dest.SubItems[9].Text = value.ACValues.DimBrightness + "%";
         this.ScheduleListView.Sort();
         this.ValidateSchedule();
     }
 }
Beispiel #6
0
        private void RecommendSchedule()
        {
            this.ScheduleListView.BeginUpdate();
            this.ScheduleListView.Items.Clear();
            this._schedule.Clear();

            string key = null;

            // デフォルトの設定
            ScheduleItem sched = new ScheduleItem();
            sched.First = DateTime.Parse("00:00");
            sched.Last  = DateTime.Parse("23:59");
            sched.ProfileName = "カスタム";
            sched.ACValues.MonitorTimeout = 1200;
            sched.ACValues.DiskTimeout = 0;
            sched.ACValues.StandByTimeout = 0;
            sched.ACValues.HibernationTimeout = 0;
            sched.ACValues.ThrottlePolicy = PowerThrottlePolicy.PO_THROTTLE_ADAPTIVE;
            sched.ACValues.DimTimeout = 0;
            sched.ACValues.Brightness = Math.Min(this._setting.Scheme.Active.Brightness, 100);
            sched.ACValues.DimBrightness = Math.Min(this._setting.Scheme.Active.DimBrightness, 30);
            this.AddSchedule(DEFAULT_SETTING_NAME, sched);

            // お昼の設定
            sched = new ScheduleItem();
            sched.First = DateTime.Parse("12:00");
            sched.Last = DateTime.Parse("13:00");
            sched.ProfileName = "カスタム";
            sched.ACValues.MonitorTimeout = 300;
            sched.ACValues.DiskTimeout = 900;
            sched.ACValues.StandByTimeout = 900;
            sched.ACValues.HibernationTimeout = 0;
            sched.ACValues.ThrottlePolicy = PowerThrottlePolicy.PO_THROTTLE_ADAPTIVE;
            sched.ACValues.DimTimeout = 120;
            sched.ACValues.Brightness = Math.Min(this._setting.Scheme.Active.Brightness, 40);
            sched.ACValues.DimBrightness = Math.Min(this._setting.Scheme.Active.DimBrightness, 30);
            key = sched.First.ToString("HH:mm") + " - " + sched.Last.ToString("HH:mm");
            this.AddSchedule(key, sched);

            // 退社後の設定
            sched = new ScheduleItem();
            sched.First = DateTime.Parse("21:00");
            sched.Last = DateTime.Parse("8:00");
            sched.ProfileName = "カスタム";
            sched.ACValues.MonitorTimeout = 300;
            sched.ACValues.DiskTimeout = 900;
            sched.ACValues.StandByTimeout = 900;
            sched.ACValues.HibernationTimeout = 0;
            sched.ACValues.ThrottlePolicy = PowerThrottlePolicy.PO_THROTTLE_ADAPTIVE;
            sched.ACValues.DimTimeout = 120;
            sched.ACValues.Brightness = Math.Min(this._setting.Scheme.Active.Brightness, 40);
            sched.ACValues.DimBrightness = Math.Min(this._setting.Scheme.Active.DimBrightness, 30);
            key = sched.First.ToString("HH:mm") + " - " + sched.Last.ToString("HH:mm");
            this.AddSchedule(key, sched);

            this._status = CloseStatus.Confirm;

            this.ScheduleListView.EndUpdate();
            this.ValidateSchedule();
        }
Beispiel #7
0
 private ScheduleItem CreateScheduleItem(ScheduleForm dialog)
 {
     ScheduleItem dest = new ScheduleItem();
     dest.First = dialog.First;
     dest.Last = dialog.Last;
     dest.ProfileName = dialog.ProfileName;
     dest.ACValues = dialog.PowerSetting;
     return dest;
 }
Beispiel #8
0
        private bool Update(ScheduleItem item)
        {
            PowerSchemeItem elem = new PowerSchemeItem();
            elem.Name = CUBEPOWER_PROFILENAME;
            elem.Description = CUBEPOWER_DESCRIPTION;
            POWER_POLICY policy = elem.Policy;
            policy.user.VideoTimeoutAc = item.ACValues.MonitorTimeout;
            policy.user.SpindownTimeoutAc = item.ACValues.DiskTimeout;
            policy.user.IdleTimeoutAc = item.ACValues.StandByTimeout;
            policy.mach.DozeS4TimeoutAc = item.ACValues.HibernationTimeout;
            policy.user.ThrottlePolicyAc = (byte)item.ACValues.ThrottlePolicy;
            elem.Policy = policy;
            elem.DimTimeout = item.ACValues.DimTimeout;
            elem.Brightness = item.ACValues.Brightness;
            elem.DimBrightness = item.ACValues.DimBrightness;
            elem.MinThrottle = item.ACValues.MinThrottle;
            elem.MaxThrottle = item.ACValues.MaxThrottle;

            bool status = true;
            if (this._setting.Scheme.Find(CUBEPOWER_PROFILENAME) == null) status &= this._setting.Scheme.Add(elem);
            else status &= this._setting.Scheme.Update(elem);
            status &= this._setting.Scheme.Activate(elem.Name);

            return status;
        }