Пример #1
0
        public Program()
        {
            m_fileName = null;
            m_isModified = false;

            m_procedures = new ProgramProcedureList(this, new ObservableCollection<Procedure>());
            m_isOptimized = false;

            m_libraries = LibraryList.Create();
            m_libraries.Add(Library.Standard);
        }
Пример #2
0
        public Query(CodeSentence codeSentence)
        {
            if (codeSentence == null)
            {
                throw new ArgumentNullException("codeSentence");
            }

            m_codeSentence = codeSentence;

            m_libraries = LibraryList.Create();
            m_libraries.Add(Library.Standard);
        }
Пример #3
0
 /// <summary>
 /// Adds given WBImage at given filePath to the library if it is not already in library
 /// </summary>
 /// <param name="image"></param>
 /// <param name="filePath"></param>
 private void AddImage(WBImage image)
 {
     // Give user message and don't add this image if it is already in library
     if (LibraryList.Any(checkImage => checkImage.Path.Equals(image.Path)))
     {
         _notifier.ShowInformation(string.Format("{0} was not added since it is already in the library",
                                                 Path.GetFileName(image.Path)));
     }
     // Otherwise add the image to the library
     else
     {
         LibraryList.Add(image);
     }
 }
        private void Button_addCustomJavaLibrary_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Jar Files (*.*)|*.*"
            };
            var result = openFileDialog.ShowDialog();

            if (result == true)
            {
                LibraryList.Add(openFileDialog.FileName);
            }

            LibraryList = LibraryList;
        }
        private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
        {
            LibraryList.BeginRefresh();

            if (string.IsNullOrWhiteSpace(e.NewTextValue))
            {
                LibraryList.ItemsSource = vm.Library;
            }
            else
            {
                LibraryList.ItemsSource = vm.Library.Where(i => i.Title.ToLower().Contains(e.NewTextValue.ToLower()));
            }

            LibraryList.EndRefresh();
        }
        private void Button_CustomJavaLibrary_Delete(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            string key = (string)btn.Tag;

            for (int i = 0; i < LibraryList.Count; i++)
            {
                if (LibraryList[i] == key)
                {
                    LibraryList.RemoveAt(i);
                }
            }

            LibraryList = LibraryList;
        }
Пример #7
0
        public List <Library> GetLibrarys([FromRoute] int page = 1)
        {
            var qry = _context.Librarys.OrderBy(p => p.LibraryName);

            PagingList <Library> LibraryList;

            if (page != 0)
            {
                LibraryList = PagingList.Create(qry, StringsPerPage, page);
            }
            else
            {
                LibraryList = PagingList.Create(qry, _context.Librarys.Count() + 1, 1);
            }

            return(LibraryList.ToList());
        }
Пример #8
0
        public static void AddElement(string elementName)
        {
            AndroidElement dragItem = LibraryList.FindElement(elementName);
            AndroidElement dropItem = ElementList.GetInternalElement();

            try
            {
                TouchAction action = new TouchAction(Appium.Instance.Driver);
                action.Press(dragItem).MoveTo(dropItem).Release().Perform();
                ConsoleMessage.Pass(String.Format("{0}. Add element to flow. Drag item: {1} and drop to: {2}",
                                                  ActivityName, elementName, ElementList.ElementName));
            }
            catch (Exception ex)
            {
                ConsoleMessage.Fail(String.Format("{0}. Can't add element to flow. Can't drag item: {1} and drop to: {2}",
                                                  ActivityName, elementName, ElementList.ElementName), ex);
                throw;
            }
        }
Пример #9
0
 public void FilterSelectedCollection()
 {
     LibraryList = LibraryFiler.FullLibraryList.Where(x => x.MatchesCollection(SelectedCollection)).ToList();
     LibraryList = LibraryList.Where(x => x.IsVisible && x.FileExists).ToList();
     //TODO: Handle empty collections. Display message "No matching items"?
     //Sort the library list
     //TODO: Custom sort field from collection, not gross hard-coding
     if (SelectedCollection.SortField == "LastPlayed")
     {
         LibraryList.Sort((a, b) => {
             if (a.LastPlayed == b.LastPlayed)
             {
                 return(0);
             }
             return(a.LastPlayed < b.LastPlayed ? 1 : -1);
         });
     }
     else
     {
         //Sort by title
         LibraryList.Sort((a, b) => a.CompareTitleTo(b));
     }
 }
