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


C# BackgroundWorker.SendResult方法代码示例

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


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

示例1: FindPidsInMap

        private void FindPidsInMap( BackgroundWorker worker, string filename, List<Tuple<int, int>> pids )
        {
            if( !filename.HaveExtension( "fomap" ) )
                return;

            FOnlineMap fomap = FOnlineMap.Load( filename, false, false, true );
            if( fomap == null )
                return;

            bool header = false;
            foreach( Dictionary<string, string> mapObject in fomap.Objects )
            {
                //mapObject["ProtoId"] = "1";

                string tmp;

                int objectType = -1;
                if( !mapObject.TryGetValue( "MapObjType", out tmp ) ||
                    !int.TryParse( tmp, out objectType ) )
                    objectType = -1;

                int objectPid;
                if( mapObject.TryGetValue( "ProtoId", out tmp ) &&
                    int.TryParse( tmp, out objectPid ) &&
                    pids.IsWantedObject( objectType, objectPid ) )
                {
                    int hx, hy;
                    if( mapObject.TryGetValue( "MapX", out tmp ) &&
                        int.TryParse( tmp, out hx ) &&
                        mapObject.TryGetValue( "MapY", out tmp ) &&
                        int.TryParse( tmp, out hy ) )
                    {
                        if( !header )
                        {
                            if( resultsLog.Text.Length > 0 )
                                worker.ReportProgress( 0, "\r\n" );
                            worker.SendResult( string.Format( "{0} ({1})\r\n\r\n",
                                "?", Path.GetFileName( filename ) ) );
                            header = true;
                        }
                        string typeString = "";

                        if( objectType == objectCritter )
                            typeString = "Critter";
                        else if( objectType == objectItem )
                            typeString = "Item";
                        else if( objectType == objectScenery )
                            typeString = "Scenery";

                        string objectPidName = null;
                        if( objectType == objectItem || objectType == objectScenery )
                            objectPidName = itemPids.Defines.FindKeyByValue( objectPid );

                        worker.SendResult( string.Format( "\t[Hex {0,3},{1,3}] {2}{3}\r\n",
                            hx, hy,
                            typeString.Length > 0 ? "(" + typeString + ") " : "",
                            objectPidName != null ? objectPidName + " <" + objectPid + ">" : "" + objectPid
                            ) );

                        worker.SendResult( "Maps"
                           + "|" + Path.GetFileName( filename )
                           + "|" + (typeString == "Scenery" ? "Sceneries" : typeString + "s")
                           + "|" + (objectPidName != null ? objectPidName + " <" + objectPid + ">" : "" + objectPid)
                           + "|Hex " + hx + "," + hy

                           );
                    }
                }
            }
        }
开发者ID:Gargash,项目名称:fo2238,代码行数:70,代码来源:frmMain.cs

示例2: FindPidsInDialog

        private void FindPidsInDialog( BackgroundWorker worker, string filename, List<Tuple<int, int>> pids )
        {
            if( !filename.HaveExtension( "fodlg" ) )
                return;

            DialogParser fodlg = new DialogParser( filename );
            if( fodlg == null )
                return;

            if( fodlg.Parse() )
            {
                bool header = false;
                string headerText = "? (" + Path.GetFileName( filename ) + ")\r\n\r\n";
                Dialog dialog = fodlg.GetDialog();
                if( dialog == null )
                    return;

                string lNode = "" + dialog.Nodes.Count.ToString().Length;
                foreach( Node node in dialog.Nodes )
                {
                    int answerId = 0;
                    string lAnswer = "" + node.Answers.Count.ToString().Length;
                    foreach( Answer answer in node.Answers )
                    {
                        answerId++;
                        int demandId = 0;
                        int resultId = 0;
                        string lDemand = "" + answer.Demands.Count.ToString().Length;
                        string lResult = "" + answer.Results.Count.ToString().Length;
                        foreach( Demand demand in answer.Demands )
                        {
                            demandId++;
                            if( demand.Item != null )
                            {
                                int pid = -1;
                                if( itemPids.Defines.TryGetValue( demand.Item.PidDefine, out pid ) &&
                                    pids.IsWantedObject( objectItem, pid ) )
                                {
                                    if( !header )
                                    {
                                        if( resultsLog.Text.Length > 0 )
                                            worker.SendResult( "\r\n" );
                                        worker.SendResult( headerText );
                                        header = true;
                                    }
                                    worker.SendResult( string.Format( "\t[Node {0," + lNode + "} Answer {1," + lAnswer + "} Demand {2," + lDemand + "}] {3} {4} {5}\r\n",
                                        node.Id,
                                        answerId,
                                        demandId,
                                        demand.Item.PidDefine,
                                        demand.Operator == "=" ? "==" : demand.Operator,
                                        demand.Value ) );

                                    worker.SendResult( "Dialogs"
                                        + "|" + Path.GetFileName( filename )
                                        + "|Node " + node.Id
                                            + "^" + node.Text["engl"]
                                        + "|Answer " + answerId
                                            + "^" + answer.Text["engl"]
                                        + "|Demand " + demandId + ": "
                                            + demand.Item.PidDefine + " "
                                            + (demand.Operator == "=" ? "==" : demand.Operator) + " "
                                            + demand.Value );
                                }
                            }
                        }
                        foreach( Result result in answer.Results )
                        {
                            resultId++;
                            if( result.Item != null )
                            {
                                int pid = -1;
                                if( itemPids.Defines.TryGetValue( result.Item.PidDefine, out pid ) &&
                                    pids.IsWantedObject( objectItem, pid ) )
                                {
                                    if( !header )
                                    {
                                        if( resultsLog.Text.Length > 0 )
                                            worker.SendResult( "\r\n" );
                                        worker.SendResult( headerText );
                                        header = true;
                                    }

                                    worker.SendResult( string.Format( "\t[Node {0," + lNode + "} Answer {1," + lAnswer + "} Result {2," + lResult + "}] {3} {4} {5}\r\n",
                                        node.Id,
                                        answerId,
                                        resultId,
                                        result.Item.PidDefine,
                                        result.Operator,
                                        result.Value ) );

                                    worker.SendResult( "Dialogs"
                                        + "|" + Path.GetFileName( filename )
                                        + "|Node " + node.Id
                                            + "^" + node.Text["engl"]
                                        + "|Answer " + answerId
                                            + "^" + answer.Text["engl"]
                                        + "|Result " + resultId + ": "
                                            + result.Item.PidDefine + " "
                                            + result.Operator + " "
//.........这里部分代码省略.........
开发者ID:Gargash,项目名称:fo2238,代码行数:101,代码来源:frmMain.cs


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