// Печать всех листов в текущем документе
        private void multiSheetPlot(Database db)
        {
            using (var t = db.TransactionManager.StartTransaction())
             {
            var bt = (BlockTable)t.GetObject(db.BlockTableId, OpenMode.ForRead);
            var pi = new PlotInfo();
            var piv = new PlotInfoValidator();
            piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;

            if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
            {
               using (var pe = PlotFactory.CreatePublishEngine())
               {
                  var layouts = new List<Layout>();
                  DBDictionary layoutDict = (DBDictionary)db.LayoutDictionaryId.GetObject(OpenMode.ForRead);
                  foreach (DBDictionaryEntry entry in layoutDict)
                  {
                     if (entry.Key != "Model")
                     {
                        layouts.Add((Layout)t.GetObject(entry.Value, OpenMode.ForRead));
                     }
                  }
                  layouts.Sort((l1, l2) => l1.LayoutName.CompareTo(l2.LayoutName));
                  var layoutsToPlot = new ObjectIdCollection(layouts.Select(l => l.BlockTableRecordId).ToArray());

                  int numSheet = 1;
                  foreach (ObjectId btrId in layoutsToPlot)
                  {
                     var btr = (BlockTableRecord)t.GetObject(btrId, OpenMode.ForRead);
                     var lo = (Layout)t.GetObject(btr.LayoutId, OpenMode.ForRead);
                     var psv = PlotSettingsValidator.Current;
                     pi.Layout = btr.LayoutId;
                     LayoutManager.Current.CurrentLayout = lo.LayoutName;
                     piv.Validate(pi);

                     if (numSheet == 1)
                     {
                        pe.BeginPlot(null, null);
                        string fileName = Path.Combine(Path.GetDirectoryName(db.Filename), Path.GetFileNameWithoutExtension(db.Filename) + ".pdf");
                        pe.BeginDocument(pi, db.Filename, null, 1, true, fileName);
                     }
                     var ppi = new PlotPageInfo();
                     pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count), null);
                     pe.BeginGenerateGraphics(null);
                     pe.EndGenerateGraphics(null);
                     // Finish the sheet
                     pe.EndPage(null);
                     numSheet++;
                  }
                  // Finish the document
                  pe.EndDocument(null);
               }
            }
            else
            {
               throw new System.Exception("Другое задание на печать уже выполняется.");
            }
            t.Commit();
             }
        }
Example #2
0
        /// <summary>
        /// 单页预览
        /// </summary>
        /// <param name="layoutId"></param>
        /// <param name="plotArea"></param>
        /// <param name="plotDevice"></param>
        /// <param name="plotCanonicalMeida"></param>
        /// <param name="plotStyle"></param>
        public static void PreviewSinglePage(
            ObjectId layoutId,
            Extents2d plotArea,
            string plotDevice,
            string plotCanonicalMeida,
            string plotStyle
            )
        {
            if (PlotFactory.ProcessPlotState != ProcessPlotState.NotPlotting)
            {
                MessageBox.Show($"当前不能预览,另一个打印任务正在进行中!");
                return;
            }

            using (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                Layout lo = mFun.m_OpenEntity(layoutId) as Layout;

                if (LayoutManager.Current.CurrentLayout != lo.LayoutName)
                {
                    LayoutManager.Current.CurrentLayout = lo.LayoutName;
                }

                using (PlotProgressDialog ppd = new PlotProgressDialog(true, 1, false))
                {
                    #region 设置进度条信息

                    #endregion 

                    using (PlotEngine pe = PlotFactory.CreatePreviewEngine(0))
                    {
                        //设置打印配置参数
                        PlotInfo pi = SetPlotInfo(lo, plotArea, plotDevice, plotCanonicalMeida, plotStyle, true);

                        pe.BeginPlot(ppd, null);

                        pe.BeginDocument(pi, mCommands.Doc.Name, null, 1, false, "");

                        pe.BeginPage(new PlotPageInfo(), pi, true, null);

                        pe.BeginGenerateGraphics(null);

                        pe.EndGenerateGraphics(null);

                        PreviewEndPlotInfo pepi = new PreviewEndPlotInfo();
                        pe.EndPage(pepi);//结束本页打印,返回预览状态

                        pe.EndDocument(null);

                        pe.EndPlot(null);
                    }
                }
            }
        }
        public void Plot(string fileName, PlotEngine pe, PlotProgressDialog ppd)
        {
            using (Transaction trans = LayoutID.Database.TransactionManager.StartTransaction())
            {
                Layout layout = (Layout)trans.GetObject(LayoutID, OpenMode.ForRead);
                LayoutManager.Current.CurrentLayout = layout.LayoutName;

                PlotInfo plotInfo = new PlotInfo();
                plotInfo.Layout = LayoutID;

                // Set plot settings
                PlotSettings ps = new PlotSettings(layout.ModelType);
                ps.CopyFrom(layout);

                PlotSettingsValidator psv = PlotSettingsValidator.Current;
                psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout);
                psv.SetUseStandardScale(ps, true);
                psv.SetStdScaleType(ps, StdScaleType.StdScale1To1);

                /*PlotConfig pConfig = PlotConfigManager.SetCurrentConfig("DWG To PDF.pc3");
                 * var devices = psv.GetPlotDeviceList();*/
                psv.SetPlotConfigurationName(ps, "DWG To PDF.pc3", null);
                psv.RefreshLists(ps);
                var media = psv.GetCanonicalMediaNameList(ps);

                psv.SetPlotConfigurationName(ps, "DWG To PDF.pc3", GetMediaName());

                plotInfo.OverrideSettings = ps;
                PlotInfoValidator piv = new PlotInfoValidator();
                piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                piv.Validate(plotInfo);

                pe.BeginDocument(plotInfo, fileName, null, 1, true, fileName);

                ppd.OnBeginSheet();
                ppd.LowerSheetProgressRange = 0;
                ppd.UpperSheetProgressRange = 100;
                ppd.SheetProgressPos        = 0;

                PlotPageInfo ppi = new PlotPageInfo();
                pe.BeginPage(ppi, plotInfo, true, null);
                pe.BeginGenerateGraphics(null);
                pe.EndGenerateGraphics(null);

                pe.EndPage(null);
                ppd.SheetProgressPos = 100;
                ppd.OnEndSheet();

                pe.EndDocument(null);
            }
        }
Example #4
0
        static public void plotterscaletofit()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            Database db  = doc.Database;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                //ask user for print window
                Point3d            first;
                PromptPointOptions ppo = new PromptPointOptions("\nSelect First corner of plot area: ");
                ppo.AllowNone = false;
                PromptPointResult ppr = ed.GetPoint(ppo);
                if (ppr.Status == PromptStatus.OK)
                {
                    first = ppr.Value;
                }
                else
                {
                    return;
                }

                Point3d             second;
                PromptCornerOptions pco = new PromptCornerOptions("\nSelect second corner of the plot area.", first);
                ppr = ed.GetCorner(pco);
                if (ppr.Status == PromptStatus.OK)
                {
                    second = ppr.Value;
                }
                else
                {
                    return;
                }

                //convert from UCS to DCS
                Extents2d window = coordinates(first, second);

                //if the current view is paperspace then need to set up a viewport first
                if (LayoutManager.Current.CurrentLayout != "Model")
                {
                }

                //set up the plotter
                PlotInfo pi = plotSetUp(window, tr, db, ed, true, false);

                //call plotter engine to run
                plotEngine(pi, "Nameless", doc, ed, false);

                tr.Dispose();
            }
        }
        /// <summary>
        /// A method triggered by the CityAdded event that adds the point to the graph
        /// </summary>
        /// <param name="sender">The solver sending the message</param>
        /// <param name="args">The information about the city added</param>
        private void OnCityAdded(object sender, CityAddedEventArgs args)
        {
            // Add to the AddedOrder list to keep track of order
            AddedOrder.Add(args.AddedCity);

            // Plot the new point on the graph
            var point = new DataPoint(args.AddedCity.XPosition, args.AddedCity.YPosition);

            PlotSeries.Points.Insert(args.Index, point);

            // Update the UI
            NotifyOfPropertyChange(nameof(AddedOrder));
            PlotInfo.InvalidatePlot(true);
        }
Example #6
0
        /// <summary>
        /// Updating plot
        /// </summary>
        /// <param name="Plot">PlotInfo Model Object as a parameter</param>
        public void UpdatePlot(PlotInfo plot)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            if (dao.GetCountOfDuplicatePlotNameForEdit(plot.FarmId, plot.PlotId, plot.PlotName) == 0)
            {
                dao.UpdatePlot(plot);
            }
            else
            {
                throw new Exception("Plot Name Already Exist.");
            }
        }
Example #7
0
        /// <summary>
        /// Creating plot
        /// </summary>
        /// <param name="Plot">PlotInfo Model Object as a parameter</param>
        public void CreatePlot(PlotInfo plot)
        {
            // Get an instance of the Registration DAO using the DALFactory
            IFarm dao = (IFarm)DALFactory.DAO.Create(DALFactory.Module.Farm);

            if (dao.GetCountOfPlotsForPlotNameOnFarm(plot.FarmId, plot.PlotName) == 0)
            {
                dao.CreatePlot(plot);
            }
            else
            {
                throw new Exception("Plot Name already exisist.");
            }
        }
Example #8
0
        /// <summary>
        /// 天地劫副本层数
        /// </summary>
        /// <param name="user"></param>
        public static void CheckUserPlotLayerNum(GameUser user)
        {
            PlotInfo plotInfo = UserHelper.CheckUserPlotKalpa(user);

            if (user != null && plotInfo != null)
            {
                //最高层
                if (user.UserExtend != null && user.UserExtend.MaxLayerNum == 0)
                {
                    user.UserExtend.MaxLayerNum = plotInfo.LayerNum;
                    //user.Update();
                }
            }
        }