Пример #10
0
        /// <summary>
        /// Checks for any missing images in library (i.e. image exists in library but not on disk); gives
        /// user message box notif and returns true if missing image(s) found; returns false otherwise
        /// </summary>
        /// <returns>True if missing image(s) found, false otherwise</returns>
        public bool CheckMissing()
        {
            List <string> missingImages = new List <string>();

            // Loop over each WBImage in library
            foreach (WBImage image in LibraryList.ToList())
            {
                // Check if image does not exist at WBImage's associated path (or no permissions to that file)
                if (!File.Exists(image.Path))
                {
                    // Add this image's file name to the list of missing images
                    missingImages.Add(Path.GetFileName(image.Path));

                    // Remove this WBImage from the library
                    LibraryList.Remove(image);
                }
            }

            // If missing images found, show message box explaining this to user and return true
            if (missingImages.Count > 0)
            {
                string message = "The following image files are missing and were removed from the library:\n\n";
                foreach (string filename in missingImages)
                {
                    message += filename + "\n";
                }
                message += "\nThese files may have been moved or deleted, or WallBrite may not have permission to access them. If you're sure " +
                           "the files are still where they were, try running WallBrite as administrator to make sure it has permissions to access them.";

                FlexibleMessageBox.Show(message, "Missing Files", WinForms.MessageBoxButtons.OK, WinForms.MessageBoxIcon.Warning);
                return(true);
            }

            // If no missing images found, return false
            return(false);
        }
Пример #11
0
        /// <summary>
        /// Remove given collection of controls (representing WBImages) from library; used with front-end button command
        /// </summary>
        /// <param name="collection">Collection of controls representing WBImages to be removed (object type since coming from command)</param>
        private void Remove(object collection)
        {
            // Cast the collection of controls to a collection of WBImages
            System.Collections.IList items = (System.Collections.IList)collection;
            var selectedImages             = items.Cast <WBImage>();

            // Remove each WBImage in the collection from the library list
            foreach (WBImage image in selectedImages.ToList())
            {
                LibraryList.Remove(image);
            }

            // Set empty flag if library is empty after removal
            if (LibraryList.Count < 1)
            {
                IsEmpty = true;
            }

            // Save changes to last library file
            SaveLastLibrary();

            // Update manager
            Manager.CheckAndUpdate();
        }
Пример #12
0
        private void Call(CodeFunctor codeFunctor, LibraryList libraries)
        {
            Functor functor = Functor.Create(codeFunctor);

            if (functor == Functor.CutFunctor)
            {
                InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.Cut));
            }
            else if (libraries.Contains(functor))
            {
                InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.LibraryCall, functor));
            }
            else
            {
                InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.Call, functor));
            }
        }
