Exemple #1
0
 private void DrawSystemSort(SystemSort sort, SystemType systemType)
 {
     GUILayoutExtension.HorizontalGroup(() =>
     {
         EditorGUILayout.LabelField(sort.typeName);
         MiscHelper.Btn("Up", 50, 35, () =>
         {
             sort.sort--;
             UpdateSystemSort();
         });
         MiscHelper.Btn("Down", 50, 35, () =>
         {
             sort.sort++;
             UpdateSystemSort();
         });
         MiscHelper.Btn("Del", 50, 35, () =>
         {
             sortAsset.GetSystemSorts(systemType).Remove(sort);
             UpdateSystemSort();
         });
         MiscHelper.Dropdown(systemType.ToString(), systemTyps, (int x) =>
         {
             SystemType newType = (SystemType)x;
             if (newType == systemType)
             {
                 return;
             }
             sortAsset.GetSystemSorts(systemType).Remove(sort);
             sortAsset.GetSystemSorts(newType).Add(sort);
             UpdateSystemSort();
         });
     });
 }
        /// <summary>
        /// Erzeugt eine neue Vermittlungsinstanz.
        /// </summary>
        /// <param name="profile">Das zugeordnete Geräteprofil.</param>
        internal LegacyHardware(P profile)
            : base(profile)
        {
            // Create the device configuration
            var settings = new Hashtable();

            // Fill the configuration
            foreach (var parameter in profile.Parameters)
            {
                if (!string.IsNullOrEmpty(parameter.Value))
                {
                    settings[parameter.Name] = parameter.Value;
                }
            }

            // Pre-set system type
            settings["Type"] = SystemType.ToString();

            // Find the primary aspect
            var aspect = profile.DeviceAspects.Find(a => string.IsNullOrEmpty(a.Aspekt));

            // Create the device
            LegacyDevice = (ILegacyDevice)Activator.CreateInstance(Type.GetType(aspect.Value, true), settings);

            // Start it
            LegacyDevice.SetVideoAudio(0, 0);
        }
        public void SaveToXML(XmlDocument objDoc)
        {
            var xeSystem = objDoc.CreateElement("System");

            objDoc.AppendChild(xeSystem);
            Common.CreateTextNode(xeSystem, "SysNat", systemType.ToString());
            Common.CreateTextNode(xeSystem, "SystemHabitability", SystemHabitability.ToString());
            Common.CreateTextNode(xeSystem, "CurrentCampaign", _configuration.CurrentCampaign.ToString());
            Common.CreateTextNode(xeSystem, "GenerateTravInfo", _configuration.GenerateTravInfo.ToString());
            Common.CreateTextNode(xeSystem, "UseFarenheight", _configuration.UseFarenheight.ToString());
            // Summary information for quick access
            Common.CreateTextNode(xeSystem, "Summary", systemType.ToString());
            Common.CreateTextNode(xeSystem, "Primary", Primary.DisplayString);
            foreach (var companion in Primary.Companions)
            {
                Common.CreateTextNode(xeSystem, "Companion", companion.DisplayString);
                foreach (var otherComp in companion.Companions)
                {
                    Common.CreateTextNode(xeSystem, "Companion", companion.DisplayString);
                }
            }
            Common.CreateTextNode(xeSystem, "PlanetoidBelts", "There are " + Primary.Count(Planet.WorldType.PLANETOID) + " planetoid belts");
            Common.CreateTextNode(xeSystem, "GasGiants", "There are " + (Primary.Count(Planet.WorldType.LGG) + Primary.Count(Planet.WorldType.SGG)) + " Gas Giants");
            var mainworld = Primary.GetMainWorld();

            if (mainworld != null)
            {
                Common.CreateTextNode(xeSystem, "Mainworld", mainworld.DisplayString);
                Common.CreateTextNode(xeSystem, "PBG", mainworld.Normal.PopMult.ToString() + BG);
                if (_configuration.CurrentCampaign == Campaign.THENEWERA)
                {
                    Common.CreateTextNode(xeSystem, "PostCollapseMainworld", mainworld.Collapse.DisplayString(mainworld.PlanetType, mainworld.Diameter));
                }
            }
            if (_configuration.GenerateTravInfo)
            {
                Common.CreateTextNode(xeSystem, "SystemPopulation", Primary.Population(false).ToString());
                if (_configuration.CurrentCampaign == Campaign.THENEWERA)
                {
                    Common.CreateTextNode(xeSystem, "PostCollapseSystemPopulation", Primary.Population(true).ToString());
                }
            }
            Primary.SaveToXML(xeSystem);
        }
Exemple #4
0
 /// <summary>
 /// Used to populate ListView
 /// </summary>
 /// <returns></returns>
 public string[] ItemArray()
 {
     return(new[]
     {
         Name,
         SystemType.ToString(),
         MaxLength.ToString(),
         Precision.ToString(),
         Scale.ToString()
     });
 }
Exemple #5
0
        public static string GetSystemCode(SystemType type)
        {
            switch (type)
            {
            case SystemType.P83:
                return("83P");

            case SystemType.X32:
                return("32X");

            default:
                return(type.ToString());
            }
        }
Exemple #6
0
 /// <summary>
 /// Assign type of system to be created
 /// </summary>
 /// <param name="s">SesamSystem type</param>
 /// <returns></returns>
 public SesamSystem OfType(SystemType s)
 {
     this.systemType = s;
     this.attrs.Add("type", String.Format("system:{0}", s.ToString().ToLower()));
     return(this);
 }