Example #9
0
        Stream(ArrayList data, PlotInfo info)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(PlotInfo)));

            data.Add(new Snoop.Data.Object("Device override", info.DeviceOverride));
            data.Add(new Snoop.Data.Bool("Is validated", info.IsValidated));
            data.Add(new Snoop.Data.ObjectId("Layout", info.Layout));
            data.Add(new Snoop.Data.Int("Merge status", info.MergeStatus));
            /// this always says that the operation is not valid 'cos of current state
            /// jai 11.30.06
            //data.Add(new Snoop.Data.Object("Override settings", info.OverrideSettings));
            data.Add(new Snoop.Data.Object("Validated config", info.ValidatedConfig));
            data.Add(new Snoop.Data.Object("Validated settings", info.ValidatedSettings));
        }
Example #10
0
        public static void ChangePlotSetting()
        {
            // 获取当前文档和数据库,启动事务
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // 引用布局管理器LayoutManager
                LayoutManager acLayoutMgr;
                acLayoutMgr = LayoutManager.Current;

                // 获取当前布局,在命令行窗口显示布局名
                Layout acLayout;
                acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout),
                                             OpenMode.ForRead) as Layout;

                // 输出当前布局名和设备名
                acDoc.Editor.WriteMessage("\nCurrent layout: " +
                                          acLayout.LayoutName);

                acDoc.Editor.WriteMessage("\nCurrent device name: " +
                                          acLayout.PlotConfigurationName);

                // 从布局中获取PlotInfo
                PlotInfo acPlInfo = new PlotInfo();
                acPlInfo.Layout = acLayout.ObjectId;

                // 复制布局中的PlotSettings
                PlotSettings acPlSet = new PlotSettings(acLayout.ModelType);
                acPlSet.CopyFrom(acLayout);

                // 更新PlotSettings对象的PlotConfigurationName属性
                PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWF6 ePlot.pc3",
                                                    "ANSI_A_(8.50_x_11.00_Inches)");

                // 更新布局
                acLayout.UpgradeOpen();
                acLayout.CopyFrom(acPlSet);

                // 输出已更新的布局设备名
                acDoc.Editor.WriteMessage("\nNew device name: " +
                                          acLayout.PlotConfigurationName);

                // 将新对象保存到数据库
                acTrans.Commit();
            }
        }
        /// <summary>
        /// A method that reads the cities from the current file
        /// </summary>
        private void ReadFile()
        {
            CitySeries.Points.Clear();
            Cities.Clear();
            // Makes sure the file is valid
            if (CurrentFile != null && !CurrentFile.Exists)
            {
                MessageBox.Show("There is no valid file selected", "No Valid File",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            StreamReader reader = new StreamReader(CurrentFile.FullName);

            // Skip the first four lines
            for (int x = 0; x < 4; x++)
            {
                reader.ReadLine();
            }

            // Get the number of destinations
            var temp      = reader.ReadLine().Split(' ');
            int cityCount = int.Parse(temp[1]);

            // Skip two more lines
            for (int y = 0; y < 2; y++)
            {
                reader.ReadLine();
            }

            // Read the data for each city
            for (int z = 0; z < cityCount; z++)
            {
                temp = reader.ReadLine().Split(' ');
                var city = new City(int.Parse(temp[0]),
                                    double.Parse(temp[1]),
                                    double.Parse(temp[2]));
                // Add the city to the list
                Cities.Add(city);

                // Add the city to the graph
                CitySeries.Points.Add(new ScatterPoint(city.XPosition, city.YPosition));
            }

            PlotInfo.InvalidatePlot(true);
            OnDataCleared(this, new EventArgs());
            GSolver.OrderData(Cities);
        }
Example #12
0
        public void Test()
        {
            PlotSettingsValidator psv = PlotSettingsValidator.Current;
            var Text   = new List <string>();
            var editor = Acad.DocumentManager.MdiActiveDocument.Editor;

            System.Collections.Specialized.StringCollection vs = psv.GetPlotDeviceList();
            foreach (var st in vs)
            {
                editor.WriteMessage(st.ToString() + Environment.NewLine);
                Text.Add(st.ToString());
            }
            using (PlotSettings ps = new PlotSettings(false))
            {
                foreach (var st in vs)
                {
                    editor.WriteMessage("Текущий/Selected: " + st.ToString() + Environment.NewLine);
                    Text.Add("Текущий/Selected: " + st.ToString());
                    if (st.ToString() == "AutoCAD PDF (High Quality Print).pc3")
                    {
                        PlotConfig config = PlotConfigManager.SetCurrentConfig(st.ToString());
                        PlotInfo   info   = new PlotInfo();
                        psv.SetPlotConfigurationName(ps, st.ToString(), null);
                        psv.RefreshLists(ps);
                        System.Collections.Specialized.StringCollection mediaName = psv.GetCanonicalMediaNameList(ps);
                        foreach (var media in mediaName)
                        {
                            editor.WriteMessage("Формат/Media name " + media.ToString() + Environment.NewLine);
                            Text.Add("Формат/Media name " + media.ToString());
                            MediaBounds bounds = config.GetMediaBounds(media.ToString());
                            editor.WriteMessage(Math.Round(bounds.PageSize.X).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.PageSize.Y).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.LowerLeftPrintableArea.X).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.UpperRightPrintableArea.Y).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.UpperRightPrintableArea.X).ToString() + Environment.NewLine);
                            editor.WriteMessage(Math.Round(bounds.LowerLeftPrintableArea.Y).ToString() + Environment.NewLine);
                            Text.Add(Math.Round(bounds.PageSize.X).ToString());
                            Text.Add(Math.Round(bounds.PageSize.Y).ToString());
                            Text.Add(Math.Round(bounds.LowerLeftPrintableArea.X).ToString());
                            Text.Add(Math.Round(bounds.UpperRightPrintableArea.Y).ToString());
                            Text.Add(Math.Round(bounds.UpperRightPrintableArea.X).ToString());
                            Text.Add(Math.Round(bounds.LowerLeftPrintableArea.Y).ToString());
                        }
                    }
                }
            }
            System.IO.File.WriteAllLines("C:\\users\\dyn1\\desktop\\info.txt", Text);
        }
        /// <summary>
        /// A method triggered by the NewBestTrip event that updates the new best path
        /// </summary>
        /// <param name="sender">The solver that sent the event</param>
        /// <param name="args">The event arguments</param>
        private void OnNewBestTrip(object sender, BestFoundEventArgs args)
        {
            PathSeries.Points.Clear();

            foreach (City point in args.NewBest.Stops)
            {
                PathSeries.Points.Add(new DataPoint(point.XPosition, point.YPosition));
            }

            ChangeSeries.Points.Add(new DataPoint(args.Generation, 1 / (args.NewBest.Fitness) + 1));

            BestDistance = (int)args.NewBest.GetDistance();

            NotifyOfPropertyChange(nameof(BestDistance));
            PlotInfo.InvalidatePlot(true);
            ChangeInfo.InvalidatePlot(true);
        }
Example #14
0
        private void UpdatePlotInfo()
        {
            this.plotInfo = new PlotInfo();

            this.plotInfo.Min = this.actualRange.minimum.Ticks;
            this.plotInfo.Max = this.actualRange.maximum.Ticks;

            if (this.actualPlotMode == AxisPlotMode.BetweenTicks || this.actualPlotMode == AxisPlotMode.OnTicksPadded)
            {
                // add one additional tick at the end
                decimal nextTicks = this.GetNextTicks(this.plotInfo.Max, this.tickZoomFactor);
                this.plotInfo.Extend = nextTicks - this.plotInfo.Max;
                this.plotInfo.Max   += this.plotInfo.Extend;
            }
            else if (this.plotInfo.Min == this.plotInfo.Max)
            {
                this.plotInfo.Max = this.GetNextTicks(this.plotInfo.Min, this.tickZoomFactor);
            }
        }
Example #15
0
        public override bool TakeAction()
        {
            List <UniversalInfo> universalList = new List <UniversalInfo>();
            int layerNum = CheckUserPlotLayerNum(ContextUser);

            hurdleNum     = CheckUserPlotHurdleNum(ContextUser);
            plotInfoArray = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == layerNum && m.PlotType == PlotType.Kalpa);
            if (plotInfoArray.Count > 0)
            {
                plotInfo = new List <PlotInfo>(plotInfoArray).Find(u => u.PlotSeqNo == hurdleNum);
                if (plotInfo != null)
                {
                    plotNpcInfoArray = new ConfigCacheSet <PlotNPCInfo>().FindAll(m => m.PlotID == plotInfo.PlotID);
                    foreach (var info in plotNpcInfoArray)
                    {
                        SparePartInfo partInfo = new ConfigCacheSet <SparePartInfo>().FindKey(info.SparePartID);
                        if (partInfo != null)
                        {
                            universalList.Add(new UniversalInfo()
                            {
                                Name = partInfo.Name, HeadID = partInfo.HeadID, Num = 1
                            });
                        }
                    }
                    npcName = plotNpcInfoArray.Count == 0 ? string.Empty : plotNpcInfoArray[0].NpcName;
                    var userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotInfo.PlotID);
                    //todo new GameDataCacheSet<UserPlot>().FindKey(Uid, plotInfo.PlotID);
                    _isOverCombat = userPlot != null && userPlot.PlotStatus == PlotStatus.Completed;
                    strEnchant    = plotInfo.EnchantID.Split(',');
                    if (strEnchant.Length > 0)
                    {
                        universalList.Add(new UniversalInfo()
                        {
                            Name = LanguageManager.GetLang().St4301_RandomEnchant, HeadID = string.Empty, Num = 1
                        });
                    }
                    universalArray = universalList.ToArray();
                }
            }

            return(true);
        }
                public ChartViewModel()
                {
                    DateTime startDate = new DateTime(2013, 6, 1);

                    var sampleData = new ObservableCollection <PlotInfo>();

                    //Generate test data
                    for (int i = 0; i < 1000; i++)
                    {
                        var item = new PlotInfo
                        {
                            Date  = startDate.AddDays(i),
                            Sales = rnd.Next(-10000, (int)(10000 * Math.Sin(i / 100)))
                        };

                        sampleData.Add(item);
                    }

                    this.SalesData = sampleData;
                }
