private void _Render_OnRender() { if (CurrentContent != null) { CurrentContent.Render(); } }
public void Done() { BookSource s = DataContext as BookSource; CurrentContent.Save(); s.Save(); }
/// <summary> /// Called when the mouse first enters this button's space. /// Also calls the OnMouseEnter hook of the currently socketed button. /// </summary> protected virtual void OnMouseEnter() { if (CurrentContent.OnMouseEnter()) { Sound.MouseOver.Play(); } }
public DocumentViewerControl(ITextBufferFactoryService textBufferFactoryService, IDsTextEditorFactoryService dsTextEditorFactoryService, IDocumentViewerHelper textEditorHelper) { if (textBufferFactoryService == null) { throw new ArgumentNullException(nameof(textBufferFactoryService)); } if (dsTextEditorFactoryService == null) { throw new ArgumentNullException(nameof(dsTextEditorFactoryService)); } this.textEditorHelper = textEditorHelper ?? throw new ArgumentNullException(nameof(textEditorHelper)); defaultContentType = textBufferFactoryService.TextContentType; cachedColorsList = new CachedColorsList(); emptyContent = new DocumentViewerContent(string.Empty, CachedTextColorsCollection.Empty, SpanDataCollection <ReferenceInfo> .Empty, new Dictionary <string, object>()); currentContent = new CurrentContent(emptyContent, defaultContentType); spanReferenceCollection = SpanDataCollection <ReferenceAndId> .Empty; var textBuffer = textBufferFactoryService.CreateTextBuffer(textBufferFactoryService.TextContentType); CachedColorsListTaggerProvider.AddColorizer(textBuffer, cachedColorsList); var roles = dsTextEditorFactoryService.CreateTextViewRoleSet(defaultRoles); var options = new TextViewCreatorOptions { EnableUndoHistory = false }; var textView = dsTextEditorFactoryService.CreateTextView(textBuffer, roles, options); var wpfTextViewHost = dsTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; wpfTextViewHost.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategoryConstants.TextEditor); wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, true); Children.Add(wpfTextViewHost.HostControl); }
public override void Dispose() { Debug.WriteLine("Disposing MainViewModel..."); if (CurrentContent != null) { CurrentContent.Dispose(); } }
public void Clear() { CurrentWaitAdorner = null; cachedColorsList.Clear(); currentContent = new CurrentContent(emptyContent, defaultContentType); spanReferenceCollection = SpanDataCollection <ReferenceAndId> .Empty; wpfTextViewHost.TextView.TextBuffer.Replace(new Span(0, wpfTextViewHost.TextView.TextBuffer.CurrentSnapshot.Length), string.Empty); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); var ecfEntry = CurrentContent.LoadEntry( CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull); this.entry = ecfEntry; }
/// <summary> /// Called by ButtonLayer each frame. /// </summary> /// <param name="sb">Spritebatch passed down from containing layer</param> public void Draw(SpriteBatch sb) { if (CurrentContent.PreDraw(sb)) { DrawButtonContent(sb); OnDrawBase(); } CurrentContent.PostDraw(sb); }
private void x_scenes_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (CurrentContent == null) { return; } CurrentContent.Save(); Cache.SetScene(x_scenes.SelectedValue as SceneDescription); SelectionPickup(); }
} //文件的文件名 public bool isModified() //判断文件是否被修改(判断是否修改并且保存了) { if (CurrentContent.Equals(SourceContent)) { return(false); } else { return(true); } }
/// <summary> /// Checks for both left and right clicks and calls /// the associated button hook if detected. /// </summary> protected virtual void HandleClicks() { if (Main.mouseLeft && Main.mouseLeftRelease) { CurrentContent.OnClick(); } if (Main.mouseRight && Main.mouseRightRelease) { CurrentContent.OnRightClick(); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (CurrentContent.IsLogged() == false) { //string controller = filterContext.RouteData.Values["controller"].ToString(); //string action = filterContext.RouteData.Values["action"].ToString(); filterContext.Result = new RedirectResult("~/Account/Login"); return; } base.OnActionExecuting(filterContext); }
private void OnContentChanged(ContentChangedMessage message) { if (CurrentContent != null) { CurrentContent.Dispose(); } CurrentContent = message.Content; if (CurrentContent != null) { CurrentContent.Initialize(); } }
public bool SetContent(DocumentViewerContent content, IContentType contentType) { if (content == null) { throw new ArgumentNullException(nameof(content)); } if (contentType == null) { contentType = defaultContentType; } HideCancelButton(); var newContent = new CurrentContent(content, contentType); if (currentContent.Equals(newContent)) { return(false); } currentContent = newContent; spanReferenceCollection = newContent.Content.GetCustomData <SpanDataCollection <ReferenceAndId> >(DocumentViewerContentDataIds.SpanReference) ?? SpanDataCollection <ReferenceAndId> .Empty; TextView.TextBuffer.ChangeContentType(contentType, null); cachedColorsList.Clear(); cachedColorsList.Add(0, content.ColorCollection); // If it's the same text, don't update text buffer and caret. It can be the same text if // it's not been cached, eg. it's the resources or some other content with UI content. // This simulates the cached code path above which also doesn't move the caret. And as // an added bonus, it will use less memory and CPU. bool sameText = IsSameTextAsCurrentSnapshot(TextView.TextSnapshot, content.Text); if (!sameText) { TextView.TextBuffer.Replace(new Span(0, TextView.TextBuffer.CurrentSnapshot.Length), content.Text); TextView.Caret.MoveTo(new SnapshotPoint(TextView.TextSnapshot, 0)); TextView.Caret.EnsureVisible(); TextView.Selection.Clear(); } return(true); }
/// <summary> /// Called when the mouse leaves this button's space. /// Also calls the OnMouseLeave hook of the currently socketed button. /// </summary> protected virtual void OnMouseLeave() { // no checking return value because...we don't do anything here CurrentContent.OnMouseLeave(); }
private void x_characters_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { CurrentContent.Save(); CurrentContent = _characterHolder; _characterHolder.Load(x_characters.SelectedValue as CharacterContent); }
private void ParseXmlContent(string content) { RegValueEntry CurrentValue = null; RegKeyEntry CurrentKey = null; StringBuilder CurrentContent = null; RegValueEntryKind CurrentKind = RegValueEntryKind.Unknown; bool isBase64Encoding = false; List <string> currentStringList = new List <string>(); using (XmlReader reader = XmlReader.Create(new StringReader(content))) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name.Equals("registry")) { string version = reader.GetAttribute("version"); if (version == "2") { // ok, this version is supported } else { throw new System.Data.SyntaxErrorException("Unexpected XML format: must be using registry version 2.0 or higher"); } } else if (reader.Name.Equals("key")) { string name = reader.GetAttribute("name"); if (CurrentKey == null) { Trace.Assert(Result == null); Result = new RegKeyEntry(null, name); CurrentKey = Result; } else { RegKeyEntry newKey = new RegKeyEntry(CurrentKey, name); CurrentKey.Keys[newKey.Name.ToLower()] = newKey; if (!reader.IsEmptyElement) { CurrentKey = newKey; } } } else if ((CurrentKind == RegValueEntryKind.MultiSZ) && reader.Name.Equals("line")) { if (reader.IsEmptyElement) { currentStringList.Add(""); } else { CurrentContent = new StringBuilder(); string encoding = reader.GetAttribute("encoding"); isBase64Encoding = (encoding != null) && encoding.Equals("base-64"); } } else { try { CurrentKind = (RegValueEntryKind)Enum.Parse(typeof(RegValueEntryKind), reader.Name); } catch (ArgumentException) { throw new System.Data.SyntaxErrorException( string.Format("ERROR, {0} is not a valid entry in a registry .XML file", reader.Name)); } string name = reader.GetAttribute("name"); CurrentValue = new RegValueEntry(name); if (name == null) { CurrentKey.DefaultValue = CurrentValue; } else { CurrentKey.Values[name.ToLower()] = CurrentValue; } if (reader.IsEmptyElement) { if (RegValueEntryKind.SZ == CurrentKind) { CurrentValue.SetStringValue(""); } else if (RegValueEntryKind.ExpandSZ == CurrentKind) { CurrentValue.SetExpandedStringValue(""); } else if (RegValueEntryKind.DWord == CurrentKind) { CurrentValue.SetIntValue(0); } else if (RegValueEntryKind.QWord == CurrentKind) { CurrentValue.SetLongValue(0); } else if (RegValueEntryKind.MultiSZ == CurrentKind) { CurrentValue.SetMultiStringValue(new List <string>()); } else { CurrentValue.SetBinaryType(CurrentKind, new byte[] { }); } CurrentValue = null; } else { CurrentContent = new StringBuilder(); string encoding = reader.GetAttribute("encoding"); isBase64Encoding = (encoding != null) && encoding.Equals("base-64"); if (CurrentKind == RegValueEntryKind.MultiSZ) { currentStringList.Clear(); } else { CurrentContent = new StringBuilder(); } } } break; case XmlNodeType.Text: if (CurrentContent != null) { CurrentContent.Append(reader.Value); } break; case XmlNodeType.EndElement: if (reader.Name.Equals("key")) { Trace.Assert(CurrentKey != null); CurrentKey = CurrentKey.Parent; } else if ((CurrentKind == RegValueEntryKind.MultiSZ) && reader.Name.Equals("line")) { if (isBase64Encoding) { byte[] bytes = Convert.FromBase64String(CurrentContent.ToString()); currentStringList.Add(System.Text.Encoding.Unicode.GetString(bytes)); } else { currentStringList.Add(CurrentContent.ToString()); } } else if (reader.Name.Equals("registry")) { } else if (reader.Name.Equals(CurrentKind.ToString())) { if (RegValueEntryKind.SZ == CurrentKind) { if (isBase64Encoding) { byte[] bytes = Convert.FromBase64String(CurrentContent.ToString()); CurrentValue.SetStringValue(System.Text.Encoding.Unicode.GetString(bytes)); } else { CurrentValue.SetStringValue(CurrentContent.ToString()); } } else if (RegValueEntryKind.ExpandSZ == CurrentKind) { if (isBase64Encoding) { byte[] bytes = Convert.FromBase64String(CurrentContent.ToString()); CurrentValue.SetExpandedStringValue(System.Text.Encoding.Unicode.GetString(bytes)); } else { CurrentValue.SetExpandedStringValue(CurrentContent.ToString()); } } else if (RegValueEntryKind.DWord == CurrentKind) { string temp = CurrentContent.ToString(); if (temp.Contains("$$")) { CurrentValue.SetEscapedIntValue(temp); } else { CurrentValue.SetIntValue(int.Parse(temp)); } } else if (RegValueEntryKind.QWord == CurrentKind) { string temp = CurrentContent.ToString(); if (temp.Contains("$$")) { CurrentValue.SetEscapedLongValue(temp); } else { CurrentValue.SetLongValue(long.Parse(temp)); } } else if (RegValueEntryKind.MultiSZ == CurrentKind) { CurrentValue.SetMultiStringValue(currentStringList); currentStringList.Clear(); } else { CurrentValue.SetBinaryType(CurrentKind, DecodeHexByteArray(CurrentContent.ToString())); } CurrentValue = null; } break; } } } }
public ActionResult Logout() { CurrentContent.destroy(); return(RedirectToAction("Index", "Home")); }