当前位置: 首页>>代码示例>>C#>>正文


C# Setting.Equals方法代码示例

本文整理汇总了C#中Setting.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Setting.Equals方法的具体用法?C# Setting.Equals怎么用?C# Setting.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Setting的用法示例。


在下文中一共展示了Setting.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckLogError

        public static void CheckLogError()
        {
            string fn = SleepPreventer.Properties.Resources.ConfigFileName;
            if (File.Exists(fn))
            {
                using(var fs = File.OpenText(fn))
                {
                    string line = fs.ReadLine();
                    if (line == null)
                    {
                        // The file is empty
                        return;
                    }
                    string[] s_ary = line.Split(' ');
                    if (s_ary.Length == 2)
                    {
                        Setting back_st;
                        back_st.ACIndex = uint.Parse(s_ary[0]);
                        back_st.DCIndex = uint.Parse(s_ary[1]);

                        // Get setting name
                        Dictionary<uint, string> index_name = new Dictionary<uint, string>();
                        index_name[0] = "不采取任何操作";
                        index_name[1] = "睡眠";
                        index_name[2] = "休眠";
                        index_name[3] = "关机";

                        // Get current setting
                        Guid guid;
                        Setting cur_setting = new Setting();
                        if (!GetActiveSchemeSetting(out guid, ref cur_setting))
                        {
                            return;
                        }
                        if (cur_setting.Equals(back_st))
                        {
                            return;
                        }

                        string ac_setting, dc_setting;
                        if (index_name.TryGetValue(back_st.ACIndex, out ac_setting)
                                && index_name.TryGetValue(back_st.DCIndex, out dc_setting))
                        {
                            if (MessageBox.Show("是否将合上盖子的操作恢复为: "
                                            + "\n\t"
                                            + "使用电池时:"+ ac_setting
                                            + ","
                                            + "使用外置电源时:" + dc_setting
                                            + "\n"
                                            + "当前的设置为: "
                                            + "\n\t"
                                            + "使用电池时:"+ index_name[cur_setting.ACIndex]
                                            + ","
                                            + "使用外置电源时:" + index_name[cur_setting.DCIndex],
                                        "本程序上次意外退出",
                                        MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                WriteActiveSchemeSetting(back_st);
                            }
                        }
                    }
                }
                // Clean file
                using (StreamWriter sw = File.CreateText(
                        SleepPreventer.Properties.Resources.ConfigFileName))
                {
                    ;
                }
            }
        }
开发者ID:mrrichardchou,项目名称:SleepPreventer,代码行数:70,代码来源:OptionSetter.cs

示例2: DoWatchPowerSetting

        private bool DoWatchPowerSetting()
        {
            Guid cur_scheme_id;
            Setting setting = new Setting();
            if (!GetActiveSchemeSetting(out cur_scheme_id, ref setting))
            {
                return false;
            }

            // Check power setting value is changed
            if (setting.Equals(target_setting_))
            {
                // Why the system send power setting changed message to me?
                return true;
            }

            if (scheme_guid_ != cur_scheme_id)
            {
                // The backup scheme is not active scheme now, write the backup setting back!
                WriteSchemeSetting(scheme_guid_, lid_close_setting_back_);
            }
            // Update the backup setting to current setting
            GetActiveSchemeSetting(out scheme_guid_, ref lid_close_setting_back_);
            // Write target Setting
            WriteSchemeSetting(cur_scheme_id, target_setting_);

            return true;
        }
开发者ID:mrrichardchou,项目名称:SleepPreventer,代码行数:28,代码来源:OptionSetter.cs


注:本文中的Setting.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。