Exemplo n.º 1
0
        public PropertyForm(ReoGridControl grid)
        {
            this.grid = grid;

            InitializeComponent();

            numberPage.Done += new EventHandler(IPropertyPage_Done);

            tabControl1.SelectedIndex = lastTabPageIndex;
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            this.Text = "ReoGrid Demo " + ProductVersion.ToString();

            string rootCategory = unvell.ReoGrid.Demo.Properties.Resources.DemoCategory;

            using (var sr = new System.IO.StringReader(rootCategory))
            {
                demoFile = (DemoFile)xmlSerializer.Deserialize(sr) as DemoFile;
            }

            if (demoFile == null)
            {
                MessageBox.Show("Cannot read demo category file correctly. Please redownload the program.");
                Close();
                return;
            }

            tree.BeforeExpand += tree_BeforeExpand;
            tree.AfterSelect  += tree_AfterSelect;

            LoadAllItems();

            var dummyGrid = new ReoGridControl();

            this.labTitle.Text = dummyGrid.ProductName + " " + dummyGrid.ProductVersion.ToString();
            web.Visible        = false;

            // load default demo item
            if (!string.IsNullOrEmpty(demoFile.defaultItem))
            {
                var demoItem = FindDemoItemByName(demoFile, demoFile.defaultItem);
                if (demoItem != null)
                {
                    this.currentItem = demoItem;
                    LoadDemo(demoItem);
                }
            }
        }
Exemplo n.º 3
0
        protected override void OnLoad(EventArgs e)
        {
            this.Text = "ReoGrid デモプログラム " + ProductVersion.ToString();

            string rootCategory = DemoJP.Properties.Resources.DemoCategory;

            using (var sr = new System.IO.StringReader(rootCategory))
            {
                demoCategoryFile = (DemoFile)xmlSerializer.Deserialize(sr) as DemoFile;
            }

            if (demoCategoryFile == null)
            {
                MessageBox.Show("カテゴリファイルの読み込みに失敗しました。もう一度ダウンロードして試してください。");
                Close();
                return;
            }

            tree.BeforeExpand += tree_BeforeExpand;
            tree.AfterSelect  += tree_AfterSelect;

            LoadAllItems();

            var dummyGrid = new ReoGridControl();

            this.labTitle.Text = dummyGrid.ProductName + " " + dummyGrid.ProductVersion.ToString();
            web.Visible        = false;

            // load default demo item
            if (!string.IsNullOrEmpty(demoCategoryFile.defaultItem))
            {
                var demoItem = FindDemoItemByName(demoCategoryFile, demoCategoryFile.defaultItem);
                if (demoItem != null)
                {
                    this.currentItem = demoItem;
                    LoadDemo(demoItem);
                }
            }
        }
Exemplo n.º 4
0
        public override void ExternalAction(ReoGridControl grid, SpreadsheetEditorNode node)
        {
            base.ExternalAction(grid, node);
            if (!IsChanged)
            {
                return;
            }

            var worksheet = string.IsNullOrWhiteSpace(WorksheetName)
                ? grid.CurrentWorksheet
                : grid.Worksheets[WorksheetName];

            int i = 0;

            worksheet.IterateCells(Range, (r, c, cell) =>
            {
                cell.Data = string.IsNullOrWhiteSpace(FlatText[i]) ? (object)FlatValue[i] : (object)FlatText[i];
                i++;
                return(true);
            });
            IsChanged = false;
        }
Exemplo n.º 5
0
        public Worksheet Generate()
        {
            if (this.patternTable == null)
            {
                throw new Exception("Pattern table is not setted");
            }
            int patternLines   = this.patternTable.RowCount;                //获取模式表行数
            int patternColumns = this.patternTable.ColumnCount;             //获取模式表列数

            this.stateMatrix = new CellState[patternLines, patternColumns]; //初始化状态矩阵

            var workbook = new ReoGridControl();

            this.resultTable             = workbook.Worksheets[0]; //初始化目标表
            this.resultTable.ColumnCount = this.patternTable.ColumnCount;
            this.resultTable.RowCount    = this.patternTable.RowCount;
            workbook.Worksheets.Remove(this.resultTable);
            this.lengthColumnResult.Clear();       //目标表各行长度
            this.lengthLineResult.Clear();         //目标表各列长度
            for (int i = 0; i < patternLines; i++) //顺序解析模式表单元格
            {
                for (int j = 0; j < patternColumns; j++)
                {
                    this.ParseCell(i, j);
                }
            }
            //自动调整结果表的行高
            for (int i = 0; i < this.resultTable.Rows; i++)
            {
                this.resultTable.AutoFitRowHeight(i);
            }
            //结果表的列宽和模式表各列一样
            for (int i = 0; i < this.resultTable.Columns; i++)
            {
                this.resultTable.SetColumnsWidth(i, 1, this.patternTable.GetColumnWidth(i));
            }
            return(this.resultTable); //返回目标表
        }
Exemplo n.º 6
0
        /// <summary>
        /// 窗体中画出表格
        /// </summary>
        /// <param name="grid">窗体表格</param>
        public void PaintReport(ref ReoGridControl grid)
        {
            //准备演算类
            RPN rpn = new RPN();

            //准备演算数据
            //SelfFunctionUtil.HistoryDataTable = HisData.getData(startTime, endTime, "60", DenseTags);

            //if (SloppyTags.Length > 0)
            //
            //	List<string> times = new List<string> { };
            //	times.Add(DateTime.Now.AddYears(-1).Year.ToString() + "-01-01 08:00:00");
            //	times.Add(DateTime.Parse(endTime).Date.ToString("yyyy-MM-dd 08:00:00"));
            //	SelfFunctionUtil.SloppyHistoryDataTable = HisData.GetDataByTime(times, SloppyTags);
            //}
            //画表头
            foreach (Range range in Header)
            {
                PaintRange(range, grid, ref rpn);
            }
            //画表体
            foreach (Range range in Body)
            {
                PaintRange(range, grid, ref rpn);
            }
            //画表尾
            foreach (Range range in Foot)
            {
                PaintRange(range, grid, ref rpn);
            }
            //自动列宽
            var sheet = grid.CurrentWorksheet;

            for (int i = 0; i < sheet.ColumnCount; i++)
            {
                sheet.AutoFitColumnWidth(i);
            }
        }
Exemplo n.º 7
0
        public static BusinessObjects.SheetFileNameInfo Open(string basePath, ReoGridControl workbook, BusinessObjects.SheetFileNameInfo sheetFilenameInfo)
        {
            var dialog = new OpenFileDialog();

            dialog.InitialDirectory = basePath;
            dialog.Filter           = "rgf files (*.rgf)|*.rgf";
            dialog.RestoreDirectory = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                workbook.CurrentWorksheet.LoadRGF(dialog.FileName);
            }
            else
            {
                return(sheetFilenameInfo);
            }

            return(new BusinessObjects.SheetFileNameInfo
            {
                SheetName = workbook.CurrentWorksheet.Name,
                FullPath = dialog.FileName
            });
        }
