示例#1
0
        void OnGUI()
        {
            this.scaledSize = style.normal.background.GetScaleSize(this.transform.localScale);
            if (this.overrideWidth > 0f || this.overrideHeight > 0f)
            {
                this.scaledSize = GUIScale.RectScaleSize(this.overrideWidth, this.overrideHeight, this.transform.localScale);
            }

            float screenW = (float)(Screen.width) / 2f - Camera.main.pixelWidth / 2;
            float screenH = (float)(Screen.height) / 2f - Camera.main.pixelHeight / 2;

            this.pos = new Vector2
                       (
                screenW + this.transform.position.x * (Camera.main.pixelWidth - this.scaledSize.Width),
                screenH + this.transform.position.y * (Camera.main.pixelHeight - this.scaledSize.Height)
                       );

            var area = new Rect(this.pos.x, this.pos.y, scaledSize.Width, scaledSize.Height);

            float finalSize = Mathf.Min(scaledSize.Width, scaledSize.Height) * this.fontSizeRatio;

            this.style.fontSize = (int)finalSize;

            this.style.contentOffset = new Vector2(
                scaledSize.Width * this.textOffsetRatio.x,
                scaledSize.Height * this.textOffsetRatio.y);

            GUI.depth = this.guiDepth;
            GUI.Label(area, this.title, this.style);
        }
示例#2
0
        public static RectSize RectScaleSize(float originalWidth, float originalHeight, Vector2 scaleRatio)
        {
            float screenHeight = Camera.main.pixelHeight;
            float screenWidth  = Camera.main.pixelWidth;

            float screenAspectRatio  = (screenWidth / screenHeight);
            float textureAspectRatio = (originalWidth / originalHeight);

            float scaledHeight;
            float scaledWidth;

            if (textureAspectRatio <= screenAspectRatio)
            {
                // The scaled size is based on the height
                scaledHeight = screenHeight;
                scaledWidth  = (screenHeight * textureAspectRatio);
            }
            else
            {
                // The scaled size is based on the width
                scaledWidth  = screenWidth;
                scaledHeight = (scaledWidth / textureAspectRatio);
            }

            scaledWidth  = scaledWidth * scaleRatio.x;
            scaledHeight = scaledHeight * scaleRatio.y;

            var size = new RectSize(scaledWidth, scaledHeight);

            return(size);
        }
    void OnGUI()
    {
        RectSize scaledSize = GUIScale.RectScaleSize(this.orginalWidth, this.orginalHeight, this.scaleRatio);

        float x = -(scaledSize.Width / 2);
        float y = -(scaledSize.Height / 2);

        guiTexture.pixelInset = new Rect(x, y, scaledSize.Width, scaledSize.Height);
    }
示例#4
0
    // Авейк
    void Awake()
    {
        wnd_alpha = 0f;

        base.Awake();

        RectSize wnd_size = new RectSize(800, 600);

        this.set_size(wnd_size);

        float x_pos = (Screen.width - wnd_size.width) / 2;
        float y_pos = Screen.height - (wnd_size.height + 20);

        this.set_pos(new Vector2(x_pos, y_pos));

        add_wnd_bg();
        add_col_btns();
    }
示例#5
0
    void Awake()
    {
        wnd_alpha = 0f;

        base.Awake();

        RectSize wnd_size = new RectSize(800, 600);

        this.set_size(wnd_size);

        float x_pos = (Screen.width - wnd_size.width) / 2;
        float y_pos = (Screen.height - wnd_size.height) / 2;

        this.set_pos(new Vector2(x_pos, y_pos));

        add_start_btn();

        Destroy(sound_btn);
    }
示例#6
0
    // Авейк
    void Awake()
    {
        wnd_alpha = 0f;

        base.Awake();

        RectSize wnd_size = new RectSize(800, 600);

        this.set_size(wnd_size);

        float x_pos = (Screen.width - wnd_size.width) / 2;
        float y_pos = (Screen.height - wnd_size.height) / 2;

        this.set_pos(new Vector2(x_pos, y_pos));

        add_col_sel_btn();
        add_figure_pan();
        add_timer_pan();
        add_scores_pan();
    }
