Esempio n. 1
0
 private void DrawLineObject(LineObject lineObject)
 {
     if (lineObject.Width == 0 || lineObject.Height == 0)
     {
         int d      = FFrames ? 1 : 0;
         int curx   = (int)Math.Round(lineObject.AbsLeft * FScaleX * XDivAdv) + d;
         int cury   = (int)Math.Round(lineObject.AbsTop * YDivAdv * FScaleY) + d;
         int cury2  = (int)Math.Floor((lineObject.AbsTop + lineObject.Height) * FScaleY * YDivAdv) + d;
         int curx2  = (int)Math.Floor((lineObject.AbsLeft + lineObject.Width) * FScaleX * XDivAdv) + d;
         int height = cury2 - cury;
         int width  = curx2 - curx;
         if (lineObject.Width == 0)
         {
             for (int i = 0; i < height; i++)
             {
                 ScreenType(curx, cury + i, FFrameChars[0]);
             }
         }
         else if (lineObject.Height == 0)
         {
             for (int i = 0; i < width; i++)
             {
                 ScreenType(curx + i, cury, FFrameChars[1]);
             }
         }
     }
 }
Esempio n. 2
0
        private void FormatearReporte(crActaTitulacion rep)
        {
            SubreportObject subrep = rep.ReportDefinition.ReportObjects["subrepTitulados"] as SubreportObject;
            ReportDocument  srTitulados = subrep.OpenSubreport("srTitulados");
            ReportObjects   objSecEncabezado = srTitulados.ReportDefinition.Sections["Section6"].ReportObjects;
            ReportObjects   objSecDetalle = srTitulados.ReportDefinition.Sections["Section5"].ReportObjects;
            int             x_ini = objSecEncabezado["lnv01"].Left, x_fin = objSecEncabezado["lnv02"].Left;
            int             n_distancia = (x_fin - x_ini) / v_nRequisitosCalificados;


            /*Response.Write(objSecEncabezado["lnv11"].GetType().ToString());
             * Response.Flush();*/

            LineObject linea = objSecEncabezado["lnv11"] as LineObject;

            /*Response.Write("<br>"+linea.Left.ToString());
             * Response.Flush();*/
            //objSecEncabezado["lnv11"].Left = 11000;



            //objSecEncabezado["lnv11"].Left = 8000;
            //objSecEncabezado["lnv12"].Left = n_distancia * 2;



            //objSecEncabezado["Text37"].Left = 0;
        }
Esempio n. 3
0
        private static bool CheckZeroMany(LineObject lineObject, bool printFlag, CheckSt st, LexRecord lexObj,
                                          CheckObject checkObject, UpdateLex updateLex, bool checkLength)

        {
            lineObject.SetGoToNext(true);
            st.UpdateLastState();

            bool flag = checkObject.IsNextStartStr(lineObject.GetLine());

            if (flag == true)

            {
                st.UpdateCurState(checkObject.GetNextState());
                lineObject.SetGoToNext(false);
                return(flag);
            }

            flag = LineCheck.CheckStartStr(lineObject, printFlag, checkObject);
            if (flag == true)

            {
                TokenObject tokenObject = new TokenObject();

                flag = LineCheck.CheckSlotFiller(lineObject, printFlag, checkObject, tokenObject, checkLength);


                if (flag == true)

                {
                    updateLex.Update(lexObj, tokenObject.GetToken());
                }
            }

            return(flag);
        }
Esempio n. 4
0
        public void ShowPropertyWindow(UIElement element)
        {
            _lineControl = element as LineControl;//旧的
            if (_lineControl == null)
            {
                return;
            }
            #region 如果是新建连线就创对_lineObject对象
            if (_lineObject == null)
            {
                LineObject obj = LineObjects.Where(p => p.LineId.Equals(_lineControl.UniqueID)).SingleOrDefault();
                if (obj == null)
                {
                    _lineObject        = new LineObject();
                    _lineObject.LineId = _lineControl.UniqueID;
                }
                else
                {
                    _lineObject = obj;
                }

                UpdateLineObject(_lineObject);
            }
            #endregion
        }