Example #17
0
        /// <summary>
        /// 当前玩家所在的层、关的副本
        /// </summary>
        /// <returns></returns>
        public static PlotInfo CheckUserPlotKalpa(GameUser user)
        {
            PlotInfo plotInfo = null;

            var userPlotArray = UserPlotHelper.UserPlotFindAll(user.UserID).FindAll(m => m.PlotType == PlotType.Kalpa);

            if (userPlotArray.Count == 0)
            {
                PlotHelper.EnablePlot(user.UserID, 8000);
                UserPlotHelper.UserPlotFindAll(user.UserID).FindAll(m => m.PlotType == PlotType.Kalpa);
            }
            if (userPlotArray.Count > 0)
            {
                userPlotArray.QuickSort((x, y) =>
                {
                    int result = 0;
                    if (x == null && y == null)
                    {
                        return(0);
                    }
                    if (x != null && y == null)
                    {
                        return(1);
                    }
                    if (x == null)
                    {
                        return(-1);
                    }
                    result = new ConfigCacheSet <PlotInfo>().FindKey(y.PlotID).LayerNum.CompareTo(
                        new ConfigCacheSet <PlotInfo>().FindKey(x.PlotID).LayerNum);
                    if (result == 0)
                    {
                        result = new ConfigCacheSet <PlotInfo>().FindKey(y.PlotID).PlotSeqNo.CompareTo(
                            new ConfigCacheSet <PlotInfo>().FindKey(x.PlotID).PlotSeqNo);
                    }
                    return(result);
                });
                plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(userPlotArray[0].PlotID);
            }
            return(plotInfo);
        }
Example #18
0
        public override bool TakeAction()
        {
            var plotTeam = new PlotTeamCombat(ContextUser);

            teamCombatResult = plotTeam.GetCombatProcess(teamID);
            teamPlot         = plotTeam.GetTeam(teamID);
            plotInfo         = new ConfigCacheSet <PlotInfo>().FindKey(plotID);

            if (teamCombatResult.IsWin)
            {
                //日常任务-多人副本
                TaskHelper.TriggerDailyTask(Uid, 4007);

                if (ContextUser.UserExtend != null && ContextUser.UserExtend.DailyInfo != null)
                {
                    if (ContextUser.UserExtend.DailyInfo.RefreshDate.Date == DateTime.Now.Date)
                    {
                        ContextUser.UserExtend.DailyInfo.MoreNum = MathUtils.Addition(ContextUser.UserExtend.DailyInfo.MoreNum, 1);
                    }
                    else
                    {
                        ContextUser.UserExtend.DailyInfo.RefreshDate = DateTime.Now;
                        ContextUser.UserExtend.DailyInfo.MoreNum     = 1;
                    }
                }
                else if (ContextUser.UserExtend != null)
                {
                    DailyRefresh dailyRefresh = new DailyRefresh();
                    dailyRefresh.RefreshDate         = DateTime.Now;
                    dailyRefresh.MoreNum             = 1;
                    ContextUser.UserExtend.DailyInfo = dailyRefresh;
                }
                //ContextUser.Update();
            }

            return(true);
        }
Example #19
0
        public override bool TakeAction()
        {
            ItemBaseInfo itemBaseInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(_materialsID);

            if (itemBaseInfo.ItemType == ItemType.CaiLiao)
            {
                //寻材料
                List <MonsterInfo> monsterArray = new ConfigCacheSet <MonsterInfo>().FindAll(m => m.ItemID == _materialsID);
                if (monsterArray.Count > 0)
                {
                    MonsterInfo monsterInfo   = monsterArray[0];
                    var         plotEmbattles = new ConfigCacheSet <PlotEmbattleInfo>().FindAll(m => m.MonsterID == monsterInfo.MonsterID);
                    foreach (var embattle in plotEmbattles)
                    {
                        PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(embattle.PlotNpcID);
                        if (npcInfo != null)
                        {
                            PlotInfo temp = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID);
                            if (temp != null && temp.CityID > CurrCityID(ContextUser.UserLv))
                            {
                                ErrorCode = LanguageManager.GetLang().ErrorCode;
                                ErrorInfo = LanguageManager.GetLang().St1604_MaterialsCityID;
                                return(false);
                            }
                            if (CheckPlot(temp))
                            {
                                _plotInfo = temp;
                                break;
                            }
                        }
                    }
                }
            }

            return(true);
        }
Example #20
0
        //// Печать с использованием класса PlotToFileConfig
        //private void MultiSheetPlot(string dir)
        //{
        //   Document doc = Application.DocumentManager.MdiActiveDocument;
        //   Database db = doc.Database;
        //   Application.Publisher.CancelledOrFailedPublishing += Publisher_CancelledOrFailedPublishing;
        //   using (var t = db.TransactionManager.StartTransaction())
        //   {
        //      var bt = (BlockTable)t.GetObject(db.BlockTableId, OpenMode.ForRead);
        //      if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
        //      {
        //         var layouts = new List<Layout>();
        //         DBDictionary layoutDict = (DBDictionary)db.LayoutDictionaryId.GetObject(OpenMode.ForRead);
        //         foreach (DBDictionaryEntry entry in layoutDict)
        //         {
        //            if (entry.Key != "Model")
        //               layouts.Add((Layout)t.GetObject(entry.Value, OpenMode.ForRead));
        //         }
        //         layouts.Sort((l1, l2) => l1.LayoutName.CompareTo(l2.LayoutName));
        //         //var layoutsToPlot = new ObjectIdCollection(layouts.Select(l => l.BlockTableRecordId).ToArray());
        //         Gile.Publish.MultiSheetsPdf gileMultiPdfPublish = new Gile.Publish.MultiSheetsPdf(dir, layouts);
        //         gileMultiPdfPublish.Publish();
        //      }
        //      else
        //      {
        //         throw new System.Exception("Другое задание на печать уже выполняется.");
        //      }
        //      t.Commit();
        //   }
        //}
        //Печать всех листов в текущем документе
        private void MultiSheetPlot(string title)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
             Database db = doc.Database;

             var layoutsToPlot = GetLayouts(db);

             using (var t = db.TransactionManager.StartTransaction())
             {
            var bt = (BlockTable)t.GetObject(db.BlockTableId, OpenMode.ForRead);
            var pi = new PlotInfo();
            var piv = new PlotInfoValidator();
            piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;

            if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
            {
               using (var pe = PlotFactory.CreatePublishEngine())
               {
                  using (var ppd = new PlotProgressDialog(false, layoutsToPlot.Count, false))
                  {
                     int numSheet = 1;
                     foreach (var item in layoutsToPlot)
                     {
                        var psv = PlotSettingsValidator.Current;
                        pi.Layout = item.Value;
                        LayoutManager.Current.CurrentLayout = item.Key;
                        piv.Validate(pi);

                        if (numSheet == 1)
                        {
                           ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, title);
                           ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Отмена");
                           ppd.set_PlotMsgString(PlotMessageIndex.MessageCanceling, "Отмена печати");
                           ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Печать листов");
                           ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Печать листа");
                           ppd.LowerPlotProgressRange = 0;
                           ppd.UpperPlotProgressRange = 100;
                           ppd.PlotProgressPos = 0;

                           ppd.OnBeginPlot();
                           ppd.IsVisible = true;
                           pe.BeginPlot(ppd, null);

                           string fileName = Path.Combine(Path.GetDirectoryName(doc.Name), Path.GetFileNameWithoutExtension(doc.Name) + ".pdf");
                           pe.BeginDocument(pi, doc.Name, null, 1, true, fileName);
                        }
                        ppd.OnBeginSheet();
                        ppd.SheetProgressPos = 0;

                        var ppi = new PlotPageInfo();
                        pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count), null);
                        pe.BeginGenerateGraphics(null);
                        ppd.SheetProgressPos = 50;
                        pe.EndGenerateGraphics(null);

                        pe.EndPage(null);
                        ppd.SheetProgressPos = 100;
                        ppd.OnEndSheet();
                        numSheet++;
                        ppd.PlotProgressPos += 100 / layoutsToPlot.Count;
                     }
                     pe.EndDocument(null);
                     ppd.PlotProgressPos = 100;
                     ppd.OnEndPlot();
                     pe.EndPlot(null);
                  }
               }
            }
            else
            {
               throw new System.Exception("Другое задание на печать уже выполняется.");
            }
            t.Commit();
             }
        }