示例#7
0
        void OnGUI()
        {
            this.scaledSize = style.normal.background.GetScaleSize(this.transform.localScale);

            float screenW = (float)(Screen.width) / 2f - Camera.main.pixelWidth / 2;
            float screenH = (float)(Screen.height) / 2f - Camera.main.pixelHeight / 2;

            if (this.linkedTo != null && this.linkedTo.tag == "MenuButton")
            {
                var linkedController = this.linkedTo.GetComponent <ButtonController>();
                linkedController.GetHeigthRatio();

                float linkX = this.transform.position.x;
                if (this.linkedOffsetRatio.x != 0f)
                {
                    linkX = linkedController.GetWidthRatio() + this.linkedOffsetRatio.x;
                }

                float linkY = this.transform.position.y;
                if (this.linkedOffsetRatio.y != 0f)
                {
                    linkY = linkedController.GetHeigthRatio() + this.linkedOffsetRatio.y;
                }

                this.transform.position = new Vector3
                                          (
                    linkX,
                    linkY,
                    this.transform.position.y
                                          );
            }

            this.pos = new Vector2
                       (
                screenW + this.transform.position.x * (Camera.main.pixelWidth - this.scaledSize.Width),
                screenH + this.transform.position.y * (Camera.main.pixelHeight - this.scaledSize.Height)
                       );

            var area = new Rect(this.pos.x, this.pos.y, scaledSize.Width, scaledSize.Height);

            float finalSize = Mathf.Min(scaledSize.Width, scaledSize.Height) * this.fontSizeRatio;

            this.style.fontSize = (int)finalSize;

            this.style.contentOffset = new Vector2(
                scaledSize.Width * this.textOffsetRatio.x,
                scaledSize.Height * this.textOffsetRatio.y);

            GUI.depth = this.guiDepth;
            if (GUI.Button(area, this.title, this.style) && this.OnClick != null)
            {
                if (this.clicked)
                {
                    return;
                }

                this.clicked = true;
                this.OnClick();
                Invoke("ResetClick", 2f);
            }
        }