Esempio n. 5
0
        public static bool Check(LineObject lineObject, bool printFlag, CheckSt catSt, LexRecord lexObj, bool debugFlag)

        {
            bool flag  = true;
            int  curSt = catSt.GetCurState();

            if (curSt == 40)

            {
                curSt = 161;
                catSt.SetCurState(curSt);
            }

            switch (curSt)

            {
            case 161:
                flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkVariant_,
                                       new UpdateModalVariant(), 4, true);


                PrintStep(161, debugFlag, lineObject.GetLine());

                break;
            }

            return(flag);
        }
Esempio n. 6
0
        public IList <SequenceData> OutputSequence(IList <MotionObjectInfo> selected, IList <ProcParam <MotionProcEnv> > args, IEnumerable <ReadOnlyMotionFrame> frames, ProgressInformation progressInfo)
        {
            List <SequenceData> ret = new List <SequenceData>();

            foreach (MotionObjectInfo info in selected)
            {
                TimeSeriesValues values = new TimeSeriesValues("x", "y", "z");
                foreach (var frame in frames)
                {
                    LineObject line = frame[info] as LineObject;
                    if (line != null)
                    {
                        try {
                            values[frame.Time] = new decimal?[] { (decimal)line.Edge.X, (decimal)line.Edge.Y, (decimal)line.Edge.Z };
                        } catch (ArithmeticException) {
                            values[frame.Time] = null;
                        }
                    }
                    else
                    {
                        values[frame.Time] = null;
                    }
                }
                SequenceData data = new SequenceData(values, null, PathEx.GiveName("Dir", info.Name));
                ret.Add(data);
            }
            return(ret);
        }
    // Update is called once per frame
    void Update()
    {
        if (t1.targetPoints.Count >= 1)
        {
            if (g1.obj[0] != null)
            {
                LineObject t2 = g1.obj[0].GetComponent <LineObject>();

                if (t2.targetPoints.Count >= 1)
                {
                    targetPath = new NavMeshPath();
                    agent.SetDestination(t2.targetPoints[0]);
                    agent.CalculatePath(t2.targetPoints[0], targetPath);
                    //Debug.Log("残り距離をみています");
                    //Debug.Log(agent.remainingDistance);

                    var destinationVec = t2.targetPoints[0] - transform.position;
                    destinationVec = destinationVec.normalized;
                    if (t2.targetPoints.Count > 1)
                    {
                        //rigidbodyCylinder.AddForce(destinationVec*10);
                        if (agent.remainingDistance < 0.5)
                        {
                            //if(targetLinePointCount<t2.targetPoints.Count-1)
                            //targetLinePointCount++;
                        }
                    }
                }
            }
        }
    }
Esempio n. 8
0
        public LineObject GetLineObject(BaseDocument doc, double lod)
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.SplineObject_GetLineObject__SWIG_1(swigCPtr, BaseDocument.getCPtr(doc), lod);
            LineObject            ret  = (cPtr == global::System.IntPtr.Zero) ? null : new LineObject(cPtr, false);

            return(ret);
        }
Esempio n. 9
0
        public LineObject GetIsoparm()
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.BaseObject_GetIsoparm(swigCPtr);
            LineObject            ret  = (cPtr == global::System.IntPtr.Zero) ? null : new LineObject(cPtr, false);

            return(ret);
        }
        public static bool IsLegalFormat(bool printFlag, LineObject lineObject, string filler, int beginIndex,
                                         bool isTab, bool checkLength)

        {
            bool flag = true;

            if (filler.Length <= 0)

            {
                if (checkLength == true)

                {
                    ErrMsg.PrintErrMsg(printFlag, 1, lineObject, filler, beginIndex, beginIndex, isTab);

                    flag = false;
                }
            }
            else if ((filler[0] == '=') || (filler[0] == ' ') || (filler[0] == '|'))


            {
                ErrMsg.PrintErrMsg(printFlag, 2, lineObject, filler, beginIndex + 1, beginIndex + 1, isTab);

                flag = false;
            }

            return(flag);
        }
