Track Editor: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
()
()
Line 23: Line 23:


; Connection
; Connection
:; ConnectToTrackService
:* ConnectToTrackService
:: Connect to specified track service.
:: Connect to specified track service.
::*
::* If URI is not given, endpoint info from configuration file will be used (if available).  
::* If URI is not given, endpoint info from configuration file will be used (if available).  
::: Binding type must be '''''BasicHttp'''''!
::: Binding type is assumed to be '''''BasicHttp'''''!
:; Disconnect
:* Disconnect
:: Disconnect from service
:: Disconnect from service
:; IsConnected
:* IsConnected
:: Get current connection status.
:: Get current connection status.
; Track lists
; Track lists
:; GetTrackLists
:* GetTrackLists
:: Retreive available tracklists from track service.
:: Retreive available tracklists from track service.
:; AddTrackList
:* AddTrackList
:: Create a new track list.
:: Create a new track list.
:; RemoveTrackList
:* RemoveTrackList
:: Remove track list, and all track info, if any.
:: Remove track list, and all track info, if any.
; Tracks
; Tracks
:; GetAllTracks
:* GetAllTracks
:: Retreive available tracks from a specific track list, matching the search criteria.  
:: Retreive available tracks from a specific track list, matching the search criteria.  
:; GetTrackData
:* GetTrackData
:: Retreive specified tracks from a specific track list.
:: Retreive specified tracks from a specific track list.
:; AddOrUpdateTrack
:* AddOrUpdateTrack
:: Create or update specific track.
:: Create or update specific track.
; Track history setting
; Track history setting
:; GetTrackHistoryOptions
:* GetTrackHistoryOptions
::
::
:; SetDefaultTrackHistoryOptions
:* SetDefaultTrackHistoryOptions
:: Set default track history options for new track lists.
:: Set default track history options for new track lists.
:; SetTrackHistoryOptions
:* SetTrackHistoryOptions
:: Retreive track history options for specified track list.
:: Retreive track history options for specified track list.
; Track history
; Track history
:; RemoveTrack
:* RemoveTrack
:: Remove specified track from specific track list
:: Remove specified track from specific track list
:; GetTrackHistory
:* GetTrackHistory
:: Retreive available track history information for specified track & track list, according to filter criteria.  
:: Retreive available track history information for specified track & track list, according to filter criteria.  
   
   

Revision as of 14:37, 18 October 2019

Maria track editor (WPF)

This section describes how to create a WPF application interacting with a Maria Track Service, without using MariaUserControl and track layer.

General

This page is under construction!


Note
  • For general description of track related info, see General track service information.
  • For this part you will need to include the TPG.Maria.TrackLayer NuGet package as a minimum.
  • You also need to have a Track Service available.
  • Sample code for this section is the MariaTrackEditor project, in the Sample Projects solution.

Start with creating a WPF App project!

Track service engine

The Track service engine encapsulates service interaction.

Available functions:

Connection
  • ConnectToTrackService
Connect to specified track service.
  • If URI is not given, endpoint info from configuration file will be used (if available).
Binding type is assumed to be BasicHttp!
  • Disconnect
Disconnect from service
  • IsConnected
Get current connection status.
Track lists
  • GetTrackLists
Retreive available tracklists from track service.
  • AddTrackList
Create a new track list.
  • RemoveTrackList
Remove track list, and all track info, if any.
Tracks
  • GetAllTracks
Retreive available tracks from a specific track list, matching the search criteria.
  • GetTrackData
Retreive specified tracks from a specific track list.
  • AddOrUpdateTrack
Create or update specific track.
Track history setting
  • GetTrackHistoryOptions
  • SetDefaultTrackHistoryOptions
Set default track history options for new track lists.
  • SetTrackHistoryOptions
Retreive track history options for specified track list.
Track history
  • RemoveTrack
Remove specified track from specific track list
  • GetTrackHistory
Retreive available track history information for specified track & track list, according to filter criteria.


Source code for MariaTrackServiceEngine

Track editor

Connect/disconnect

At startup, the Track Editor will try to connect to the latest track service successfully connected to. To store the last value used, add a string value, StrLastUri to the project setting.

Creating the map window component

Add the following to window xaml:

<GroupBox Header="Connection" >
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="100"/>
        </Grid.ColumnDefinitions>
        <Label Content="Service URI"/>
        <TextBox Grid.Row="0" Grid.Column="1" Margin="2"
                 Text="{Binding ConnectionUri}"/>
        <Button Grid.Row="0" Grid.Column="3" Height="22" Margin="2" 
                Content="Connect"
                Command="{Binding ConnectCmd}" />
        <Label Grid.Row="1" Grid.Column="0" Margin="2"
               Content="Status"/>
        <TextBlock Grid.Row="1" Grid.Column="1" Margin="2"
                   VerticalAlignment="Center"
                   Text="{Binding ConnectionStatus}"/>
        <Button Grid.Row="1" Grid.Column="3" Height="22" Margin="2"
                Content="Disconnect" 
                Command="{Binding DisconnectCmd}"/>
    </Grid>
</GroupBox>

Then, add the following to your view model:

. . .
public ICommand ConnectCmd { get { return new DelegateCommand(Connect, CanConnect); } }
public ICommand DisconnectCmd { get { return new DelegateCommand(Disconnect, CanDisconnect); } }
. . .
private void Connect(object obj = null)
{
    ConnectionStatus = "Connection requested ... ";

    if (_trackServiceEngine.ConnectToTrackService(ref _connectionUri))
    {
        Settings.Default.StrLastUri = ConnectionUri;
        Settings.Default.Save();

        ConnectionStatus = "Connected!";
    }
    else 
    {
        ConnectionStatus = "Not connected, connection failed! ";

        if (string.IsNullOrWhiteSpace(ConnectionUri))
        {
            ConnectionStatus += "\nSupply URI - or correct 'system.serviceModel' configuration!";
        }
    }

    RefreshConnectionInfo();
}

private bool CanConnect(object obj)
{
    return !_trackServiceEngine.IsConnected();
}

private void Disconnect(object obj)
{
    _trackServiceEngine.Disconnect();

    ConnectionStatus = "Disconnected!";
}

private bool CanDisconnect(object obj)
{
    return  _trackServiceEngine.IsConnected(); 
}
. . .
public string ConnectionUri {
    get { return _connectionUri; }
    set
    {
        _connectionUri = value;
        NotifyPropertyChanged(() => ConnectionUri);
    }
}

public string ConnectionStatus
{
    get { return _connectionStatus; }
    set
    {
        _connectionStatus = value;
        NotifyPropertyChanged(() => ConnectionStatus);
    }
}      
. . .
internal void RefreshConnectionInfo()
{
    NotifyPropertyChanged(() => ConnectionStatus);
    NotifyPropertyChanged(() => ConnectionUri);
}
. . .

Track list management

Track info management

Track history

Track history settings

Track history info