SG Code - Design
  • Home
  • Impressum
.NET Projects
  • AndroidCtrl.dll
  • AndroidCtrlUI.dll
  1. You are here:  
  2. Home
  3. English (UK)
  4. AndroidCtrlUI.dll
  5. How - To
Here i show u how to use the Logging.Logger class
// Top of ur .cs file
using AndroidCtrl.Logging;

// Activate the logger
Logger.Instance.Active = true;

// Here u can tell the log writer that it has to write each new log directly to the log-file
Logger.Instance.WriteParts = true;

// Log-file path (by default the file will be generated beside the dll)
Logger.Instance.Path = "C:\\myLogFile.txt";

// Here are the events u can subscribe to, to get the logs in ur progam-code
Logger.Instance.CallbackDebug += CallbackLogger;
Logger.Instance.CallbackError += CallbackLogger;
Logger.Instance.CallbackInfo += CallbackLogger;
Logger.Instance.CallbackOutput += CallbackLogger;
Logger.Instance.CallbackWarning += CallbackLogger;

// This is the callback for all events
public void CallbackLogger(object sender, LoggerArgs e)
{
     App.Current.Dispatcher.Invoke((Action)delegate
     {
          // Do what u want with the log-data "e.Log"
     });
}


// Define the log-level (that is a bit tricky but i'll explain)
Logger.Instance.SetLogLevel(IDLog.DEBUG);

// In the above example we "only" define the level "Debug", this will log all events!
// U can also define the log levels like the following examples...

// All events and all outputs
Logger.Instance.SetLogLevel(IDLog.DEBUG, IDLog.OUTPUT);

// This will do the same as the above example
Logger.Instance.SetLogLevel(IDLog.ERROR, IDLog.INFO, IDLog.OUTPUT, IDLog.WARNING);
Simply, u can define a "special" part u want to log, with-/out output or everything that happens. Here is a short explain about the log-levels.

  • DEBUG = Logs everything that happens
  • ERROR = Log all errors and *hopefully* all exceptions (caused by my dll)
  • INFO = Log all calls and sub-call (currently "only" the ProcessModels namespace got he log-writer)
  • OUTPUT = Log all outputs
  • WARNING = Log all warnings
Here i'll show you how to implement the Drag & Drop in your program code.
// Top us 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.