Esempio n. 11
0
        public static ApiOutput ToXmlFromText(string text)

        {
            CheckSt st    = new CheckSt();
            CheckSt catSt = new CheckSt(40);

            LineObject    lineObject = new LineObject();
            StringBuilder xmlOut     = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");

            xmlOut.Append("<lexRecords>\n");
            int recordNum = 0;

            string unixText = text.Replace("\r\n", "\n");

            string[] buf = unixText.Split('\n').ToList().Where(x => x != "").ToArray();

            foreach (string line in buf)
            {
                if (lineObject.IsGoToNext() == true)

                {
                    lineObject.SetLine(line);
                    lineObject.IncreaseLineNum();
                }

                recordNum = CheckLine(st, catSt, lineObject, xmlOut, recordNum);
            }

            xmlOut.Append("</lexRecords>\n");
            ApiOutput apiOutput = new ApiOutput(xmlOut.ToString(), recordNum);

            return(apiOutput);
        }
Esempio n. 12
0
        private static bool CheckNone(LineObject lineObject, CheckSt catSt, int nextState)

        {
            lineObject.SetGoToNext(false);
            catSt.UpdateCurState(nextState);
            return(true);
        }
        public IList <MotionObject> EditObject(IList <MotionObjectInfo> targetInfoList, IList <ProcParam <MotionProcEnv> > args, ReadOnlyMotionFrame frame, bool previewMode)
        {
            SingleSelectParameter mode = args[0] as SingleSelectParameter;
            List <MotionObject>   ret  = new List <MotionObject>();

            foreach (MotionObjectInfo info in targetInfoList)
            {
                LineObject line = frame[info] as LineObject;
                if (line != null)
                {
                    switch (mode.Value)
                    {
                    case 0:
                        ret.Add(new LineObject(line.Position + line.Edge, -line.Edge));
                        break;

                    case 1:
                        ret.Add(new LineObject(line.Position, -line.Edge));
                        break;

                    default:
                        ret.Add((LineObject)line.Clone());
                        break;
                    }
                }
                else
                {
                    ret.Add(null);
                }
            }
            return(ret);
        }
Esempio n. 14
0
 public void DrawLineObject(SpriteBatch sb, LineObject lineObj, bool DrawinGridScale = true)
 {
     foreach (Line line in lineObj.Lines)
     {
         DrawLine(sb, line, lineObj.Location, DrawinGridScale);
     }
 }
Esempio n. 15
0
        private static bool CheckZeroOneWholeLine(LineObject lineObject, bool printFlag, CheckSt st, LexRecord lexObj,
                                                  CheckObject checkObject, UpdateLex updateLex)

        {
            bool flag = checkObject.IsNextStartStr(lineObject.GetLine());

            if (flag == true)

            {
                st.UpdateCurState(checkObject.GetNextState());
                lineObject.SetGoToNext(false);
                return(flag);
            }

            if (st.GetCurState() != st.GetLastState())

            {
                st.UpdateLastState();
                flag = CheckOneWholeLine(lineObject, printFlag, st, lexObj, checkObject, updateLex);
            }
            else

            {
                string line = lineObject.GetLine();
                st.UpdateLastState();
                ErrMsg.PrintErrMsg(printFlag, 82, lineObject, line, 0, line.Length, checkObject.IsTab());
            }

            return(flag);
        }
Esempio n. 16
0
        public static LineObject Alloc(int pcnt, int scnt)
        {
            global::System.IntPtr cPtr = C4dApiPINVOKE.LineObject_Alloc(pcnt, scnt);
            LineObject            ret  = (cPtr == global::System.IntPtr.Zero) ? null : new LineObject(cPtr, false);

            return(ret);
        }
Esempio n. 17
0
        /// <summary>
        /// Creates a LineObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the LineObject instance.</param>
        /// <param name="parent">The parent of the LineObject instance.</param>
        /// <returns>The LineObject instance.</returns>
        public static LineObject CreateLineObject(string name, Base parent)
        {
            LineObject line = new LineObject();

            line.Name   = name;
            line.Parent = parent;
            return(line);
        }