Exemplo n.º 8
0
        /// <summary>
        /// Construct the control
        /// </summary>
        public SheetTabControl(ReoGridControl grid)
        {
            this.grid = grid;

            this.Font = new Font(SystemFonts.DefaultFont.Name, 8f, FontStyle.Regular);
            //this.SelectedBackColor = SystemColors.Window;
            //this.SelectedTextColor = Color.DimGray;
            //this.BorderColor = SystemColors.ControlDark;
            this.NewButtonVisible = true;

            using (var ms = new System.IO.MemoryStream(Properties.Resources.NewBuildDefinition_8952_png))
            {
                this.newButtonImage = Image.FromStream(ms);
            }

            using (var ms = new System.IO.MemoryStream(Properties.Resources.NewBuildDefinition_8952_inactive_png))
            {
                this.newButtonDisableImage = Image.FromStream(ms);
            }

            DoubleBuffered = true;
            this.g         = System.Drawing.Graphics.FromHwnd(this.Handle);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 画range
        /// </summary>
        /// <param name="range"></param>
        private void PaintRange(Range range, ReoGridControl grid, ref RPN rpn)
        {
            var sheet = grid.CurrentWorksheet;
            //合并单元格
            string _posString = range.Postion.TopLeft + ":" + range.Postion.BottomRight;
            var    _Gridrange = sheet.Ranges[_posString];

            _Gridrange.Merge();
            //设置range边框
            sheet.SetRangeBorders(_Gridrange, BorderPositions.Outside, new RangeBorderStyle
            {
                Color = unvell.ReoGrid.Graphics.SolidColor.Black,
                Style = BorderLineStyle.Solid,
            });
            //填充数据
            switch (range.RangeType)
            {
            case RANGETYPE.Text: _Gridrange.Data = range.FormulaOrText;
                //_Gridrange.Style.HorizontalAlign = ReoGridHorAlign.Center;
                //_Gridrange.Style.VerticalAlign = ReoGridVerAlign.Middle;
                break;

            case RANGETYPE.Calc:
                object value = rpn.Evaluate(range.FormulaOrText);
                _Gridrange.Data = value;
                sheet.SetRangeDataFormat(_Gridrange, CellDataFormatFlag.Number, range.NumberFormatArgs);
                break;

            default:
                _Gridrange.Data = range.FormulaOrText;
                break;
            }
            _Gridrange.Style.HorizontalAlign = range.HAlign;
            _Gridrange.Style.VerticalAlign   = range.VAlign;
            _Gridrange.Style.FontName        = range.Font;
            _Gridrange.Style.FontSize        = range.FontSize;
        }
Exemplo n.º 10
0
        public MainWindow()
        {
            InitializeComponent();

            // Wrap winform control into WPF
            var grid = new ReoGridControl
            {
                Dock = DockStyle.Fill,
            };

            WindowsFormsHost.Child = grid;

            // Hide sheet tab control
            grid.SetSettings(WorkbookSettings.View_ShowSheetTabControl, false);

            DataContext = new MainWindowViewModel(grid.Worksheets[0]);

            ViewModel = (MainWindowViewModel)DataContext;

            ContentRendered += MainWindow_ContentRendered;

            // SearchTextBox settings----------------------------------------------------
            // Supply the control with the list of sections
            var sections = new List <string> {
                "All", "Companies", "Requisites", "Contact persons", "License", "Products", "Contracts", "Additional info"
            };

            SearchTextBox.SectionsList = sections;

            // Choose a style for displaying sections
            SearchTextBox.SectionsStyle = SearchTextBox.SectionsStyles.CheckBoxStyle;

            // Add a routine handling the event OnSearch
            SearchTextBox.OnSearch += OnSearch;
            // --------------------------------------------------------------------------
        }
Exemplo n.º 11
0
        private void Navigate1_NavigateEvent(object sender, MessageEventArgs e)
        {
            navigateTabContent.Controls.Clear();
            currentOperation = e.Message;
            switch (e.Message)
            {
            case "Home":
                homeControl = new ViewReport();
                navigateTabContent.Controls.Add(homeControl);
                sheet    = homeControl.sheet;
                workBook = homeControl.workBook;
                break;

            case "Import":
                importExcel = new Controls.ImportExcel();
                navigateTabContent.Controls.Add(importExcel);
                sheet = null;
                break;

            case "View":
                view = new Controls.View();
                navigateTabContent.Controls.Add(view);
                sheet    = view.sheet;
                workBook = view.workBook;
                break;

            case "Set":
                setControl = new Set();
                navigateTabContent.Controls.Add(setControl);
                sheet = null;
                break;

            case "ModifyPassword":
                break;
            }
        }
Exemplo n.º 12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //https://www.codeproject.com/Articles/691749/Free-NET-Spreadsheet-Control
            // create instance
            var grid = new ReoGridControl()
            {
                // put to fill the parent control
                Dock = DockStyle.Fill,
            };

            var worksheet = grid.CurrentWorksheet;

            worksheet["A1"] = "會計科目編號";
            worksheet["B1"] = "會計科目名稱";
            worksheet["C1"] = "子目編號";
            worksheet["D1"] = "子目名稱";
            worksheet["E1"] = "金額";
            worksheet.AutoFitColumnWidth(0, false);
            worksheet.AutoFitColumnWidth(1, false);
            worksheet.AutoFitColumnWidth(2, false);
            worksheet.AutoFitColumnWidth(3, false);
            worksheet["A2"] = new object[, ] {
                { "2123", "應付代收款", null, null, "=SUM(E3:E5)" },
                { "2123", "應付代收款", "A00006", "公庫利息", 109827 },
                { "2123", "應付代收款", "C00016", "畢業旅行經費", 250000 },
                { "2123", "應付代收款", "C00017", "家長會費", 5889000 },
            };
            worksheet.HideRows(2, 3);

            // https://reogrid.net/document/row-and-column/
            //worksheet.HideColumns(7, 3); //H、I、J欄被隱藏了

            //worksheet.HideRows(8, 5); //9到13列被隱藏了

            this.Controls.Add(grid);
        }
Exemplo n.º 13
0
        private void Form1_Load(object sender, EventArgs e)
        {
            reoGridControl3.Hide();
            ReoMain              = this.reoGridControl2;
            this.ForeColor       = EdLib.CFore; this.BackColor = EdLib.CBack;
            menuStrip1.ForeColor = EdLib.CFore; menuStrip1.BackColor = EdLib.CBack;
            IHighlightingDefinition customHighlighting;
            var path = EdLib.path_AppData + "\\EditorHighlighting.xshd";

            using (StreamReader s = new StreamReader(path))
            {
                if (s == null)
                {
                    throw new InvalidOperationException("加载编辑器数据失败。");
                }
                using (XmlReader reader = new XmlTextReader(s))
                {
                    customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.
                                         HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
            mainEditor.ShowLineNumbers = true;
            HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".csscript" }, customHighlighting);
            mainEditor.SyntaxHighlighting = customHighlighting;
            mainEditor.FontSize           = 15f;
            var converter = new System.Windows.Media.BrushConverter();
            var brush     = (System.Windows.Media.Brush)converter.ConvertFromString(ColorTranslator.ToHtml(Color.FromArgb(30, 30, 30)));
            var brush2    = (System.Windows.Media.Brush)converter.ConvertFromString(ColorTranslator.ToHtml(Color.FromArgb(218, 218, 218)));

            mainEditor.Background            = brush;
            mainEditor.Foreground            = brush2;
            mainEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered;
            k_hook = new KeyboardHook();
            k_hook.KeyDownEvent += new KeyEventHandler(hook_KeyDown); //钩住键按下
            k_hook.Start();                                           //安装键盘钩子
        }
Exemplo n.º 14
0
        public static void AutoFitReoGridColumnWidth(ReoGridControl reoGrid)
        {
            var worksheet = reoGrid.CurrentWorksheet;

            for (int i = 0; i < worksheet.Columns; i++)
            {
                if (worksheet.ColumnHeaders[i].IsVisible == false)
                {
                    continue;
                }
                worksheet.AutoFitColumnWidth(i);
                string headerText  = worksheet.ColumnHeaders[i].Text;
                ushort headerWidth = (ushort)(headerText.Length * 10);
                //如果内容宽度小于表头长度,取表头宽度。
                if (worksheet.GetColumnWidth(i) < headerWidth)
                {
                    worksheet.SetColumnsWidth(i, 1, (ushort)(headerWidth + 20));
                }//否则取内容宽度
                else
                {
                    worksheet.SetColumnsWidth(i, 1, (ushort)(worksheet.GetColumnWidth(i) + 10));
                }
            }
        }
Exemplo n.º 15
0
 void grid_Disposed(object sender, EventArgs e)
 {
     this.GridControl = null;
 }
