Пример #1
0
 public void InitializePlugin(ArgumentCollection args)
 {
     this.args         = args ?? new ArgumentCollection();
     this.isPluginMode = this.args.Get <bool>(ArgumentCollection.ArgumentType.IsPluginMode);
     this.Initialize();
     this.isInitialized = true;
 }
 public void Initialize(ArgumentCollection args)
 {
     if (args != null)
     {
     }
     this.AvailablePlugins = this.GetAvailablePlugins();
     this.Title            = Consts.WindowTitle;
 }
 public void Set(ArgumentCollection args)
 {
     if (args != null)
     {
         foreach (ArgumentType key in args.Keys)
         {
             this.Set(key, args.Get(key));
         }
     }
 }
        private List <PluginViewModel> GetAvailablePlugins()
        {
            List <PluginViewModel> result = new List <PluginViewModel>();

            try
            {
                IViewModelFactory factory      = new ViewModelFactory();
                PluginState[]     pluginStates = null;

                pluginStates = UserSettings.LoadSetting <PluginState[]>(UserSettings.SettingType.PluginState);

                result = pluginManager.GetPlugins()?.Select(p =>
                {
                    ArgumentCollection viewModelArgs  = new ArgumentCollection();
                    ArgumentCollection pluginInitArgs = new ArgumentCollection();

                    pluginInitArgs.Set(ArgumentCollection.ArgumentType.IsPluginMode, true);

                    if (pluginStates != null)
                    {
                        PluginState pluginState = pluginStates.FirstOrDefault(ps => String.Equals(ps.Name, p.GetPluginName()));
                        if (pluginState == null)
                        {
                            pluginState = new PluginState(p.GetPluginName(), false)
                            {
                                WindowState = p.GetDefaultWindowState()
                            }
                        }
                        ;
                        if (pluginState.WindowState == null)
                        {
                            pluginState.WindowState = p.GetDefaultWindowState();
                        }

                        pluginInitArgs.Set(ArgumentCollection.ArgumentType.PluginState, pluginState);
                        viewModelArgs.Set(ArgumentCollection.ArgumentType.RestorePlugin, pluginState.IsActive);
                    }

                    viewModelArgs.Set(ArgumentCollection.ArgumentType.Plugin, p);
                    viewModelArgs.Set(ArgumentCollection.ArgumentType.PluginArgs, pluginInitArgs);

                    PluginViewModel pluginViewModel = factory.CreateViewModel <PluginViewModel>(viewModelArgs);
                    return(pluginViewModel);
                }).ToList() ?? new List <PluginViewModel>();
            }
            catch (Exception ex)
            {
                Logger.Log(EventID.DesktopDashboard.Application.Exception, nameof(GetAvailablePlugins), ex);
            }
            finally
            {
                Logger.Log(EventID.DesktopDashboard.Application.FoundedAvailablePlugins, result.Count, String.Join(",", result.Select(p => p.Name)));
            }
            return(result);
        }
 public void Initialize(ArgumentCollection args)
 {
     this.DriveInfo = args.Get <System.IO.DriveInfo>(ArgumentCollection.ArgumentType.DriveInfo);
     if (this.DriveInfo == null)
     {
         throw new ArgumentException($"{nameof(this.DriveInfo)} cannot be null");
     }
     this.PartitionName  = String.Format("{0} ({1})", String.IsNullOrEmpty(this.DriveInfo.VolumeLabel) ? "Disc" : this.DriveInfo.VolumeLabel, this.DriveInfo.Name);
     this.TotalSize      = GetTotalSize();
     this.ScaleBarSize   = 25;
     this.ScaleBarHeight = (double)this.ScaleBarSize * 1.5;
 }
Пример #6
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();
        }
Пример #7
0
        public void InitializePlugin(ArgumentCollection args)
        {
            //if (this.domain == null)
            //{
            //    string appDirectory = System.IO.Path.GetDirectoryName(this.Path);
            //    //PermissionSet permSet = new PermissionSet(PermissionState.None);
            //    //permSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
            //    this.domain = AppDomain.CreateDomain(this.GetPluginName(), null, new AppDomainSetup() { ApplicationBase = appDirectory });

            //}
            //domain.ExecuteAssembly(this.Path);


            this.args = args ?? new ArgumentCollection();
            this.args.Set(ArgumentCollection.ArgumentType.IsPluginMode, true);
            this.instance?.InitializePlugin(args);
        }
        private void Initialize(ArgumentCollection args)
        {
            try
            {
                if (args == null)
                {
                    args = new ArgumentCollection();
                }

                ViewModelFactory factory = new ViewModelFactory();
                this.viewModel   = factory.CreateViewModel <DesktopDashboardViewModel>(args);
                this.DataContext = viewModel;
            }
            catch (Exception ex)
            {
                Logger.Log(EventID.Application.Exception, ex);
            }
        }
        public void Initialize(ArgumentCollection args)
        {
            if (this.Controls == null)
            {
                this.Controls = new List <IDashboardControl>();
            }

            this.Controls.Add(new ucCpuInfo());
            this.Controls.Add(new ucRamInfo());

            #region PartitionInfo

            List <System.IO.DriveInfo> partitionInfo = new List <System.IO.DriveInfo>();
            try
            {
                System.IO.DriveInfo[] allDrives = System.IO.DriveInfo.GetDrives();
                if (allDrives != null && allDrives.Length > 0)
                {
                    partitionInfo = allDrives.Where(d => d.DriveType == System.IO.DriveType.Fixed).ToList();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(EventID.DIComputerPerformance.Application.Exception, "LoadingPartitionInfo", ex);
            }

            if (partitionInfo.Count > 0)
            {
                foreach (System.IO.DriveInfo diItem in partitionInfo)
                {
                    ArgumentCollection patitionInfoArgs = new ArgumentCollection();
                    patitionInfoArgs.Set(ArgumentCollection.ArgumentType.DriveInfo, diItem);
                    this.Controls.Add(new ucPartitionInfo(patitionInfoArgs));
                }
            }

            #endregion
            this.dashboardUpdateTaskCancellationTokenSource = new CancellationTokenSource();
            dashboardUpdateTask = new Task(() => DashboardUpdater(this.dashboardUpdateTaskCancellationTokenSource.Token), this.dashboardUpdateTaskCancellationTokenSource.Token, TaskCreationOptions.LongRunning);
            dashboardUpdateTask.Start();
        }
Пример #10
0
 public void Initialize(ArgumentCollection args)
 {
     try
     {
         Task.Factory.StartNew(() =>
         {
             if (System.Diagnostics.PerformanceCounterCategory.CounterExists("% Processor Time", "Processor"))
             {
                 this.cpuTotalCntr = new System.Diagnostics.PerformanceCounter("Processor", "% Processor Time", "_Total", true);
             }
             else
             {
                 this.cpuTotalCntr = new System.Diagnostics.PerformanceCounter("Processor Information", "% Processor Time", "_Total", true);
             }
         });
     }
     catch (Exception ex)
     {
         Logger.Log(EventID.DIComputerPerformance.Application.Exception, "InitializingCpuInfoViewModel", ex);
     }
 }
Пример #11
0
        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);
            }
        }
Пример #12
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(); });
        }
 public void Initialize(ArgumentCollection args)
 {
 }