Exemple #7
0
        //Output all warnings and errors to general list view control
        private void OutputGeneralWarningsAndErrors()
        {
            //Inits
            NFLanguageCompiler.Message msg = null;
            ListViewItem item = null;
            SystemType   proc = SystemType.ST_NONE;

            //Clear warnings and errors
            listViewGeneralWarningsAndErrors.Items.Clear();

            //Output all warnings
            for (int i = 0; i < compiler.WarningCount; i++)
            {
                //Get Message object
                msg = compiler.GetWarning(i);

                //Get system type
                proc = msg.System;

                //Output lexer warnings
                if (proc == SystemType.ST_LEXER)
                {
                    //Create listview item
                    item = new ListViewItem(proc.ToString());
                    item.SubItems.Add("Warning");
                    item.SubItems.Add(msg.Line.ToString());
                    item.SubItems.Add(msg.Column.ToString());
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add(msg.Text);
                }
                else if (proc == SystemType.ST_PARSER)
                {
                    //Create listview item
                    item = new ListViewItem(proc.ToString());
                    item.SubItems.Add("Warning");
                    item.SubItems.Add(msg.Line.ToString());
                    item.SubItems.Add(msg.Column.ToString());
                    item.SubItems.Add(msg.Grammar.ToString());
                    if (msg.Token != null)
                    {
                        item.SubItems.Add(msg.Token.Type.ToString());
                    }
                    else
                    {
                        item.SubItems.Add("");
                    }

                    item.SubItems.Add(msg.TokenIndex.ToString());
                    item.SubItems.Add(msg.Text);
                }

                //Add item to list
                listViewGeneralWarningsAndErrors.Items.Add(item);
            }

            //Output all errors
            for (int i = 0; i < compiler.ErrorCount; i++)
            {
                //Get Message object
                msg = compiler.GetError(i);

                //Get system type
                proc = msg.System;

                //Output lexer warnings
                if (proc == SystemType.ST_LEXER)
                {
                    //Create listview item
                    item = new ListViewItem(proc.ToString());
                    item.SubItems.Add("Error");
                    item.SubItems.Add(msg.Line.ToString());
                    item.SubItems.Add(msg.Column.ToString());
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    item.SubItems.Add(msg.Text);
                }
                else if (proc == SystemType.ST_PARSER)
                {
                    //Create listview item
                    item = new ListViewItem(proc.ToString());
                    item.SubItems.Add("Error");
                    item.SubItems.Add(msg.Line.ToString());
                    item.SubItems.Add(msg.Column.ToString());
                    item.SubItems.Add(msg.Grammar.ToString());
                    if (msg.Token != null)
                    {
                        item.SubItems.Add(msg.Token.Type.ToString());
                    }
                    else
                    {
                        item.SubItems.Add("");
                    }
                    item.SubItems.Add(msg.TokenIndex.ToString());
                    item.SubItems.Add(msg.Text);
                }

                //Add to list
                listViewGeneralWarningsAndErrors.Items.Add(item);
            }
        }
Exemple #8
0
        /// <summary>
        /// 主函数
        /// </summary>
        /// <param name="args">配置参数</param>
        public static void Main(string[] args)
        {
            //未捕获异常处理
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionEventHandler;

            //启动参数配置项
            IConfigurationRoot commandConfig = new ConfigurationBuilder()
                                               .AddCommandLine(args)
                                               .Build();
            SystemType system     = commandConfig.GetValue <SystemType>("System");
            int        listenPort = commandConfig.GetValue <int>("ListenPort");

            //初始化日志
            List <string> tempArgs = args.ToList();

            tempArgs.Add($"LogName={system}");
            args = tempArgs.ToArray();
            List <ILoggerProvider> loggerProviders = new List <ILoggerProvider>
            {
                new ConsoleLogger(LogLevel.Debug, LogLevel.Error),
                new FileLogger(LogLevel.Debug, LogLevel.Error, system.ToString(), LogPool.Directory, LogPool.HoldDays)
            };

            LogPool.SetLoggerProviders(loggerProviders);
            //添加日志和监听端口
            IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args)
                                      .ConfigureLogging((hostingContext, logging) =>
            {
                logging.ClearProviders();
                foreach (ILoggerProvider loggerProvider in loggerProviders)
                {
                    logging.AddProvider(loggerProvider);
                }
            })
                                      .UseUrls($"http://+:{listenPort}/");

            //http配置项
            //if (system!=(int)SystemType.系统管理中心&&systemUrl != null)
            //{
            //    builder.ConfigureAppConfiguration((hostingContext, config) =>
            //    {
            //        config.AddHttpConfiguration(systemUrl, parameterType);
            //    });
            //}

            if (system == SystemType.Flow)
            {
                builder.UseStartup <FlowStartup>();
            }
            else if (system == SystemType.Density)
            {
                builder.UseStartup <DensityStartup>();
            }
            else
            {
                builder.UseStartup <SystemStartup>();
            }

            IWebHost webHost = builder.Build();

            LogPool.Logger.LogInformation((int)LogEvent.配置项, $"System {system}");
            LogPool.Logger.LogInformation((int)LogEvent.配置项, $"ListenPort {listenPort}");
            webHost.Run();
        }