Exemplo n.º 16
0
        /// <summary>
        /// 用于设置任务初始化表格参数
        /// </summary>
        /// <param name="reoGridControl">需要被初始化的第三方表格控件</param>
        public void 初始化任务表格框架(ReoGridControl reoGridControl_New1, ReoGridControl reoGridControl_New2)
        {
            while (reoGridControl_New1.Worksheets.Count != 0 || reoGridControl_New2.Worksheets.Count != 0)
            {
                if (reoGridControl_New1.Worksheets.Count != 0)
                {
                    reoGridControl_New1.Worksheets.RemoveAt(0);
                }

                if (reoGridControl_New2.Worksheets.Count != 0)
                {
                    reoGridControl_New2.Worksheets.RemoveAt(0);
                }
            }

            reoGridControl_New1.Worksheets.Add(reoGridControl_New1.Worksheets.Create("任务基础框架"));
            reoGridControl_New1.Worksheets.Add(reoGridControl_New1.Worksheets.Create("必填完成条件"));
            reoGridControl_New1.Worksheets.Add(reoGridControl_New1.Worksheets.Create("必填完成奖励"));
            reoGridControl_New1.Worksheets.Add(reoGridControl_New1.Worksheets.Create("额外选择项"));
            reoGridControl_New1.Worksheets.Add(reoGridControl_New1.Worksheets.Create("自选奖励"));

            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("前置任务"));
            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("给予道具"));
            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("额外地图"));
            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("限制副本"));
            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("冲突任务"));
            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("怪物掉落"));
            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("敌人掉落"));
            reoGridControl_New2.Worksheets.Add(reoGridControl_New2.Worksheets.Create("弹出任务"));

            //设置第一个表格的数据
            for (int i = 0; i < reoGridControl_New1.Worksheets.Count; i++)
            {
                int ColCount = (int)QuestTou1[i][0];
                reoGridControl_New1.Worksheets[i].ColumnCount = ColCount;

                object[] LinShi = new TongYongFangFa().GetObjShuZu(QuestTou1[i], 1, QuestTou1[i].Length - 1);

                if (ColCount == LinShi.Length / 2)
                {
                    for (int a = 0; a < ColCount; a++)
                    {
                        reoGridControl_New1.Worksheets[i].ColumnHeaders[a].Text  = (string)LinShi[a * 2];
                        reoGridControl_New1.Worksheets[i].ColumnHeaders[a].Width = Convert.ToUInt16(LinShi[a * 2 + 1]);
                    }
                }
                else
                {
                    int Pos = 0;
                    for (int a = 0; a < ColCount; a++)
                    {
                        if (Pos > LinShi.Length - 1)
                        {
                            Pos = 0;
                        }

                        reoGridControl_New1.Worksheets[i].ColumnHeaders[a].Text  = (string)LinShi[Pos];
                        reoGridControl_New1.Worksheets[i].ColumnHeaders[a].Width = Convert.ToUInt16(LinShi[Pos + 1]);

                        Pos += 2;
                    }
                }
            }

            //设置第二个表格的数据
            for (int i = 0; i < reoGridControl_New2.Worksheets.Count; i++)
            {
                int ColCount = (int)QuestTou2[i][0];
                reoGridControl_New2.Worksheets[i].ColumnCount = ColCount;

                object[] LinShi = new TongYongFangFa().GetObjShuZu(QuestTou2[i], 1, QuestTou2[i].Length - 1);

                if (ColCount == LinShi.Length / 2)
                {
                    for (int a = 0; a < ColCount; a++)
                    {
                        reoGridControl_New2.Worksheets[i].ColumnHeaders[a].Text  = (string)LinShi[a * 2];
                        reoGridControl_New2.Worksheets[i].ColumnHeaders[a].Width = Convert.ToUInt16(LinShi[a * 2 + 1]);
                    }
                }
                else
                {
                    int Pos = 0;
                    for (int a = 0; a < ColCount; a++)
                    {
                        if (Pos > LinShi.Length - 1)
                        {
                            Pos = 0;
                        }

                        reoGridControl_New2.Worksheets[i].ColumnHeaders[a].Text  = (string)LinShi[Pos];
                        reoGridControl_New2.Worksheets[i].ColumnHeaders[a].Width = Convert.ToUInt16(LinShi[Pos + 1]);

                        Pos += 2;
                    }
                }
            }

            new Grid_SheJiTu().设置行数(reoGridControl_New1, 25);
            new Grid_SheJiTu().设置行数(reoGridControl_New2, 25);
        }
Exemplo n.º 17
0
 /// <summary>
 /// 删除表格所有信息并且恢复到开始原有状态
 /// </summary>
 /// <param name="reoGridControl">需要被更改的第三方控件</param>
 public void 重置设计图表格(ReoGridControl reoGridControl)
 {
     初始化设计图表格框架(reoGridControl);
 }
Exemplo n.º 18
0
 public override void OnSetup(ReoGridControl ctrl, ReoGridCell cell)
 {
     this.Grid = ctrl;
 }
Exemplo n.º 19
0
        public static double Avg(ReoGridControl ctrl, ReoGridRange range)
        {
            double val = 0;
            int count = 0;

            ctrl.IterateCells(range, (row, col, cell) =>
            {
                if (cell != null && ScriptRunningMachine.IsNumber(cell.Data))
                {
                    val += ScriptRunningMachine.GetDoubleValue(cell.Data);
                    count++;
                }
                return true;
            });

            return val / count;
        }
Exemplo n.º 20
0
 public override void OnSetup(ReoGridControl ctrl, ReoGridCell cell)
 {
     // set text to center
     cell.Style.HAlign = ReoGridHorAlign.Center;
     cell.Style.VAlign = ReoGridVerAlign.Middle;
 }
Exemplo n.º 21
0
 public override void OnSetup(ReoGridControl ctrl, ReoGridCell cell)
 {
     ImageAnimator.Animate(Gif, OnFrameChanged);
 }