Example #21
0
        public void QueryPaperSize()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            LayoutManager         layMgr   = LayoutManager.Current;
            PlotSettingsValidator plSetVdr = PlotSettingsValidator.Current;

            Dictionary <string, Point2d> customPaperSize = new Dictionary <string, Point2d>(StringComparer.CurrentCultureIgnoreCase);

            customPaperSize.Add("A4", new Point2d(210.0, 297.0));
            customPaperSize.Add("A3", new Point2d(297.0, 420.0));
            customPaperSize.Add("A2", new Point2d(420.0, 594.0));
            customPaperSize.Add("A1", new Point2d(594.0, 841.0));
            customPaperSize.Add("A0", new Point2d(841.0, 1189.0));
            customPaperSize.Add("A0Plus", new Point2d(841.0, 1480.0));
            customPaperSize.Add("A0+", new Point2d(841.0, 1470.0));
            customPaperSize.Add("GBKN", new Point2d(594.0, 1051.0));

            customPaperSize.Add("4Z", new Point2d(297.0, 750.0));
            customPaperSize.Add("5Z", new Point2d(297.0, 930.0));
            customPaperSize.Add("6Z", new Point2d(297.0, 1110.0));
            customPaperSize.Add("7Z", new Point2d(297.0, 1290.0));

            customPaperSize.Add("Z3", new Point2d(297.0, 594.0));
            customPaperSize.Add("Z4", new Point2d(297.0, 841.0));
            customPaperSize.Add("Z6", new Point2d(297.0, 1189.0));

            customPaperSize.Add("3A4", new Point2d(297.0, 630.0));
            customPaperSize.Add("4A4", new Point2d(297.0, 841.0));
            customPaperSize.Add("5A4", new Point2d(297.0, 1050.0));
            customPaperSize.Add("6A4", new Point2d(297.0, 1260.0));
            customPaperSize.Add("7A4", new Point2d(297.0, 1470.0));



            db.TileMode = false;        //goto Paperspace if not already
            ed.SwitchToPaperSpace();    //turn PVP off

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Layout theLayout = (Layout)tr.GetObject(layMgr.GetLayoutId(layMgr.CurrentLayout), OpenMode.ForWrite);

                // Get the PlotInfo from the layout
                PlotInfo plInfo = new PlotInfo();
                plInfo.Layout = theLayout.ObjectId;

                PlotSettings np = new PlotSettings(theLayout.ModelType);
                np.CopyFrom(theLayout);

                string devName = "DWG To PDF.pc3";  //OceTds600.pc3
                plSetVdr.SetPlotConfigurationName(np, devName, null);
                plSetVdr.RefreshLists(np);

                StringCollection canMedNames = plSetVdr.GetCanonicalMediaNameList(np);
                for (int i = 0; i < canMedNames.Count; i++)
                {
                    plSetVdr.SetCanonicalMediaName(np, canMedNames[i]);
                    plSetVdr.RefreshLists(np);
                    string medName = plSetVdr.GetLocaleMediaName(np, i);
                    //ed.WriteMessage("\n{0}: Can. MediaName={1}/{2}", i, np.CanonicalMediaName, medName);
                    if (medName.Equals("ISO A1 (841.00 x 594.00 MM)"))
                    {
                        ed.WriteMessage("\n{0}: Can. MediaName={1}/{2}", i, np.CanonicalMediaName, medName);
                        Point2d pSize = np.PlotPaperSize;
                        ed.WriteMessage("\n\tPaperSize={0}", pSize.ToString());
                        PlotRotation pRot = np.PlotRotation;
                        ed.WriteMessage("\n\tPlot Rotation={0}", pRot.ToString());
                        Extents2d pM = np.PlotPaperMargins;
                        ed.WriteMessage("\n\tPaper Margins={0}, {1}", pM.MinPoint.ToString(), pM.MaxPoint.ToString());
                    }
                }
            }
        }
Example #22
0
        //set up plotinfo
        static public PlotInfo plotSetUp(Extents2d window, Transaction tr, Database db, Editor ed, bool scaleToFit, bool pdfout)
        {
            using (tr)
            {
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
                // We need a PlotInfo object linked to the layout
                PlotInfo pi = new PlotInfo();
                pi.Layout = btr.LayoutId;

                //current layout
                Layout lo = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);

                // We need a PlotSettings object based on the layout settings which we then customize
                PlotSettings ps = new PlotSettings(lo.ModelType);
                ps.CopyFrom(lo);

                //The PlotSettingsValidator helps create a valid PlotSettings object
                PlotSettingsValidator psv = PlotSettingsValidator.Current;

                //set rotation
                psv.SetPlotRotation(ps, orientation(window)); //perhaps put orientation after window setting window??

                // We'll plot the window, centered, scaled, landscape rotation
                psv.SetPlotWindowArea(ps, window);
                psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Window);//breaks here on some drawings

                // Set the plot scale
                psv.SetUseStandardScale(ps, true);
                if (scaleToFit == true)
                {
                    psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
                }
                else
                {
                    psv.SetStdScaleType(ps, StdScaleType.StdScale1To1);
                }

                // Center the plot
                psv.SetPlotCentered(ps, true);//finding best location

                //get printerName from system settings
                PrinterSettings settings           = new PrinterSettings();
                string          defaultPrinterName = settings.PrinterName;

                psv.RefreshLists(ps);
                // Set Plot device & page size
                // if PDF set it up for some PDF plotter
                if (pdfout == true)
                {
                    psv.SetPlotConfigurationName(ps, "DWG to PDF.pc3", null);
                    var mns = psv.GetCanonicalMediaNameList(ps);
                    if (mns.Contains("ANSI_expand_A_(8.50_x_11.00_Inches)"))
                    {
                        psv.SetCanonicalMediaName(ps, "ANSI_expand_A_(8.50_x_11.00_Inches)");
                    }
                    else
                    {
                        string mediaName = setClosestMediaName(psv, ps, 8.5, 11, true);
                    }
                }
                else
                {
                    psv.SetPlotConfigurationName(ps, defaultPrinterName, null);
                    var mns = psv.GetCanonicalMediaNameList(ps);
                    if (mns.Contains("Letter"))
                    {
                        psv.SetCanonicalMediaName(ps, "Letter");
                    }
                    else
                    {
                        string mediaName = setClosestMediaName(psv, ps, 8.5, 11, true);
                    }
                }

                //rebuilts plotter, plot style, and canonical media lists
                //(must be called before setting the plot style)
                psv.RefreshLists(ps);

                //ps.ShadePlot = PlotSettingsShadePlotType.AsDisplayed;
                //ps.ShadePlotResLevel = ShadePlotResLevel.Normal;

                //plot options
                //ps.PrintLineweights = true;
                //ps.PlotTransparency = false;
                //ps.PlotPlotStyles = true;
                //ps.DrawViewportsFirst = true;
                //ps.CurrentStyleSheet

                // Use only on named layouts - Hide paperspace objects option
                // ps.PlotHidden = true;

                //psv.SetPlotRotation(ps, PlotRotation.Degrees180);


                //plot table needs to be the custom heavy lineweight for the Uphol specs
                psv.SetCurrentStyleSheet(ps, "monochrome.ctb");

                // We need to link the PlotInfo to the  PlotSettings and then validate it
                pi.OverrideSettings = ps;
                PlotInfoValidator piv = new PlotInfoValidator();
                piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                piv.Validate(pi);

                return(pi);
            }
        }