Esempio n. 18
0
        public IList <SequenceData> OutputSequence(IList <MotionObjectInfo> selected, IList <ProcParam <MotionProcEnv> > args, IEnumerable <ReadOnlyMotionFrame> frames, ProgressInformation progressInfo)
        {
            MotionObjectSingleSelectParameter main = args[0] as MotionObjectSingleSelectParameter;
            SingleSelectParameter             unit = args[1] as SingleSelectParameter;

            bool                     useRatio      = unit.Value == 0;
            MotionObjectInfo         firstAxis     = main.Value;
            MotionObjectInfo         secondAxis    = selected.Where(info => info.IsTypeOf(typeof(LineObject)) && info != firstAxis).First();
            IList <MotionObjectInfo> pointInfoList = selected.Where(info => info.IsTypeOf(typeof(PointObject))).ToList();
            List <SequenceData>      ret           = new List <SequenceData>();

            foreach (MotionObjectInfo pointInfo in pointInfoList)
            {
                TimeSeriesValues values = new TimeSeriesValues("axis1", "axis2", "axis3");
                foreach (var frame in frames)
                {
                    PointObject point     = frame[pointInfo] as PointObject;
                    LineObject  line1     = frame[firstAxis] as LineObject;
                    LineObject  line2     = frame[secondAxis] as LineObject;
                    decimal?[]  relValues = null;
                    if (point != null && line1 != null && line2 != null)
                    {
                        Vector3 anchor      = line1.Position;
                        Vector3 pointRelPos = point.Position - anchor;
                        Vector3 axis1       = line1.Edge;
                        Vector3 axis2       = line2.Edge;
                        Vector3 axis1norm   = Vector3.Normalize(axis1);
                        Vector3 axis2norm   = Vector3.Normalize(axis2);
                        Vector3 axis3       = Vector3.Cross(axis1norm, axis2norm) * (float)Math.Sqrt(axis1.Length() * axis2.Length());

                        if (!useRatio)
                        {
                            axis1 = Vector3.Normalize(axis1);
                            axis2 = Vector3.Normalize(axis2);
                            axis3 = Vector3.Normalize(axis3);
                        }
                        float[,] mat = new float[, ] {
                            { axis1.X, axis2.X, axis3.X }, { axis1.Y, axis2.Y, axis3.Y }, { axis1.Z, axis2.Z, axis3.Z }
                        };
                        float[] vec = new float[] { pointRelPos.X, pointRelPos.Y, pointRelPos.Z };
                        SimultaneousEquations solve = SimultaneousEquations.Solve(mat, vec);
                        if (solve.Answers.Length == 3)
                        {
                            relValues = new decimal?[3];
                            try {
                                relValues[0] = (decimal)solve.Answers[0];
                                relValues[1] = (decimal)solve.Answers[1];
                                relValues[2] = (decimal)solve.Answers[2];
                            } catch (OverflowException) { relValues = null; }
                        }
                    }
                    values.SetValue(frame.Time, relValues);
                }
                SequenceData data = new SequenceData(values, null, PathEx.GiveName("RelPos", pointInfo.Name));
                ret.Add(data);
            }
            return(ret);
        }
Esempio n. 19
0
        public static string GetStartStr(LineObject lineObject, string delim)
        {
            string line = lineObject.GetLine();

            string[] buf      = line.Split(delim.ToCharArray()).ToList().Where(x => x != "").ToArray();
            string   startStr = buf.Length > 0 ? buf[buf.Length - 1] : "";

            return(startStr);
        }
Esempio n. 20
0
 public override void MouseDown(SchetsControl s, Point p)
 {
     base.MouseDown(s, p);
     mDrawingObject = new LineObject()
     {
         Color = s.PenColor, LineWidth = s.PenSize
     };
     s.Schets.BeginAddObject(mDrawingObject);
 }
Esempio n. 21
0
        public void ConditionBind(LineObject activity)
        {
            var e = from a in LineObjects
                    where a.LineId == activity.LineId
                    select a;

            _conditionList         = e.FirstOrDefault().ConditionList;
            dgCodition.ItemsSource = null;
            dgCodition.ItemsSource = e.FirstOrDefault().ConditionList;
        }
Esempio n. 22
0
        public static bool Check(LineObject lineObject, bool printFlag, CheckSt catSt, LexRecord lexObj, bool debugFlag)

        {
            bool flag  = true;
            int  curSt = catSt.GetCurState();

            if (curSt == 40)

            {
                curSt = 191;
                catSt.SetCurState(curSt);
            }

            switch (curSt)

            {
            case 191:
                flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkVariants_,
                                       new UpdatePronVariants(), 4, true);


                PrintStep(191, debugFlag, lineObject.GetLine());

                break;

            case 192:
                flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkGender_, new UpdatePronGender(),
                                       2, true);


                PrintStep(192, debugFlag, lineObject.GetLine());

                break;

            case 193:
                flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkInterrogative_,
                                       new UpdatePronInterrogative(), 6, false);


                PrintStep(193, debugFlag, lineObject.GetLine());

                break;

            case 194:
                flag = CheckCode.Check(lineObject, printFlag, catSt, lexObj, checkType_, new UpdatePronType(), 3,
                                       false);


                PrintStep(194, debugFlag, lineObject.GetLine());

                break;
            }

            return(flag);
        }