示例#8
0
        public ActionResult btnOutputWord_Click(int record_id)
        {
            // 关闭本窗体(触发窗体的关闭事件)
            //PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            try
            {
                var    record  = db.view_record2word.Find(record_id);
                string dotName = record.bg_dot_name;
                if (dotName.Equals(""))
                {
                    dotName = "xcbl.dot";
                }
                string path = Server.MapPath("~/pbs_data/");
                NameValueCollection val1 = (NameValueCollection)ConfigurationManager.GetSection("myUrl");
                if (System.IO.File.Exists(path + "\\" + record.record_no + ".doc"))
                {
                    return(Redirect(val1["apiUrl"] + "GetWordFile?fileName=" + record.record_no + ".doc"));
                }
                CCWordApp word = new CCWordApp();
                word.OpenFromDot(Server.MapPath("~/App_Data/") + dotName);

                word.GotoBookMark("kyyear");
                word.InsertText(record.ky_date.Value.Year.ToString());

                word.GotoBookMark("ky_no");
                word.InsertText(record.record_no.Substring(record.record_no.Count() - 6));

                word.GotoBookMark("ky_unit");
                word.SetFont("Underlined");
                word.InsertText(record.unit_full_name);
                word.SetFont("Underlined");

                word.GotoBookMark("kyyear2");
                word.InsertText(record.ky_date.Value.Year.ToString());

                word.GotoBookMark("ky_no2");
                word.InsertText(record.record_no.Substring(record.record_no.Count() - 6));

                word.GotoBookMark("ky_unit2");
                word.InsertText(record.ky_unit_name);

                word.GotoBookMark("bg_unit");
                word.InsertText(record.bg_unit_name);


                word.GotoBookMark("ky_date");
                word.InsertText(record.ky_date.Value.ToString("yyyy"));
                word.GotoBookMark("ky_date_month");
                word.InsertText(record.ky_date.Value.ToString("MM"));
                word.GotoBookMark("ky_date_dd");
                word.InsertText(record.ky_date.Value.ToString("dd"));
                word.GotoBookMark("ky_date_hh");
                word.InsertText(record.ky_date.Value.ToString("hh"));
                word.GotoBookMark("ky_date_mm");
                word.InsertText(record.ky_date.Value.ToString("mm"));

                word.GotoBookMark("record_reason");
                string reason = record.record_reason;
                if (reason == null)
                {
                    reason = "";
                }
                reason = reason.PadRight(340 - reason.ToCharArray().Length);

                word.InsertText(reason);

                word.GotoBookMark("kykssj");
                word.InsertText(record.kyks_time.Value.ToString("yyyy"));
                word.GotoBookMark("kykssj_month");
                word.InsertText(record.kyks_time.Value.ToString("MM"));
                word.GotoBookMark("kykssj_dd");
                word.InsertText(record.kyks_time.Value.ToString("dd"));
                word.GotoBookMark("kykssj_hh");
                word.InsertText(record.kyks_time.Value.ToString("hh"));
                word.GotoBookMark("kykssj_mm");
                word.InsertText(record.kyks_time.Value.ToString("mm"));

                word.GotoBookMark("kyjssj");
                word.InsertText(record.kyjs_time.Value.ToString("yyyy"));
                word.GotoBookMark("kyjssj_month");
                word.InsertText(record.kyjs_time.Value.ToString("MM"));
                word.GotoBookMark("kyjssj_dd");
                word.InsertText(record.kyjs_time.Value.ToString("dd"));
                word.GotoBookMark("kyjssj_hh");
                word.InsertText(record.kyjs_time.Value.ToString("hh"));
                word.GotoBookMark("kyjssj_mm");
                word.InsertText(record.kyjs_time.Value.ToString("mm"));


                word.GotoBookMark("xc_loc");
                string loc = "";
                if (record.xc_loc == null)
                {
                    loc = record.fs_loc;
                }
                else
                {
                    loc = record.fs_loc + record.xc_loc;
                }
                loc = loc.PadRight(190 - loc.ToCharArray().Length);

                word.InsertText(loc);

                word.GotoBookMark("bh_flag");
                if (record.bh_flag == null)
                {
                    word.InsertText("无");
                }
                else
                {
                    if (record.bh_flag.Value == 1)
                    {
                        word.InsertText("有");
                    }
                    else
                    {
                        word.InsertText("无");
                    }
                }


                word.GotoBookMark("bhr");
                word.InsertText(record.bhr_name);

                word.GotoBookMark("bhr_unit");
                word.InsertText(record.bhr_unit_name);

                word.GotoBookMark("bhr_pos");
                word.InsertText(record.bhr_pos);

                //保护方式
                if (record.bh_function != null && record.bh_function.Length > 0 && record.bh_function.Substring(0, 1).Equals("专"))
                {
                    word.GotoBookMark("bh_function_flag1");
                    word.replaceText("□", "☑");
                }
                else if (record.bh_function != null && record.bh_function.Length > 0 && record.bh_function.Substring(0, 1).Equals("设"))
                {
                    word.GotoBookMark("bh_function_flag2");
                    word.replaceText("□", "☑");
                }
                else if (record.bh_function != null && record.bh_function.Length > 0 && record.bh_function.Substring(0, 1).Equals("封"))
                {
                    word.GotoBookMark("bh_function_flag3");
                    word.replaceText("□", "☑");
                    word.GotoBookMark("bhr_function");
                    word.InsertText(record.bh_function);
                }
                //现场情况
                if (record.xc_info != null && record.xc_info.Length > 1 && record.xc_info.Substring(0, 2).Equals("原始"))
                {
                    word.GotoBookMark("xc_info_flag1");
                    word.replaceText("□", "☑");
                }
                else if (record.xc_info != null && record.xc_info.Length > 1 && record.xc_info.Substring(0, 2).Equals("变动"))
                {
                    word.GotoBookMark("xc_info_flag2");
                    word.replaceText("□", "☑");
                }
                //变动原因
                if (record.bd_reason != null && record.bd_reason.Length > 1 && record.bd_reason.Substring(0, 2).Equals("事主"))
                {
                    word.GotoBookMark("bd_reason_flag1");
                    word.replaceText("□", "☑");
                }
                else if (record.bd_reason != null && record.bd_reason.Length > 1 && record.bd_reason.Substring(0, 2).Equals("报案"))
                {
                    word.GotoBookMark("bd_reason_flag2");
                    word.replaceText("□", "☑");
                }
                else if (record.bd_reason != null && !record.bd_reason.Equals(""))
                {
                    word.GotoBookMark("bd_reason_flag3");
                    word.replaceText("□", "☑");
                    word.GotoBookMark("bd_reason");
                    word.InsertText(record.bd_reason);
                }

                //天气
                switch (record.weather_info)
                {
                case "阴":
                    word.GotoBookMark("tq_flag1");
                    word.replaceText("□", "☑");
                    break;

                case "晴":
                    word.GotoBookMark("tq_flag2");
                    word.replaceText("□", "☑");
                    break;

                case "雨":
                    word.GotoBookMark("tq_flag3");
                    word.replaceText("□", "☑");
                    break;

                case "雪":
                    word.GotoBookMark("tq_flag4");
                    word.replaceText("□", "☑");
                    break;

                case "雾":
                    word.GotoBookMark("tq_flag5");
                    word.replaceText("□", "☑");
                    break;
                }
                word.GotoBookMark("wd");
                word.InsertText(record.temper_info);

                word.GotoBookMark("sd");
                word.InsertText(record.humidity_info);

                word.GotoBookMark("fx");
                word.InsertText(record.trend_info);

                //光照
                if (record.light_info != null && record.light_info.Contains("自然光"))
                {
                    word.GotoBookMark("light_flag1");
                    word.replaceText("□", "☑");
                }
                if (record.light_info != null && record.light_info.Contains("灯光"))
                {
                    word.GotoBookMark("light_flag2");
                    word.replaceText("□", "☑");
                }
                if (record.light_info != null && record.light_info.Contains("特种光"))
                {
                    word.GotoBookMark("light_flag3");
                    word.replaceText("□", "☑");
                }

                word.GotoBookMark("zhr");
                word.InsertText(record.zhr_name);

                word.GotoBookMark("zhr_unit");
                word.InsertText(record.zhr_unit_name);

                word.GotoBookMark("zhr_pos");
                word.InsertText(record.zhr_pos);

                word.GotoBookMark("xc_disp");
                word.InsertText(record.xc_disp.PadRight(1400));

                word.GotoBookMark("blr");
                string blr = record.blr_name;
                if (blr == null)
                {
                    blr = "";
                }
                word.InsertText(blr.PadRight(70));

                word.GotoBookMark("ztr");
                string ztr = record.ztr_name;
                if (ztr == null)
                {
                    ztr = "";
                }
                word.InsertText(ztr.PadRight(70));

                word.GotoBookMark("zxr");
                string zxr = record.zxr_name;
                if (zxr == null)
                {
                    zxr = "";
                }
                word.InsertText(zxr.PadRight(70));

                word.GotoBookMark("lxr");
                string lxr = record.lxr_name;
                if (lxr == null)
                {
                    lxr = "";
                }
                word.InsertText(lxr.PadRight(70));

                word.GotoBookMark("lyr");
                string lyr = record.lyr_name;
                if (lyr == null)
                {
                    lyr = "";
                }
                word.InsertText(lyr.PadRight(70));

                word.GotoBookMark("jzrsex");
                word.InsertText(record.jzr_sex);

                word.GotoBookMark("jzrbirth");
                word.InsertText(record.jzr_birth);

                word.GotoBookMark("jzraddress");
                word.InsertText(record.jzr_address);

                word.GotoBookMark("jzrqm");
                System.Drawing.Image qmImg = System.Drawing.Image.FromFile(path + record.uuid + "\\" + record.uuid + ".png");
                qmImg = UtilsTool.RotateImg(qmImg, -90);
                string rotatePath = path + "tmp\\" + record.uuid + "_tmp.png";
                qmImg.Save(rotatePath);
                word.InsertPictureStatic(rotatePath, 100, 100);
                word.GotoBookMark("jzrqm2");
                word.InsertPictureStatic(rotatePath, 100, 100);

                word.GotoBookMark("bg_date1_year");
                word.InsertText(UtilsTool.NumtoUpper(DateTime.Now.Year % 10));
                word.GotoBookMark("bg_date1_month");
                word.InsertText(UtilsTool.MonthtoUpper(DateTime.Now.Month));
                word.GotoBookMark("bg_date1_day");
                word.InsertText(UtilsTool.DaytoUpper(DateTime.Now.Day));

                word.GotoBookMark("bg_date2_year");
                word.InsertText(UtilsTool.NumtoUpper(DateTime.Now.Year % 10));
                word.GotoBookMark("bg_date2_month");
                word.InsertText(UtilsTool.MonthtoUpper(DateTime.Now.Month));
                word.GotoBookMark("bg_date2_day");
                word.InsertText(UtilsTool.DaytoUpper(DateTime.Now.Day));

                word.GotoBookMark("photos");

                int i      = 1;
                var pics   = db.sys_upload_file.Where(m => m.rec_uuid.Equals(record.uuid));
                var ztpics = pics.Where(m => m.file_type == 2004);
                int ztnum  = ztpics.Count();
                word.GotoBookMark("zt_num");
                word.InsertText("" + ztnum);

                foreach (sys_upload_file pic in ztpics)
                {
                    if (ValidateFileType(pic.file_url))
                    {
                        word.GotoBookMark("photo" + (i++).ToString());
                        word.InsertLineBreak(14);
                        word.InsertPicture(Server.MapPath("~/App_Data/") + "blank.png", 10, 10);//矫正后续图片位置
                        string   bgFilePath      = Server.MapPath("~/App_Data/") + "xct_bg.jpg";
                        Bitmap   bmp             = new Bitmap(bgFilePath);
                        Graphics g               = Graphics.FromImage(bmp);
                        Font     titlefont       = new Font("宋体", 65);
                        Font     contentfont     = new Font("宋体", 40);
                        Font     minicontentfont = new Font("宋体", 30);

                        SolidBrush sbrush   = new SolidBrush(Color.Black);
                        string     title    = record.af_time.Value.ToString("yyyyMMdd") + " " + record.fs_loc + record.xc_loc + record.xz;
                        string     markHint = "";
                        if (pic.file_url.Substring(pic.file_url.Length - 8).Equals("xct.jpeg"))
                        {
                            title   += "中心现场方位示意图";
                            markHint = "中心现场";
                        }
                        else if (pic.file_url.Substring(pic.file_url.Length - 8).Equals("pmt.jpeg"))
                        {
                            title   += "中心现场方位示意图";
                            markHint = "案发位置";
                        }

                        g.DrawString(title, titlefont, sbrush, new PointF(300, 200));
                        g.DrawString(markHint, titlefont, sbrush, new PointF(2600, 1150));

                        if (record.xc_loc.Length > 12)
                        {
                            g.DrawString(record.xc_loc.Substring(0, 12), minicontentfont, sbrush, new PointF(2600, 1770));
                            g.DrawString(record.xc_loc.Substring(12), minicontentfont, sbrush, new PointF(2600, 1830));
                        }
                        else
                        {
                            g.DrawString(record.xc_loc, contentfont, sbrush, new PointF(2600, 1800));
                        }

                        g.DrawString(record.bj_time.Value.ToString("yyyy年MM月dd日 HH时mm分"), contentfont, sbrush, new PointF(2600, 1900));
                        //g.DrawString(record.unit_full_name, contentfont, sbrush, new PointF(2600, 2030));
                        if (record.unit_full_name.Length > 12)
                        {
                            g.DrawString(record.unit_full_name.Substring(0, 12), minicontentfont, sbrush, new PointF(2600, 2000));
                            g.DrawString(record.unit_full_name.Substring(12), minicontentfont, sbrush, new PointF(2600, 2060));
                        }
                        else
                        {
                            g.DrawString(record.unit_full_name, contentfont, sbrush, new PointF(2600, 2030));
                        }

                        g.DrawString(record.ztr_name, contentfont, sbrush, new PointF(2600, 2150));
                        g.DrawString(DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分"), contentfont, sbrush, new PointF(2600, 2270));

                        System.Drawing.Image mapImg = System.Drawing.Image.FromFile(path + record.uuid + "\\" + pic.file_url);

                        g.DrawImage(mapImg, 100, 400, 2100, 1600);
                        //bmp.Save(path + record.uuid + "\\tmp_" + pic.file_url);

                        System.Drawing.Image img    = UtilsTool.RotateImg(bmp, -90); //旋转90度
                        RectSize             target = UtilsTool.getCTSize(img);
                        img.Save(path + record.uuid + "\\tmp_" + pic.file_url);
                        word.InsertPicture(path + record.uuid + "\\tmp_" + pic.file_url, target.width, target.height);
                        word.InsertLineBreak();
                        //word.SetAlignment("Center");
                        //word.InsertText(pic.file_hint);
                        //word.InsertPagebreak();
                    }
                }

                var fwpics   = pics.Where(m => m.file_type == 2001 || m.file_type == 2002 || m.file_type == 2003).OrderBy(m => m.file_type);
                int photonum = fwpics.Count();
                word.GotoBookMark("photo_num");
                word.InsertText("" + photonum);

                foreach (sys_upload_file pic in fwpics)
                {
                    if (ValidateFileType(pic.file_url))
                    {
                        word.GotoBookMark("photo" + (i++).ToString());
                        word.InsertLineBreak(6);
                        word.InsertPicture(Server.MapPath("~/App_Data/") + "blank.png", 10, 10);//矫正后续图片位置
                        System.Drawing.Image img    = System.Drawing.Image.FromFile(path + record.uuid + "\\" + pic.file_url);
                        RectSize             target = UtilsTool.getConfSize(img);
                        word.InsertPicture(path + record.uuid + "\\" + pic.file_url, target.width, target.height);
                        word.InsertLineBreak();
                        word.SetAlignment("Center");
                        word.InsertText(pic.file_hint);
                    }
                }

                string newFile = path + record.record_no + ".doc";
                word.SaveAs(newFile);
                word.Close();
                word.Quit();

                return(Redirect(val1["apiUrl"] + "GetWordFile?fileName=" + record.record_no + ".doc"));
            }
            catch (Exception exc)
            {
                throw (exc);
            }

            //return UIHelper.Result();
        }
示例#9
0
 // Установить размеры элемента
 public void set_size(RectSize size)
 {
     rect_trans.SetWidth(size.width);
     rect_trans.SetHeight(size.height);
 }