Example #23
0
        private void PlotResults(AutoResult oResult)
        {
            graphControl1.ZedControl.GraphPane.CurveList.Clear();
            var oRot = new ColorSymbolRotator();
            CurrentPlot = new List<PlotInfo>();

            foreach (AutoResultRun run in oResult.AllRuns)
            {
                var series = run.DataSeries;

                if (series.Count < 2) continue;

                if (series[0].Length < 10) continue;

                for (int i = 0; i < series.Count - 1; i++)
                {
                    var sLabel = GetNthName(i);
                    var oLineColor = oRot.NextColor;
                    var info = new PlotInfo {
                        Label = sLabel,
                        MainCurve = new PointPairList(series[0], series[i+1])
                    };

                    if (oResult.Positions.Count == 0)
                    {
                        AddNthCurveToGraph(i, series, sLabel, oLineColor);
                    }
                    else
                    {
                        var thickSegments = FindNthThickSegments(i, oResult, series);
                        AddNthSegmentedCurveToGraph(i, thickSegments, series, sLabel, oLineColor);
                        info.ThickSegments = thickSegments;
                    }
                    CurrentPlot.Add(info);
                }

                foreach (IntTripple tripple in oResult.Labels)
                {
                    for (int i = 0; i < series.Count - 1; i++)
                    {
                        int currentPos = UtilLib.FindClosestStablePoint(tripple.Key, oResult.Positions);

                        double x = series[0][currentPos];
                        double y = series[1 + i][currentPos];
                        var text = new TextObj(UtilLib.ConvertIntTypeToShortString(tripple.Value2), x, y);
                        text.Tag = new TagData {Series = 1 + i, Tripple = tripple, Label = GetNthName(i)};

                        graphControl1.ZedControl.GraphPane.GraphObjList.Add(text);
                    }
                }
            }

            graphControl1.ZedControl.GraphPane.XAxis.Scale.MaxGrace = 0f;
            graphControl1.ZedControl.GraphPane.XAxis.Scale.MinGrace = 0f;
            graphControl1.ZedControl.GraphPane.YAxis.Scale.MaxGrace = 0f;
            graphControl1.ZedControl.GraphPane.YAxis.Scale.MinGrace = 0f;

            SetParameterAxisTitle();

            graphControl1.ZedControl.AxisChange();
            tabControl1.Refresh();
        }
        public void PlotToPDF()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;


            //var filename = doc.Name.Split('.');
            
            var filePathArray = db.Filename.Split('\\');
            var filename = filePathArray[filePathArray.Length - 1].Split('.')[0];


            Transaction tr =
              db.TransactionManager.StartTransaction();
            using (tr)
            {

                // We'll be plotting the current layout

                Application.DocumentManager.MdiActiveDocument = doc;
                LayoutManager.Current.CurrentLayout = GetFirstLayout();

                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
                Layout lo = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);

                // We need a PlotInfo object
                // linked to the layout

                PlotInfo pi = new PlotInfo();
                pi.Layout = btr.LayoutId;

                // We need a PlotSettings object
                // based on the layout settings
                // which we then customize

                PlotSettings ps = new PlotSettings(lo.ModelType);
                ps.CopyFrom(lo);

                // The PlotSettingsValidator helps
                // create a valid PlotSettings object

                PlotSettingsValidator psv =
                  PlotSettingsValidator.Current;

                // We'll plot the extents, centered and
                // scaled to fit

                psv.SetPlotType(
                  ps,
                  Autodesk.AutoCAD.DatabaseServices.PlotType.Extents
                );
                psv.SetUseStandardScale(ps, true);
                psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
                psv.SetPlotCentered(ps, true);
                psv.RefreshLists(ps);
                psv.SetCurrentStyleSheet(lo, "C:\\ProgramData\\Autodesk\\ACA 2015\\enu\\Plotters\\Plot Styles\\COWI_EL-v00.ctb");

                // We'll use the standard DWF PC3, as
                // for today we're just plotting to file

                psv.SetPlotConfigurationName(
                  ps,
                  "DWG to PDF.pc3",
                  "ISO_A0_(841.00_x_1189.00_MM)"
                );

                // We need to link the PlotInfo to the
                // PlotSettings and then validate it

                pi.OverrideSettings = ps;
                PlotInfoValidator piv = new PlotInfoValidator();
                piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                piv.Validate(pi);

                // A PlotEngine does the actual plotting
                // (can also create one for Preview)

                if (PlotFactory.ProcessPlotState ==
                    ProcessPlotState.NotPlotting)
                {
                    PlotEngine pe = PlotFactory.CreatePublishEngine();
                    using (pe)
                    {
                        // Create a Progress Dialog to provide info
                        // and allow the user to cancel

                        PlotProgressDialog ppd = new PlotProgressDialog(true, 1, true);
                        using (ppd)
                        {
                            ppd.set_PlotMsgString(
                              PlotMessageIndex.DialogTitle,
                              "Custom Plot Progress"
                            );
                            ppd.set_PlotMsgString(
                              PlotMessageIndex.CancelJobButtonMessage,
                              "Cancel Job"
                            );
                            ppd.set_PlotMsgString(
                              PlotMessageIndex.CancelSheetButtonMessage,
                              "Cancel Sheet"
                            );
                            ppd.set_PlotMsgString(
                              PlotMessageIndex.SheetSetProgressCaption,
                              "Sheet Set Progress"
                            );
                            ppd.set_PlotMsgString(
                              PlotMessageIndex.SheetProgressCaption,
                              "Sheet Progress"
                            );
                            ppd.LowerPlotProgressRange = 0;
                            ppd.UpperPlotProgressRange = 100;
                            ppd.PlotProgressPos = 0;

                            // Let's start the plot, at last

                            ppd.OnBeginPlot();
                            ppd.IsVisible = true;
                            pe.BeginPlot(ppd, null);

                            // We'll be plotting a single document

                            pe.BeginDocument(
                              pi,
                              doc.Name,
                              null,
                              1,
                              true, // Let's plot to file
                              "E:\\Plottfefiløving\\PDF\\" + filename + ".pdf"
                            );

                            // Which contains a single sheet

                            ppd.OnBeginSheet();

                            ppd.LowerSheetProgressRange = 0;
                            ppd.UpperSheetProgressRange = 100;
                            ppd.SheetProgressPos = 0;

                            PlotPageInfo ppi = new PlotPageInfo();
                            pe.BeginPage(
                              ppi,
                              pi,
                              true,
                              null
                            );
                            pe.BeginGenerateGraphics(null);
                            pe.EndGenerateGraphics(null);

                            // Finish the sheet
                            pe.EndPage(null);
                            ppd.SheetProgressPos = 100;
                            ppd.OnEndSheet();

                            // Finish the document

                            pe.EndDocument(null);

                            // And finish the plot

                            ppd.PlotProgressPos = 100;
                            ppd.OnEndPlot();
                            pe.EndPlot(null);
                        }
                    }
                }
                else
                {
                    ed.WriteMessage(
                      "\nAnother plot is in progress."
                    );
                }
            }
        }