Esempio n. 23
0
 // Use this for initialization
 void Start()
 {
     refObj                = GameObject.Find("LineObject");
     refLineObj            = GameObject.Find("LineController");
     agent                 = GetComponent <NavMeshAgent>();
     playerToPointDistance = 10;
     targetLinePointCount  = 0;
     t1 = refObj.GetComponent <LineObject>();
     g1 = refLineObj.GetComponent <LineController>();
     rigidbodyCylinder = GetComponent <Rigidbody>();
 }
        /// <summary>
        /// Creates a LineObject instance with specified name and parent.
        /// </summary>
        /// <param name="name">The name of the LineObject instance.</param>
        /// <param name="parent">The parent of the LineObject instance.</param>
        /// <returns>The LineObject instance.</returns>
        public static LineObject CreateLineObject(string name, Base parent)
        {
            LineObject line = new LineObject();

            line.Name = name;
            if ((parent as IParent).CanContain(line))
            {
                line.Parent = parent;
            }
            return(line);
        }
Esempio n. 25
0
        public static List <Agreement> GetAgreementsFromTextFile(string inFile)

        {
            CheckSt st    = new CheckSt();
            CheckSt catSt = new CheckSt(40);

            LineObject       lineObject = new LineObject();
            List <Agreement> agreements = new List <Agreement>();

            try

            {
                System.IO.StreamReader inReader = new System.IO.StreamReader(
                    new System.IO.FileStream(inFile, System.IO.FileMode.Open, System.IO.FileAccess.Read),
                    Encoding.UTF8);

                while (lineObject != null)

                {
                    if (lineObject.IsGoToNext() == true)

                    {
                        lineObject.SetLine(inReader.ReadLine());
                        lineObject.IncreaseLineNum();
                    }

                    if (lineObject.GetLine() == null)
                    {
                        break;
                    }


                    bool flag = CheckGrammer.Check(lineObject, true, st, catSt, false);

                    if ((st.GetCurState() == 10) && (flag == true))

                    {
                        InflVarsAndAgreements agrs = new InflVarsAndAgreements(CheckGrammer.GetLexRecord());
                        agreements.AddRange(agrs.GetAgreementValues());
                    }
                }

                inReader.Close();
            }
            catch (Exception e)

            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            return(agreements);
        }
Esempio n. 26
0
 // Use this for initialization
 void Awake()
 {
     PlayControl.players [PlayControl.counter] = this;
     PlayControl.counter++;
     runLine            = new LineObject(this.gameObject);
     runLine.color      = Color.blue;
     throwLine          = new LineObject(this.gameObject);
     throwLine.straight = throwLine.checkCollide = true;
     throwLine.color    = Color.red;
     initialPos         = transform.position;
     initialRotation    = transform.rotation;
     drawLine           = GetComponentInChildren <DrawLine> ();
 }
Esempio n. 27
0
        public static ApiOutput ToXmlFromTextFile(string inFile)

        {
            CheckSt st    = new CheckSt();
            CheckSt catSt = new CheckSt(40);

            LineObject    lineObject = new LineObject();
            StringBuilder xmlOut     = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");

            xmlOut.Append("<lexRecords>\n");
            int recordNum = 0;

            try

            {
                System.IO.StreamReader inReader = new System.IO.StreamReader(
                    new System.IO.FileStream(inFile, System.IO.FileMode.Open, System.IO.FileAccess.Read),
                    Encoding.UTF8);

                while (lineObject != null)

                {
                    if (lineObject.IsGoToNext() == true)

                    {
                        lineObject.SetLine(inReader.ReadLine());
                        lineObject.IncreaseLineNum();
                    }

                    if (lineObject.GetLine() == null)
                    {
                        break;
                    }

                    recordNum = CheckLine(st, catSt, lineObject, xmlOut, recordNum);
                }

                inReader.Close();
            }
            catch (Exception e)

            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            xmlOut.Append("</lexRecords>\n");
            ApiOutput apiOutput = new ApiOutput(xmlOut.ToString(), recordNum);

            return(apiOutput);
        }
