Exemplo n.º 1
0
 public GameController(IGameView gameView, IFilerView filerView, IFiler filer, IGame game, IFileable gameFileable)
 {
     GameView     = gameView;
     FilerView    = filerView;
     Filer        = filer;
     Game         = game;
     GameFileable = gameFileable;
 }
Exemplo n.º 2
0
 //public DesignerController(IManualDesignerView designerView, IFilerView filerView, IFiler filer, IDesigner designer, IFileable designerFileable)
 //public DesignerController(IDesignerButtonView designerView, IFilerView filerView, IFiler filer, IDesigner designer, IFileable designerFileable)
 public DesignerController(IDesignerView designerView, IFilerView filerView, IFiler filer, IDesigner designer, IFileable designerFileable)
 {
     FilerView        = filerView;
     DesignerView     = designerView;
     Filer            = filer;
     Designer         = designer;
     DesignerFileable = designerFileable;
 }
Exemplo n.º 3
0
 public GameController(IGameView /*IGameView_Render*/ /*IGameView_Manual*/ gameView, IFilerView filerView, IFiler filer, IGame game, IFileable gameFileable)
 {
     GameView     = gameView;
     FilerView    = filerView;
     Filer        = filer;
     Game         = game;
     GameFileable = gameFileable;
 }
Exemplo n.º 4
0
 public SokobanController(IGame game, IView view, IDesign design, IFiler filer, IFileManager fm)
 {
     Game     = game;
     View     = view;
     Designer = design;
     Filer    = filer;
     FM       = fm;
 }
        public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument activeDoc = commandData.Application.ActiveUIDocument;

            Autodesk.Revit.DB.Document doc = activeDoc.Document;
            if (null == doc)
            {
                return(Result.Failed);
            }

            try
            {
                // Start detailed steel modeling transaction
                using (FabricationTransaction trans = new FabricationTransaction(doc, false, "Update connection parameters"))
                {
                    // for more details, please consult http://www.autodesk.com/adv-steel-api-walkthroughs-2019-enu
                    Reference eRef = activeDoc.Selection.PickObject(ObjectType.Element, "Pick a base plate connection");

                    Element elem = doc.GetElement(eRef.ElementId);
                    if (null == elem || !(elem is StructuralConnectionHandler))
                    {
                        return(Result.Failed);
                    }

                    StructuralConnectionHandler rvtConnection = (StructuralConnectionHandler)elem;

                    FilerObject filerObj = Utilities.Functions.GetFilerObject(doc, eRef);

                    if (null == filerObj || !(filerObj is UserAutoConstructionObject))
                    {
                        return(Result.Failed);
                    }

                    UserAutoConstructionObject asConnection = (UserAutoConstructionObject)filerObj;
                    //
                    //read connection parameters
                    IFiler connectionFiler = asConnection.Save();

                    if (connectionFiler != null)
                    {
                        //I choose to modify thickess of the base plate
                        connectionFiler.WriteItem(Convert.ToDouble(50.0), "BaseThickness"); //units must be milimmeters;
                        asConnection.Load(connectionFiler);                                 //update connection parameters
                        asConnection.Update();
                        //
                        //if the connection parameters are modified, than we have to set this flag to true,
                        //meaning that this connection has different parameters than it's connection type.
                        rvtConnection.OverrideTypeParams = true;
                    }
                    trans.Commit();
                }
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return(Result.Cancelled);
            }
            return(Result.Succeeded);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialize a new instance of <see cref="BookTextPageViewModel"/> class.
        /// </summary>
        /// <param name="book">EPUB book.</param>
        /// <param name="settings">The settings entity.</param>
        /// <param name="settingsRepository">The settings repository.</param>
        public BookTextPageViewModel(EpubBook book, SettingsEntity settings, ISettingsRepository settingsRepository)
        {
            this.settings           = settings;
            this.settingsRepository = settingsRepository;
            IFiler filer = DependencyService.Get <IFiler>();

            #region Custom HTML template

            HtmlDocument template = new HtmlDocument();
            // Hardcode filename
            Stream stream = filer.GetResourceFileStreamAsync("index.html").GetAwaiter().GetResult();
            template.Load(stream);

            var      script     = "<script>var lastPageNumber = " + this.settings.LastPage + "</script>";
            HtmlNode scriptNode = HtmlNode.CreateNode(script);

            var head = template.DocumentNode.ChildNodes.FirstOrDefault(c => c.Name == "html")
                       .ChildNodes.FirstOrDefault(f => f.Name == "head");

            head.ChildNodes.Add(scriptNode);

            var textContainer = template.DocumentNode.ChildNodes.FirstOrDefault(c => c.Name == "html")
                                .ChildNodes.FirstOrDefault(f => f.Name == "body")
                                .ChildNodes.FirstOrDefault(d => d.Id == "page");

            foreach (var html in book.Content.Html)
            {
                HtmlDocument document   = new HtmlDocument();
                string       htmlString = html.Value.Content.Replace(@"\", string.Empty);
                document.LoadHtml(htmlString);

                var body =
                    document.DocumentNode.ChildNodes.FirstOrDefault(c => c.Name == "html")
                    .ChildNodes.FirstOrDefault(f => f.Name == "body");

                foreach (var child in body.ChildNodes)
                {
                    textContainer.ChildNodes.Add(child);
                }
            }

            #endregion

            string htmlText = template.DocumentNode.OuterHtml.Replace(@"\", string.Empty);

            this.webView = new WebView
            {
                Source = new HtmlWebViewSource {
                    Html = htmlText
                },
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            this.webView.Navigating += this.NavigatingHandler;
            this.Content             = this.webView;
        }
Exemplo n.º 7
0
        //protected IFiler Filer;

        public FileHandlerController(ISaver saver, ILoader loader, IFiler filer, FilerNS.IFiler gameFiler, GameNS.Game game, FilerForm view)
        {
            Saver             = saver;
            Loader            = loader;
            View              = view;
            theGame           = game;
            Filer             = filer;
            FilerGame         = gameFiler;
            FileHandled       = new FileEventHandler(OnFileEvent);
            View.FileHandled += FileHandled;
            Filer.CreateSaveFolder();
            View.setDirectory(Filer.getSaveLocation());
        }
Exemplo n.º 8
0
        public override void Run()
        {
            var formats = ContentFormats.Split(';');
            List <ContentFormat> contentFormats = new List <ContentFormat>();

            foreach (var format in formats)
            {
                contentFormats.Add((ContentFormat)Enum.Parse(typeof(ContentFormat), format));
            }
            var    t     = Type.GetType("APITaskManagement.Logic.Filer." + Classname);
            IFiler filer = (IFiler)Activator.CreateInstance(t, contentFormats);

            filer.AddLogger(new SystemLogger());
            filer.AddLogger(new ApplicationLogger());
            filer.Send(Shares, this);
            LatestResponse = filer.GetLatestResponse();
        }
Exemplo n.º 9
0
 public string GetImage()
 {
     if (plugin == null)
     {
         return(image);
     }
     else
     {
         if (plugin is IFiler)
         {
             IFiler filer = plugin as IFiler;
             return(filer.GetImage(image));
         }
         else
         {
             return(image);
         }
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Opens the book asynchronously without reading its content. Holds the handle to the EPUB file.
        /// </summary>
        /// <param name="filePath">path to the EPUB file</param>
        /// <returns></returns>
        public static async Task <EpubBookRef> OpenBookAsync(string filePath)
        {
            IFiler   filer   = DependencyService.Get <IFiler>();
            IZipFile zipFile = DependencyService.Get <IZipFile>();

            if (!await filer.DoesFileExistAsync(filePath).ConfigureAwait(false))
            {
                throw new FileNotFoundException("Specified epub file not found.", filePath);
            }

            IZipArchive epubArchive = await zipFile.OpenReadAsync(filePath).ConfigureAwait(false);

            EpubBookRef bookRef = new EpubBookRef(epubArchive);

            bookRef.FilePath = filePath;
            bookRef.Schema   = await SchemaReader.ReadSchemaAsync(epubArchive).ConfigureAwait(false);

            bookRef.Title      = bookRef.Schema.Package.Metadata.Titles.FirstOrDefault() ?? String.Empty;
            bookRef.AuthorList = bookRef.Schema.Package.Metadata.Creators.Select(creator => creator.Creator).ToList();
            bookRef.Author     = string.Join(", ", bookRef.AuthorList);
            bookRef.Content    = await Task.Run(() => ContentReader.ParseContentMap(bookRef)).ConfigureAwait(false);

            return(bookRef);
        }
        /// <summary>
        /// This method is looking for a books, adds books to the main page if they are not contains in the database,
        /// deletes books if they don't exist on the user's device. It helps to hold actual data.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">An object that contains the event data.</param>
        private async void OnClickSearchBooksButton(object sender, EventArgs args)
        {
            IFiler filer = DependencyService.Get <IFiler>();
            IEnumerable <string> pathsOfFoundFiles = await filer.GetFilesPathsAsync(FileExtension.EPUB).ConfigureAwait(false);

            List <EpubBook> epubBooks = new List <EpubBook>();

            foreach (var path in pathsOfFoundFiles)
            {
                EpubBook book = await EpubReader.EpubReader.ReadBookAsync(path).ConfigureAwait(false);

                epubBooks.Add(book);
            }

            List <string> pathsOfExistingFiles = this.bookEntities.Select(entity => entity.FilePath).ToList();

            // Try to read not all book information.
            // I need to read only a necessary information e.g. Title, Author, Cover.
            foreach (EpubBook epubBook in epubBooks)
            {
                // If the book entity does not exist.
                // Add a new book info to the main page.
                if (pathsOfExistingFiles.Contains(epubBook.FilePath) == false)
                {
                    BookEntity bookEntity = new BookEntity
                    {
                        Id     = Guid.NewGuid().ToNonDashedString(),
                        Title  = epubBook.Title,
                        Author = epubBook.Author,
                        // It should be changed.
                        // An image might be missed.
                        Cover    = epubBook.Content.Images.FirstOrDefault().Value.Content,
                        FilePath = epubBook.FilePath
                    };

                    SettingsEntity settingsEntity = new SettingsEntity
                    {
                        BookId   = bookEntity.Id,
                        LastPage = 1,
                        FontSize = 14
                    };

                    SQLiteResult result = this.bookRepository.Add(bookEntity);
                    SQLiteResult settingsInsertResult = this.settingsRepository.Add(settingsEntity);

                    // 0 is SQLITE_OK
                    // But returns 1 and entity is successfully saved into database.
                    //if (bookInsertStatusCode == 1)
                    //{
                    this.bookEntities.Add(bookEntity);
                    BookInfoViewModel model = bookEntity.ToBookInfoModelMapper();
                    this.books.Add(model);
                    //}
                }
            }

            // Delete book info models and book entities which do not exist yet.
            foreach (var pathOfExistingFile in pathsOfExistingFiles)
            {
                if (pathsOfFoundFiles.Contains(pathOfExistingFile) == false)
                {
                    // Delete entity.
                    BookEntity deletedBookEntity = this.bookEntities.FirstOrDefault(e => e.FilePath == pathOfExistingFile);
                    this.bookRepository.DeleteById(deletedBookEntity.Id);
                    this.bookEntities.Remove(deletedBookEntity);

                    // Delete book info view model.
                    BookInfoViewModel deletedBookInfoViewModel = this.books.FirstOrDefault(m => m.FilePath == pathOfExistingFile);
                    this.books.Remove(deletedBookInfoViewModel);
                }
            }

            Xamarin.Forms.Device.BeginInvokeOnMainThread(() => this.UpdateBookLibrary(this.books));
        }
Exemplo n.º 12
0
 public void OutField(IFiler pFiler)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
 public Game(IFiler filer)
 {
     Filer = filer;
 }