Пример #13
0
        public WamInstructionStream Compile(CodeSentence codeSentence, Functor functor, int index, bool isLast, LibraryList libraries, bool optimize)
        {
            Initialize();

            // When true, indicates we are compiling code for a procedure clause.  When false, indicates we
            // are compiling for an ad hoc query.
            //
            bool isClause = (functor != null);

            if (isClause)
            {
                WamInstructionStreamClauseAttribute clauseAttribute = new WamInstructionStreamClauseAttribute(
                    m_instructionStreamBuilder.NextIndex,
                    functor,
                    index);
                m_instructionStreamBuilder.AddAttribute(clauseAttribute);
            }

            if (isClause)
            {
                if (isLast)
                {
                    if (index == 0)
                    {
                        // Procedure only has one clause in it.  No retry logic required.
                    }
                    else
                    {
                        TrustMe();
                    }
                }
                else
                {
                    if (index == 0)
                    {
                        TryMeElse(functor, index + 1);
                    }
                    else
                    {
                        RetryMeElse(functor, index + 1);
                    }
                }
            }

            Allocate();

            if (codeSentence.Head != null)
            {
                for (int idx = 0; idx < codeSentence.Head.Children.Count; ++idx)
                {
                    Get(codeSentence.Head.Children[idx], GetArgumentRegister(idx));
                }
            }

            if (codeSentence.Body.Count > 0)
            {
                for (int idxProcedure = 0; idxProcedure < codeSentence.Body.Count; ++idxProcedure)
                {
                    CodeCompoundTerm codeCompoundTerm = codeSentence.Body[idxProcedure];

                    for (int idxArgument = 0; idxArgument < codeCompoundTerm.Children.Count; ++idxArgument)
                    {
                        Put(codeCompoundTerm.Children[idxArgument], GetArgumentRegister(idxArgument), libraries);
                    }

                    bool isLastCall = (idxProcedure == codeSentence.Body.Count - 1);

                    if (isClause)
                    {
                        if (isLastCall)
                        {
                            if (optimize
                                && !libraries.Contains(Functor.Create(codeCompoundTerm.Functor))
                                && codeCompoundTerm.Functor != CodeFunctor.CutFunctor)
                            {
                                Deallocate();
                                Execute(codeCompoundTerm.Functor);
                            }
                            else
                            {
                                Call(codeCompoundTerm.Functor, libraries);
                                Deallocate();
                                Proceed();
                            }
                        }
                        else
                        {
                            Call(codeCompoundTerm.Functor, libraries);
                        }
                    }
                    else // isQuery
                    {
                        Call(codeCompoundTerm.Functor, libraries);

                        if (isLastCall)
                        {
                            Success();
                        }
                    }
                }
            }
            else // fact
            {
                if (isClause)
                {
                    Deallocate();
                    Proceed();
                }
                else // isQuery
                {
                    // No action required.
                }
            }

            return InstructionStreamBuilder.ToInstructionStream();
        }
Пример #14
0
 public WamInstructionStream Compile(CodeSentence codeSentence, LibraryList libraries, bool optimize)
 {
     return Compile(codeSentence, null, -1, false, libraries, optimize);
 }
Пример #15
0
        private void Put(CodeCompoundTerm codeCompoundTerm, WamInstructionRegister targetRegister, LibraryList libraries)
        {
            WamInstructionRegister[] childrenRegisters = new WamInstructionRegister[codeCompoundTerm.Children.Count];

            // Build substructures.
            //
            for (int idx = 0; idx < codeCompoundTerm.Children.Count; ++idx)
            {
                CodeTerm child = codeCompoundTerm.Children[idx];

                if (child.IsCodeList)
                {
                    child = ConvertCodeList(child.AsCodeList);
                }

                if (child.IsCodeCompoundTerm)
                {
                    childrenRegisters[idx] = GetNextTemporaryRegister();
                    Put(child, childrenRegisters[idx], libraries);
                }
            }

            Functor functor = Functor.Create(codeCompoundTerm.Functor);

            InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.PutStructure, functor, targetRegister));
            for (int idx = 0; idx < codeCompoundTerm.Children.Count; ++idx)
            {
                CodeTerm child = codeCompoundTerm.Children[idx];

                if (child.IsCodeList)
                {
                    child = ConvertCodeList(child.AsCodeList);
                }

                if (child.IsCodeVariable)
                {
                    string variableName = child.AsCodeVariable.Name;
                    WamInstructionRegister variableRegister = GetRegisterAssignment(variableName);
                    if (variableRegister.IsUnused)
                    {
                        variableRegister = GetNextPermanentRegister(variableName);
                        InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.SetUnboundVariable, variableRegister));
                    }
                    else
                    {
                        InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.SetBoundVariable, variableRegister));
                    }
                }
                else if (child.IsCodeCompoundTerm)
                {
                    InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.SetBoundVariable, childrenRegisters[idx]));
                }
                else if (child.IsCodeValue)
                {
                    InstructionStreamBuilder.Write(new WamInstruction(WamInstructionOpCodes.SetValue, WamValue.Create(child.AsCodeValue)));
                }
                else
                {
                    throw new InvalidOperationException("Unsupported codeTerm type.");
                }
            }
        }
