public static void Main() { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //create bookmarks Bookmarks bookmarks = new Bookmarks(); Bookmark childBookmark1 = new Bookmark(); childBookmark1.PageNumber = 1; childBookmark1.Title = "First Child"; Bookmark childBookmark2 = new Bookmark(); childBookmark2.PageNumber = 2; childBookmark2.Title = "Second Child"; bookmarks.Add(childBookmark1); bookmarks.Add(childBookmark2); Bookmark bookmark = new Bookmark(); bookmark.Action = "GoTo"; bookmark.PageNumber = 1; bookmark.Title = "Parent"; bookmark.ChildItems = bookmarks; //create PdfBookmarkEditor class PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor(); //bind PDF document bookmarkEditor.BindPdf(dataDir+ "input.pdf"); //create bookmarks bookmarkEditor.CreateBookmarks(bookmark); //save updated document bookmarkEditor.Save(dataDir+ "output.pdf"); }
private void PrintBookmarks( Bookmarks bookmarks ) { if(bookmarks == null) return; foreach(Bookmark bookmark in bookmarks) { // Show current bookmark! Console.WriteLine("Bookmark '" + bookmark.Title + "'"); Console.Write(" Target: "); PdfObjectWrapper target = bookmark.Target; if(target is Destination) {PrintDestination((Destination)target);} else if(target is actions::Action) {PrintAction((actions::Action)target);} else if(target == null) {Console.WriteLine("[not available]");} else {Console.WriteLine("[unknown type: " + target.GetType().Name + "]");} // Show child bookmarks! PrintBookmarks(bookmark.Bookmarks); } }
XDocument settings; //xml settings document #endregion Fields #region Constructors public DataHandler() { //instantiate lists history = new History(); bookmarks = new Bookmarks(); //set path to user.home path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\settings.xml"; //Read xml from user home, if no document exist, skip try { reader = XmlTextReader.Create(@path); settings = XDocument.Load(reader); //create objects and lists from xml loadBookmarks(); loadHistory(); loadHomePage(); reader.Close(); } catch (FileNotFoundException) { //skip this step } }
public ManageBookmarkDataViewModel(Bookmarks.Models.Bookmark bookmark) { this.Id = bookmark.Id; this.Url = bookmark.Url; this.Title = bookmark.Title; this.Description = bookmark.Title; this.Category = bookmark.Category.Name; }
public bool CreateBookmark(Bookmarks instance) { if (instance.ID == 0) { Db.Bookmarks.InsertOnSubmit(instance); Db.Bookmarks.Context.SubmitChanges(); return true; } return false; }
private async Task SaveToDiskAsync() { await(TaskRelayer = await ApplicationData.Current.LocalFolder .CreateFileAsync("bookmarks.xml", CreationCollisionOption.ReplaceExisting) .AsTask() .ContinueWith(async t => { using var stream = await t.Result.OpenStreamForWriteAsync(); Bookmarks.ToArray().Serialize(stream); })); }
public void UnseccessfulNextSearchInEmptyBookmarksContainer() { IBookmarks bmks = new Bookmarks(CreateBmkFactory()); var foundBmk = bmks.GetNext(CreateBmk(0, "", 0), true); Assert.IsNull(foundBmk); foundBmk = bmks.GetNext(CreateBmk(0, "", 0), false); Assert.IsNull(foundBmk); }
public void AddBookmark(string id, int bookmarkStyleIndex) { if (Bookmarks.ContainsKey(id)) { Bookmarks.Remove(id); } Bookmarks.Add(id, bookmarkStyleIndex); NotifyOfPropertyChange("BookmarksAvailable"); }
public bool UpdateBookmark(Bookmarks instance) { Bookmarks cache = Db.Bookmarks.FirstOrDefault(p => p.ID == instance.ID); if (cache != null) { cache.Name = instance.Name; cache.Url = instance.Url; Db.Bookmarks.Context.SubmitChanges(); return true; } return false; }
public void SimpleNextSearchTest() { IBookmarks bmks = new Bookmarks(CreateBmkFactory()); var b1 = bmks.ToggleBookmark(CreateBmk(10, "", 0)); var b2 = bmks.ToggleBookmark(CreateBmk(20, "", 0)); var foundBmk = bmks.GetNext(CreateBmk(0, "", 0), true); Assert.AreSame(b1, foundBmk); foundBmk = bmks.GetNext(CreateBmk(30, "", 0), false); Assert.AreSame(b2, foundBmk); }
private void Delete() { if (SelectedBookmark != null) { ClearStar(SelectedBookmark.SearchFor, SelectedBookmark.ReplaceWith, SelectedBookmark.FilePattern); var bmk = new Bookmark(SelectedBookmark.SearchFor, SelectedBookmark.ReplaceWith, SelectedBookmark.FilePattern); BookmarkLibrary.Instance.Bookmarks.Remove(bmk); BookmarkLibrary.Save(); Bookmarks.Remove(SelectedBookmark); } }
public void UnseccessfulNextSearchTest() { IBookmarks bmks = new Bookmarks(CreateBmkFactory()); bmks.ToggleBookmark(CreateBmk(10, "", 0)); bmks.ToggleBookmark(CreateBmk(20, "", 0)); var foundBmk = bmks.GetNext(CreateBmk(40, "", 0), true); Assert.IsNull(foundBmk); foundBmk = bmks.GetNext(CreateBmk(5, "", 0), false); Assert.IsNull(foundBmk); }
private void button1_Click(object sender, EventArgs e) { Bookmarks b = new Bookmarks(); if (b.CheckIfBookmarkExists(t_Name.Text, t_Path.Text)) { MessageBox.Show("Bookmark already exists!"); } else { b.CreateNewBookmark(t_Name.Text, t_Path.Text); this.DialogResult = DialogResult.OK; Close(); } }
public async Task<bool> SaveBookmark(Bookmarks bookmark) { Bookmarks _bookmark = new Bookmarks(); _bookmark.Title = bookmark.Title; _bookmark.URL = bookmark.URL; BsonDocument document = new BsonDocument { {"URL", bookmark.URL }, {"Title", bookmark.Title } }; await _bookmarkCollection.InsertOneAsync(document); return true; }
public async Task<bool> SaveBookmark(Bookmarks bookmark) { bool isSave = false; return await Task.Run(() => { using (var session = _store.OpenSession()) { Bookmarks _bookmark = new Bookmarks(); _bookmark.URL = bookmark.URL; _bookmark.Title = bookmark.Title; session.Store(bookmark); session.SaveChanges(); isSave = true; } return isSave; }); }
public static Bookmarks LoadFromSettings(string settings) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(Bookmarks)); Bookmarks retVal; byte[] data = ASCIIEncoding.Default.GetBytes(settings); using (MemoryStream memStream = new MemoryStream(data)) { try { retVal = (Bookmarks)xmlSerializer.Deserialize(memStream); } catch { retVal = new Bookmarks(); } } return retVal; }
public Task<IEnumerable<Bookmarks>> ListBookmarks() { List<Bookmarks> b = new List<Bookmarks>(); return Task.Run(async () => { _bookmarksList = await _bookmarkCollection.Find(new BsonDocument()).ToListAsync(); foreach (var bookmark in _bookmarksList) { Bookmarks _bookmark = new Bookmarks(); _bookmark.Id = Convert.ToString(bookmark.GetElement("_id").Value); _bookmark.Title = bookmark.GetElement("Title").Value.AsString; _bookmark.URL = bookmark.GetElement("URL").Value.AsString; b.Add(_bookmark); } return b as IEnumerable<Bookmarks>; }); }
protected void AddBookmarkButton_Click(object sender, EventArgs e) { try { _data = Bookmarks.LoadFromSettings(WidgetHost.GetHost(this).WidgetInfo.Settings); if (!newLinkURL.Text.Substring(0, 4).Equals("http")) { newLinkURL.Text = "http://" + newLinkURL.Text; } if (newLinkTitle.Text != "") { _data.LinkTitlePairs.Add(new LinkTitlePair(newLinkURL.Text, newLinkTitle.Text)); Repeater1.DataSource = _data.LinkTitlePairs.ToArray(); Repeater1.DataBind(); WidgetHost.GetHost(this).Save(_data.ToXml()); } newLinkURL.Text = ""; newLinkTitle.Text = ""; } catch { } }
protected void Page_Init(object sender, EventArgs e) { _host = WidgetHost.GetHost(this); _host.Edit += new EditDelegate(EditEvent); _host.Minimize += new MinimizeDelegate(MinimizeEvent); _host.Maximize += new MaximizeDelegate(MaximizeEvent); _host.Create += new CreateDelegate(CreateEvent); _host.Title = Server.HtmlEncode("Bookmarks"); _data = Bookmarks.LoadFromSettings(_host.WidgetInfo.Settings); MainView(); }
internal override void Dispose(bool disposing) { if (disposing) { // Free managed if (_sections != null && !_sections.IsDisposed) { _sections.Dispose(); _sections = null; } if (_bookmarks != null && !_bookmarks.IsDisposed) { _bookmarks.Dispose(); _bookmarks = null; } if (_contentControls != null && !_contentControls.IsDisposed) { _contentControls.Dispose(); _contentControls = null; } } base.Dispose(true); }
/// <summary> /// Parse the RopFindRow structure. /// </summary> /// <param name="s">An stream containing RopFindRow structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.LogonId = ReadByte(); this.InputHandleIndex = ReadByte(); this.FindRowFlags = (FindRowFlags)ReadByte(); this.RestrictionDataSize = ReadUshort(); if (RestrictionDataSize > 0) { RestrictionType tempRestriction = new RestrictionType(); this.RestrictionData = tempRestriction; this.RestrictionData.Parse(s); } this.Origin = (Bookmarks)ReadByte(); this.BookmarkSize = ReadUshort(); this.Bookmark = ReadBytes(BookmarkSize); }
/// <summary> /// Parse the RopSeekRowRequest structure. /// </summary> /// <param name="s">An stream containing RopSeekRowRequest structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.LogonId = ReadByte(); this.InputHandleIndex = ReadByte(); this.Origin = (Bookmarks)ReadByte(); this.RowCount = ReadINT32(); this.WantRowMovedCount = ReadBoolean(); }
private static Bookmarks LoadFF2Bookmarks(File file) { var bookmarks = new Bookmarks(); var matches = Regex.Matches(file.Contents()); foreach (Match match in matches) bookmarks.AddRange(LaunchableForBookmark(match)); return bookmarks; }
private static Bookmarks CreateBookmarks(string bookmarkDescription, string url, string keyword) { var bookmarks = new Bookmarks(); if (!string.IsNullOrEmpty(bookmarkDescription)) bookmarks.Add(new Bookmark(bookmarkDescription, url, icon)); if (!string.IsNullOrEmpty(keyword)) bookmarks.Add(new Bookmark(keyword, url, icon)); return bookmarks; }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { try { _data = Bookmarks.LoadFromSettings(WidgetHost.GetHost(this).WidgetInfo.Settings); _data.LinkTitlePairs.RemoveAt(e.Item.ItemIndex); WidgetHost.GetHost(this).Save(_data.ToXml()); Repeater1.DataSource = _data.LinkTitlePairs.ToArray(); Repeater1.DataBind(); } catch { ViewSet.SetActiveView(View); } }
void EditEvent(string settings) { try { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), @"WidgetEnterCheck" + _host.WidgetInfo.ID.ToString(), "<script type='text/javascript'>function checkForEnter" + _host.WidgetInfo.ID.ToString() + @"(e, saveButtonID){var evt = e ? e : window.event;if(evt.keyCode == 13){document.forms[0].onsubmit = function () { return false; }; evt.cancelBubble = true; if (evt.stopPropagation) evt.stopPropagation(); return false; }}</script>", false); newLinkURL.Attributes.Add("onkeydown", @"javascript:checkForEnter" + _host.WidgetInfo.ID.ToString() + @"(event, '" + AddBookmarkButton.ClientID + "')"); newLinkTitle.Attributes.Add("onkeydown", @"javascript:checkForEnter" + _host.WidgetInfo.ID.ToString() + @"(event, '" + AddBookmarkButton.ClientID + "')"); _data = Bookmarks.LoadFromSettings(settings); Repeater1.DataSource = _data.LinkTitlePairs.ToArray(); Repeater1.DataBind(); ViewSet.SetActiveView(Edit); } catch { ViewSet.SetActiveView(View); } }
public void InitGoods() { ClearTransform(layoutShopItems); int lvl = MainController.Instance.PlayerData.Level; var countShopItems = Mathf.Clamp(lvl - 2, 1, Int32.MaxValue); for (int i = countShopItems; i <= lvl ; i++) { var e = DataBaseController.GetItem<HeroShopRandomItem>(HeroShopWeapon); e.Init(i); CreatShopElement(e); var e2 = DataBaseController.GetItem<HeroShopRandomItem>(HeroShopArmor); e2.Init(i); CreatShopElement(e2); var e3 = DataBaseController.GetItem<HeroShopRandomItem>(HeroShopTalisman); e3.Init(i); CreatShopElement(e3); #if DEBUG var e4 = DataBaseController.GetItem<HeroShopCheat>(PrefabHeroShopCheat); e4.Init(i); CreatShopElement(e4); #endif } var bonItem = DataBaseController.GetItem<HeroShopBonusItem>(PrefabHeroShopBonusItem); bonItem.Init(lvl); CreatShopElement(bonItem); var execItem = DataBaseController.GetItem<HeroShopExecutableItem>(PrefabHeroShopExecutableItem); execItem.Init(lvl); CreatShopElement(execItem); Bookmarks = Bookmarks.weapons; NullSelection(); }
public void InitRecipies() { ClearTransform(layoutShopItems); int lvl = MainController.Instance.PlayerData.Level; for (int i = Mathf.Clamp(lvl - 1, 1, Int32.MaxValue); i <= lvl; i++) { var execItem = DataBaseController.GetItem<HeroShopRecipeItem>(PrefabHeroShopRecipeItem); execItem.Init(lvl); CreatShopElement(execItem); } Bookmarks = Bookmarks.recipies; NullSelection(); }
/// <summary> /// Initializes a new instance of the <see cref="HWPFDocument"/> class. /// </summary> /// <param name="directory">The directory.</param> public HWPFDocument(DirectoryNode directory) : base(directory) { _endnotes = new NotesImpl(_endnotesTables); _footnotes = new NotesImpl(_footnotesTables); // Load the main stream and FIB // Also handles HPSF bits // Do the CP Split _cpSplit = new CPSplitCalculator(_fib); // Is this document too old for us? if (_fib.GetNFib() < 106) { throw new OldWordFileFormatException("The document is too old - Word 95 or older. Try HWPFOldDocument instead?"); } // use the fib to determine the name of the table stream. String name = "0Table"; if (_fib.IsFWhichTblStm()) { name = "1Table"; } // Grab the table stream. DocumentEntry tableProps; try { tableProps = (DocumentEntry)directory.GetEntry(name); } catch (FileNotFoundException) { throw new InvalidOperationException("Table Stream '" + name + "' wasn't found - Either the document is corrupt, or is Word95 (or earlier)"); } // read in the table stream. _tableStream = new byte[tableProps.Size]; directory.CreatePOIFSDocumentReader(name).Read(_tableStream); _fib.FillVariableFields(_mainStream, _tableStream); // read in the data stream. try { DocumentEntry dataProps = (DocumentEntry)directory.GetEntry("Data"); _dataStream = new byte[dataProps.Size]; directory.CreatePOIFSDocumentReader("Data").Read(_dataStream); } catch (FileNotFoundException) { _dataStream = new byte[0]; } // Get the cp of the start of text in the main stream // The latest spec doc says this is always zero! int fcMin = 0; //fcMin = _fib.GetFcMin() // Start to load up our standard structures. _dop = new DocumentProperties(_tableStream, _fib.GetFcDop()); _cft = new ComplexFileTable(_mainStream, _tableStream, _fib.GetFcClx(), fcMin); TextPieceTable _tpt = _cft.GetTextPieceTable(); // Now load the rest of the properties, which need to be adjusted // for where text really begin _cbt = new CHPBinTable(_mainStream, _tableStream, _fib.GetFcPlcfbteChpx(), _fib.GetLcbPlcfbteChpx(), _tpt); _pbt = new PAPBinTable(_mainStream, _tableStream, _dataStream, _fib.GetFcPlcfbtePapx(), _fib.GetLcbPlcfbtePapx(), _tpt); _text = _tpt.Text; /* * in this mode we preserving PAPX/CHPX structure from file, so text may * miss from output, and text order may be corrupted */ bool preserveBinTables = false; try { preserveBinTables = Boolean.Parse( ConfigurationManager.AppSettings[PROPERTY_PRESERVE_BIN_TABLES]); } catch (Exception) { // ignore; } if (!preserveBinTables) { _cbt.Rebuild(_cft); _pbt.Rebuild(_text, _cft); } /* * Property to disable text rebuilding. In this mode changing the text * will lead to unpredictable behavior */ bool preserveTextTable = false; try { preserveTextTable = Boolean.Parse( ConfigurationManager.AppSettings[PROPERTY_PRESERVE_TEXT_TABLE]); } catch (Exception) { // ignore; } if (!preserveTextTable) { _cft = new ComplexFileTable(); _tpt = _cft.GetTextPieceTable(); TextPiece textPiece = new SinglentonTextPiece(_text); _tpt.Add(textPiece); _text = textPiece.GetStringBuilder(); } // Read FSPA and Escher information // _fspa = new FSPATable(_tableStream, _fib.getFcPlcspaMom(), // _fib.getLcbPlcspaMom(), getTextTable().getTextPieces()); _fspaHeaders = new FSPATable(_tableStream, _fib, FSPADocumentPart.HEADER); _fspaMain = new FSPATable(_tableStream, _fib, FSPADocumentPart.MAIN); if (_fib.GetFcDggInfo() != 0) { _dgg = new EscherRecordHolder(_tableStream, _fib.GetFcDggInfo(), _fib.GetLcbDggInfo()); } else { _dgg = new EscherRecordHolder(); } // read in the pictures stream _pictures = new PicturesTable(this, _dataStream, _mainStream, _fspa, _dgg); // And the art shapes stream _officeArts = new ShapesTable(_tableStream, _fib); // And escher pictures _officeDrawingsHeaders = new OfficeDrawingsImpl(_fspaHeaders, _dgg, _mainStream); _officeDrawingsMain = new OfficeDrawingsImpl(_fspaMain, _dgg, _mainStream); _st = new SectionTable(_mainStream, _tableStream, _fib.GetFcPlcfsed(), _fib.GetLcbPlcfsed(), fcMin, _tpt, _cpSplit); _ss = new StyleSheet(_tableStream, _fib.GetFcStshf()); _ft = new FontTable(_tableStream, _fib.GetFcSttbfffn(), _fib.GetLcbSttbfffn()); int listOffset = _fib.GetFcPlcfLst(); int lfoOffset = _fib.GetFcPlfLfo(); if (listOffset != 0 && _fib.GetLcbPlcfLst() != 0) { _lt = new ListTables(_tableStream, _fib.GetFcPlcfLst(), _fib.GetFcPlfLfo()); } int sbtOffset = _fib.GetFcSttbSavedBy(); int sbtLength = _fib.GetLcbSttbSavedBy(); if (sbtOffset != 0 && sbtLength != 0) { _sbt = new SavedByTable(_tableStream, sbtOffset, sbtLength); } int rmarkOffset = _fib.GetFcSttbfRMark(); int rmarkLength = _fib.GetLcbSttbfRMark(); if (rmarkOffset != 0 && rmarkLength != 0) { _rmat = new RevisionMarkAuthorTable(_tableStream, rmarkOffset, rmarkLength); } _bookmarksTables = new BookmarksTables(_tableStream, _fib); _bookmarks = new BookmarksImpl(_bookmarksTables); _endnotesTables = new NotesTables(NoteType.ENDNOTE, _tableStream, _fib); _endnotes = new NotesImpl(_endnotesTables); _footnotesTables = new NotesTables(NoteType.FOOTNOTE, _tableStream, _fib); _footnotes = new NotesImpl(_footnotesTables); _fieldsTables = new FieldsTables(_tableStream, _fib); _fields = new FieldsImpl(_fieldsTables); }