SG Code - Design
  • Home
  • Impressum
.NET Projekte
  • AndroidCtrl.dll
  • AndroidCtrlUI.dll
  1. Aktuelle Seite:  
  2. Home
  3. Deutsch (DE)
  4. AndroidCtrlUI.dll
  5. How - To
Here i'll show you how to implement the Drag & Drop in your program code.
// Top of ur .cs file
...
using AndroidCtrl;
using AndroidCtrlUI.Explorer;
using AndroidCtrlUI.Explorer.Actions.Windows;
...


// OnDrop handler
public void OnDrop(object sender, DragEventArgs e)
{
    // Drop destination path
    string dest = "C:\\";

    // Here we check if the drop element includes a DataObject
    if (e.Data is DataObject d && d.ContainsFileDropList())
    {
        // Extract the sender
        string s = d.GetText(TextDataFormat.Text);

        // Check if the sender is the android viewmodel.
        if (s == "android" && d.GetDataPresent(typeof(DeviceInfo)))
        {
            // Now init the copy process
            Copy copy = new Copy(this, (DeviceInfo)d.GetData(typeof(DeviceInfo)), s, "local", dest, d.GetFileDropList(), e.Effects == DragDropEffects.Move);

            // (optional) Here you can define a callback which is raised if the copy window is closed.
            copy.Closed += DropCallback;

            // Show the copy window
            copy.Show();
        }

        // If the sender isn't the android viewmodel, your OnDrop code will be executed.
        else
        {
             // Your OnDrop code goes here.
        }
    }
    e.Handled = true;
}

// (optional) Callback after the window is closed.
private void DropCallback(object sender, EventArgs e)
{
    // Do a refresh or something.
}
Here i show you how you can implement the Explorer Part of this dll in your Project. This example is based on an xaml Page.

Remote-Explorer
<Page x:Class="MyApp.MyPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:view="clr-namespace:AndroidCtrlUI.Explorer;assembly=AndroidCtrlUI"
      xmlns:viewPart="clr-namespace:AndroidCtrlUI.Explorer.Views;assembly=AndroidCtrlUI"
      xmlns:sharedPart="clr-namespace:SharedUI.Explorer.Shares.Views;assembly=SharedUI">
      
      
      <!-- Now u can use the following ready-to-go models: -->
      
      ...
      <view:MultiExplorerView DataContext="{Binding ExplorerMR}"/>
      ...
      <sharedPart:AddressBar DataContext="{Binding ExplorerR.AddressBar}"/>
      <sharedPart:AddressBarCompact DataContext="{Binding ExplorerR.AddressBar}"/>
      <sharedPart:AddressBarExtended DataContext="{Binding ExplorerR.AddressBar}"/>
      
      <viewPart:ExplorerView DataContext="{Binding ExplorerR}"/>
      
      <sharedPart:InfoBar DataContext="{Binding ExplorerR.InfoBar}"/>
      <viewPart:ListView DataContext="{Binding ExplorerR.ListView}"/>
      <viewPart:TreeView DataContext="{Binding ExplorerR.TreeView}"/>
      ...
</Page>
Local-Explorer
<Page x:Class="MyApp.MyPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:view="clr-namespace:SharedUI.Explorer.Local;assembly=SharedUI"
      xmlns:viewPart="clr-namespace:SharedUI.Explorer.Local.Views;assembly=SharedUI"
      xmlns:sharedPart="clr-namespace:SharedUI.Explorer.Shares.Views;assembly=SharedUI">
      
      
      <!-- Now u can use the following ready-to-go models: -->
      
      ...
      <sharedPart:AddressBar DataContext="{Binding ExplorerL.AddressBar}"/>
      <sharedPart:AddressBarCompact DataContext="{Binding ExplorerL.AddressBar}"/>
      <sharedPart:AddressBarExtended DataContext="{Binding ExplorerL.AddressBar}"/>
      
      <view:ExplorerView DataContext="{Binding ExplorerL}"/>
      
      <sharedPart:InfoBar DataContext="{Binding ExplorerL.InfoBar}"/>
      <viewPart:ListView DataContext="{Binding ExplorerL.ListView}"/>
      <viewPart:TreeView DataContext="{Binding ExplorerL.TreeView}"/>
      ...
</Page>
After u have placed these elements u can compile ur project and test it.
(U need also to add the ViewModel to ur .cs as described in Getting Started.)

That's all for the moment.
If u want to include AndroidCtrlUI.dll in ur current or new .NET project, you have to do the following steps.
  • Open for example VisualStudio and ur project
  • Go to References
  • Add the AndroidCtrlUI.dll
  • Add the SharedUI.dll
  • (Optional) place the AndroidCtrlUI.xml and SharedUI.xml beside both dlls.(This will give you the markup in VisualStudio)

And in your code you have to assign the namespaces like:
// Top of ur .cs file
...
using UIREM=AndroidCtrlUI.Explorer;
using UILOC=SharedUI.Explorer.Local;
using AndroidCtrlUI.Tools;
...
To access the ExplorerModel you must act like the following example.
// Here we load the needed language strings

// This is the AutoLoad() method, it will check the current UI language and try
// to load the given language if it exists. If not, it will load the english language.
Language.AutoLoad();

// This is the Set() method, it will load the given language as default if it exists.
// If not, it will load the english language.
// Currently, you can use the following keys "en-EN" and "de-DE".
// This method check only the 1st and 2cnd char, so if your key look for example like "en-GB"
// or "de-AT" it will load the english (en-EN) or german (de-DE) language file.
Language.Set(string langkey);


// Here we create a Remote-Explorer view (for single element placement)
UIREM.Models.ExplorerModel ExplorerR = new UIREM.Models.ExplorerModel();
//or
UIREM.Models.ExplorerModel ExplorerR = new UIREM.Models.ExplorerModel(IDeviceInfo device);
//or
UIREM.Models.ExplorerModel ExplorerR = new UIREM.Models.ExplorerModel(bool actOnDllSelection, IDeviceInfo device = null);
//or
UIREM.Models.ExplorerModel ExplorerR = new UIREM.Models.ExplorerModel(bool actOnDllSelection, bool useMediaScanner, IDeviceInfo device = null);


// Here we create the Remote-Multi-Explorer view
UIREM.MultiExplorerModel ExplorerMR = new UIREM.MultiExplorerModel();
//or
UIREM.MultiExplorerModel ExplorerMR = new UIREM.MultiExplorerModel(bool useDllSelection, bool useMediaScanner);


// Here we create the Local-Explorer view
UILOC.ExplorerModel ExplorerL = new UILOC.ExplorerModel();
Now pls have a look on the navigation on the left side and choose ur XAML implementation way.

That's all for the moment.