Example #25
0
        // A PlotEngine does the actual plotting
        // (can also create one for Preview)
        //***NOTE- always be sure that back ground plotting is off, in code and the users computer.
        static void plotEngine(PlotInfo pi, string name, Document doc, Editor ed, bool pdfout)
        {
            if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
            {
                PlotEngine pe = PlotFactory.CreatePublishEngine();
                using (pe)
                {
                    // Create a Progress Dialog to provide info or allow the user to cancel
                    PlotProgressDialog ppd = new PlotProgressDialog(false, 1, true);
                    using (ppd)
                    {
                        ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Custom Plot Progress");
                        ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job");
                        ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet");
                        ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress");
                        ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress");
                        ppd.LowerPlotProgressRange = 0;
                        ppd.UpperPlotProgressRange = 100;
                        ppd.PlotProgressPos        = 0;

                        // Let's start the plot, at last
                        ppd.OnBeginPlot();
                        ppd.IsVisible = true;
                        pe.BeginPlot(ppd, null);

                        // We'll be plotting a single document
                        //name should be file location + prompeted answer
                        string fileLoc = Path.GetDirectoryName(doc.Name);
                        pe.BeginDocument(pi, doc.Name, null, 1, pdfout, fileLoc + @"\" + name);

                        // Which contains a single sheet
                        ppd.OnBeginSheet();
                        ppd.LowerSheetProgressRange = 0;
                        ppd.UpperSheetProgressRange = 100;
                        ppd.SheetProgressPos        = 0;

                        PlotPageInfo ppi = new PlotPageInfo();
                        pe.BeginPage(ppi, pi, true, null);
                        pe.BeginGenerateGraphics(null);
                        pe.EndGenerateGraphics(null);

                        // Finish the sheet
                        pe.EndPage(null);
                        ppd.SheetProgressPos = 100;
                        ppd.OnEndSheet();

                        // Finish the document
                        pe.EndDocument(null);

                        // And finish the plot
                        ppd.PlotProgressPos = 100;
                        ppd.OnEndPlot();
                        pe.EndPlot(null);
                    }
                }
            }

            else
            {
                ed.WriteMessage("\nAnother plot is in progress.");
            }
        }
Example #26
0
        /// <summary>
        /// 天地劫副本层数
        /// </summary>
        /// <param name="user"></param>
        public static int CheckUserPlotLayerNum(GameUser user)
        {
            int      layerNum = 0;
            PlotInfo plotInfo = CheckUserPlotKalpa(user);

            if (user != null && plotInfo != null)
            {
                //最高层
                if (user.UserExtend != null)
                {
                    //修改:当前层大于最大层数时更新
                    if (user.UserExtend.MaxLayerNum < plotInfo.LayerNum)
                    {
                        user.UserExtend.UpdateNotify(obj =>
                        {
                            user.UserExtend.MaxLayerNum = plotInfo.LayerNum;
                            return(true);
                        });
                        //user.Update();
                    }
                }
                //当前层
                if (user.UserExtend != null && user.UserExtend.LayerNum > 0)
                {
                    UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(user.UserID);
                    if (dailyRestrain != null && dailyRestrain.UserExtend != null && dailyRestrain.UserExtend.LastKalpaNum > 0)
                    {
                        layerNum = user.UserExtend.LayerNum;
                    }
                    else
                    {
                        layerNum = plotInfo.LayerNum;
                        user.UserExtend.UpdateNotify(obj =>
                        {
                            user.UserExtend.LayerNum = layerNum;
                            return(true);
                        });
                        //user.Update();
                    }
                }
                else
                {
                    layerNum = plotInfo.LayerNum;
                    if (user.UserExtend == null)
                    {
                        user.UserExtend = new GameUserExtend();
                    }
                    user.UserExtend.UpdateNotify(obj =>
                    {
                        user.UserExtend.LayerNum = layerNum;
                        return(true);
                    });
                    //user.Update();
                }
            }
            else
            {
                layerNum = 1;
            }
            return(layerNum);
        }
Example #27
0
        /// <summary>
        /// 创建布局和视口
        ///
        /// </summary>
        public static void CreateLayout(double[] B_Sta, Document doc, Database db)
        {
            //  var doc = Application.DocumentManager.MdiActiveDocument;

            if (doc == null)
            {
                return;
            }
            // var db = doc.Database;
            var ed     = doc.Editor;
            var ext    = new Extents2d();
            int k      = 0;// 100000 / 2600 / 3
            int zhushi = 0;
            //求布局数
            double Layoutnum = (B_Sta[B_Sta.Length - 1] - B_Sta[0]) / 350 / 3;

            for (int j = 0; j < Layoutnum + 1; j++)
            {
                using (var tr = db.TransactionManager.StartTransaction())
                {
                    //以读模式打开块表
                    BlockTable acBlkTbl;
                    acBlkTbl = tr.GetObject(db.BlockTableId,
                                            OpenMode.ForRead) as BlockTable;
                    //以写模式打开块表记录Paper空间
                    BlockTableRecord acBlkTblRec;
                    acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.PaperSpace],
                                               OpenMode.ForWrite) as BlockTableRecord;
                    //切换到Paper空间布局
                    Application.SetSystemVariable("TILEMODE", 0);
                    doc.Editor.SwitchToPaperSpace();

                    // Create and select a new layout tab
                    var id = LayoutManager.Current.CreateAndMakeLayoutCurrent("病害处理" + j);
                    // Open the created layout
                    var lay = (Layout)tr.GetObject(id, OpenMode.ForWrite);
                    // Make some settings on the layout and get its extents

                    /*     lay.SetPlotSettings(
                     *   //  "ISO_full_bleed_2A0_(1189.00_x_1682.00_MM)", // Try this big boy!
                     *     "ANSI_B_(11.00_x_17.00_Inches)",
                     *     "monochrome.ctb",
                     *     "DWF6 ePlot.pc3");*/
                    //从布局中获取PlotInfo
                    PlotInfo acPlInfo = new PlotInfo();
                    acPlInfo.Layout = lay.ObjectId;
                    //复制布局中的PlotSettings
                    PlotSettings acPlSet = new PlotSettings(lay.ModelType);
                    acPlSet.CopyFrom(lay);
                    //更新PlotSettings对象
                    PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                    //设置打印区域
                    acPlSetVdr.SetPlotType(acPlSet,
                                           Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
                    //设置打印比例
                    acPlSetVdr.SetUseStandardScale(acPlSet, true);
                    acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);
                    //居中打印
                    acPlSetVdr.SetPlotCentered(acPlSet, true);
                    ext = lay.GetMaximumExtents();
                    //绘制边框
                    //Create a polyline with two segments (3 points)
                    using (Autodesk.AutoCAD.DatabaseServices.Polyline acPoly = new Autodesk.AutoCAD.DatabaseServices.Polyline())

                    {
                        acPoly.AddVertexAt(0, new Point2d(0.2, 0.7), 0, 0, 0);
                        acPoly.AddVertexAt(1, new Point2d(0.2, ext.MaxPoint.Y - 0.3), 0, 0, 0);
                        acPoly.AddVertexAt(2, new Point2d(ext.MaxPoint.X - 0.13, ext.MaxPoint.Y - 0.3), 0, 0, 0);
                        acPoly.AddVertexAt(3, new Point2d(ext.MaxPoint.X - 0.13, 0.7), 0, 0, 0);
                        acPoly.AddVertexAt(4, new Point2d(0.2, 0.7), 0, 0, 0);
                        acPoly.LineWeight = LineWeight.LineWeight200;
                        //将新对象添加到块表记录和事务
                        acBlkTblRec.AppendEntity(acPoly);
                        tr.AddNewlyCreatedDBObject(acPoly, true);
                    }
                    //创建下方直线分隔
                    double[] Xiafangzuobiao = new double[] { 1.5, 4, 7, 7.5, 8.1, 8.6, 9.2, 9.7, 10.3, 10.8 };
                    for (int i = 0; i < Xiafangzuobiao.Length; i++)
                    {
                        WxxTU.Createline(acBlkTblRec, tr, Xiafangzuobiao[i], Xiafangzuobiao[i], 0.7, 1);
                    }
                    //创建下方需要填写的文字
                    string[] Xiafangwenzi        = new string[] { "路面病害处治设计图", "设计", "复核", "审核", "图号" };
                    double[] Xiafangwenzizuobiao = new double[] { 4.5, 7, 8.15, 9.2, 10.4 };
                    for (int i = 0; i < Xiafangwenzi.Length; i++)
                    {
                        //创建一个单行文字对象
                        using (DBText acText = new DBText())
                        {
                            acText.Position = new Point3d(Xiafangwenzizuobiao[i], 0.8, 0);
                            acText.Height   = 0.15;

                            acText.TextString = Xiafangwenzi[i];
                            acText.ColorIndex = 0;
                            //文字反向   acText.IsMirroredInX = false;
                            acText.Rotation = 0;
                            acBlkTblRec.AppendEntity(acText);
                            tr.AddNewlyCreatedDBObject(acText, true);


                            //释放DBObject对象
                        }
                    }
                    //创建上方直线分割
                    double[] Shangfangzuobiao = new double[] { 10, 10.8 };
                    for (int i = 0; i < Shangfangzuobiao.Length; i++)
                    {
                        WxxTU.Createline(acBlkTblRec, tr, Shangfangzuobiao[i], Shangfangzuobiao[i], ext.MaxPoint.Y - 0.3, ext.MaxPoint.Y - 0.65);
                    }
                    //创建上方需要填写的文字
                    string[] Shangfangwenzi = new string[] { "第" + j + "页", "共" + Math.Truncate(Layoutnum) + "页" };
                    for (int i = 0; i < Shangfangwenzi.Length; i++)
                    {
                        //创建一个单行文字对象
                        using (DBText acText = new DBText())
                        {
                            acText.Position = new Point3d(Shangfangzuobiao[i], ext.MaxPoint.Y - 0.5, 0);
                            acText.Height   = 0.15;

                            acText.TextString = Shangfangwenzi[i];
                            acText.ColorIndex = 0;
                            //文字反向   acText.IsMirroredInX = false;
                            acText.Rotation = 0;
                            acBlkTblRec.AppendEntity(acText);
                            tr.AddNewlyCreatedDBObject(acText, true);


                            //释放DBObject对象
                        }
                    }
                    //创建桩号起终点注释
                    double[] Sta_Y = new double[] { 2.75, 5, 7.1 };
                    for (int i = 0; i < 3; i++)
                    {
                        using (DBText acText = new DBText())
                        {
                            acText.Position = new Point3d(9, Sta_Y[i], 0);
                            acText.Height   = 0.15;

                            acText.TextString = WxxTU.Station_Double2Str(B_Sta[0] + 350 * (zhushi - 3)) + "-" + WxxTU.Station_Double2Str(B_Sta[0] + 350 * (zhushi - 2));
                            acText.ColorIndex = 0;
                            //文字反向   acText.IsMirroredInX = false;
                            acText.Rotation = 0;
                            acBlkTblRec.AppendEntity(acText);
                            tr.AddNewlyCreatedDBObject(acText, true);
                            zhushi++;

                            //释放DBObject对象
                        }
                    }

                    //创建多个视口
                    for (int i = 0; i < 3; i++)
                    {
                        lay.ApplyToViewport(
                            tr, i,
                            vp =>
                        {
                            // Size the viewport according to the extents calculated when
                            // we set the PlotSettings (device, page size, etc.)
                            // Use the standard 10% margin around the viewport
                            // (found by measuring pixels on screenshots of Layout1, etc.)

                            vp.ResizeViewport(ext, 0.8, 2 * i + 1, k);
                            k++;

                            /* // Adjust the view so that the model contents fit
                             * if (ValidDbExtents(db.Extmin, db.Extmax))
                             * {
                             *   vp.FitContentToViewport(new Extents3d(db.Extmin, db.Extmax),0.8);
                             * }
                             *
                             * // Finally we lock the view to prevent meddling*/


                            vp.Locked = true;
                        }
                            );
                    }
                    //  k++;

                    // Commit the transaction
                    tr.Commit();
                }
            }
            // Zoom so that we can see our new layout, again with a little padding

            /*    ed.Command("_.ZOOM", "_E");
             *  ed.Command("_.ZOOM", ".7X");
             *  ed.Regen();*/
        }
