public override void Process(WCell.Util.Commands.CmdTrigger<ToolCmdArgs> trigger) { using (var wowFile = new WoWFile(trigger.Text.NextWord())) { GameObjectTypeExtractor.Extract(wowFile); } //base.Process(trigger); }
public void SelectLine(WCell.Util.Graphics.Vector3 p1, WCell.Util.Graphics.Vector3 p2, Color color, bool doNotReplace = true) { const float halfLineWidth = 0.5f; var s1 = p1 - halfLineWidth; var s2 = p1 + halfLineWidth; var t1 = p2 - halfLineWidth; var t2 = p2 + halfLineWidth; s1.Z = s2.Z = Math.Max(s1.Z, s2.Z); t1.Z = t2.Z = Math.Max(t1.Z, t2.Z); var tri1 = new Triangle(s1, s2, t2); var tri2 = new Triangle(t2, t1, s1); Select(ref tri1, doNotReplace, color); Select(ref tri2, true, color); }
public void SelectPoint(WCell.Util.Graphics.Vector3 p, Color color, bool doNotReplace = true) { const float sideDist = 0.5f; var p1 = p; var p2 = p; var p3 = p; p1.X += sideDist; p2.X -= sideDist; p2.Y -= sideDist; p3.X -= sideDist; p3.Y += sideDist; var tri1 = new Triangle(p1, p2, p3); Select(ref tri1, doNotReplace, color); }
protected override void OnCommandFail(WCell.Util.Commands.CmdTrigger<Squishy.Irc.Commands.IrcCmdArgs> trigger, Exception ex) { CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, "Exception Occured: " + ex.InnerException.Message); foreach (string text in ex.GetAllMessages()) CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, text); }
public override bool MayTriggerCommand(WCell.Util.Commands.CmdTrigger<Squishy.Irc.Commands.IrcCmdArgs> trigger, Squishy.Irc.Commands.IrcCommand cmd) { return trigger.Args.User.UserLevel >= cmd.RequiredAccountLevel; }
/// <summary> /// 取出一个表中的数据列集合 /// </summary> /// <param name="table"></param> /// <param name="firstCode"></param> /// <param name="itemCodeList"></param> /// <returns></returns> private static List <WCol> getColListFromTable(DataTable table, List <string> itemCodeList) { List <WCol> dataColList = new List <WCol>(); int[] firstCodeLocation = findFirstItemCodeLocation(table, itemCodeList);//存放第一个代码的行和列,找出存放代码的列和行 if (firstCodeLocation[0] == -1 || firstCodeLocation[1] == -1) { return(dataColList);//此表格没有ItemCode,继续下一个表格 } EnumTableType tableType = EnumTableType.None; Dictionary <string, string[]> codeUnitConvert = new Dictionary <string, string[]>(); //记录IEP的行 int IEPRow = -1; int ICPRow = -1; int ECPRow = -1; #region "表内数据的行循环,找出由于单位不同需要转换的数据行" for (int row = firstCodeLocation[0]; row < table.Rows.Count; row++) { string rowContent = table.Rows[row][firstCodeLocation[1]].ToString().Trim(); rowContent = Units.ToDBC(rowContent); if (rowContent.Equals("G00")) { tableType = EnumTableType.Light; } while (itemCodeList.Count < row)//补充前面空行,使itemcodelist顺序与行号一致 { itemCodeList.Add(""); } //记录下此表的行的itemcode顺序 itemCodeList.Add(rowContent); //记录下温度行 if (rowContent.Contains("IEP")) { IEPRow = row; } if (rowContent.Contains("ICP")) { ICPRow = row; } if (rowContent.Contains("ECP")) { ECPRow = row; } if (tableType != EnumTableType.Light) { #region 单位转换 //先读取行前面的 单位,确定哪一行如何单位转换 int colIndex = firstCodeLocation[1];//取出列位置 #region 获取代码列前面的值 string frontContent = ""; if (colIndex >= 1) { frontContent = table.Rows[row][colIndex - 1].ToString().Trim(); if (colIndex >= 2) { frontContent += table.Rows[row][colIndex - 2].ToString().Trim(); } if (colIndex >= 3) { frontContent += table.Rows[row][colIndex - 3].ToString().Trim(); } //D20单位转换要先记录下所有需要转换的行,等wcol填满后,再计算需要转换的行 } else { //throw } frontContent = Units.ToDBC(frontContent); #endregion string matchCode = ""; foreach (var item in Units.UnitList) { if (frontContent.Contains(item)) { if (item.Length > matchCode.Length) //有可能多个匹配、部分匹配,记录下最长的 { matchCode = item; } } } //包含可能转换的单位,matchCode是excel中的单位,为空则表示无单位,去查看这个代码在程序中的单位 //除去IEP string tUnit = ""; if (!rowContent.Contains("IEP")) { try { var rowEntity = OilTableRowBll._OilTableRow.Where(d => new int[] { 2, 6, 7, 8 }.Contains(d.oilTableTypeID) && d.itemCode == rowContent).FirstOrDefault(); if (rowEntity != null) { tUnit = rowEntity.itemUnit; } } catch { MessageBox.Show("未找到itemunit" + rowContent); } } //tUnit = _rowCache[rowContent, EnumTableType.Wide].itemUnit; if (!string.IsNullOrWhiteSpace(matchCode) && !string.IsNullOrWhiteSpace(tUnit) && !tUnit.Equals(matchCode)) { codeUnitConvert.Add(row.ToString(), new string[] { matchCode, tUnit }); } #endregion } } #endregion #region "表内数据的列循环" for (int col = firstCodeLocation[1] + 1; col < table.Columns.Count; col++) { WCol colData = new WCol();//获取列数据 if (tableType != EnumTableType.Light) { #region 读取IEP行 if (IEPRow != -1) { string colContent = table.Rows[IEPRow][col].ToString().Trim(); colContent = Units.ToDBC(colContent); if (colContent.Contains("原油")) { colData.TableType = EnumTableType.Whole; } else { List <int> IEPNum = GetIEPNum(colContent); #region "" //有数,个数小于两个 if (IEPNum.Count <= 2 && IEPNum.Count > 0) { if (IEPNum.Count == 2) { if (IEPNum[0] < IEPNum[1]) { //这一行是 if (tableType != EnumTableType.Narrow) { colData.TableType = EnumTableType.Wide; } else { colData.TableType = EnumTableType.Narrow; } colData.ICP = IEPNum[0]; colData.ECP = IEPNum[1]; } else { continue; } } else { //只得到一个值,有可能是 bool isICP = true; if (colContent.Contains(">")) {//这个值是ECP isICP = false; } else if (colContent.Contains("<")) { isICP = true; } else if (colContent.Contains("~")) { int signIndex = colContent.IndexOf("~"); //--------------------------获得一个 为数字的值 Regex regex = new Regex(@"\d"); int numIndex = regex.Match(colContent).Index; if (signIndex < numIndex) { isICP = false; } else { isICP = true; } } else if (colContent.Contains("-")) { int signIndex = colContent.IndexOf("-"); //--------------------------获得一个 为数字的值 Regex regex = new Regex(@"\d"); int numIndex = regex.Match(colContent).Index; if (signIndex < numIndex) { isICP = false; } else { isICP = true; } } if (tableType != EnumTableType.Narrow) { if (colContent.Contains("+") || colContent.Contains(">")) { //渣油 colData.TableType = EnumTableType.Residue; colData.ICP = IEPNum[0]; } else { colData.TableType = EnumTableType.Wide; if (isICP == true) { colData.ICP = IEPNum[0]; } else { colData.ECP = IEPNum[0]; } } } else { colData.TableType = EnumTableType.Narrow; if (isICP == true) { colData.ICP = IEPNum[0]; } else { colData.ECP = IEPNum[0]; } } } } else { continue; } #endregion } } #endregion #region 查ICP 和 ECP 的数据 if (ICPRow != -1 && colData.TableType == EnumTableType.None) { string ICPContent = table.Rows[ICPRow][col].ToString().Trim(); string ECPContent = ""; if (ECPRow != -1) { ECPContent = table.Rows[ECPRow][col].ToString().Trim(); } ICPContent = Units.ToDBC(ICPContent); ECPContent = Units.ToDBC(ECPContent); if (IsInt(ICPContent) && IsInt(ECPContent)) { if (int.Parse(ICPContent) < int.Parse(ECPContent)) { if (tableType != EnumTableType.Narrow) { colData.TableType = EnumTableType.Wide; } else { colData.TableType = EnumTableType.Narrow; } colData.ICP = int.Parse(ICPContent); colData.ECP = int.Parse(ECPContent); } else { continue; } } else if (IsInt(ICPContent)) { if (tableType != EnumTableType.Narrow)//渣油 { colData.TableType = EnumTableType.Residue; } else { colData.TableType = EnumTableType.Narrow; } colData.ICP = int.Parse(ICPContent); } else if (IsInt(ECPContent)) { if (tableType != EnumTableType.Narrow) { colData.TableType = EnumTableType.Wide; } else { colData.TableType = EnumTableType.Narrow; } colData.ECP = int.Parse(ECPContent); } else { continue; } } #endregion } else { colData.TableType = EnumTableType.Light; } List <string> lightItemtCode = new List <string>(); //记录轻端itemcode for (int row = firstCodeLocation[0]; row < table.Rows.Count; row++) //for(int row = ) 一列一列循环单元格,放入List<wcol>中 { if (row == IEPRow || row == ECPRow || row == ICPRow) { continue; } string content = table.Rows[row][col].ToString().Trim(); content = Units.ToDBC(content); if (tableType == EnumTableType.Light) { if (!string.IsNullOrWhiteSpace(itemCodeList[row])) { if (lightItemtCode.Contains(itemCodeList[row])) { if (colData.Cells.Count() != 0) { dataColList.Add(colData); } lightItemtCode.Clear(); lightItemtCode.Add(itemCodeList[row]); colData = new WCol(); colData.TableType = EnumTableType.Light; } else { lightItemtCode.Add(itemCodeList[row]); } } } if (string.IsNullOrWhiteSpace(content) || string.IsNullOrWhiteSpace(itemCodeList[row])) { continue; } WCell cell = new WCell(); cell.ItemCode = itemCodeList[row];//itemcodelist中存有空值,根据content不为空,则存入coldata中的都不为空 //需要单位转换的 if (codeUnitConvert.ContainsKey(row.ToString())) { string[] tempstr = codeUnitConvert[row.ToString()]; double dContent = double.Parse(content); Units.UnitConvert(ref dContent, tempstr[0], tempstr[1]); content = dContent.ToString(); } cell.LabData = content; colData.Add(cell); } if (colData.Cells.Count() != 0) { dataColList.Add(colData); } } #endregion return(dataColList); }
public override bool MayTriggerCommand(WCell.Util.Commands.CmdTrigger<IrcCmdArgs> trigger, WCell.Util.Commands.Command<IrcCmdArgs> cmd) { return true; }
public override void Process(WCell.Util.Commands.CmdTrigger<IrcCmdArgs> trigger) { //TODO: Write code to login to the bot }
public List <Cell> ReturnCellsInRow(int rowNumber) { List <Cell> cols = new List <Cell>(); int colIndex = 0; foreach (List <string> l in _parsedFile) { MultipleCell multi = null; // there will be 5 items in each .APP file if (l.Count != 5) { break; } string label = l[0]; string type = l[1]; int digits; // not really necessary for this application, but leaving for reverse compatibility int.TryParse(l[2], out digits); int precision; int.TryParse(l[3], out precision); string connectionInfo = l[4]; switch (type) { // keyboard cell case "K": if (MultipleCell.IsMultiCell(label) && cols.OfType <MultipleCell>().ToList().Count > 0) { colIndex--; } KCell k = new KCell(label, digits, precision, connectionInfo, rowNumber, colIndex); if (MultipleCell.IsMultiCell(label)) { multi = BuildMultipleCell(k, cols); if (multi != null) { cols.Add(multi); } } else { cols.Add(k); } break; // weight cell case "W": if (MultipleCell.IsMultiCell(label) && cols.OfType <MultipleCell>().ToList().Count > 0) { colIndex--; } WCell w = new WCell(label, digits, precision, connectionInfo, rowNumber, colIndex); if (MultipleCell.IsMultiCell(label)) { multi = BuildMultipleCell(w, cols); if (multi != null) { cols.Add(multi); } } else { cols.Add(w); } break; // calculation cell case "C": List <string> names = connectionInfo.Split(new char[] { '(', ')', '+', '-', '*', '/', '^' }).ToList(); // need for TryParse double n; List <string> dependencyNamesPossibleDupes = (from name in names where name.Length > 0 && !double.TryParse(name, out n) // make sure the value isn't an integer select name).ToList(); List <string> dependencyNames = dependencyNamesPossibleDupes.Distinct().ToList(); List <Cell> dependencies = new List <Cell>(); foreach (string name in dependencyNames) { Cell dependency = cols.First(x => x.Label == name); if (dependency != null) { dependencies.Add(dependency); } } if (MultipleCell.IsMultiCell(label) && cols.OfType <MultipleCell>().ToList().Count > 0) { colIndex--; } CCell c = new CCell(label, digits, precision, connectionInfo, rowNumber, colIndex, dependencies); if (MultipleCell.IsMultiCell(label)) { multi = BuildMultipleCell(c, cols); if (multi != null) { cols.Add(multi); } } else { cols.Add(c); } break; // mirror cell case "M": // find cell to mirror var columnToMirror = cols.FirstOrDefault(x => x.Label == connectionInfo); if (MultipleCell.IsMultiCell(label) && cols.OfType <MultipleCell>().ToList().Count > 0) { colIndex--; } MCell m = new MCell(label, digits, precision, connectionInfo, rowNumber, colIndex, columnToMirror); if (MultipleCell.IsMultiCell(label)) { multi = BuildMultipleCell(m, cols); if (multi != null) { cols.Add(multi); } } else { cols.Add(m); } break; // newscreen, for backwards compatibility case "0": NewScreen newScreen = new NewScreen(label, digits, precision, connectionInfo, rowNumber, colIndex); cols.Add(newScreen); break; } colIndex++; } return(cols); }
// Finished Editing Cell Event Handler void NewBalanceDataGridView_CellEndEdit(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { _cellBeginEdit = NewBalanceDataGridView[e.ColumnIndex, e.RowIndex]; // arbitrary number bool changed; double?d = null; string s = String.Empty; // need to update logic layer string valueToCheck = (string)_cellBeginEdit.Value ?? ""; if (valueToCheck == oldCellValue) { return; } else { changed = true; } if (_cellBeginEdit.Value != null) { d = nullableDoubleTryParse(_cellBeginEdit.Value.ToString()); } if (_cellBeginEdit.Value != null && d == null) { s = _cellBeginEdit.Value.ToString(); } switch (ViewData.GetCellType(e.RowIndex, e.ColumnIndex)) { // don't update if value is not valid case CellType.C: CCell c = ViewData.GetCell(e.RowIndex, e.ColumnIndex) as CCell; if (c == null) { return; } if (changed == true && d != null) { c.OverrideValue((double)d); } else { c.Value = null; } break; case CellType.K: KCell k = ViewData.GetCell(e.RowIndex, e.ColumnIndex) as KCell; if (k == null) { return; } if (s.Length > 0) { k.KValue = s; } else if (d != null && changed == true) { k.KValue = d.ToString(); } else { k.KValue = null; } break; case CellType.M: MCell m = ViewData.GetCell(e.RowIndex, e.ColumnIndex) as MCell; if (m == null) { return; } if (changed == true && d != null) { m.OverrideValue((double)d); } else { m.Value = null; } break; case CellType.W: WCell w = ViewData.GetCell(e.RowIndex, e.ColumnIndex) as WCell; if (w == null) { return; } if (changed == true && d != null) { w.Value = d; } else { w.Value = null; } break; } RecentlySaved = false; }