Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
SuggestionRe: How to increase filtering speed in DataGridView? Pin
Richard MacCutchan29-May-21 22:45
mveRichard MacCutchan29-May-21 22:45 
AnswerRe: How to increase filtering speed in DataGridView? Pin
OriginalGriff30-May-21 2:07
mveOriginalGriff30-May-21 2:07 
GeneralRe: How to increase filtering speed in DataGridView? Pin
Alex Dunlop31-May-21 0:58
Alex Dunlop31-May-21 0:58 
GeneralRe: How to increase filtering speed in DataGridView? Pin
OriginalGriff31-May-21 2:14
mveOriginalGriff31-May-21 2:14 
GeneralRe: How to increase filtering speed in DataGridView? Pin
Alex Dunlop31-May-21 3:59
Alex Dunlop31-May-21 3:59 
GeneralRe: How to increase filtering speed in DataGridView? Pin
OriginalGriff31-May-21 4:43
mveOriginalGriff31-May-21 4:43 
GeneralRe: How to increase filtering speed in DataGridView? Pin
Gerry Schmitz31-May-21 7:30
mveGerry Schmitz31-May-21 7:30 
QuestionPluginLoader with GtkSharp 3.22.x Pin
Jens Eckervogt 25-May-21 23:22
Jens Eckervogt 25-May-21 23:22 
Hello everyone,

I have made nice Interface for example with NotebookPlugin like that:

C#
namespace ExampleApp.Interfaces
{
    public interface INotebookPlugin
    {
        string LabelName { get; set; }

        Gtk.Widget GetNotebook(); // If you use Subclass of Plugin's class 
    /*    Gtk.Widget Notebook { get; set; } // you use instance of Gtk.Widget in Plugin's content */

        Gtk.Window CurrentWindow { get; set; }
    }
}

I create pluginpaths with Array of string as string[] and I add PluginUtilities for different interfaces like I(name of plugin types)Plugin
C#
public static IEnumerable<INotebookPlugin> LoadNotebookPlugin(string plugin_path)
{
    string root = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"));
    string pluginLocation = Path.GetFullPath(Path.Combine(root, plugin_path.Replace('/', Path.DirectorySeparatorChar)));
    Assembly asm = Assembly.LoadFile(pluginLocation);
    int count = 0;
    foreach (Type type in asm.GetTypes())
    {
        if (typeof(INotebookPlugin).IsAssignableFrom(type))
        {
            if (Activator.CreateInstance(type) is INotebookPlugin result)
            {
                count++;
                yield return result;
            }
        }
    }

    if (count == 0)
    {
        string availableTypes = string.Join(",", asm.GetTypes().Select(t => t.FullName));
        throw new ApplicationException(
            $"Can't find any type which implements INotebookPlugin in {asm} from {asm.Location}.\n" +
            $"Available types: {availableTypes}");
    }
}

You know it is same to AppWithPlugin.
And you know to create Window with GtkSharp 3.x

I made example with Gtk.Notebook
C#
// Advanced loading notebook tabs
foreach (INotebookPlugin notebookPlugin in notebookPlugins)
{
    // Pass to current window if you have parent of window like
    // MessageDialog
    notebookPlugin.CurrentWindow = this;

    // Load plugin from sub-widget
    if (notebookPlugin.GetNotebook() != null)
        notebook.AppendPage(notebookPlugin.GetNotebook(),
            new Gtk.Label(notebookPlugin.LabelName));
}

Then you will create library for Plugin
C#
public class SimpleTab : Gtk.VBox, INotebookPlugin
{
    public SimpleTab() : base(false, 0)
    {
        Gtk.Button btn = new Gtk.Button("Open Dialog!");
        PackStart(btn, false, false, 0);
        btn.Clicked += delegate {
            Gtk.MessageDialog md = new Gtk.MessageDialog(CurrentWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.Ok, "Hello I am loading from plugin.");
            md.Run();
            md.Destroy();
        };
        ShowAll();
    }

    // What is name of Notebook's tablabel?
    public string LabelName { get; set; } = "SimpleTab";

    // Ignore it - I tell you in current MainWindow or applicatioon's window.
    public Gtk.Window CurrentWindow { get; set; }

    // Pass to current widget!
    public Gtk.Widget GetNotebook() => this;
}

Compile all then you create directory "Plugins" in Release or Debug and copy from Plugin's output dll file to Plugin directory of Application's output directory and prompt it:
dotnet run or mono Example.App.exe

Look my example application - I made with PowerHammer for Goldsrc Mapping... But It works in process. Because I have not idea before that is why I am too late to find and to resolve Plugin System like MEF, DotNetWithPlugins or other are not good because they assign to instances - But I love AppWithPlugin from Microsoft because It looks very promising for loading plugins - but I don't know before how do I load plugin with GtkSharp or WinForms ( I found here CodeProject ) But it is really catastrophically with MEF like it need instance of plugin assemblies.

That is why AppWithPlugin looks like it works close to old version of Mono / Net Frameworks 7.x

And I have success with GtkSharp 3 and Plugin System ( Loader )
If you bundle with mkbundle then It doesn't happen with Plugin assemblies if they can't load required references - It just works from bundled application with required assemblies and Plugins directory with single plugin assembly like SimpleTabNotebook.dll.

Note for Dotnet / Net Core - You shouldn't forget to package like this:
/.
./BundleExecutableOfNetCore ( Bundled by Dotnet )
./Plugins
  /SimpleTabNotebook.dll


I hope you enjoy your happy coding with C# AppWithPlugin like function or my old assembly .
Sorry for my bad English!
AnswerRe: PluginLoader with GtkSharp 3.22.x Pin
OriginalGriff25-May-21 23:40
mveOriginalGriff25-May-21 23:40 
QuestionMultidimensional Arrays error in fill IList Interface Pin
michael nabil21-May-21 7:57
michael nabil21-May-21 7:57 
AnswerRe: Multidimensional Arrays error in fill IList Interface Pin
Dave Kreskowiak21-May-21 8:12
mveDave Kreskowiak21-May-21 8:12 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
michael nabil21-May-21 9:09
michael nabil21-May-21 9:09 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
Dave Kreskowiak21-May-21 9:43
mveDave Kreskowiak21-May-21 9:43 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
michael nabil21-May-21 10:03
michael nabil21-May-21 10:03 
AnswerRe: Multidimensional Arrays error in fill IList Interface Pin
OriginalGriff21-May-21 8:21
mveOriginalGriff21-May-21 8:21 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
michael nabil21-May-21 8:35
michael nabil21-May-21 8:35 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
Richard Andrew x6421-May-21 9:06
professionalRichard Andrew x6421-May-21 9:06 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
OriginalGriff21-May-21 9:13
mveOriginalGriff21-May-21 9:13 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
Gerry Schmitz21-May-21 9:02
mveGerry Schmitz21-May-21 9:02 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
michael nabil21-May-21 9:29
michael nabil21-May-21 9:29 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
OriginalGriff21-May-21 9:56
mveOriginalGriff21-May-21 9:56 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
michael nabil21-May-21 10:05
michael nabil21-May-21 10:05 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
OriginalGriff21-May-21 10:31
mveOriginalGriff21-May-21 10:31 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
michael nabil21-May-21 10:55
michael nabil21-May-21 10:55 
GeneralRe: Multidimensional Arrays error in fill IList Interface Pin
OriginalGriff21-May-21 11:38
mveOriginalGriff21-May-21 11:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.