Esempio n. 28
0
        private static void CheckLine(CheckSt st, CheckSt catSt, LineObject lineObject, List <LexRecord> lexRecords)

        {
            bool flag      = false;
            bool printFlag = true;

            flag = CheckGrammer.Check(lineObject, printFlag, st, catSt, false);

            if ((st.GetCurState() == 10) && (flag == true))

            {
                lexRecords.Add(CheckGrammer.GetLexRecord());
            }
        }
Esempio n. 29
0
        private bool BuildStartRoad(IPlayer player, bool buildWithDevCard)
        {
            int mouseCoorX = 0;
            int mouseCoorY = 0;

            if (this.newMouseState.LeftButton == ButtonState.Pressed &&
                this.oldMouseState.LeftButton == ButtonState.Released &&
                Mouse.GetState().X > 0 && Mouse.GetState().Y > 0)
            {
                mouseCoorX = Mouse.GetState().X;
                mouseCoorY = Mouse.GetState().Y;
            }
            LineObject roadOrBoat = GameClass.Game.RoadsAndBoats.FirstOrDefault(r => r.Rectangle.Contains(mouseCoorX, mouseCoorY));

            if (roadOrBoat != null)
            {
                try
                {
                    var startTempX = roadOrBoat.StartPointX;
                    var startTempY = roadOrBoat.StartPointY;
                    var endTempX   = roadOrBoat.EndPointX;
                    var endTempY   = roadOrBoat.EndPointY;
                    var tempX      = roadOrBoat.ScreenX;
                    var tempY      = roadOrBoat.ScreenY;

                    var imageString = DataGenerator.GenerateRoadImageType(roadOrBoat.StartPointX,
                                                                          roadOrBoat.StartPointY,
                                                                          roadOrBoat.EndPointX,
                                                                          roadOrBoat.EndPointY) + player.Id;
                    Road newRoad = new Road(startTempX, startTempY, endTempX, endTempY, 0,
                                            Content, imageString, tempX, tempY, 20, 30);
                    newRoad.Build(player, buildWithDevCard);
                    LineObject oldRoad = GameClass.GetRoadByBothEnds(startTempX, startTempY, endTempX, endTempY);
                    GameClass.Game.RoadsAndBoats.Remove(oldRoad);
                    GameClass.Game.RoadsAndBoats.Add(newRoad);
                    player.LineObjects.Add(newRoad);
                    return(true);
                }
                catch (Exceptions.IllegalBuildPositionException ib)
                {
                    this.errorMessage = ib.Message;
                }
                catch (Exception e)
                {
                    this.errorMessage = e.Message;
                }
            }
            return(true);
        }
Esempio n. 30
0
        private void LoadLine(XmlNode node, Base parent)
        {
            LineObject line = ComponentsFactory.CreateLineObject(node.Name, parent);

            AddLocalizationItemsAttributes(node);
            LoadComponent(node, line);
            LoadSize(node, line);
            LoadBorder(node, line.Border);
            string width = GetAttribute(node, "LineWidth");

            if (!String.IsNullOrEmpty(width))
            {
                line.Border.Width = Convert.ToSingle(width);
            }
        }
Esempio n. 31
0
 public WrapperLine(LineObject line)
 {
     wrapObj = line;
     this.side = -1;
 }