Example #28
0
        public void PlotToPDF(CptPlotOptions options, string path, string title)
        {
            try
            {
                Application.SetSystemVariable("BACKGROUNDPLOT", 0);
                using (var pi = new PlotInfo())
                {
                    pi.Layout = layout.ObjectId;
                    using (var ps = new PlotSettings(layout.ModelType))
                    {
                        ps.CopyFrom(layout);
                        var psv = PlotSettingsValidator.Current;

                        var minpt = options.PlotWindowArea.MinPoint.TransformByTarget();
                        var maxpt = options.PlotWindowArea.MaxPoint.TransformByTarget();

                        psv.SetPlotConfigurationName(ps, plotConfig, options.CanonicalMediaName);
                        psv.SetCurrentStyleSheet(ps, options.CurrentStyleSheet);
                        psv.SetPlotWindowArea(ps, new Extents2d(minpt, maxpt));
                        psv.SetPlotType(ps, PlotType.Window);
                        psv.SetPlotCentered(ps, true);
                        psv.SetPlotPaperUnits(ps, PlotPaperUnit.Millimeters);
                        psv.SetPlotRotation(ps, options.PlotRotation);
                        if (options.ScaleToFit)
                        {
                            psv.SetUseStandardScale(ps, true);
                            psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
                        }
                        else
                        {
                            psv.SetUseStandardScale(ps, false);
                            psv.SetCustomPrintScale(ps, options.CustomPrintScale);
                        }
                        pi.OverrideSettings = ps;
                        using (var piv = new PlotInfoValidator())
                        {
                            piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                            piv.Validate(pi);
                            using (var pe = PlotFactory.CreatePublishEngine())
                            {
                                using (var ppd = new PlotProgressDialog(false, 1, false))
                                {
                                    using (var ppi = new PlotPageInfo())
                                    {
                                        ppd.LowerPlotProgressRange = 0;
                                        ppd.UpperPlotProgressRange = 100;
                                        ppd.PlotProgressPos        = 0;
                                        ppd.OnBeginPlot();
                                        ppd.IsVisible = true;

                                        pe.BeginPlot(ppd, null);
                                        pe.BeginDocument(pi, layout.Database.OriginalFileName, null, 1, true, path);

                                        ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, title);
                                        ppd.OnBeginSheet();
                                        ppd.LowerSheetProgressRange = 0;
                                        ppd.UpperSheetProgressRange = 100;
                                        ppd.SheetProgressPos        = 0;

                                        pe.BeginPage(ppi, pi, true, null);
                                        pe.BeginGenerateGraphics(null);
                                        ppd.SheetProgressPos = 99;
                                        pe.EndGenerateGraphics(null);

                                        pe.EndPage(null);
                                        ppd.SheetProgressPos = 100;
                                        ppd.OnEndSheet();

                                        pe.EndDocument(null);

                                        ppd.PlotProgressPos = 100;
                                        ppd.OnEndPlot();
                                        pe.EndPlot(null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Application.SetSystemVariable("BACKGROUNDPLOT", defaultbkpltVar);
            }
        }
Example #29
0
        public void PlotToPDF(string filePath)
        {
            if (File.Exists(filePath))
            {
                Application.ShowAlertDialog("File already exists");
                return;
            }

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            Database db  = doc.Database;



            Transaction tr =
                db.TransactionManager.StartTransaction();

            using (tr)
            {
                // We'll be plotting the current layout

                Application.DocumentManager.MdiActiveDocument = doc;
                LayoutManager.Current.CurrentLayout           = GetFirstLayout();

                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
                Layout           lo  = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);

                // We need a PlotInfo object
                // linked to the layout

                PlotInfo pi = new PlotInfo();
                pi.Layout = btr.LayoutId;

                // We need a PlotSettings object
                // based on the layout settings
                // which we then customize

                PlotSettings ps = new PlotSettings(lo.ModelType);
                ps.CopyFrom(lo);

                // The PlotSettingsValidator helps
                // create a valid PlotSettings object

                PlotSettingsValidator psv =
                    PlotSettingsValidator.Current;

                // We'll plot the extents, centered and
                // scaled to fit

                psv.SetPlotType(
                    ps,
                    Autodesk.AutoCAD.DatabaseServices.PlotType.Extents
                    );
                psv.SetUseStandardScale(ps, true);
                psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
                psv.SetPlotCentered(ps, true);
                psv.RefreshLists(ps);
                //psv.SetCurrentStyleSheet(lo, "E:\\Plottefil\\COWI_EL-v00.ctb");

                // We'll use the standard DWF PC3, as
                // for today we're just plotting to file

                psv.SetPlotConfigurationName(
                    ps,
                    "DWG to PDF.pc3",
                    "ISO_A0_(841.00_x_1189.00_MM)"
                    );

                // We need to link the PlotInfo to the
                // PlotSettings and then validate it

                pi.OverrideSettings = ps;
                PlotInfoValidator piv = new PlotInfoValidator();
                piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                piv.Validate(pi);

                // A PlotEngine does the actual plotting
                // (can also create one for Preview)

                if (PlotFactory.ProcessPlotState ==
                    ProcessPlotState.NotPlotting)
                {
                    PlotEngine pe = PlotFactory.CreatePublishEngine();
                    using (pe)
                    {
                        // Create a Progress Dialog to provide info
                        // and allow the user to cancel

                        PlotProgressDialog ppd = new PlotProgressDialog(true, 1, true);
                        using (ppd)
                        {
                            ppd.set_PlotMsgString(
                                PlotMessageIndex.DialogTitle,
                                "Custom Plot Progress"
                                );
                            ppd.set_PlotMsgString(
                                PlotMessageIndex.CancelJobButtonMessage,
                                "Cancel Job"
                                );
                            ppd.set_PlotMsgString(
                                PlotMessageIndex.CancelSheetButtonMessage,
                                "Cancel Sheet"
                                );
                            ppd.set_PlotMsgString(
                                PlotMessageIndex.SheetSetProgressCaption,
                                "Sheet Set Progress"
                                );
                            ppd.set_PlotMsgString(
                                PlotMessageIndex.SheetProgressCaption,
                                "Sheet Progress"
                                );
                            ppd.LowerPlotProgressRange = 0;
                            ppd.UpperPlotProgressRange = 100;
                            ppd.PlotProgressPos        = 0;

                            // Let's start the plot, at last

                            ppd.OnBeginPlot();
                            ppd.IsVisible = true;
                            pe.BeginPlot(ppd, null);

                            // We'll be plotting a single document


                            pe.BeginDocument(
                                pi,
                                doc.Name,
                                null,
                                1,
                                true, // Let's plot to file
                                filePath);

                            // Which contains a single sheet

                            ppd.OnBeginSheet();

                            ppd.LowerSheetProgressRange = 0;
                            ppd.UpperSheetProgressRange = 100;
                            ppd.SheetProgressPos        = 0;

                            PlotPageInfo ppi = new PlotPageInfo();
                            pe.BeginPage(
                                ppi,
                                pi,
                                true,
                                null
                                );
                            pe.BeginGenerateGraphics(null);
                            pe.EndGenerateGraphics(null);

                            // Finish the sheet
                            pe.EndPage(null);
                            ppd.SheetProgressPos = 100;
                            ppd.OnEndSheet();

                            // Finish the document

                            pe.EndDocument(null);

                            // And finish the plot

                            ppd.PlotProgressPos = 100;
                            ppd.OnEndPlot();
                            pe.EndPlot(null);
                        }
                    }
                }
                else
                {
                    ed.WriteMessage(
                        "\nAnother plot is in progress."
                        );
                }
            }
        }
Example #30
0
        public void SetLayoutPlotSetting()
        {
            Document       acDoc          = Application.DocumentManager.MdiActiveDocument;
            Database       acCurDb        = acDoc.Database;
            StandartCopier standartCopier = new StandartCopier();

            PlotConfigManager.SetCurrentConfig(standartCopier.Pc3Location);

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                Layout acLayout;

                LayoutModels = LayoutModels.OrderBy(x => x.Layout.TabOrder).ToList();

                foreach (var layout in LayoutModels)
                {
                    acLayout = acTrans.GetObject(layout.LayoutPlotId,
                                                 OpenMode.ForRead) as Layout;

                    if (acLayout == null)
                    {
                        continue;
                    }

                    LayoutManager lm = LayoutManager.Current;
                    lm.CurrentLayout = acLayout.LayoutName;

                    var plotArea = acLayout.Extents;
                    // Output the name of the current layout and its device
                    acDoc.Editor.WriteMessage("\nCurrent layout: " +
                                              acLayout.LayoutName);

                    acDoc.Editor.WriteMessage("\nCurrent device name: " +
                                              acLayout.PlotConfigurationName);

                    // Get the PlotInfo from the layout
                    PlotInfo acPlInfo = new PlotInfo();
                    acPlInfo.Layout = acLayout.ObjectId;

                    // Get a copy of the PlotSettings from the layout
                    PlotSettings acPlSet = new PlotSettings(acLayout.ModelType);
                    acPlSet.CopyFrom(acLayout);

                    // Update the PlotConfigurationName property of the PlotSettings object
                    PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                    //acPlSetVdr.SetCurrentStyleSheet(acPlSet, "monochrome.ctb");
                    bool isHor = layout.PrintModel.IsFormatHorizontal();

                    acPlSetVdr.SetPlotType(acPlSet, PlotType.Extents);
                    acPlSetVdr.SetPlotRotation(acPlSet, isHor ? PlotRotation.Degrees000 : PlotRotation.Degrees090);
                    acPlSetVdr.SetPlotWindowArea(acPlSet, Get2dExtentsFrom3d(plotArea));
                    acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);

                    // Center the plot
                    acPlSetVdr.SetPlotCentered(acPlSet, true);

                    acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG_To_PDF_Uzle.pc3",
                                                        layout.CanonicalName);
                    acPlSetVdr.SetZoomToPaperOnUpdate(acPlSet, true);
                    // Update the layout
                    acLayout.UpgradeOpen();
                    acLayout.CopyFrom(acPlSet);

                    // Output the name of the new device assigned to the layout
                    acDoc.Editor.WriteMessage("\nNew device name: " +
                                              acLayout.PlotConfigurationName);

                    Active.Editor.Regen();
                }

                // Save the new objects to the database
                acTrans.Commit();
            }
        }
Example #31
0
        public static void ChangePlotSetting()
        {
            // Get the current document and database, and start a transaction
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Reference the Layout Manager
                LayoutManager acLayoutMgr;
                acLayoutMgr = LayoutManager.Current;

                // Get the current layout and output its name in the Command Line window
                Layout acLayout;

                LayoutModelCollection layoutModelCollection = new LayoutModelCollection();
                layoutModelCollection.ListLayouts("Model");
                var layouts = layoutModelCollection.LayoutModels.OrderBy(x => x.Layout.TabOrder).ToList();

                foreach (var layout in layouts)
                {
                    acLayout = acTrans.GetObject(layout.LayoutPlotId,
                                                 OpenMode.ForRead) as Layout;
                    if (acLayout != null)
                    {
                        // Output the name of the current layout and its device
                        acDoc.Editor.WriteMessage("\nCurrent layout: " +
                                                  acLayout.LayoutName);

                        acDoc.Editor.WriteMessage("\nCurrent device name: " +
                                                  acLayout.PlotConfigurationName);

                        // Get the PlotInfo from the layout
                        PlotInfo acPlInfo = new PlotInfo();
                        acPlInfo.Layout = acLayout.ObjectId;

                        // Get a copy of the PlotSettings from the layout
                        PlotSettings acPlSet = new PlotSettings(acLayout.ModelType);
                        acPlSet.CopyFrom(acLayout);

                        // Update the PlotConfigurationName property of the PlotSettings object
                        PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                        acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG_To_PDF_Uzle.pc3",
                                                            "UserDefinedMetric (891.00 x 420.00мм)");

                        acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);
                        // Center the plot
                        //acPlSetVdr.SetPlotCentered(acPlSet, true);

                        // Update the layout
                        acLayout.UpgradeOpen();
                        acLayout.CopyFrom(acPlSet);

                        // Output the name of the new device assigned to the layout
                        acDoc.Editor.WriteMessage("\nNew device name: " +
                                                  acLayout.PlotConfigurationName);
                    }
                }

                // Save the new objects to the database
                acTrans.Commit();
            }
        }
