aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/CustomAttributes/DBViewAttribute.cs
blob: d512ae460c20e9a607d2281163714f14bcc383b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.MachineStudio.DB.CustomAttributes
{
    /// <summary>
    /// Represents a database view attribute. This will tell the module to treat the view as a data table view.
    /// </summary>
    /// <seealso cref="System.Attribute" />
    public class DBViewAttribute : Attribute
    {
    }
}
ng.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using CefSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.PPC.Browser.Navigation;
using Tango.PPC.Browser.ViewContracts;
using Tango.PPC.Common;
using Tango.PPC.Common.Navigation;
using Tango.Touch.Keyboard;

namespace Tango.PPC.Browser.ViewModels
{
    /// <summary>
    /// Represents the main view VM and entry point for <see cref="Synchronization.MyModule"/>.
    /// </summary>
    /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
    public class BrowserViewVM : PPCViewModel<IBrowserView>, INavigationObjectReceiver<BrowserNavigationRequest>
    {
        private bool _isFromObject;

        private String _address;
        public String Address
        {
            get { return _address; }
            set { _address = value; RaisePropertyChangedAuto(); }
        }

        private bool _displayAddressBar;
        public bool DisplayAddressBar
        {
            get { return _displayAddressBar; }
            set { _displayAddressBar = value; RaisePropertyChangedAuto(); }
        }

        public RelayCommand GoCommand { get; set; }

        public BrowserViewVM()
        {
            DisplayAddressBar = true;

            GoCommand = new RelayCommand(Go);
        }

        public override void OnViewAttached()
        {
            base.OnViewAttached();
            View.AddressChanged += View_AddressChanged;
        }

        private void View_AddressChanged(object sender, string address)
        {
            Address = address;
        }

        public override void OnNavigatedTo()
        {
            base.OnNavigatedTo();

            KeyboardView.Default.OutputMode = KeyboardOutputMode.Windows;

            if (!_isFromObject)
            {
                DisplayAddressBar = true;
            }

            _isFromObject = false;
        }

        public override void OnNavigatedFrom()
        {
            base.OnNavigatedFrom();
            KeyboardView.Default.OutputMode = KeyboardOutputMode.Wpf;
        }

        public override Task<bool> OnNavigateBackRequest() 
        {
            if (View != null && View.CanGoBack())
            {
                View.GoBack();
                return Task.FromResult(false);
            }
            else
            {
                return Task.FromResult(true);
            }
        }

        /// <summary>
        /// Called when the application has been started
        /// </summary>
        public override void OnApplicationStarted()
        {

        }

        public override void OnApplicationShuttingDown()
        {
            base.OnApplicationShuttingDown();

            try
            {
                Cef.Shutdown();
            }
            catch (Exception ex)
            {
                LogManager.Log(ex, "Error shutting down cef.");
            }
        }

        private void Go()
        {
            if (View != null)
            {
                View.NavigateTo(Address);
            }
        }

        public void OnNavigatedToWithObject(BrowserNavigationRequest obj)
        {
            _isFromObject = true;

            DisplayAddressBar = obj.DisplayAddressBar;

            if (obj.Address != null)
            {
                Address = obj.Address;
                Go();
            }
        }
    }
}