Esempio n. 32
0
        /// <summary>
        /// 生成默认报表
        /// </summary>
        /// <returns></returns>
        public FastReport.Report DefaultReport()
        {

            FastReport.Report report = new FastReport.Report();
            //判断有报表数据,则注册数据
            if (dt != null && dt.Rows.Count > 0)
            {
                report.RegisterData(dt, styleObject);
            }
            else
            {
                return null;
            }
            //查询报表设置
            DataTable dtReportSet = DBHelper.GetTable("", "tb_report_set", "*", string.Format("set_object='{0}' and set_user='******'", styleObject, GlobalStaticObj.UserID), "", "order by set_num");
            if (dtReportSet == null || dtReportSet.Rows.Count == 0)
            {
                return null;
            }
            // enable the "Employees" table to use it in the report
            report.GetDataSource(styleObject).Enabled = true;

            // add report page
            ReportPage page = new ReportPage();
            if (paperSize != null)
            {
                page.PaperWidth = paperSize.Width;
                page.PaperHeight = paperSize.Height;
            }
            report.Pages.Add(page);
            // always give names to objects you create. You can use CreateUniqueName method to do this;
            // call it after the object is added to a report.
            page.CreateUniqueName();

            // create title band
            page.ReportTitle = new ReportTitleBand();
            // native FastReport unit is screen pixel, use conversion 
            page.ReportTitle.Height = Units.Centimeters * 1;
            page.ReportTitle.CreateUniqueName();

            // create title text
            TextObject titleText = new TextObject();
            titleText.Parent = page.ReportTitle;
            titleText.CreateUniqueName();
            //titleText.Bounds = new RectangleF(Units.Centimeters * 5, 0, Units.Centimeters * 10, Units.Centimeters * 1);
            titleText.Bounds = new RectangleF(0, 0, Units.Millimeters * page.PaperWidth, Units.Centimeters * 1);
            titleText.Font = new Font("Arial", 14, FontStyle.Bold);
            titleText.Text = styleTitle;
            titleText.HorzAlign = HorzAlign.Center;
            titleText.VertAlign = VertAlign.Center;
            //内容行高
            float rowHeight = Units.Centimeters * 1F;
            //标题行高,如果有合并列,怎行高价高
            float rowHeaderHeight = rowHeight;
            if (dicSpanRows != null && dicSpanRows.Count > 0)
            {
                rowHeaderHeight = Units.Centimeters * 1.5f;
            }
            page.PageHeader = new PageHeaderBand();
            page.PageHeader.Height = rowHeaderHeight;
            page.PageHeader.CreateUniqueName();
            #region 生成报表内容
            // create data band
            DataBand dataBand = new DataBand();
            page.Bands.Add(dataBand);
            dataBand.CreateUniqueName();
            dataBand.DataSource = report.GetDataSource(styleObject);
            dataBand.Height = rowHeight;
            float x = 0F;//x坐标

            foreach (DataRow dr in dtReportSet.Rows)
            {
                //判断是否要打印
                if (CommonCtrl.IsNullToString(dr["is_print"]) != "1")
                {
                    continue;
                }
                //列宽
                float columnWidth = Units.Centimeters * 2;
                //标题
                string headerName = string.Empty;
                //获取设置的列宽和标题
                float.TryParse(dr["set_width"].ToString(), out columnWidth);
                //columnWidth = columnWidth * 0.9f;
                headerName = dr["set_name"].ToString();
                //生成标题
                TextObject txtHeader = new TextObject();
                txtHeader.Parent = page.PageHeader;
                txtHeader.CreateUniqueName();
                txtHeader.Text = headerName;
                txtHeader.HorzAlign = HorzAlign.Center;
                txtHeader.VertAlign = VertAlign.Center;
                //生成标题竖线
                LineObject lineHeaderVer = new LineObject();
                lineHeaderVer.Parent = page.PageHeader;
                //生成标题横线
                LineObject lineHeaderHor = new LineObject();
                lineHeaderHor.Parent = page.PageHeader;
                lineHeaderHor.Bounds = new RectangleF(x, 0, columnWidth, 1f);

                //数据源列名称
                string dataName = dr["set_data_name"].ToString();
                string spanName = IsContainDataColumn(dataName);
                //判断列是否是合并列
                if (spanName.Length > 0)
                {
                    #region 合并列标题
                    txtHeader.Bounds = new RectangleF(x, rowHeaderHeight / 2, columnWidth, rowHeaderHeight / 2);
                    lineHeaderVer.Bounds = new RectangleF(x, rowHeaderHeight / 2, 1F, rowHeaderHeight / 2);
                    //生成合并列的短竖线
                    LineObject lineHeaderHorSpan = new LineObject();
                    lineHeaderHorSpan.Parent = page.PageHeader;
                    lineHeaderHorSpan.Bounds = new RectangleF(x, rowHeaderHeight / 2, columnWidth, 1F);
                    //判断是否包含合并列头
                    if (dicSpanWidth.ContainsKey(spanName))
                    {
                        //增加合并列头的列宽
                        RectangleF rf = dicSpanWidth[spanName];
                        rf.Width += columnWidth;
                        dicSpanWidth[spanName] = rf;
                    }
                    else
                    {
                        //记录合并列头
                        RectangleF rf = new RectangleF();
                        rf.X = x;
                        rf.Y = 0;
                        rf.Width = columnWidth;
                        rf.Height = rowHeaderHeight / 2;
                        dicSpanWidth.Add(spanName, rf);
                    }
                    #endregion
                }
                else
                {
                    lineHeaderVer.Bounds = new RectangleF(x, 0, 1F, rowHeaderHeight);
                    txtHeader.Bounds = new RectangleF(x, 0, columnWidth, rowHeaderHeight);
                }
                // create two text objects with employee's name and birth date
                //生成内容
                TextObject empNameText = new TextObject();
                empNameText.Parent = dataBand;
                empNameText.CreateUniqueName();
                empNameText.Bounds = new RectangleF(x, 0, columnWidth, rowHeight);
                DataColumn dc = dt.Columns[dataName];
                empNameText.Text = string.Format("[{0}.{1}]", styleObject, dataName);
                //empNameText.HideZeros = true;
                if (dc != null && dc.DataType != typeof(string))
                {
                    empNameText.HorzAlign = HorzAlign.Right;
                }
                else
                {
                    empNameText.HorzAlign = HorzAlign.Center;
                }
                empNameText.VertAlign = VertAlign.Center;
                //生成内容列的竖线
                LineObject lineVertical = new LineObject();
                lineVertical.Parent = dataBand;
                lineVertical.Bounds = new RectangleF(x, 0, 1F, rowHeight);
                //生成内容列顶部的横线
                LineObject lineHorizontal = new LineObject();
                lineHorizontal.Parent = dataBand;
                lineHorizontal.Bounds = new RectangleF(x, 0, columnWidth, 1f);
                //生成内荣列底部的横线
                LineObject lineHorizontalD = new LineObject();
                lineHorizontalD.Parent = dataBand;
                lineHorizontalD.Bounds = new RectangleF(x, rowHeight, columnWidth, 1f);

                //x坐标增加当前列
                x += columnWidth;
            }

            //生成标题右边的竖线
            LineObject lineHeaderRightVer = new LineObject();
            lineHeaderRightVer.Parent = page.PageHeader;
            lineHeaderRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight);
            //生成内容右边的竖线
            LineObject lineRightVer = new LineObject();
            lineRightVer.Parent = dataBand;
            lineRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight);
            //生成合并列头
            foreach (string span in dicSpanWidth.Keys)
            {
                //合并列头
                TextObject txtSpan = new TextObject();
                txtSpan.Parent = page.PageHeader;
                txtSpan.CreateUniqueName();
                txtSpan.Bounds = dicSpanWidth[span];
                txtSpan.Text = span;
                txtSpan.HorzAlign = HorzAlign.Center;
                txtSpan.VertAlign = VertAlign.Center;
                //合并列头的竖线
                LineObject lineHeaderVer = new LineObject();
                lineHeaderVer.Parent = page.PageHeader;
                lineHeaderVer.Bounds = new RectangleF(txtSpan.Bounds.X, txtSpan.Bounds.Y, 1f, txtSpan.Bounds.Height);
            }
            #endregion
            #region 生成页脚
            page.PageFooter = new PageFooterBand();
            page.PageFooter.Height = rowHeaderHeight;
            page.PageHeader.CreateUniqueName();
            TextObject txtPageN = new TextObject();
            txtPageN.Parent = page.PageFooter;
            txtPageN.CreateUniqueName();
            txtPageN.Text = "[PageNofM]";
            txtPageN.Bounds = new RectangleF(100, 0, 200, rowHeaderHeight);

            //TextObject txtTotalPages = new TextObject();
            //txtTotalPages.Parent = page.PageFooter;
            //txtTotalPages.CreateUniqueName();
            //txtTotalPages.Text = "[TotalPages]";
            //txtTotalPages.Bounds = new RectangleF(350, 0, 200, rowHeaderHeight);
            #endregion
            return report;

        }
Esempio n. 33
0
 public void SetIsoparm(LineObject l) {
   C4dApiPINVOKE.BaseObject_SetIsoparm(swigCPtr, LineObject.getCPtr(l));
 }