Exemplo n.º 22
0
 private void OnLoadedCommand(ReoGridControl reoGridControl)
 {
     _WorksheetModel = new WorksheetModel(reoGridControl, typeof(Book), _Books);
     _WorksheetModel.OnBeforeChangeRecord += WorksheetModel_OnBeforeChangeRecord;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Load border info from grid
        /// </summary>
        /// <param name="grid"></param>
        public void ReadFromGrid(ReoGridControl grid)
        {
            if (grid.SelectionRange.IsEmpty)
            {
                this.Enabled = false;
            }
            else
            {
                ReoGridRangeBorderInfo info = grid.GetRangeBorder(grid.SelectionRange, false);

                if (!info.Left.IsEmpty) borders[ReoGridBorderPos.Left] = info.Left;
                if (!info.Right.IsEmpty) borders[ReoGridBorderPos.Right] = info.Right;
                if (!info.Top.IsEmpty) borders[ReoGridBorderPos.Top] = info.Top;
                if (!info.Bottom.IsEmpty) borders[ReoGridBorderPos.Bottom] = info.Bottom;
                if (!info.InsideHorizontal.IsEmpty) borders[ReoGridBorderPos.InsideHorizontal] = info.InsideHorizontal;
                if (!info.InsideVertical.IsEmpty) borders[ReoGridBorderPos.InsideVertical] = info.InsideVertical;

                rows = grid.SelectionRange.Rows > 2 ? 2 : grid.SelectionRange.Rows;
                cols = grid.SelectionRange.Cols > 2 ? 2 : grid.SelectionRange.Cols;

                mixBorders |= info.NonUniformPos;
            }
        }
Exemplo n.º 24
0
        public RGSetRangeBorderAction CreateUpdateAction(ReoGridControl grid)
        {
            // just creating actions for changed borders
            if (borderAdded != ReoGridBorderPos.None || borderRemoved != ReoGridBorderPos.None)
            {
                List<ReoGridBorderPosStyle> styles = new List<ReoGridBorderPosStyle>();

                AddBorderPosStyle(styles, borderAdded);

                // fix bug: border cannot be removed
                //AddBorderPosStyle(styles, borderRemoved);
                styles.Add(new ReoGridBorderPosStyle(borderRemoved, ReoGridBorderStyle.Empty));

                RGSetRangeBorderAction action = new RGSetRangeBorderAction(grid.SelectionRange, styles.ToArray());
                return action;
            }
            else
                return null;
        }
Exemplo n.º 25
0
 public override void OnSetup(ReoGridControl ctrl, ReoGridCell cell)
 {
     cell.Style.TextColor = Color.Blue;
     cell.Style.Underline = true;
 }
Exemplo n.º 26
0
 public override void OnSetup(ReoGridControl ctrl, ReoGridCell cell)
 {
     this.GridInstance = ctrl;
     this.Cell = cell;
 }
Exemplo n.º 27
0
        public void loadAll()
        {
            var pos2 = GetPath("{game}\\TetraProject_Data\\StreamingAssets\\Packages\\Builtin\\Database\\CardCommand.csv");

            if (EdLib.HasFile(pos2))
            {
                if (AutoCompleteData == null)
                {
                    AutoCompleteData = new List <ICompletionData>();
                    var obj = new ReoGridControl();
                    obj.Load(pos2, unvell.ReoGrid.IO.FileFormat.CSV);
                    for (int i = 1; i < obj.CurrentWorksheet.RowCount; i++)
                    {
                        if (obj.CurrentWorksheet[i, 0] != null)
                        {
                            if (obj.CurrentWorksheet[i, 1] != null)
                            {
                                AutoCompleteData.Add(new MyCompletionData(obj.CurrentWorksheet[i, 0].ToString(), obj.CurrentWorksheet[i, 1].ToString()));
                            }
                        }
                    }
                    obj.Dispose();
                }
            }


            if (EdLib.HasFile(path_CurrentPackage, true))
            {
                //sheet.SetColumnsWidth(0, 1, 50);
                IsCurrentPackageSteamWorkshop = false;
                var pos = GetPath(path_CurrentPackage) + "\\Database\\";
                if (path_CurrentPackage.Contains("steamapps"))
                {
                    IsCurrentPackageSteamWorkshop = true;
                }
                //return;
                try
                {
                    if (IsCSVLoader)
                    {
                        LoadCSV(pos);
                    }
                    else
                    {
                        if (EdLib.HasFile(pos + "database.xlsx"))
                        {
                            ReoMain.Load(pos + "database.xlsx", unvell.ReoGrid.IO.FileFormat.Excel2007);
                        }
                        else
                        {
                            ReoMain.Load(pos + "database.xls", unvell.ReoGrid.IO.FileFormat.Excel2007);
                        }
                    }
                }
                catch (Exception e)
                {
                    if (e.Message.Contains("ZipFile"))
                    {
                        //直接读取--- csv
                        LoadCSV(pos);
                    }
                    else
                    {
                        EdLib.AskMsg("读取资料库时发生严重异常,错误信息:\n" + e.ToString() + "\n" + e.Message);

                        return;
                    }
                }

                ReoMain.Readonly = IsCurrentPackageSteamWorkshop;

                foreach (var item in reoGridControl2.Worksheets)
                {
                    item.NameTextColor          = EdLib.CFore;
                    item.NameBackColor          = EdLib.CBack;
                    item.SelectionRangeChanged += Item_SelectionRangeChanged;
                    if (item.Name == "Card")
                    {
                        ReoMain.CurrentWorksheet = item;
                    }
                }

                LoadSheet();
                return;
            }
        }
Exemplo n.º 28
0
        public static void DumpGrid(ReoGridControl grid, Stream stream)
        {
            var sw = new StreamWriter(stream);

            for (int row = 0; row < grid.RowCount; row++)
            {
                for (int col = 0; col < grid.ColCount; col++)
                {
                    var hborder = grid.RetrieveHBorder(row, col);
                    if (hborder != null)
                    {
                        sw.Write(hborder.Cols);
                    }

                    sw.Write("\t");
                }

                sw.WriteLine("\n");
            }
        }
Exemplo n.º 29
0
        public bool FormatCell(ReoGridControl grid, ReoGridCell cell)
        {
            bool isFormat = false;

            object data = cell.Data;
            double currency = double.NaN;

            if (data is double)
            {
                isFormat = true;
                currency = (double)data;
            }
            else if (data is DateTime)
            {
                currency = (new DateTime(1900, 1, 1) - (DateTime)data).TotalDays;
                isFormat = true;
            }
            else
            {
                string str = Convert.ToString(data).Trim();
                string number = string.Empty;

                if (str.StartsWith("$"))
                {
                    number = str.Substring(1);
                    if (double.TryParse(number, out currency))
                    {
                        isFormat = true;
                        cell.Data = currency;
                    }
                }
                else
                {
                    DateTime date = new DateTime(1900, 1, 1);
                    if (DateTime.TryParse(str, out date))
                    {
                        currency = (date - new DateTime(1900, 1, 1)).TotalDays;
                        isFormat = true;
                    }
                    else
                    {
                        isFormat = double.TryParse(str, out currency);
                    }
                }
            }

            if (isFormat)
            {
                if (cell.Style.HAlign == ReoGridHorAlign.General)
                {
                    cell.RenderHorAlign = ReoGridRenderHorAlign.Right;
                }

                string symbol = null;
                short decimals = 2;
                NumberDataFormatter.NumberNegativeStyle negativeStyle = NumberDataFormatter.NumberNegativeStyle.Minus;

                if (cell.DataFormatArgs != null && cell.DataFormatArgs is CurrencyFormatArgs)
                {
                    CurrencyFormatArgs args = (CurrencyFormatArgs)cell.DataFormatArgs;
                    symbol = args.Symbol;
                    decimals = args.DecimalPlaces;
                    negativeStyle = args.NegativeStyle;
                }
                else
                {
                    symbol = Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol;
                    cell.DataFormatArgs = new CurrencyFormatArgs { Symbol = symbol, DecimalPlaces = decimals };
                }

                if (currency < 0)
                {
                    if ((negativeStyle & NumberDataFormatter.NumberNegativeStyle.Red) == NumberDataFormatter.NumberNegativeStyle.Red)
                        cell.RenderColor = Color.Red;
                    else
                        cell.RenderColor = Color.Empty;
                }

                // decimal places
                string decimalPlacePart = new string('0', decimals);

                // number
                string numberPart = symbol + "#,##0." + decimalPlacePart;
                if ((negativeStyle & NumberDataFormatter.NumberNegativeStyle.Brackets) == NumberDataFormatter.NumberNegativeStyle.Brackets)
                {
                    numberPart = (currency < 0) ? ("(" + numberPart + ")") : numberPart;
                }

                // negative
                if (negativeStyle != NumberDataFormatter.NumberNegativeStyle.Minus)
                {
                    currency = Math.Abs(currency);
                }

                cell.Display = currency.ToString(numberPart);

                //string decimalPlaceFormat = new string('0', decimalPlaces);
                //cell.Display = string.Format("{0}{1:#,##0." + decimalPlaceFormat + "}", symbol, currency);
            }

            return isFormat;
        }
Exemplo n.º 30
0
 internal static void SetupBuiltinFunctions(ReoGridControl grid, ScriptRunningMachine srm)
 {
     srm["sum"] = new NativeFunctionObject("sum", (ctx, owner, args) => Sum(grid, RSUtility.GetRangeFromArgs(grid, args)));
     srm["SUM"] = new NativeFunctionObject("SUM", (ctx, owner, args) => Sum(grid, RSUtility.GetRangeFromArgs(grid, args)));
     srm["avg"] = new NativeFunctionObject("avg", (ctx, owner, args) => Avg(grid, RSUtility.GetRangeFromArgs(grid, args)));
     srm["AVG"] = new NativeFunctionObject("AVG", (ctx, owner, args) => Avg(grid, RSUtility.GetRangeFromArgs(grid, args)));
     srm["count"] = new NativeFunctionObject("count", (ctx, owner, args) => Count(grid, RSUtility.GetRangeFromArgs(grid, args)));
     srm["COUNT"] = new NativeFunctionObject("COUNT", (ctx, owner, args) => Count(grid, RSUtility.GetRangeFromArgs(grid, args)));
 }
Exemplo n.º 31
0
        internal void FormatCell(ReoGridControl grid, ReoGridCell cell)
        {
            // clear cell render color
            // render color used for draw a negative number
            cell.RenderColor = Color.Empty;

            if (cell.DataFormat == CellDataFormatFlag.General)
            {
                bool found = false;
                foreach (CellDataFormatFlag flag in dataFormatters.Keys)
                {
                    var formatter = dataFormatters[flag];

                    if (formatter.PerformTestFormat()
                        && dataFormatters[flag].FormatCell(grid, cell))
                    {
                        cell.DataFormat = flag;
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    cell.Display = Convert.ToString(cell.Data);

                    // if horizontal-align is auto self-adapt,
                    // set the render alignment to left for string type
                    if (cell.Style.HAlign == ReoGridHorAlign.General)
                    {
                        cell.RenderHorAlign = ReoGridRenderHorAlign.Left;
                    }
                }

            }
            else
            {
                bool success = DataFormatters[cell.DataFormat].FormatCell(grid, cell);

                if (!success)
                {
                    DataFormatters[CellDataFormatFlag.Text].FormatCell(grid, cell);
                }
            }
        }
Exemplo n.º 32
0
        public Spreadsheet(Flowsheet fs)
        {
            Columns.AddRange(new[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" });

            flowsheet = fs;
            scontrol  = new ReoGridFullControl();
            Sheet     = scontrol.GridControl;
            SetCustomFunctions();
            flowsheet.GetSpreadsheetObjectFunc = () => { return(Sheet); };
            Sheet.CurrentWorksheet.Name        = "MAIN";

            scontrol.ImportDataMenuItem.Click += (sender, e) =>
            {
                Application.Instance.Invoke(() =>
                {
                    var selector = new PropertySelector()
                    {
                        Flowsheet = flowsheet, ObjList = ObjList
                    };

                    selector.btnOK.Click += (sender2, e2) =>
                    {
                        var units = "";
                        if (selector.list4.SelectedValue != null)
                        {
                            units = selector.list4.SelectedValue.ToString();
                        }
                        Sheet.CurrentWorksheet.Cells[Sheet.CurrentWorksheet.SelectionRange.StartPos].Formula =
                            String.Format("GETPROPVAL({3}{1}{3}{0}{3}{2}{3}{0}{3}{4}{3})",
                                          ';',
                                          selector.list2.SelectedKey,
                                          selector.list3.SelectedKey,
                                          '"', units);

                        selector.Close();

                        Sheet.CurrentWorksheet.EndEdit(EndEditReason.Cancel);
                    };

                    selector.ShowModal();
                });
            };

            scontrol.ExportDataMenuItem.Click += (sender, e) =>
            {
                Application.Instance.Invoke(() =>
                {
                    var selector = new PropertySelector()
                    {
                        Flowsheet = flowsheet, ObjList = ObjList
                    };

                    selector.btnOK.Click += (sender2, e2) =>
                    {
                        var units = "";
                        if (selector.list4.SelectedValue != null)
                        {
                            units = selector.list4.SelectedValue.ToString();
                        }
                        var scell     = Sheet.CurrentWorksheet.Cells[Sheet.CurrentWorksheet.SelectionRange.StartPos];
                        var currdata  = scell.Formula == null ? scell.Data : scell.Formula;
                        scell.Formula = String.Format("SETPROPVAL({3}{1}{3}{0}{3}{2}{3}{0}{3}{4}{3}{0}{3}{5}{3})",
                                                      ';',
                                                      selector.list2.SelectedKey,
                                                      selector.list3.SelectedKey,
                                                      '"',
                                                      currdata, units);

                        selector.Close();

                        Sheet.CurrentWorksheet.EndEdit(EndEditReason.Cancel);
                    };

                    selector.ShowModal();
                });
            };

            scontrol.CreateChartMenuItem.Click += (sender, e) =>
            {
                Application.Instance.Invoke(() =>
                {
                    CreateChartFromRange(sender, e);
                });
            };
        }
Exemplo n.º 33
0
        public bool FormatCell(ReoGridControl grid, ReoGridCell cell)
        {
            object data = cell.Data;

            bool isFormat = false;

            DateTime value = new DateTime(1900, 1, 1);

            if (data is DateTime)
            {
                value = (DateTime)data;
                isFormat = true;
            }
            else if (data is double)
            {
                try
                {
                    value = value.AddDays((double)data);
                    isFormat = true;
                }
                catch { }
            }
            else
            {
                string strdata = Convert.ToString(data);

                double days = 0;
                if (double.TryParse(strdata, out days))
                {
                    try
                    {
                        value = value.AddDays(days);
                        isFormat = true;
                    }
                    catch { }
                }
                else
                {
                    isFormat = (DateTime.TryParse(strdata, out value));
                }
            }

            if (isFormat)
            {
                if (cell.Style.HAlign == ReoGridHorAlign.General)
                {
                    cell.RenderHorAlign = ReoGridRenderHorAlign.Right;
                }

                CultureInfo culture = null;

                string format = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;

                if (cell.DataFormatArgs != null && cell.DataFormatArgs is DateTimeFormatArgs)
                {
                    DateTimeFormatArgs dargs = (DateTimeFormatArgs)cell.DataFormatArgs;

                    format = dargs.Format;
                    culture = new CultureInfo(dargs.CultureName);
                }
                else
                {
                    culture = System.Threading.Thread.CurrentThread.CurrentCulture;
                    cell.DataFormatArgs = new DateTimeFormatArgs { Format = format, CultureName = culture.Name };
                }

                cell.Display = value.ToString(format, culture);
            }

            return isFormat;
        }
Exemplo n.º 34
0
 public void SetGrid(ReoGridControl grid)
 {
     ReoGridCell cell = (grid == null) ? null : (grid.GetCell(grid.SelectionRange.StartPos));
     ProcessAllPages(p =>
     {
         p.Grid = grid;
         p.LoadPage();
     });
 }
Exemplo n.º 35
0
 public static void DumpGrid(ReoGridControl grid, string file)
 {
     using (var fs = new FileStream(file, FileMode.Create, FileAccess.Write))
     {
         DumpGrid(grid, fs);
     }
 }
Exemplo n.º 36
0
 public DropdownCell(ReoGridControl grid)
 {
     this.Grid = grid;
 }
Exemplo n.º 37
0
        public bool FormatCell(ReoGridControl grid, ReoGridCell cell)
        {
            object data = cell.Data;

            double percent = 0;
            bool isFormat = false;
            short dec = 0;

            if (data is double)
            {
                percent = (double)data;
                isFormat = true;
                dec = 9;
            }
            else if (data is DateTime)
            {
                percent = ((DateTime)data - new DateTime(1900, 1, 1)).TotalDays;
                isFormat = true;
                dec = 0;
            }
            else
            {
                string str = Convert.ToString(data);
                if (str.Length > 1 && str.EndsWith("%"))
                {
                    str = str.Substring(0, str.Length - 1);

                    isFormat = double.TryParse(str, out percent);

                    if (isFormat)
                    {
                        int decimalPlaceIndex = str.LastIndexOf('.');
                        if (decimalPlaceIndex >= 0)
                        {
                            dec = (short)(str.Length - decimalPlaceIndex);
                        }
                    }
                }
                else
                {
                    isFormat = double.TryParse(str, out percent);

                    if (!isFormat)
                    {
                        DateTime date = new DateTime(1900, 1, 1);
                        if (DateTime.TryParse(str, out date))
                        {
                            percent = (date - new DateTime(1900, 1, 1)).TotalDays;
                            isFormat = true;
                        }
                    }

                    // should not use 'else' here
                    if (isFormat)
                    {
                        int decimalPlaceIndex = str.LastIndexOf('.');
                        if (decimalPlaceIndex >= 0)
                        {
                            dec = (short)(str.Length - decimalPlaceIndex);
                        }
                    }
                }

                if (isFormat) cell.Data = percent;
            }

            if (isFormat)
            {
                if (cell.DataFormatArgs != null && cell.DataFormatArgs is PercentFormatArgs)
                {
                    dec = ((PercentFormatArgs)cell.DataFormatArgs).DecimalPlaces;
                }
                else
                {
                    cell.DataFormatArgs = new PercentFormatArgs { DecimalPlaces = dec };
                }

                string decimalPlacePart = new string('0', dec);

                cell.Display = percent.ToString("0." + decimalPlacePart) + "%";

                if (cell.Style.HAlign == ReoGridHorAlign.General)
                {
                    cell.RenderHorAlign = ReoGridRenderHorAlign.Right;
                }
            }

            return isFormat;
        }
Exemplo n.º 38
0
        public void AddSheJiTuInfo(ReoGridControl reoGridControl, Dictionary <string, string> SheJiTu)
        {
            for (int a = 0; a < reoGridControl.Worksheets[0].RowCount; a++)
            {
                string        Name            = "";
                string        Explain         = "";
                string        FlavorText      = "";
                string        Grade           = "";
                string        Rarity          = "";
                string        UsableJob       = "";
                string        AttachType      = "";
                string        MinimumLevel    = "";
                string        Cooltime        = "";
                string        Price           = "";
                string        Value           = "";
                string        Icon            = "";
                string        IconId          = "";
                string        FieldImage      = "";
                string        FieldImageId    = "";
                string        MoveWav         = "";
                string        FileName        = "";
                StringBuilder IntDataMaterial = new StringBuilder();
                StringBuilder IntDataEnd      = new StringBuilder();
                string        IconMark        = "";
                string        IconMarkId      = "";
                string        NeedMaterialId  = "";
                string        NeedMaterialSl  = "";
                string        StackLimit      = "";
                string        SuccessRate     = "";
                string        BroadcastType   = "";
                string        MaintainAbility = "";
                string        FailOutputId    = "";
                string        FailOutputSl    = "";
                string        StringData      = "";
                string        UpgradeTable    = "";
                string        FuZhiYeType     = "";
                string        FuZhiYeLevel    = "";
                string        BeadItemId      = "";
                string        BeadItemSl      = "";
                string        StkType         = "[stackable type]\r\n`[recipe]`\r\n1\t\r\n";
                string        FileTou         = "#PVF_File\r\n\r\n";

                int Count = 0;
                for (int b = 0; b < reoGridControl.Worksheets.Count; b++)
                {
                    for (int c = 0; c < reoGridControl.Worksheets[b].ColumnCount; c++)
                    {
                        string LinShiText = reoGridControl.Worksheets[b].GetCellText(a, c);
                        if (LinShiText == "")
                        {
                            continue;
                        }

                        switch (b)
                        {
                        case 0:
                            switch (c)
                            {
                            case 0:
                                Name = $"[name]\r\n`{LinShiText}`\r\n\r\n";
                                break;

                            case 1:
                                Explain = $"[explain]\r\n`{LinShiText}`\r\n\r\n";
                                break;

                            case 2:
                                FlavorText = $"[flavor text]\r\n`{LinShiText}`\r\n\r\n";
                                break;

                            case 3:
                                Grade = $"[grade]\r\n{LinShiText}\t\r\n";
                                break;

                            case 4:
                                Rarity = $"[rarity]\r\n{LinShiText}\t\r\n";
                                break;

                            case 5:
                                UsableJob = $"[usable job]\r\n`[{LinShiText}]`\r\n\r\n[/usable job]\r\n\r\n";
                                break;

                            case 6:
                                AttachType = $"[attach type]\r\n`[{LinShiText}]`\r\n\r\n";
                                break;

                            case 7:
                                MinimumLevel = $"[minimum level]\r\n{LinShiText}\t\r\n";
                                break;

                            case 8:
                                Cooltime = $"[cool time]\r\n{LinShiText}\t\r\n";
                                break;

                            case 9:
                                Price = $"[price]\r\n{LinShiText}\t\r\n";
                                break;

                            case 10:
                                Value = $"[value]\r\n{LinShiText}\t\r\n";
                                break;

                            case 11:
                                Icon = $"[icon]\r\n`{LinShiText}`\r\n";
                                break;

                            case 12:
                                IconId = $"{LinShiText}\t\r\n";
                                break;

                            case 13:
                                FieldImage = $"[field image]\r\n`{LinShiText}`\r\n";
                                break;

                            case 14:
                                FieldImageId = $"{LinShiText}\t\r\n";
                                break;

                            case 15:
                                MoveWav = $"[move wav]\r\n`{LinShiText}`\r\n\r\n";
                                break;

                            case 16:
                                StringData = $"[string data]\r\n`[{LinShiText}]`\r\n\r\n[/string data]\r\n\r\n";
                                break;

                            case 17:
                                FileName = $"{LinShiText}.stk";
                                break;
                            }
                            break;

                        case 1:
                            IntDataMaterial.Append(LinShiText + "\t");
                            Count++;
                            break;

                        case 2:
                            IntDataEnd.Append(LinShiText + "\t");
                            Count++;
                            break;

                        case 3:
                            switch (c)
                            {
                            case 0:
                                IconMark = $"[icon mark]\r\n`{LinShiText}`\r\n";
                                break;

                            case 1:
                                IconMarkId = $"{LinShiText}\t\r\n";
                                break;

                            case 2:
                                NeedMaterialId = $"[need material]\r\n{LinShiText}\t";
                                break;

                            case 3:
                                NeedMaterialSl = $"{LinShiText}\t\r\n";
                                break;

                            case 4:
                                StackLimit = $"[stack limit]\r\n{LinShiText}\t\r\n";
                                break;

                            case 5:
                                SuccessRate = $"[success rate]\r\n{LinShiText}\t\r\n";
                                break;

                            case 6:
                                BroadcastType = $"[broadcast type]\r\n{LinShiText}\t\r\n";
                                break;

                            case 7:
                                MaintainAbility = $"[maintain ability]\r\n{LinShiText}\t\r\n";
                                break;

                            case 8:
                                FailOutputId = $"[fail output]\r\n{LinShiText}\t";
                                break;

                            case 9:
                                FailOutputSl = $"{LinShiText}\t\r\n[/fail output]\r\n\r\n";
                                break;

                            case 10:
                                UpgradeTable = $"[{LinShiText}]\r\n\r\n";
                                break;

                            case 11:
                                FuZhiYeType = $"{LinShiText}\t";
                                break;

                            case 12:
                                FuZhiYeLevel = $"{LinShiText}\t2\t";
                                break;

                            case 13:
                                BeadItemId = $"[bead item]\r\n{LinShiText}\t";
                                break;

                            case 14:
                                BeadItemSl = $"{LinShiText}\t\r\n[/bead item]\r\n\r\n";
                                break;
                            }
                            break;
                        }
                    }

                    switch (b)
                    {
                    case 1:
                        IntDataMaterial.Insert(0, Count / 2 + "\t");
                        Count = 0;
                        break;

                    case 2:
                        IntDataEnd.Insert(0, Count / 2 + "\t");
                        Count = 0;
                        break;
                    }
                }

                if (FuZhiYeType == "")
                {
                    SheJiTu.Add(FileName, FileTou + Name + Explain + FlavorText + NeedMaterialId + NeedMaterialSl + Grade + Rarity + UsableJob + AttachType + MinimumLevel + Cooltime + Price + Value + StackLimit + Icon + IconId + FieldImage + FieldImageId + IconMark + IconMarkId + StkType + MoveWav + $"[int data]\r\n{IntDataMaterial.ToString()}{IntDataEnd.ToString()}0\t\r\n[/int data]\r\n\r\n" + SuccessRate + BroadcastType + MaintainAbility + FailOutputId + FailOutputSl + StringData + UpgradeTable);
                }
                else
                {
                    SheJiTu.Add(FileName, FileTou + Name + Explain + FlavorText + NeedMaterialId + NeedMaterialSl + Grade + Rarity + UsableJob + AttachType + MinimumLevel + Cooltime + Price + Value + StackLimit + Icon + IconId + FieldImage + FieldImageId + IconMark + IconMarkId + StkType + MoveWav + $"[int data]\r\n{IntDataMaterial.ToString()}{IntDataEnd.ToString()}1\t{FuZhiYeType}{FuZhiYeLevel}\r\n[/int data]\r\n\r\n" + BeadItemId + BeadItemSl + SuccessRate + BroadcastType + MaintainAbility + FailOutputId + FailOutputSl + StringData + UpgradeTable);
                }
            }
        }
Exemplo n.º 39
0
        public bool FormatCell(ReoGridControl grid, ReoGridCell cell)
        {
            object data = cell.Data;

            // check numeric
            bool isNumeric = false;

            double value = 0;
            if (data is int)
            {
                value = (double)(int)data;
                isNumeric = true;
            }
            else if (data is double)
            {
                value = (double)data;
                isNumeric = true;
            }
            else if (data is string)
            {
                string strdata = (data as string).Trim();

                isNumeric = double.TryParse(strdata, out value);

                if (isNumeric) cell.Data = value;
            }

            if (isNumeric)
            {
                if (cell.Style.HAlign == ReoGridHorAlign.General)
                {
                    cell.RenderHorAlign = ReoGridRenderHorAlign.Right;
                }

                cell.Display = Convert.ToString(value);

                return true;
            }
            else
                return false;
        }
Exemplo n.º 40
0
        public void AddSheJiTuInfo(ReoGridControl reoGridControl_New1, ReoGridControl reoGridControl_New2, Dictionary <string, string> RenWu)
        {
            for (int a = 0; a < reoGridControl_New1.Worksheets[0].RowCount; a++)
            {
                string Grade            = "";
                string NpcId            = "";
                string CompleteNpcId    = "";
                string Job              = "";
                string GrowType         = "";
                string Level            = "";
                string Name             = "";
                string DependMessage    = "";
                string ConditionMessage = "";
                string SolveMessage     = "";
                string RenWuFileName    = "";

                string        Type    = "";
                string        SubType = "";
                StringBuilder IntData = new StringBuilder();

                string        RewardType    = "";
                StringBuilder RewardIntData = new StringBuilder();

                StringBuilder RewardSelectionIntData = new StringBuilder();

                string Event        = "";
                string CantGiveup   = "";
                string DeleteNpcId  = "";
                string GoldMultiple = "";
                string QuestPoint   = "";
                string PVPRANK      = "";

                StringBuilder PreRequiredQuest  = new StringBuilder();
                StringBuilder DependGiveItem    = new StringBuilder();
                StringBuilder AppearMap         = new StringBuilder();
                StringBuilder LimitDungeonId    = new StringBuilder();
                StringBuilder CollisionQuest    = new StringBuilder();
                StringBuilder MonsterRewardItem = new StringBuilder();
                StringBuilder EnemyRewardItem   = new StringBuilder();
                string        RelationQuest     = "";

                string FileTou = "#PVF_File\r\n\r\n";

                for (int b = 0; b < reoGridControl_New1.Worksheets.Count; b++)
                {
                    for (int c = 0; c < reoGridControl_New1.Worksheets[b].ColumnCount; c++)
                    {
                        string AddText = reoGridControl_New1.Worksheets[b].GetCellText(a, c);
                        if (AddText == "")
                        {
                            continue;
                        }

                        switch (b)
                        {
                        case 0:
                            switch (c)
                            {
                            case 0:
                                Grade = $"[grade]\r\n`[{AddText}]`\r\n\r\n";
                                break;

                            case 1:
                                NpcId = $"[npc index]\r\n{AddText}\t\r\n";
                                break;

                            case 2:
                                CompleteNpcId = $"[complete npc index]\r\n{AddText}\t\r\n";
                                break;

                            case 3:
                                Job = $"[job]\r\n`[{AddText}]`\r\n\r\n";
                                break;

                            case 4:
                                GrowType = $"[grow type]\r\n{AddText}\t\r\n";
                                break;

                            case 5:
                                Level = $"[level]\r\n{AddText}\t";
                                break;

                            case 6:
                                Level += $"{AddText}\t\r\n";
                                break;

                            case 7:
                                Name = $"[name]\r\n`{AddText}`\r\n\r\n";
                                break;

                            case 8:
                                DependMessage = $"[depend message]\r\n`{AddText}`\r\n\r\n";
                                break;

                            case 9:
                                ConditionMessage = $"[condition message]\r\n`{AddText}`\r\n\r\n";
                                break;

                            case 10:
                                SolveMessage = $"[solve message]\r\n`{AddText}`\r\n\r\n";
                                break;

                            case 11:
                                RenWuFileName = $"{AddText}.qst";
                                break;
                            }
                            break;

                        case 1:
                            switch (c)
                            {
                            case 0:
                                Type = $"[type]\r\n`[{AddText}]`\r\n\r\n";
                                break;

                            case 1:
                                SubType = $"[sub type]\r\n{AddText}\t\r\n";
                                break;

                            default:
                                IntData.Append(AddText + "\t");
                                break;
                            }
                            break;

                        case 2:
                            switch (c)
                            {
                            case 0:
                                RewardType = $"[reward type]\r\n`[{AddText}]`\r\n\r\n";
                                break;

                            default:
                                RewardIntData.Append(AddText + "\t");
                                break;
                            }
                            break;

                        case 3:
                            switch (c)
                            {
                            case 0:
                                Event = $"[event]\r\n{AddText}\t\r\n";
                                break;

                            case 1:
                                CantGiveup = $"[cant giveup]\r\n{AddText}\t\r\n";
                                break;

                            case 2:
                                DeleteNpcId = $"[delete npc index]\r\n{AddText}\t\r\n";
                                break;

                            case 3:
                                GoldMultiple = $"[gold multiple]\r\n{AddText}\t\r\n";
                                break;

                            case 4:
                                QuestPoint = $"[quest point]\r\n{AddText}\t\r\n";
                                break;

                            case 5:
                                PVPRANK = $"[PVP RANK]\r\n{AddText}\t\r\n";
                                break;
                            }
                            break;

                        case 4:
                            RewardSelectionIntData.Append(AddText + "\t");
                            break;
                        }
                    }
                }

                for (int b = 0; b < reoGridControl_New2.Worksheets.Count; b++)
                {
                    for (int c = 0; c < reoGridControl_New2.Worksheets[b].ColumnCount; c++)
                    {
                        string Text = reoGridControl_New2.Worksheets[b].GetCellText(a, c);
                        if (Text == "")
                        {
                            break;
                        }

                        switch (b)
                        {
                        case 0:
                            PreRequiredQuest.Append(Text + "\t");
                            break;

                        case 1:
                            DependGiveItem.Append(Text + "\t");
                            break;

                        case 2:
                            AppearMap.Append(Text + "\t");
                            break;

                        case 3:
                            LimitDungeonId.Append(Text + "\t");
                            break;

                        case 4:
                            CollisionQuest.Append(Text + "\t");
                            break;

                        case 5:
                            MonsterRewardItem.Append(Text + "\t");
                            break;

                        case 6:
                            EnemyRewardItem.Append(Text + "\t");
                            break;

                        case 7:
                            RelationQuest = $"[relation quest]\r\n{Text}\t\r\n";
                            break;
                        }
                    }
                }

                if (IntData.Length > 0)
                {
                    IntData.Insert(0, "[int data]\r\n", 1).Append("\r\n[/int data]\r\n\r\n");
                }

                if (RewardIntData.Length > 0)
                {
                    RewardIntData.Insert(0, "[reward int data]\r\n", 1).Append("\r\n[/reward int data]\r\n\r\n");
                }

                if (RewardSelectionIntData.Length > 0)
                {
                    RewardSelectionIntData.Insert(0, "[reward selection int data]\r\n", 1).Append("\r\n[/reward selection int data]\r\n\r\n");
                }

                if (PreRequiredQuest.Length > 0)
                {
                    PreRequiredQuest.Insert(0, "[pre required quest]\r\n", 1).Append("\r\n[/pre required quest]\r\n\r\n");
                }
                if (DependGiveItem.Length > 0)
                {
                    DependGiveItem.Insert(0, "[depend give item]\r\n", 1).Append("\r\n[/depend give item]\r\n\r\n");
                }
                if (AppearMap.Length > 0)
                {
                    AppearMap.Insert(0, "[appear map]\r\n", 1).Append("\r\n");
                }
                if (LimitDungeonId.Length > 0)
                {
                    LimitDungeonId.Insert(0, "[limit dungeon index]\r\n", 1).Append("\r\n[/limit dungeon index]\r\n\r\n");
                }
                if (CollisionQuest.Length > 0)
                {
                    CollisionQuest.Insert(0, "[collision quest]\r\n", 1).Append("\r\n[/collision quest]\r\n\r\n");
                }
                if (MonsterRewardItem.Length > 0)
                {
                    MonsterRewardItem.Insert(0, "[monster reward item]\r\n", 1).Append("\r\n[/monster reward item]\r\n\r\n");
                }
                if (EnemyRewardItem.Length > 0)
                {
                    EnemyRewardItem.Insert(0, "[enemy reward item]\r\n", 1).Append("\r\n[/enemy reward item]\r\n\r\n");
                }


                RenWu.Add(RenWuFileName, FileTou + Grade + NpcId + CompleteNpcId + Job + GrowType + Level + Event + CantGiveup + DeleteNpcId + GoldMultiple + QuestPoint + PVPRANK + PreRequiredQuest.ToString() + DependGiveItem.ToString() + AppearMap.ToString() + LimitDungeonId.ToString() + CollisionQuest.ToString() + MonsterRewardItem.ToString() + EnemyRewardItem.ToString() + Type + SubType + IntData.ToString() + RewardType + RewardIntData.ToString() + RewardSelectionIntData.ToString() + RelationQuest + Name + DependMessage + ConditionMessage + SolveMessage);
            }
        }
Exemplo n.º 41
0
        public bool FormatCell(ReoGridControl grid, ReoGridCell cell)
        {
            cell.Display = Convert.ToString(cell.Data);

            if (cell.Style.HAlign == ReoGridHorAlign.General)
            {
                cell.RenderHorAlign = ReoGridRenderHorAlign.Left;
            }

            return true;
        }
Exemplo n.º 42
0
        public object Export(params object[] datas)
        {
            var param = datas[0] as ExpandoObject;
            var dict  = ((IDictionary <string, Object>)param);

            using (var grid = ReoGridControl.CreateMemoryWorkbook())
            {
                try
                {
                    var items     = dict["items"] as List <object>;
                    var worksheet = grid.Worksheets[0];

                    if (items is null)
                    {
                        return(false);
                    }

                    foreach (var item in items)
                    {
                        ApplyRow(worksheet, item);
                    }

                    if (dict.ContainsKey("options"))
                    {
                        var options = dict["options"] as List <object>;

                        if (options != null)
                        {
                            foreach (var option in options)
                            {
                                ApplyOptions(worksheet, option);
                            }
                        }
                    }

                    var oThread = new Thread(() => {
                        var basePath  = AppDomain.CurrentDomain.BaseDirectory;
                        var dialog    = new SaveFileDialog();
                        dialog.Filter = "Excel | *.xlsx";

                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            //save
                            grid.Save(dialog.FileName);
                        }
                    });

                    oThread.SetApartmentState(ApartmentState.STA);
                    oThread.Start();
                    var isSafe = oThread.Join(new TimeSpan(2, 0, 0));
                    if (isSafe)
                    {
                        oThread.Abort();
                    }

                    return(true);
                }
                catch (KeyNotFoundException ex)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 43
0
 public override void OnAfterFormatGrid(ReoGridControl gridControl)
 {
     base.OnAfterFormatGrid(gridControl);
 }
Exemplo n.º 44
0
        private bool CreateBookingReport(string destination, DateTime start, DateTime end)
        {
            var result    = true;
            var start_row = 5;

            using (var workbook = ReoGridControl.CreateMemoryWorkbook())
                using (var context = new HotelContext())
                {
                    if (string.IsNullOrEmpty(destination))
                    {
                        return(false);
                    }
                    var worksheet       = workbook.Worksheets[0];
                    var transactionList = new List <Booking>();

                    try
                    {
                        transactionList = context.Bookings
                                          .Include(t => t.Type)
                                          .Include(t => t.Room)
                                          .Include(t => t.Guest)
                                          .Where(t => t.BookingAt >= start.Date)
                                          .Where(t => t.BookingAt < end.Date)
                                          .Where(t => t.CheckoutAt.HasValue)
                                          .ToList();
                    } catch
                    {
                        result = false;
                    }

                    try
                    {
                        worksheet.Cells[start_row, 0].Data  = "Booking Date";
                        worksheet.Cells[start_row, 1].Data  = "Arrival Date";
                        worksheet.Cells[start_row, 2].Data  = "Departure Date";
                        worksheet.Cells[start_row, 3].Data  = "Checkin Date";
                        worksheet.Cells[start_row, 4].Data  = "Checkout Date";
                        worksheet.Cells[start_row, 5].Data  = "Booking Type";
                        worksheet.Cells[start_row, 6].Data  = "Room Number";
                        worksheet.Cells[start_row, 7].Data  = "Guest Id";
                        worksheet.Cells[start_row, 8].Data  = "Guest Name";
                        worksheet.Cells[start_row, 9].Data  = "Total Adult";
                        worksheet.Cells[start_row, 10].Data = "Total Child";
                        worksheet.Cells[start_row, 11].Data = "Total Price";
                        worksheet.Cells[start_row, 12].Data = "Total Pay";

                        for (int i = 1; i <= transactionList.Count; i++)
                        {
                            var bookingData = transactionList[i - 1];
                            var rowNum      = start_row + i;

                            if (rowNum >= worksheet.RowCount - 1)
                            {
                                worksheet.RowCount = rowNum + 2;
                            }

                            worksheet.Cells[rowNum, 0].Data  = bookingData.BookingAt;
                            worksheet.Cells[rowNum, 1].Data  = bookingData.ArrivalDate;
                            worksheet.Cells[rowNum, 2].Data  = bookingData.DepartureDate;
                            worksheet.Cells[rowNum, 3].Data  = bookingData.CheckinAt;
                            worksheet.Cells[rowNum, 4].Data  = bookingData.CheckoutAt;
                            worksheet.Cells[rowNum, 5].Data  = bookingData.Type.TypeName;
                            worksheet.Cells[rowNum, 6].Data  = bookingData.Room.RoomNumber;
                            worksheet.Cells[rowNum, 7].Data  = bookingData.Guest.IdNumber;
                            worksheet.Cells[rowNum, 8].Data  = bookingData.Guest.Fullname;
                            worksheet.Cells[rowNum, 9].Data  = bookingData.CountAdult;
                            worksheet.Cells[rowNum, 10].Data = bookingData.CountChild;
                            worksheet.Cells[rowNum, 11].Data = GetPrice(bookingData.Id);
                            worksheet.Cells[rowNum, 12].Data = GetPay(bookingData.Id);

                            worksheet.Cells[rowNum, 0].DataFormat = CellDataFormatFlag.DateTime;
                            worksheet.Cells[rowNum, 1].DataFormat = CellDataFormatFlag.DateTime;
                            worksheet.Cells[rowNum, 2].DataFormat = CellDataFormatFlag.DateTime;
                            worksheet.Cells[rowNum, 3].DataFormat = CellDataFormatFlag.DateTime;
                            worksheet.Cells[rowNum, 4].DataFormat = CellDataFormatFlag.DateTime;
                            worksheet.Cells[rowNum, 6].DataFormat = CellDataFormatFlag.Text;
                            worksheet.Cells[rowNum, 7].DataFormat = CellDataFormatFlag.Text;
                        }

                        workbook.Save(destination);
                    } catch
                    {
                        result = false;
                    }
                }

            return(result);
        }
Exemplo n.º 45
0
        public static double Count(ReoGridControl ctrl, ReoGridRange range)
        {
            int count = 0;

            ctrl.IterateCells(range, (row, col, cell) =>
            {
                count++;
                return true;
            });

            return count;
        }
Exemplo n.º 46
0
        /// <summary>
        /// Format given cell
        /// </summary>
        /// <param name="grid">Instance of grid control</param>
        /// <param name="cell">Instance of cell to be formatted</param>
        /// <returns></returns>
        public bool FormatCell(ReoGridControl grid, ReoGridCell cell)
        {
            object data = cell.Data;

            // check numeric
            bool isNumeric = false;

            double value = 0;
            if (data is int)
            {
                value = (double)(int)data;
                isNumeric = true;
            }
            else if (data is float)
            {
                value = (double)(float)data;
                isNumeric = true;
            }
            else if (data is double)
            {
                value = (double)data;
                isNumeric = true;
            }
            else if (data is string)
            {
                string strdata = (data as string).Trim();

                isNumeric = double.TryParse(strdata, out value);

                if (!isNumeric) isNumeric = double.TryParse(strdata.Replace(",", ""), out value);

                if (isNumeric) cell.Data = value;
            }
            else if (data is DateTime)
            {
                value = ((DateTime)data - new DateTime(1900, 1, 1)).TotalDays;
                isNumeric = true;
            }

            if (isNumeric)
            {
                if (cell.Style.HAlign == ReoGridHorAlign.General)
                {
                    cell.RenderHorAlign = ReoGridRenderHorAlign.Right;
                }

                short decimals = 2;
                bool useSeparator = true;
                NumberNegativeStyle negativeStyle = NumberNegativeStyle.Minus;

                if (cell.DataFormatArgs != null && cell.DataFormatArgs is NumberFormatArgs)
                {
                    NumberFormatArgs args = (NumberFormatArgs)cell.DataFormatArgs;
                    decimals = args.DecimalPlaces;
                    negativeStyle = args.NegativeStyle;
                    useSeparator = args.UseSeparator;
                }
                else
                {
                    //cell.DataFormatArgs = new NumberFormatArgs
                    //{
                    //  DecimalPlaces = decimals,
                    //  NegativeStyle = negativeStyle,
                    //  UseSeparator = true
                    //};
                }

                if (value < 0)
                {
                    if ((negativeStyle & NumberNegativeStyle.Red) == NumberNegativeStyle.Red)
                        cell.RenderColor = Color.Red;
                    else
                        cell.RenderColor = Color.Empty;
                }

                // decimal places
                string decimalPlacePart = new string('0', decimals);

                // number
                string numberPart = (useSeparator ? "#,##0." : "0.") + decimalPlacePart;
                if ((negativeStyle & NumberNegativeStyle.Brackets) == NumberNegativeStyle.Brackets)
                {
                    numberPart = (value < 0) ? ("(" + numberPart + ")") : numberPart;
                }

                // negative
                if (negativeStyle != NumberNegativeStyle.Minus)
                {
                    value = Math.Abs(value);
                }

                cell.Display = value.ToString(numberPart);

                return true;
            }
            else
                return false;
        }
Exemplo n.º 47
0
 public void Setup()
 {
     control = new ReoGridControl();
     sheet   = control.Worksheets[0];
 }