public TextFieldAttribute(TextFieldType type, string title, string path, string extension) { this.type = type; this.title = title; this.path = path; this.extension = extension; }
private void SetupSimplePanelHelper(TextFieldType fieldType) { switch(fieldType) { case TextFieldType.modelunits: if (Doc != null) formatString = Doc.GetUnitSystemName(true, false, false, false); break; case TextFieldType.notes: if (Doc != null) { string notes = Doc.Notes; formatString = string.IsNullOrEmpty(notes) ? "####" : notes; } break; case TextFieldType.numpages: if (Doc != null) { var pageviews = Doc.Views.GetPageViews(); int count = pageviews == null ? 0 : pageviews.Length; formatString = count.ToString(); } break; case TextFieldType.pagename: if (Doc != null) { var page = Doc.Views.ActiveView as Rhino.Display.RhinoPageView; formatString = page == null ? "####" : page.MainViewport.Name; } break; case TextFieldType.pagenumber: if (Doc != null) { var page = Doc.Views.ActiveView as Rhino.Display.RhinoPageView; formatString = page == null ? "####" : page.PageNumber.ToString(); } break; } }
private void SetupSelectObjectPanelHelper(TextFieldType fieldType, bool resetId) { if( resetId ) SelectedObjectId = Guid.Empty; if (fieldType != TextFieldType.usertext) return; hideUserTextFieldCollection = (SelectedObjectId == Guid.Empty || Doc == null); _nameValuePairCollection.Clear(); selectedNameValuePairIndex = -1; if (!hideUserTextFieldCollection) { var rhobj = SelectedObject; if (null != rhobj) { var userstrings = rhobj.Attributes.GetUserStrings(); var keys = userstrings.Keys; for (int i = 0; i < userstrings.Count; i++) { var namevalue = new NameValuePair(keys[i], userstrings[i]); _nameValuePairCollection.Add(namevalue); } } } #if ON_OS_MAC RaisePropertyChanged(() => nameValuePairCollectionArray); #endif }
public TextFieldData(TextFieldType style, string local_name, string description) { m_style = style; m_local_name = local_name; m_description = description; }
internal void Load(XElement xDocumentInfo) { if (xDocumentInfo == null) { throw new ArgumentNullException("xDocumentInfo"); } // Load document authors _documentAuthors.Clear(); IEnumerable <XElement> xAuthors = xDocumentInfo.Elements(_fileNameSpace + AuthorType.AuthorElementName); if (xAuthors != null) { foreach (XElement xAuthor in xAuthors) { AuthorItem author = new AuthorItem { Namespace = _fileNameSpace }; try { author.Load(xAuthor); _documentAuthors.Add(author); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading document authors : {0}", ex.Message)); continue; } } } // load Program used to create ProgramUsed2Create = null; XElement xProgramUsed = xDocumentInfo.Element(_fileNameSpace + ProgramUsedElementName); if (xProgramUsed != null) { ProgramUsed2Create = new TextFieldType(); try { ProgramUsed2Create.Load(xProgramUsed); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading program used to create : {0}", ex.Message)); } } // Load creation date DocumentDate = null; XElement xDate = xDocumentInfo.Element(_fileNameSpace + DateItem.Fb2DateElementName); if (xDate != null) { DocumentDate = new DateItem(); try { DocumentDate.Load(xDate); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading document date : {0}", ex.Message)); } } // Load Source URLs _sourceUrLs.Clear(); IEnumerable <XElement> xSrcURLs = xDocumentInfo.Elements(_fileNameSpace + SourceURLElementName); if (xSrcURLs != null) { foreach (XElement xSrcURL in xSrcURLs) { if ((xSrcURL != null) && (xSrcURL.Value != null)) { string srcURL = xSrcURL.Value; _sourceUrLs.Add(srcURL); } } } // Load SourceOCR SourceOCR = null; XElement xSrcOcr = xDocumentInfo.Element(_fileNameSpace + SourceOCRElementName); if (xSrcOcr != null) { SourceOCR = new TextFieldType(); try { SourceOCR.Load(xSrcOcr); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading source OCR : {0}", ex.Message)); } } // load document's ID ID = null; XElement xID = xDocumentInfo.Element(_fileNameSpace + IdElementName); if ((xID != null) && (xID.Value != null)) { ID = xID.Value; } // load document's version DocumentVersion = null; XElement xVersion = xDocumentInfo.Element(_fileNameSpace + VersionElementName); if ((xVersion != null) && (xVersion.Value != null)) { string version = xVersion.Value; try { var cult = new CultureInfo(""); DocumentVersion = float.Parse(version, cult.NumberFormat); } catch (FormatException ex) { Debug.WriteLine(string.Format("Error reading document version : {0}", ex.Message)); } } // Load change history History = null; XElement xHistory = xDocumentInfo.Element(_fileNameSpace + HistoryElementName); if (xHistory != null) { History = new AnnotationType() { ElementName = HistoryElementName }; try { History.Load(xHistory); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading document history : {0}", ex.Message)); } } // Load copyright owners _documentPublishers.Clear(); IEnumerable <XElement> xPublishers = xDocumentInfo.Elements(_fileNameSpace + AuthorType.PublisherElementName); if (xPublishers != null) { foreach (XElement xPublisher in xPublishers) { PublisherItem publisher = new PublisherItem { Namespace = _fileNameSpace }; try { publisher.Load(xPublisher); _documentPublishers.Add(publisher); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading document publishers : {0}", ex.Message)); continue; } } } }
/// <summary> /// textFieldType determines whether certain inputs like Tab, Return, Up Arrow and Down Arrow /// are treaded as reserved input /// </summary> public bool DetectTextFieldReservedInput(Event inputEvent, TextFieldType textFieldType) { switch (inputEvent.keyCode) { case KeyCode.Escape: return(false); case KeyCode.LeftArrow: case KeyCode.RightArrow: //no modifers: move cursor to next/previous letter //ctrl: move cursor to next/previous word //shift: select next/previous letter //ctrl+shift: select next/previous word return((inputEvent.modifiers & EventModifiers.Alt) == EventModifiers.None); case KeyCode.UpArrow: case KeyCode.DownArrow: //no modifers: move cursor to below/above row //ctrl: move cursor to very top or bottom //shift: select upto letter in below/above row //ctrl+shift: select upto letter in top or bottom return((inputEvent.modifiers & EventModifiers.Alt) == EventModifiers.None && textFieldType != TextFieldType.Numeric); case KeyCode.Home: case KeyCode.End: case KeyCode.PageUp: case KeyCode.PageDown: return(inputEvent.modifiers == EventModifiers.FunctionKey); //UPDATE: Tab, return and enter are only treated as text input in Unity's text areas, //not in normal text fields case KeyCode.Return: case KeyCode.KeypadEnter: case KeyCode.Tab: return(inputEvent.modifiers == EventModifiers.None && textFieldType == TextFieldType.TextArea); case KeyCode.CapsLock: return(inputEvent.modifiers == EventModifiers.CapsLock); case KeyCode.Delete: case KeyCode.Backspace: //Debug.Log("inputEvent.modifiers = "+inputEvent.modifiers); //return inputEvent.modifiers == EventModifiers.FunctionKey || (inputEvent.control && !inputEvent.alt && !inputEvent.shift); //inputEvent.modifiers == EventModifiers.Control; //backspace and delete are used for clearing input one letter at at time //ctrl + backspace or delete are used for clearing input one word at a time return(inputEvent.modifiers == EventModifiers.FunctionKey || (inputEvent.modifiers | (EventModifiers.FunctionKey | EventModifiers.Control)) == (EventModifiers.FunctionKey | EventModifiers.Control)); case KeyCode.None: return(false); default: if (inputEvent.modifiers == EventModifiers.None) { return(true); } //shift is used for changing uppercasing if (inputEvent.modifiers == EventModifiers.Shift) { return(true); } return(false); } }
internal void Load(XElement xPublishInfo) { if (xPublishInfo == null) { throw new ArgumentNullException(nameof(xPublishInfo)); } // Load book name BookTitle = null; XElement xBookName = xPublishInfo.Element(FileNameSpace + BookNameElementName); if (xBookName != null) { BookTitle = new TextFieldType(); try { BookTitle.Load(xBookName); } catch (Exception ex) { Debug.WriteLine($"Error reading publisher book name : {ex.Message}"); } } // Load publisher Publisher = null; XElement xPublisher = xPublishInfo.Element(FileNameSpace + PublisherElementName); if (xPublisher != null) { Publisher = new TextFieldType(); try { Publisher.Load(xPublisher); } catch (Exception ex) { Debug.WriteLine($"Error reading publishers : {ex.Message}"); } } // Load city City = null; XElement xCity = xPublishInfo.Element(FileNameSpace + CityElementName); if (xCity != null) { City = new TextFieldType(); try { City.Load(xCity); } catch (Exception ex) { Debug.WriteLine($"Error reading publishers' City: {ex.Message}"); } } // Load year Year = null; XElement xYear = xPublishInfo.Element(FileNameSpace + YearElementName); if (xYear != null) { if (int.TryParse(xYear.Value, out var year)) { Year = year; } } // Load ISBN ISBN = null; XElement xISBN = xPublishInfo.Element(FileNameSpace + ISBNElementName); if (xISBN != null) { ISBN = new TextFieldType(); try { ISBN.Load(xISBN); } catch (Exception ex) { Debug.WriteLine($"Error reading publishers' ISBN: {ex.Message}"); } } // Load sequence here ItemSequences.Clear(); foreach (var xSequence in xPublishInfo.Elements(FileNameSpace + SequenceType.SequenceElementName)) { var sec = new SequenceType(); try { sec.Load(xSequence); ItemSequences.Add(sec); } catch (Exception ex) { Debug.WriteLine($"Error reading publisher sequence data: {ex.Message}"); } } }
private void SetupDocTextPanelHelper(TextFieldType fieldType) { if (fieldType != TextFieldType.documenttext) return; _nameValuePairCollection.Clear(); selectedNameValuePairIndex = -1; if (Doc != null && Doc.Strings.Count > 0) { int count = Doc.Strings.Count; for (int i = 0; i < count; i++) { var key = Doc.Strings.GetKey(i); var value = Doc.Strings.GetValue(i); var item = new NameValuePair(key, value); _nameValuePairCollection.Add(item); } } #if ON_OS_MAC RaisePropertyChanged(() => nameValuePairCollectionArray); #endif }
public TextFieldAttribute(TextFieldType type, string title) : this(type, title, PATH, EXTENSION) { }
public TextFieldAttribute(TextFieldType type, string title, string path) : this(type, title, path, EXTENSION) { }
public TextFieldAttribute(TextFieldType type) : this(type, TITLE, PATH, EXTENSION) { }
/// <summary> /// Initializes a new instance of the <see cref="T:TextFieldValue"/> class. /// </summary> /// <param name="text">The text.</param> public TextFieldValue(string text, TextFieldType type) { Text = text; _type = type; }
private void SetupFilenamePanelHelper(TextFieldType fieldType) { if (null == Doc || fieldType != TextFieldType.filename) return; string path = includeFullPath ? Doc.Path : Doc.Name; if (!includeFileExtension && path.EndsWith(".3dm", StringComparison.OrdinalIgnoreCase)) path = path.Substring(0, path.Length - ".3dm".Length); formatString = string.IsNullOrEmpty(path) ? "####" : path; }
public TextFieldAttribute(TextFieldType type) : this(type, PATH, TITLE, EXTENSION) { }
private void SetupDatePanelHelper(TextFieldType fieldType) { if (fieldType != TextFieldType.date && fieldType != TextFieldType.datemodified) return; if (_dateFormatList.Count < 1) { var dt = DateTime.Now; if (fieldType == TextFieldType.datemodified && Doc != null) { var doc_dt = Doc.DateLastEdited; if (doc_dt != DateTime.MinValue) dt = doc_dt; } // Use the same format codes as Word _dateFormatList.Add(new DateFormat("M/d/yyyy", dt)); _dateFormatList.Add(new DateFormat("dddd, MMMM dd, yyyy", dt)); _dateFormatList.Add(new DateFormat("MMMM d, yyyy", dt)); _dateFormatList.Add(new DateFormat("M/d/yy", dt)); _dateFormatList.Add(new DateFormat("yyyy-MM-dd", dt)); _dateFormatList.Add(new DateFormat("d-MMM-yy", dt)); _dateFormatList.Add(new DateFormat("M.d.yyyy", dt)); _dateFormatList.Add(new DateFormat("MMM. d, yy", dt)); _dateFormatList.Add(new DateFormat("d MMMM yyyy", dt)); _dateFormatList.Add(new DateFormat("MMMM yy", dt)); _dateFormatList.Add(new DateFormat("MMM-yy", dt)); _dateFormatList.Add(new DateFormat("M/d/yyyy h:mm", dt)); _dateFormatList.Add(new DateFormat("M/d/yyyy h:mm:ss", dt)); _dateFormatList.Add(new DateFormat("h:mm", dt)); _dateFormatList.Add(new DateFormat("h:mm:ss", dt)); _dateFormatList.Add(new DateFormat("HH:mm", dt)); _dateFormatList.Add(new DateFormat("HH:mm:ss", dt)); RaisePropertyChanged(() => dateFormatList); #if ON_OS_MAC RaisePropertyChanged(() => dateFormatArray); #endif } if (selectedDateFormat >= 0 && selectedDateFormat < _dateFormatList.Count) formatString = _dateFormatList[selectedDateFormat].Format; else formatString = string.Empty; }
public TextFieldAttribute(TextFieldType type, string path) : this(type, path, TITLE, EXTENSION) { }
private void SetupCountPanelHelper(TextFieldType fieldType) { if (fieldType != TextFieldType.blockinstancecount) return; if (Doc != null && _blockNameList.Count == 0) { Rhino.DocObjects.InstanceDefinition[] idefs = Doc.InstanceDefinitions.GetList(true); for (int i = 0; i < idefs.Length; i++) { if (idefs[i].InUse(0)) { string name = idefs[i].Name; if (!string.IsNullOrEmpty(name)) _blockNameList.Add(name); } } RaisePropertyChanged(() => blockNameList); } if (selectedBlockNameIndex < 0) formatString = Rhino.UI.LOC.STR("Selct block to count"); else if (null == Doc) formatString = string.Empty; else if (blockNameList.Count < 1) formatString = Rhino.UI.LOC.STR("No blocks to count"); else { var blockName = _blockNameList[selectedBlockNameIndex]; var idef = Doc.InstanceDefinitions.Find(blockName, true); if (null == idef) formatString = string.Empty; else { var instanceobjs = idef.GetReferences(0); int count = instanceobjs.Length; formatString = count.ToString(); } } }
public TextFieldAttribute(TextFieldType type, string path, string title) : this(type, path, title, EXTENSION) { }
internal void Load(XElement xPublishInfo) { if (xPublishInfo == null) { throw new ArgumentNullException("xPublishInfo"); } // Load book name BookTitle = null; XElement xBookName = xPublishInfo.Element(FileNameSpace + BookNameElementName); if (xBookName != null) { BookTitle = new TextFieldType(); try { BookTitle.Load(xBookName); } catch (Exception ex) { Debug.Fail(string.Format("Error reading publisher book name : {0}", ex.Message)); } } // Load publisher Publisher = null; XElement xPublisher = xPublishInfo.Element(FileNameSpace + PublisherElementName); if (xPublisher != null) { Publisher = new TextFieldType(); try { Publisher.Load(xPublisher); } catch (Exception ex) { Debug.Fail(string.Format("Error reading publishers : {0}", ex.Message)); } } // Load city City = null; XElement xCity = xPublishInfo.Element(FileNameSpace + CityElementName); if (xCity != null) { City = new TextFieldType(); try { City.Load(xCity); } catch (Exception ex) { Debug.Fail(string.Format("Error reading publishers' City: {0}", ex.Message)); } } // Load year Year = null; XElement xYear = xPublishInfo.Element(FileNameSpace + YearElementName); if ((xYear != null)) { int year; if (int.TryParse(xYear.Value, out year)) { Year = year; } } // Load ISBN ISBN = null; XElement xISBN = xPublishInfo.Element(FileNameSpace + ISBNElementName); if (xISBN != null) { ISBN = new TextFieldType(); try { ISBN.Load(xISBN); } catch (Exception ex) { Debug.Fail(string.Format("Error reading publishers' ISBN: {0}", ex.Message)); } } // Load sequence here ItemSequences.Clear(); IEnumerable <XElement> xSequences = xPublishInfo.Elements(FileNameSpace + SequenceType.SequenceElementName); foreach (var xSequence in xSequences) { var sec = new SequenceType(); try { sec.Load(xSequence); } catch (Exception ex) { Debug.Fail(string.Format("Error reading publisher sequence data: {0}", ex.Message)); continue; } } }
public void Load(XElement xTitleInfo) { if (xTitleInfo == null) { throw new ArgumentNullException("xTitleInfo"); } // Load genres genres.Clear(); IEnumerable <XElement> xGenres = xTitleInfo.Elements(fileNameSpace + GenreElementName); if (xGenres != null) { foreach (XElement xGenre in xGenres) { if ((xGenre != null) && (xGenre.Value != null)) { TitleGenreType genre = new TitleGenreType(); genre.Genre = xGenre.Value; XAttribute xMatch = xGenre.Attribute("match"); if (xMatch != null && !string.IsNullOrEmpty(xMatch.Value)) { int percentage; if (int.TryParse(xMatch.Value, out percentage)) { genre.Match = percentage; } } genres.Add(genre); } } } // Load authors bookAuthors.Clear(); IEnumerable <XElement> xAuthors = xTitleInfo.Elements(fileNameSpace + AuthorType.AuthorElementName); if (xAuthors != null) { foreach (XElement xAuthor in xAuthors) { AuthorItem author = new AuthorItem { Namespace = fileNameSpace }; try { author.Load(xAuthor); bookAuthors.Add(author); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading author: {0}", ex.Message)); continue; } } } // Load Title BookTitle = null; XElement xBookTitle = xTitleInfo.Element(fileNameSpace + BookTitleElementName); if (xBookTitle != null) { BookTitle = new TextFieldType(); try { BookTitle.Load(xBookTitle); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading book title: {0}", ex.Message)); } } // Load Annotation Annotation = null; XElement xAnnotation = xTitleInfo.Element(fileNameSpace + AnnotationElementName); if (xAnnotation != null) { Annotation = new AnnotationItem(); try { Annotation.Load(xAnnotation); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading annotation: {0}", ex.Message)); } } // Load keywords Keywords = null; XElement xKeywords = xTitleInfo.Element(fileNameSpace + KeywordsElementName); if (xKeywords != null) { Keywords = new TextFieldType(); try { Keywords.Load(xKeywords); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading keywords: {0}", ex.Message)); } } // Load Book date BookDate = null; XElement xBookDate = xTitleInfo.Element(fileNameSpace + DateItem.Fb2DateElementName); if (xBookDate != null) { BookDate = new DateItem(); try { BookDate.Load(xBookDate); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading book date: {0}", ex.Message)); } } Cover = null; // we should load coverpage images here but no use for them as for now XElement xCoverPage = xTitleInfo.Element(fileNameSpace + CoverPageElementName); if (xCoverPage != null) { Cover = new CoverPage { Namespace = fileNameSpace }; try { Cover.Load(xCoverPage); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading cover: {0}", ex.Message)); } } // Load Language Language = null; XElement xLanguage = xTitleInfo.Element(fileNameSpace + LanguageElementName); if ((xLanguage != null) && (xLanguage.Value != null)) { Language = xLanguage.Value; } else { Debug.WriteLine("Language not specified in title section"); } // Load source language SrcLanguage = null; XElement xSrcLanguage = xTitleInfo.Element(fileNameSpace + SourceLanguageElementName); if ((xSrcLanguage != null) && (xSrcLanguage.Value != null)) { SrcLanguage = xSrcLanguage.Value; } // Load translators translators.Clear(); IEnumerable <XElement> xTranslators = xTitleInfo.Elements(fileNameSpace + AuthorType.TranslatorElementName); if (xTranslators != null) { foreach (XElement xTranslator in xTranslators) { TranslatorItem translator = new TranslatorItem() { Namespace = fileNameSpace }; try { translator.Load(xTranslator); translators.Add(translator); } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading translator: {0}", ex.Message)); continue; } } } // Load sequences sequences.Clear(); IEnumerable <XElement> xSequences = xTitleInfo.Elements(fileNameSpace + SequenceType.SequenceElementName); foreach (var xSequence in xSequences) { SequenceType sec = new SequenceType() { Namespace = fileNameSpace }; try { sec.Load(xSequence); if (!string.IsNullOrEmpty(sec.Name)) { sequences.Add(sec); } } catch (Exception ex) { Debug.WriteLine(string.Format("Error reading sequence data: {0}", ex.Message)); //Debug.WriteLine(string.Format("Error reading sequence data: {0}",ex.Message)); continue; } } }
public TextMatch() { SearchText = String.Empty; MatchMethod = TextMatchType.Exact; FieldType = TextFieldType.Body; }