public void Initialize(ArgumentCollection args)
        {
            bool restorePlugin = false;

            if (args != null)
            {
                if (args.Contains(ArgumentCollection.ArgumentType.Plugin))
                {
                    this.Plugin = args.Get <IPlugin>(ArgumentCollection.ArgumentType.Plugin);
                }
                if (args.Contains(ArgumentCollection.ArgumentType.PluginArgs))
                {
                    this.pluginInitArgs = args.Get <ArgumentCollection>(ArgumentCollection.ArgumentType.PluginArgs);
                }
                if (args.Contains(ArgumentCollection.ArgumentType.RestorePlugin))
                {
                    restorePlugin = args.Get <bool>(ArgumentCollection.ArgumentType.RestorePlugin);
                }
            }
            this.Size = Consts.NormalTileSize;
            if (this.Plugin == null)
            {
                this.InitializePluginCommand = new Command((object parameter) => { });
            }
            else
            {
                this.InitializePluginCommand = new Command((object parameter) =>
                {
                    if (!(this.Plugin?.IsPluginInitialized() ?? false))
                    {
                        this.Plugin?.InitializePlugin(this.pluginInitArgs);
                    }
                    this.Plugin?.GetPluginWindow()?.Show();
                });
            }
            if (restorePlugin)
            {
                this.InitializePluginCommand.Execute(null);
            }
        }
Пример #2
0
        public void Initialize(ArgumentCollection args)
        {
            if (args == null || args.Length == 0)
            {
                throw new Exception("Parameters cannot be empty");
            }
            if (!args.Contains(ArgumentCollection.ArgumentType.Downloader) && !(args.Get(ArgumentCollection.ArgumentType.Downloader) is IDownloader))
            {
                throw new Exception("First parametr needs to implement IDownloader interface");
            }
            this.downloader = args.Get(ArgumentCollection.ArgumentType.Downloader) as IDownloader;

            this.FindMediaButtonCommand = new Command((object parameter) => { LoadMediaInfoAsync(parameter?.ToString()); }, param => FindMediaIsEnabled);
            this.CancelButtonCommand    = new Command((object parameter) => { CancelDownload(); });
            this.SetDownloaderEvents();
        }
Пример #3
0
        public void Initialize(ArgumentCollection args)
        {
            double?windowWidth  = null;
            double?windowHeight = null;

            if (args != null)
            {
                if (args.Contains(ArgumentCollection.ArgumentType.WindowTitle))
                {
                    this.WindowTitle = args.Get(ArgumentCollection.ArgumentType.WindowTitle)?.ToString();
                }
                if (args.Contains(ArgumentCollection.ArgumentType.WindowIcon))
                {
                    this.WindowIcon = WPFUtils.ToBitmapImage(args.Get(ArgumentCollection.ArgumentType.WindowIcon));
                }
                if (args.Contains(ArgumentCollection.ArgumentType.WindowCloseCommand))
                {
                    this.CloseButtonCommand = args.Get <Command>(ArgumentCollection.ArgumentType.WindowCloseCommand);
                }
                if (args.Contains(ArgumentCollection.ArgumentType.WindowTitle))
                {
                    this.WindowTitle = args.Get <string>(ArgumentCollection.ArgumentType.WindowTitle);
                }

                this.windowState = null;

                if (args.Contains(ArgumentCollection.ArgumentType.PluginState))
                {
                    windowState = args.Get <PluginState>(ArgumentCollection.ArgumentType.PluginState)?.WindowState;
                }
                if (args.Contains(ArgumentCollection.ArgumentType.WindowState))
                {
                    windowState = args.Get <Common.WindowState>(ArgumentCollection.ArgumentType.WindowState);
                }

                windowWidth  = windowState?.Width;
                windowHeight = windowState?.Height;

                if (args.Contains(ArgumentCollection.ArgumentType.WindowWidth) && !windowWidth.HasValue)
                {
                    windowWidth = args.Get <double>(ArgumentCollection.ArgumentType.WindowWidth);
                }
                if (args.Contains(ArgumentCollection.ArgumentType.WindowHeight) && !windowHeight.HasValue)
                {
                    windowHeight = args.Get <double>(ArgumentCollection.ArgumentType.WindowHeight);
                }

                double?windowTop     = windowState?.PositionTop;
                double?windowLeft    = windowState?.PositionLeft;
                bool?  windowTopMost = windowState?.TopMost;

                if (windowTop.HasValue)
                {
                    this.WindowTop = windowTop.Value;
                }
                if (windowLeft.HasValue)
                {
                    this.WindowLeft = windowLeft.Value;
                }
                if (windowTopMost.HasValue)
                {
                    this.WindowTopMost = windowTopMost.Value;
                }
            }
            if (!windowWidth.HasValue)
            {
                windowWidth = 800;
            }
            if (!windowHeight.HasValue)
            {
                windowHeight = 600;
            }

            this.WindowWidth  = windowWidth.Value;
            this.WindowHeight = windowHeight.Value;

            if (String.IsNullOrWhiteSpace(this.WindowTitle) && !args.Contains(ArgumentCollection.ArgumentType.WindowTitle))
            {
                this.WindowTitle = "Base Window";
            }

            this.TopMostButtonCommand       = new Command((object parameter) => { this.TopMostToogle(parameter); });
            this.CloseButtonCommandOverride = new Command((object parameter) => { this.Close(); });
        }