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


C# Settings.attr方法代码示例

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


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

示例1: Main


//.........这里部分代码省略.........
                        center = false;

                    } else if (a.Equals("edit", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("notepad.exe", file);
                    } else if (a.Equals("email", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("mailto:Kody Brown <[email protected]>");
                    } else if (a.Equals("web", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("http://bricksoft.com");
                    } else if (a.Equals("src", StringComparison.CurrentCultureIgnoreCase) || a.Equals("source", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("http://github.com/kodybrown/" + app);
                    } else if (a.Equals("license", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("http://opensource.org/licenses/MIT");

                    } else {
                        DisplayError(settings, "unknown argument.");
                        return 1;
                    }
                }
            }

            DisplayAppName();

            // If '--config' was specified without any other arguments,
            // it will only output the current values from config.
            if (writeToConfig && !width.HasValue && !height.HasValue && !center.HasValue) {
                DisplayCopyright();
                DisplayConfig(settings);
                return 0;
            }

            // Write config values before they are (possibly) overwritten below.
            if (writeToConfig) {
                if (width.HasValue) {
                    settings.attr<int>("width", width.Value);
                }
                if (height.HasValue) {
                    settings.attr<int>("height", height.Value);
                }
                if (center.HasValue) {
                    settings.attr<bool>("center", center.Value);
                }
                settings.write();
            }

            // If a value was not specified: use the value from config,
            // otherwise use its current value.
            if (!width.HasValue) {
                width = settings.contains("width") ? settings.attr<int>("width") : Console.WindowWidth;
            }
            if (!height.HasValue) {
                height = settings.contains("height") ? settings.attr<int>("height") : Console.WindowHeight;
            }
            // If center was not specified, use the value from config,
            // or default it to defaultCenter.
            if (!center.HasValue) {
                center = settings.contains("center") ? settings.attr<bool>("center") : defaultCenter;
            }

            //
            // Update the console.
            //
            try {
                Console.WindowWidth = Math.Min(widthMaximum, Math.Max(widthMinimum, width.Value));
                Console.BufferWidth = Console.WindowWidth;
            } catch (Exception ex) {
                error.AppendLine(string.Format("{0," + appLen + "} | Could not set the width.", "** error")).AppendLine(ex.Message);
开发者ID:kodybrown,项目名称:shrink,代码行数:67,代码来源:shrink.cs

示例2: Main


//.........这里部分代码省略.........
                    } else if (a.Equals("config", StringComparison.CurrentCultureIgnoreCase)) {
                        writeToConfig = true;
                    } else if (a.Equals("!config", StringComparison.CurrentCultureIgnoreCase)) {
                        writeToConfig = false;

                    } else if (a.Equals("edit", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("notepad.exe", file);
                    } else if (a.Equals("email", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("mailto:Kody Brown <[email protected]>");
                    } else if (a.Equals("web", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("http://bricksoft.com");
                    } else if (a.Equals("src", StringComparison.CurrentCultureIgnoreCase) || a.Equals("source", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("http://github.com/kodybrown/" + app);
                    } else if (a.Equals("license", StringComparison.CurrentCultureIgnoreCase)) {
                        LaunchUrl("http://opensource.org/licenses/MIT");

                    } else {
                        DisplayError(settings, "unknown argument.");
                        return 1;
                    }
                }
            }

            DisplayAppName();

            // If '--config' was specified without any other arguments,
            // it will only output the current values from config.
            if (writeToConfig && direction == ConsoleUtils.WindowPosition.NotSet && !margin.HasValue && !cmargin.HasValue && !rmargin.HasValue) {
                DisplayAppName();
                DisplayCopyright();
                DisplayConfig(settings);
                return 0;
            }

            // Write config values before they are (possibly) overwritten below.
            if (writeToConfig) {
                if (direction != ConsoleUtils.WindowPosition.NotSet) {
                    settings.attr<int>("direction", (int)direction);
                }
                if (margin.HasValue) {
                    settings.attr<int>("margin", margin.Value);
                }
                if (cmargin.HasValue) {
                    settings.attr<int>("cmargin", cmargin.Value);
                }
                if (rmargin.HasValue) {
                    settings.attr<int>("rmargin", rmargin.Value);
                }
                settings.write();
            }

            // If a direction was not specified: use the direction from config,
            // otherwise don't change anything.
            if (direction == ConsoleUtils.WindowPosition.NotSet) {
                if (settings.contains("direction")) {
                    direction = (ConsoleUtils.WindowPosition)settings.attr<int>("direction");
                } else {
                    DisplayAppName();
                    DisplayCopyright();
                    DisplayError(settings, "no direction specified");
                    DisplayConfig(settings);
                    return 3;
                }
            }
            // If a margin was not specified: use the margin from config,
            // otherwise use zero.
            if (!margin.HasValue) {
                margin = settings.contains("margin") ? settings.attr<int>("margin") : 0;
            }
            if (!cmargin.HasValue) {
                cmargin = settings.contains("cmargin") ? settings.attr<int>("cmargin") : 0;
            }
            if (!rmargin.HasValue) {
                rmargin = settings.contains("rmargin") ? settings.attr<int>("rmargin") : 0;
            }

            //
            // Update the console.
            //
            try {
                if (margin.HasValue || (cmargin.Value == 0 && rmargin.Value == 0)) {
                    // Specifying a margin overrides col and row margins.
                    ConsoleUtils.MoveWindow((ConsoleUtils.WindowPosition)(int)direction, margin.Value, margin.Value);
                } else {
                    ConsoleUtils.MoveWindow((ConsoleUtils.WindowPosition)(int)direction, cmargin.Value, rmargin.Value);
                }
            } catch (Exception ex) {
                Console.Write("{0," + appLen + "} | Could not move the window.\n{1}", "** error", ex.Message);
            }

            if (DEBUG) {
                Console.Write("press any key to continue: ");
                Console.ReadKey(true);
                Console.CursorLeft = 0;
                Console.Write("                            ");
                Console.CursorLeft = 0;
            }

            return 0;
        }
开发者ID:kodybrown,项目名称:reloc,代码行数:101,代码来源:reloc.cs

示例3: DisplayConfig

 private static void DisplayConfig( Settings settings )
 {
     Console.WriteLine("\nCURRENT WINDOW:");
     Console.WriteLine("  width  = {0,3}", Console.WindowWidth);
     Console.WriteLine("  height = {0,3}", Console.WindowHeight);
     Console.WriteLine("\nSAVED CONFIG:");
     Console.WriteLine("  width  = {0}", settings.contains("width") ? settings.attr<int>("width").ToString() : "not set");
     Console.WriteLine("  height = {0}", settings.contains("height") ? settings.attr<int>("height").ToString() : "not set");
     Console.WriteLine("  center = {0}", settings.contains("center") ? settings.attr<bool>("center").ToString().ToLower() : defaultCenter.ToString().ToLower());
 }
开发者ID:kodybrown,项目名称:shrink,代码行数:10,代码来源:shrink.cs

示例4: DisplayConfig

        private static void DisplayConfig( Settings settings )
        {
            int w = Console.WindowWidth,
                a = 2,
                b = 14;

            Console.WriteLine("\nSAVED CONFIG:");
            Console.WriteLine();

            writeExpression("direction", (settings.contains("direction") ? ((ConsoleUtils.WindowPosition)settings.attr<int>("direction")).ToString() : "not set"), a, b, w);
            //writeExpression("margin", (settings.contains("margin") ? settings.attr<int>("margin").ToString() : "not set"), a, b, w);
            //writeExpression("cmargin", (settings.contains("cmargin") ? settings.attr<int>("cmargin").ToString() : "not set"), a, b, w);
            //writeExpression("rmargin", (settings.contains("rmargin") ? settings.attr<int>("rmargin").ToString() : "not set"), a, b, w);
        }
开发者ID:kodybrown,项目名称:reloc,代码行数:14,代码来源:reloc.cs


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