public static void InitializeHistory(TokenEdit tokenEdit) { foreach (Contact contact in DataHelper.Contacts) { TokenEditToken item = new TokenEditToken(contact.Email, contact); tokenEdit.Properties.Tokens.Add(item); } }
public TokenEditBinder(IPropertyBinderNotifier <TObjectType, IEnumerable <TValue> > propertyBinder, TokenEdit tokenEdit) : base(propertyBinder) { _tokenEdit = tokenEdit; _displayFor = x => x.ToString(); _onSelectedItemChanged = delegate { }; _tokenEdit.SelectedItemsChanged += selectedItemsChanged; _tokenEdit.Properties.EditValueType = TokenEditValueType.List; }
void DoUpdateTaskEmployees(TokenEdit edit, Task task) { task.ClearEmployees(); foreach (int id in (IList)edit.EditValue) { Employee emp = EmployeesRegistry.GetEmployee(id); task.AddEmployee(emp); } }
private void FormatByDaxEditor() { int lineCont = _source.GetLineCount(); for (int line = 0; line < lineCont; line++) { int lineEnd = 0; TokenInfo[] lineInfos = _source.GetColorizer().GetLineInfo(_source.GetTextLines(), line, _colorState); if (lineInfos != null) { for (int i = 0; i < lineInfos.Length; i++) { // Store it for future usage TokenInfo tokenInfo = lineInfos[i]; var te = new TokenEdit() { TokenInfo = tokenInfo }; te.TextSpan = new TextSpan() { iStartLine = line, iStartIndex = tokenInfo.StartIndex, iEndLine = line, iEndIndex = tokenInfo.EndIndex + 1 }; lineEnd = tokenInfo.EndIndex + 1; te.OriginalText = _source.GetText(te.TextSpan); if (te.TokenInfo.Token == (int)Tokens.LEX_ERROR) { te = ReplaceInvalidChars(te); } _tokenEdits.AddLast(te); } } // Insert token for EOL var tokenInfoEOL = new TokenInfo() { Type = TokenType.WhiteSpace }; var teEOL = new TokenEdit() { TokenInfo = tokenInfoEOL }; teEOL.TextSpan = new TextSpan() { iStartLine = line, iStartIndex = lineEnd, iEndLine = line + 1, iEndIndex = 0 }; teEOL.OriginalText = Environment.NewLine; _tokenEdits.AddLast(teEOL); } NormilizeWhitespaces(); InsertEol(); CheckHeadAndTail(); ApplyEdits(); }
void UpdateTaskEmployees(TokenEdit edit, Task task) { if (update) { return; } this.update = true; try { DoUpdateTaskEmployees(edit, task); gridView.UpdateCurrentRow(); } finally { this.update = false; } }
void OnSelectedItemsChanged(object sender, ListChangedEventArgs e) { if (update) { return; } TokenEdit edit = sender as TokenEdit; if (edit == null) { return; } Employee emp = (Employee)gridView1.GetFocusedRow(); UpdateTokens(edit, emp); }
void OnTokenEditSelectedItemsChanged(object sender, ListChangedEventArgs e) { if (update) { return; } TokenEdit edit = sender as TokenEdit; if (edit == null) { return; } Task task = (Task)gridView.GetFocusedRow(); UpdateTaskEmployees(edit, task); }
void UpdateTokens(TokenEdit edit, Employee emp) { if (update) { return; } this.update = true; try { emp.Tokens.Clear(); foreach (ObjectWrapper wr in (IList)edit.EditValue) { string tok = TokenRegistry.GetToken(wr.Obj); emp.Tokens.Add(tok); } gridView1.UpdateCurrentRow(); } finally { this.update = false; } }
/// <summary> /// Replace invalid chars in DAX with valid. Example '&npsp' with a space /// </summary> /// <param name="te">input token edit</param> /// <returns></returns> private TokenEdit ReplaceInvalidChars(TokenEdit te) { Debug.Assert(te.TokenInfo.Token == (int)Tokens.LEX_ERROR); switch (te.OriginalText) { case "–": // dash te.TokenInfo.Token = (int)'-'; te.TokenInfo.Type = TokenType.Operator; te.EditSpan = new EditSpan(te.TextSpan, "-"); break; case " ": //   te.TokenInfo.Token = (int)Tokens.LEX_WHITE; te.TokenInfo.Type = TokenType.WhiteSpace; te.EditSpan = new EditSpan(te.TextSpan, " "); break; } return(te); }
public CustomTokenEdithandler(TokenEdit tokenEdit) : base(tokenEdit) { }
public TokenEditTokenListPopupControllerV2(TokenEdit edit) : base(edit) { }
public TokenEditHandlerV2(TokenEdit tokenEdit) : base(tokenEdit) { }
public MyTokenEditPopupForm(TokenEdit tokenEdit) : base(tokenEdit) { }
/// <summary> /// Replaces any whitespace with ' '(=space) and insert a whitespace after every token (except comment) /// Also expand change token type for multi line comment. It is required because Lexer does analyzis /// line by line and it does not have information that the current token might be a comment token. /// </summary> private void NormilizeWhitespaces() { var currentNode = _tokenEdits.First; while (currentNode != null) { var previous = currentNode.Previous; // Expand multi line comments // Lexer used in the callee function works line by line // So if it scans 2 lines /*\nabc\n the first line is a comment // but 'abc' on the second line is not a comment. // Fix it with this check if (previous != null && currentNode.Value.TokenInfo.Type != TokenType.Comment && previous.Value.TokenInfo.Type == TokenType.Comment && !string.Equals(previous.Value.OriginalText, @"*/")) { currentNode.Value.TokenInfo.Type = TokenType.Comment; } switch (currentNode.Value.TokenInfo.Type) { case TokenType.LineComment: case TokenType.Comment: break; case TokenType.Delimiter: case TokenType.Identifier: case TokenType.Keyword: case TokenType.Literal: case TokenType.Operator: case TokenType.String: case TokenType.Text: // Insert whitespace before these tokens. There are some exceptions - like there must be no whitespace between function and opening Parenthesis if (previous != null) { if (previous.Value.TokenInfo.Type != TokenType.WhiteSpace) { // No whitespace between 2 identifiers if (previous.Value.TokenInfo.Type == TokenType.Identifier && currentNode.Value.TokenInfo.Type == TokenType.Identifier) { break; } // No whitespaces before ';' if (currentNode.Value.TokenInfo.Type == TokenType.Delimiter && string.Equals(currentNode.Value.OriginalText, ";")) { break; } var te = new TokenEdit(); te.TokenInfo = new TokenInfo() { Type = TokenType.WhiteSpace }; te.TextSpan = new TextSpan() { iStartLine = currentNode.Value.TextSpan.iStartLine, iStartIndex = currentNode.Value.TextSpan.iStartIndex, iEndLine = currentNode.Value.TextSpan.iStartLine, iEndIndex = currentNode.Value.TextSpan.iStartIndex }; te.EditSpan = new EditSpan( te.TextSpan, " "); _tokenEdits.AddAfter(previous, te); currentNode = previous; // Need to walk at the currently added node. Side effect - this block might be executed 2 times } } break; case TokenType.Unknown: Debug.Assert(false); break; case TokenType.WhiteSpace: TextSpan span; string newWhitespace = " "; // Do not insert whitespace after comments if (previous != null && (previous.Value.TokenInfo.Type == TokenType.LineComment || previous.Value.TokenInfo.Type == TokenType.Comment)) { break; } // If previous token is a whitespace as well - merge their spans and remove the previos token if (previous != null && previous.Value.TokenInfo.Type == TokenType.WhiteSpace) { if (previous.Previous != null && (previous.Previous.Value.TokenInfo.Type == TokenType.LineComment || previous.Previous.Value.TokenInfo.Type == TokenType.Comment)) { break; } span.iStartLine = previous.Value.TextSpan.iStartLine; span.iStartIndex = previous.Value.TextSpan.iStartIndex; span.iEndLine = currentNode.Value.TextSpan.iEndLine; span.iEndIndex = currentNode.Value.TextSpan.iEndIndex; _tokenEdits.Remove(previous); previous = currentNode.Previous; } else { span = currentNode.Value.TextSpan; } // In serven cases whitespace needs to be removed or replaced with EOL if (previous != null && currentNode.Next != null) { if ( // [cube]. (currentNode.Next.Value.TokenInfo.Type == TokenType.Delimiter && string.Equals(currentNode.Next.Value.OriginalText, ".")) // .[cube] || (previous.Value.TokenInfo.Type == TokenType.Delimiter && string.Equals(previous.Value.OriginalText, ".")) // TableRef[ColRef] || (previous.Value.TokenInfo.Type == TokenType.Identifier && currentNode.Next.Value.TokenInfo.Type == TokenType.Identifier) // just before comma || (currentNode.Next.Value.TokenInfo.Type == TokenType.Delimiter && string.Equals(currentNode.Next.Value.OriginalText, ",")) ) { newWhitespace = ""; } else if (previous.Value.TokenInfo.Type == TokenType.Keyword && string.Equals("evaluate", previous.Value.OriginalText, StringComparison.CurrentCultureIgnoreCase)) { currentNode.Value.EolType = EolType.Eol; } else if (currentNode.Next.Value.TokenInfo.Type == TokenType.Keyword) { // Measure starts with a new line, 1 indent, only if the previous token is not CREATE if (string.Equals("measure", currentNode.Next.Value.OriginalText, StringComparison.CurrentCultureIgnoreCase) && previous != null && !string.Equals("create", previous.Value.OriginalText, StringComparison.CurrentCultureIgnoreCase)) { currentNode.Value.EolType = EolType.EolHardIndent1; newWhitespace = _eolText; } // EVALUATE, ORDER and CREATE always starts with a new line, 0 indent else if (string.Equals("evaluate", currentNode.Next.Value.OriginalText, StringComparison.CurrentCultureIgnoreCase) || string.Equals("order", currentNode.Next.Value.OriginalText, StringComparison.CurrentCultureIgnoreCase) || string.Equals("create", currentNode.Next.Value.OriginalText, StringComparison.CurrentCultureIgnoreCase) ) { newWhitespace = _eolText; currentNode.Value.EolType = EolType.Eol; } } } currentNode.Value.EditSpan = new EditSpan(span, newWhitespace); currentNode.Value.TextSpan = span; break; default: break; } currentNode = currentNode.Next; } }
public static TokenEditBinder <TObjectType, TValue> To <TObjectType, TValue>(this IScreenToElementBinder <TObjectType, IEnumerable <TValue> > screenToElementBinder, TokenEdit tokenEditControl) { var element = new TokenEditBinder <TObjectType, TValue>(screenToElementBinder.PropertyBinder, tokenEditControl); screenToElementBinder.ScreenBinder.AddElement(element); return(element); }
public MyTokenEditTokenListPopupController(TokenEdit tokenEdit) : base(tokenEdit) { }
protected override object CreateControlCore() { control = new TokenEdit(); control.DoubleClick += Control_DoubleClick; return(control); }
public override void Initialize(TokenEdit ownerEdit, TokenEditPopupForm ownerPopup) { base.Initialize(ownerEdit, ownerPopup); }
public TokenEditPopupFormV2(TokenEdit edit) : base(edit) { }
public MyTokenEditPopupForm(TokenEdit edit) : base(edit) { }
public static void InitializeSeparator(this TokenEdit tokenEdit, params string[] separators) { tokenEdit.Properties.Separators.Clear(); tokenEdit.Properties.Separators.AddRange(separators); }
public static void Initialize(this TokenEdit tokenEdit) { tokenEdit.Properties.EditMode = TokenEditMode.Manual; tokenEdit.Properties.ShowDropDown = true; }