Пример #16
0
        private void Put(CodeTerm codeTerm, WamInstructionRegister targetRegister, LibraryList libraries)
        {
            if (codeTerm.IsCodeList)
            {
                codeTerm = ConvertCodeList(codeTerm.AsCodeList);
            }

            if (codeTerm.IsCodeVariable)
            {
                Put(codeTerm.AsCodeVariable, targetRegister);
                return;
            }

            if (codeTerm.IsCodeCompoundTerm)
            {
                Put(codeTerm.AsCodeCompoundTerm, targetRegister, libraries);
                return;
            }

            if (codeTerm.IsCodeValue)
            {
                Put(codeTerm.AsCodeValue, targetRegister);
                return;
            }

            throw new InvalidOperationException("Unsupported codeTerm type.");
        }
Пример #17
0
        protected void LoadProviders()
        {
            lock (concurrentCompositionLock)
            {
                var loader = new IndexedPluginLoader<int>("Id");
                loader.AddFromTreeMatch(@"PlugIns\MPExtended.PlugIns.MAS.*", @"Plugins\Media");
                loader.AddExport<IPluginData>(new PluginData());
                loader.AddRequiredMetadata("Id");
                loader.AddRequiredMetadata("Name");

                MovieLibraries = new LibraryList<IMovieLibrary>(loader.GetIndexedPlugins<IMovieLibrary>(), ProviderType.Movie);
                MusicLibraries = new LibraryList<IMusicLibrary>(loader.GetIndexedPlugins<IMusicLibrary>(), ProviderType.Music);
                TVShowLibraries = new LibraryList<ITVShowLibrary>(loader.GetIndexedPlugins<ITVShowLibrary>(), ProviderType.TVShow);
                PictureLibraries = new LibraryList<IPictureLibrary>(loader.GetIndexedPlugins<IPictureLibrary>(), ProviderType.Picture);
                FileSystemLibraries = new LibraryList<IFileSystemLibrary>(loader.GetIndexedPlugins<IFileSystemLibrary>(), ProviderType.Filesystem);
                PlaylistLibraries = new LibraryList<IPlaylistLibrary>(loader.GetIndexedPlugins<IPlaylistLibrary>(), ProviderType.Playlist);
            }
        }
Пример #18
0
        public MainForm()
        {
            InitializeComponent();

            BookListView.MouseDoubleClick += new MouseEventHandler(BookListView_MouseDoubleClick);
            BookListView.View              = View.Details;
            this.LibraryList = new List <Core.Library>();

            LibraryList.Add(new Core.Library(0, "Oscars Bibliotek"));

            foreach (var library in LibraryList)
            {
                LibraryDropdown.Items.Add($"{library.Id} : {library.Name}");
            }

            //var row = new string[] { "0", "Hello", "World!", "Yes" };


            this.activeLibrary = LibraryList[0];

            if (LibraryDropdown.SelectedItem != null)
            {
                foreach (var library in LibraryList)
                {
                    if (LibraryDropdown.SelectedItem.ToString() == library.Name)
                    {
                        this.activeLibrary = library;
                        break;
                    }
                }
            }
            else
            {
                LibraryDropdown.SelectedItem = LibraryDropdown.Items[0];
            }


            if (this.activeLibrary == null)
            {
                this.activeLibrary = LibraryList[0];
            }

            for (int i = 0; i < 5; i++)
            {
                this.activeLibrary.AvailibleGenreList.Add("Genre: " + i);
            }


            foreach (string Genere in this.activeLibrary.AvailibleGenreList)
            {
                this.GenreSelectionBox.Items.Add(Genere);
            }



            for (int i = 0; i < 2; i++)
            {
                this.activeLibrary.AddBook("Hello World Volume." + i, "God");
            }


            foreach (var Book in this.activeLibrary.BookList)
            {
                var row = new string[] { Book.Id.ToString(), Book.Titel, Book.Author, Book.Loaned.ToString() };

                var lvi = new ListViewItem(row);

                lvi.Tag = "Book";

                lvi.ToolTipText = "Doubble click to open or edit book!";

                BookListView.Items.Add(lvi);
            }
        }