Example #32
0
 public override void Write()
 {
     _worldPacket.WriteInt32((int)GarrTypeID);
     PlotInfo.Write(_worldPacket);
 }
Example #33
0
        public override bool TakeAction()
        {
            List <PlotNPCInfo> plotNPCInfoList = new ConfigCacheSet <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);

            npcCount = (short)plotNPCInfoList.Count;
            var cacheSet = new GameDataCacheSet <UserQueue>();
            List <UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            if (userQueueList.Count > 0)
            {
                UserQueue userQueue = userQueueList[0];
                coldTime = userQueue.DoRefresh();
                if (coldTime == 0)
                {
                    cacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                int tempNum = PlotHelper.GetBattleNum(userQueue.GetTiming()) + 1;
                if (npcCount > 0)
                {
                    turnsNum = PlotHelper.GetTurnsNum(npcCount, tempNum);
                    timesNum = PlotHelper.GetTimesNum(npcCount, tempNum);
                }
                //PlotHelper.CheckSweepCount(npcCount, userQueue.GetTiming(), out turnsNum, out battleNum);

                //if (battleNum >= npcCount)
                //{
                //    turnsNum = turnsNum + 1;
                //}
                //else
                //{
                //    battleNum = battleNum + 1;
                //}
            }
            userItemCount = (short)UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao).Count;
            plotInfo      = new ConfigCacheSet <PlotInfo>().FindKey(plotID);
            if (plotInfo == null)
            {
                return(false);
            }
            foreach (PlotNPCInfo npcInfo in plotNPCInfoList)
            {
                if (npcInfo == null)
                {
                    continue;
                }
                List <PlotEmbattleInfo> embattleInfoList = new ConfigCacheSet <PlotEmbattleInfo>().FindAll(m => m.PlotNpcID == npcInfo.PlotNpcID);
                foreach (PlotEmbattleInfo embattleInfo in embattleInfoList)
                {
                    if (monsterDict.ContainsKey(embattleInfo.MonsterID))
                    {
                        if (monsterNumDict.ContainsKey(embattleInfo.MonsterID))
                        {
                            monsterNumDict[embattleInfo.MonsterID] = monsterNumDict[embattleInfo.MonsterID] + 1;
                        }
                    }
                    else
                    {
                        MonsterInfo monsterInfo = new ConfigCacheSet <MonsterInfo>().FindKey(embattleInfo.MonsterID);
                        if (monsterInfo != null)
                        {
                            monsterDict.Add(embattleInfo.MonsterID, monsterInfo);
                            monsterNumDict.Add(embattleInfo.MonsterID, 1);
                        }
                    }
                }
            }
            return(true);
        }
Example #34
0
        //打印模型布局的范围
        //打印到DWF文件

        //[CommandMethod("PlotCurrentLayout")]
        /// <summary>
        /// 打印输出单个文件
        /// </summary>
        /// <param name="LayerName"></param>
        /// <param name="FileName"></param>
        /// <param name="outputFilePath"></param>
        /// <param name="printer"></param>
        /// <param name="paperFormat"></param>
        public static void PlotCurrentLayout(string LayerName, string FileName, string outputFilePath, string printer, string paperFormat)
        {
            // 获取当前文档和数据库,启动事务
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            Editor   ed      = acDoc.Editor;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // 获取图层
                LayerTable acLyrTbl;
                acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId, OpenMode.ForRead) as LayerTable;

                // 将活动图层修改为第一个,即图层0
                acCurDb.Clayer = acLyrTbl[LayerName];
                LayerTableRecord acLayerTblRec = acTrans.GetObject(acLyrTbl[LayerName], OpenMode.ForWrite) as LayerTableRecord;
                acLayerTblRec.IsOff = false; //显示该图层

                // 引用布局管理器LayoutManager
                LayoutManager acLayoutMgr;
                acLayoutMgr = LayoutManager.Current;

                // 获取当前布局,在命令行窗口显示布局名字
                Layout acLayout;
                acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout),
                                             OpenMode.ForRead) as Layout;

                // 从布局中获取PlotInfo
                PlotInfo acPlInfo = new PlotInfo();
                acPlInfo.Layout = acLayout.ObjectId;

                // 复制布局中的PlotSettings
                PlotSettings acPlSet = new PlotSettings(acLayout.ModelType);
                acPlSet.CopyFrom(acLayout);

                // 更新PlotSettings对象
                PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;

                //// 获取打印设备
                //StringCollection deviceList = acPlSetVdr.GetPlotDeviceList();

                //// 打印设备列表-MessageBox形式
                //foreach (string d in deviceList)
                //{
                //    ed.WriteMessage("打印设备:" + d + "\n");
                //}

                //// 获取纸张列表
                //StringCollection mediaList = acPlSetVdr.GetCanonicalMediaNameList(acPlSet);

                //ed.WriteMessage("图纸种类:" + Convert.ToString(mediaList.Count) + " 个\n");
                //foreach (string m in mediaList)
                //{
                //    ed.WriteMessage("打印图纸:" + m + "\n");
                //}

                // 设置打印区域
                acPlSetVdr.SetPlotType(acPlSet,
                                       Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);

                // 设置打印比例
                acPlSetVdr.SetUseStandardScale(acPlSet, true);
                acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.ScaleToFit);

                // 居中打印
                acPlSetVdr.SetPlotCentered(acPlSet, true);

                // 设置使用的打印设备
                //acPlSetVdr.SetPlotConfigurationName(acPlSet, "PostScript Level 2.pc3",
                //"ANSI_A_(8.50_x_11.00_Inches)");
                //设置采用的打印设备与纸张格式
                acPlSetVdr.SetPlotConfigurationName(acPlSet, printer,
                                                    paperFormat);


                // 用上述设置信息覆盖PlotInfo对象,
                // 不会将修改保存回布局
                acPlInfo.OverrideSettings = acPlSet;

                // 验证打印信息
                PlotInfoValidator acPlInfoVdr = new PlotInfoValidator();
                acPlInfoVdr.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                acPlInfoVdr.Validate(acPlInfo);

                // 检查是否有正在处理的打印任务
                if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
                {
                    using (PlotEngine acPlEng = PlotFactory.CreatePublishEngine())
                    {
                        // 使用PlotProgressDialog对话框跟踪打印进度
                        PlotProgressDialog acPlProgDlg = new PlotProgressDialog(false,
                                                                                1,
                                                                                true);

                        using (acPlProgDlg)
                        {
                            // 定义打印开始时显示的状态信息
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.DialogTitle,
                                                          "Plot Progress");
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage,
                                                          "Cancel Job");
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage,
                                                          "Cancel Sheet");
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption,
                                                          "Sheet Set Progress");
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption,
                                                          "Sheet Progress");

                            // 设置打印进度范围
                            acPlProgDlg.LowerPlotProgressRange = 0;
                            acPlProgDlg.UpperPlotProgressRange = 100;
                            acPlProgDlg.PlotProgressPos        = 0;

                            // 显示打印进度对话框
                            acPlProgDlg.OnBeginPlot();
                            acPlProgDlg.IsVisible = true;

                            // 开始打印
                            acPlEng.BeginPlot(acPlProgDlg, null);

                            string opFile = outputFilePath + LayerName;
                            // 定义打印输出
                            acPlEng.BeginDocument(acPlInfo,
                                                  acDoc.Name,
                                                  null,
                                                  1,
                                                  true,
                                                  opFile);

                            // 显示当前打印任务的有关信息
                            //acPlProgDlg.set_PlotMsgString(PlotMessageIndex.Status,
                            //                              "Plotting: " + acDoc.Name + " - " +
                            //                              acLayout.LayoutName);
                            acPlProgDlg.set_PlotMsgString(PlotMessageIndex.Status,
                                                          "Plotting: " + acDoc.Name + " - " +
                                                          LayerName);

                            // 设置图纸进度范围
                            acPlProgDlg.OnBeginSheet();
                            acPlProgDlg.LowerSheetProgressRange = 0;
                            acPlProgDlg.UpperSheetProgressRange = 100;
                            acPlProgDlg.SheetProgressPos        = 0;

                            // 打印第一张图/布局
                            PlotPageInfo acPlPageInfo = new PlotPageInfo();
                            acPlEng.BeginPage(acPlPageInfo,
                                              acPlInfo,
                                              true,
                                              null);

                            acPlEng.BeginGenerateGraphics(null);
                            acPlEng.EndGenerateGraphics(null);

                            // 结束第一张图/布局的打印
                            acPlEng.EndPage(null);
                            acPlProgDlg.SheetProgressPos = 100;
                            acPlProgDlg.OnEndSheet();

                            // 结束文档局的打印
                            acPlEng.EndDocument(null);

                            // 打印结束
                            acPlProgDlg.PlotProgressPos = 100;
                            acPlProgDlg.OnEndPlot();
                            acPlEng.EndPlot(null);
                        }
                    }
                }


                acLayerTblRec.IsOff = true; //关闭该图层
                printFlag           = true;
                //ed.WriteMessage("打印完成 \n");
            }
        }