示例#1
0
 /// <summary>
 /// Gets a resource string from the ResourceManager
 ///
 /// You can bind to this property using the .[KEY] syntax e.g.:
 ///
 /// {Binding Source={StaticResource localisation}, Path=.[MainScreenResources.IntroTextLine1]}
 /// </summary>
 /// <param name="key">Key to retrieve in the format [ManagerName].[ResourceKey]</param>
 /// <returns></returns>
 public string this[string key]
 {
     get
     {
         if (key is null)
         {
             throw new ArgumentNullException(nameof(key));
         }
         bool isValidKey = ValidKey(key);
         if (!isValidKey && String.IsNullOrEmpty(DefaultManager))
         {
             throw new ArgumentException("Key cannot be empty, and must be in the valid [ManagerName].[ResourceKey] format. Key = \"" + key + "\"");
         }
         if (DesignHelpers.IsInDesignModeStatic)
         {
             return(key); //throw new Exception("Design mode is not supported.");
         }
         if (isValidKey)
         {
             return(ResourceManagerService.GetResourceString(GetManagerKey(key), GetResourceKey(key)));
         }
         else
         {
             return(ResourceManagerService.GetResourceString(DefaultManager, key));
         }
     }
 }
示例#2
0
 public AboutTheProgramViewModel(UserControl headerControl)
 {
     _headerControl       = headerControl;
     TestCommand          = new DelegateCommand(o => TestSwatches());
     TestButtonVisibility = Settings.Same().ButtonTestVisibility; // ТЕСТОВАЯ КНОПКА
     ResourceManagerService.RegisterManager("AboutTheProgramRes", AboutTheProgramRes.ResourceManager, true);
 }
示例#3
0
        /// <summary>
        /// Initialize a new instance of the <see cref="MainWindowViewModel"/> class
        /// </summary>
        public MainWindowViewModel()
        {
            _model               = new Model.Model(new GameController());
            BeginGameEvent      += BeginGame;
            GenerateFleetCommand = new DelegateCommand(GenerateFleet);
            StartCommand         = new DelegateCommand(Start);
            OkCommand            = new DelegateCommand(Ok);
            InformationCommand   = new DelegateCommand(Information);
            ExitCommand          = new DelegateCommand(Exit);
            TopPlayersCommand    = new DelegateCommand(TopPlayersView);
            GreetingCommand      = new DelegateCommand(Greeting);
            MouseDownCommand     = new DelegateCommand(OnMouseDown);
            UpdateCommand        = new DelegateCommand(Update);
            RussianCommand       = new DelegateCommand(Russian);
            EnglishCommand       = new DelegateCommand(English);
            ShipAmountLeft       = Field.ShipsCount + " ";
            ShipAmountRight      = Field.ShipsCount + " ";
            ShotAmountLeft       = Field.Size * Field.Size + " ";
            ShotAmountRight      = Field.Size * Field.Size + " ";
            ResourceManagerService.RegisterManager("MainWindowRes", MainWindowRes.ResourceManager, true);

            BeforeGame();
            TopPlayersCollection = _model.Players.GetTopTen();
            _model.Game.RandomArrangement(_model.Game.LeftField);
            _model.Game.LeftField.DisplayCompletionCell();
            SetLeftFieldCells();
        }
示例#4
0
 /// <summary>
 /// Initialize a new instance of the <see cref="GreetingViewModel"/> class
 /// </summary>
 public GreetingViewModel()
 {
     CloseCommand   = new DelegateCommand(Close);
     RussianCommand = new DelegateCommand(Russian);
     EnglishCommand = new DelegateCommand(English);
     ResourceManagerService.RegisterManager("MainWindowRes", MainWindowRes.ResourceManager, true);
 }
示例#5
0
        public static async Task Run(TimerInfo myTimer, CloudTable configTbl, CloudTable statsTbl, CloudTable invalidTypesTbl, ICollector <string> outQueue, TraceWriter log)
        {
            _log      = log;
            _outQueue = outQueue;
            log.Info("Starding subscription audit.");
            var invalidTagResourcesQuery = await invalidTypesTbl.ExecuteQuerySegmentedAsync(new TableQuery <InvalidTagResource>(), null);

            var auditConfigQuery = await configTbl.ExecuteQuerySegmentedAsync(new TableQuery <AuditConfig>(), null);

            // Init config table if new deployment
            if (auditConfigQuery.Results.Count == 0)
            {
                AuditConfig initConfig = new AuditConfig {
                    SubscriptionId = "enter_valid_subscription_id", RowKey = Guid.NewGuid().ToString(), RequiredTags = "comma,separated,tag,list,here", PartitionKey = "init"
                };
                TableOperation insertOperation = TableOperation.InsertOrReplace(initConfig);
                await configTbl.ExecuteAsync(insertOperation);

                log.Info("First run for new deployment. Please populate the AuditConfig table.");
                return;
            }

            foreach (var auditConfig in auditConfigQuery.Results)
            {
                try
                {
                    AuditStats stats = new AuditStats {
                        JobStart = DateTime.Now, PartitionKey = auditConfig.SubscriptionId, RowKey = Guid.NewGuid().ToString()
                    };
                    IEnumerable <string> requiredTagsList = auditConfig.RequiredTags.Split(',');

                    try
                    {
                        string token = await AuthenticationService.GetAccessTokenAsync();

                        _resourceManager = new ResourceManagerService(token);
                    }
                    catch (Exception ex)
                    {
                        log.Error("Unable to connect to the ARM API, Message: " + ex.Message);
                    }

                    await ProcessResourceGroups(requiredTagsList, invalidTagResourcesQuery.Results, auditConfig.SubscriptionId, stats);

                    log.Info("Completed audit of subscription: " + auditConfig.SubscriptionId);
                    stats.JobEnd = DateTime.Now;

                    TableOperation insertOperation = TableOperation.InsertOrReplace(stats);
                    await statsTbl.ExecuteAsync(insertOperation);
                }
                catch (Exception ex)
                {
                    log.Error("Failure processing resource groups for auditConfig: " + auditConfig.RowKey);
                    log.Error(ex.Message);
                }
            }
        }
示例#6
0
        public static async Task Run(string myQueueItem, CloudTable invalidResourceTable, TraceWriter log)
        {
            log.Info($"C# Queue trigger function triggered: {myQueueItem}");

            ResourceItem           updateItem      = JsonConvert.DeserializeObject <ResourceItem>(myQueueItem);
            ResourceManagerService resourceManager = null;

            try
            {
                string token = await AuthenticationService.GetAccessTokenAsync();

                resourceManager = new ResourceManagerService(token);
            }
            catch (Exception ex)
            {
                log.Error("Unable to connect to the ARM API, Message: " + ex.Message);
            }

            try
            {
                await resourceManager.UpdateResource(updateItem);
            }
            catch (Exception ex)
            {
                log.Error(updateItem.Id + " failed with: " + ex.Message);

                InvalidTagResource matchingInvalidResource = null;
                var invalidTagResourcesQuery = await invalidResourceTable.ExecuteQuerySegmentedAsync(new TableQuery <InvalidTagResource>(), null);

                if (invalidTagResourcesQuery.Results != null)
                {
                    matchingInvalidResource = invalidTagResourcesQuery.Results.Where(x => x.Type == updateItem.Type).FirstOrDefault();
                }

                if (matchingInvalidResource == null)
                {
                    InvalidTagResource invalidItem = new InvalidTagResource
                    {
                        Type         = updateItem.Type,
                        Message      = ex.Message,
                        RowKey       = Guid.NewGuid().ToString(),
                        PartitionKey = updateItem.Subscription
                    };

                    TableOperation insertOperation = TableOperation.InsertOrReplace(invalidItem);
                    await invalidResourceTable.ExecuteAsync(insertOperation);
                }
            }
        }
        /// <summary>
        /// Change localization
        /// </summary>
        /// <param name="regionName">Style name</param>
        private void ChangeLocalization(string regionName)
        {
            switch (regionName)
            {
            case "Русский":
                ResourceManagerService.ChangeLocale("ru-Ru");
                break;

            case "English":
                ResourceManagerService.ChangeLocale("en-US");
                break;

            default:
                ResourceManagerService.ChangeLocale("en-US");
                break;
            }
        }
示例#8
0
        public static async Task Run([QueueTrigger("resources-to-tag", Connection = "AzureWebJobsStorage")] string myQueueItem,
                                     [Table("ResourceTypes")] CloudTable resourceTypesTable,
                                     TraceWriter log
                                     )
        {
            log.Info($"C# Queue trigger function processed: {myQueueItem}");
            ResourceItem           updateItem      = JsonConvert.DeserializeObject <ResourceItem>(myQueueItem);
            ResourceManagerService resourceManager = null;

            try
            {
                string token = AuthenticationService.GetAccessTokenAsync();
                resourceManager = new ResourceManagerService(token);
            }
            catch (Exception ex)
            {
                log.Error("Unable to connect to the ARM API, Message: " + ex.Message);
            }

            try
            {
                await resourceManager.UpdateResource(updateItem);
            }
            catch (Exception ex)
            {
                log.Error(updateItem.Id + " failed with: " + ex.Message);

                var resourceItemsQuery = await resourceTypesTable.ExecuteQuerySegmentedAsync(new TableQuery <ResourceType>(), null);

                var resourceType = resourceItemsQuery.Results.Where(x => x.Type == updateItem.Type).FirstOrDefault();

                if (resourceType != null)
                {
                    resourceType.ErrorMessage = ex.Message;
                    TableOperation insertOperation = TableOperation.InsertOrReplace(resourceType);
                    await resourceTypesTable.ExecuteAsync(insertOperation);
                }
            }
        }
示例#9
0
        public App() : base()
        {
            // Регистрируем ресурсы локализации
            ResourceManagerService.RegisterManager("MainWindowRes", MainWindowRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("MessageConfirmRes", MessageConfirmRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ImagesRes", ImagesRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ContentFoldersRes", ContentFoldersRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ContentCatalogRes", ContentCatalogRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ContentCatalogItemsRes", ContentCatalogItemsRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ContentImageTypesRes", ContentImageTypesRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ContentVideoTypesRes", ContentVideoTypesRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ContentCommentsRes", ContentCommentsRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("SettingOptionsRes", SettingOptionsRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("ColorsRes", ColorsRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("TicTacToeRes", TicTacToeRes.ResourceManager, false);
            ResourceManagerService.RegisterManager("DMLRes", DMLRes.ResourceManager, false);

            // Current status
            Settings.Same().AppStatus = TaskStatus.Running;

            this.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(App_DispatcherUnhandledException);
        }
示例#10
0
        private void EndGame()
        {
            _isPlaying = false;
            IsEnabled  = false;
            _model.Game.RightPlayer.TransferMove -= _model.Game.Transfer_Move;
            _model.Game.LeftPlayer.TransferMove  -= _model.Game.Transfer_Move;
            UnsubscriptionOponentField();
            _model.Game.LeftPlayer.OponentChanged -= Oponent_Changed;
            _model.Game.GameOver(_model.Game.LeftStatistics, _model.Game.RightStatistics);
            AddOrEditPlayer();
            SetLeftFieldCells();
            foreach (var child in Grid.Children)
            {
                UpdateCommand.Execute(child);
            }

            MessageBox.Show(_model.Game.CountWin != 0
                ? ResourceManagerService.GetResourceString("MainWindowRes", "Winner_message")
                : ResourceManagerService.GetResourceString("MainWindowRes", "Loser_message"));



            IsEndButton = true;
            _model.Game.ResetStatistics(_model.Game.RightStatistics);
            _model.Game.ResetStatistics(_model.Game.LeftStatistics);

            ShipAmountLeft  = _model.Game.RightStatistics.CountShips + " ";
            ShotAmountLeft  = _model.Game.RightStatistics.CountLeftShot + " ";
            ShipAmountRight = _model.Game.LeftStatistics.CountShips + " ";
            ShotAmountRight = _model.Game.LeftStatistics.CountLeftShot + " ";

            ResetRightField();
            foreach (var child in GridR.Children)
            {
                UpdateCommand.Execute(child);
            }
        }
示例#11
0
        public AdminView()
        {
            InitializeComponent();
            this.DataContext = new MainScreenViewModel();
            // set handles and initialize databinding
            Logger.Instance.ViewHandle = this;
            m_Instance = this;

            // Instantiate settings
            ResourceManagerService.ChangeLocale(SettingsManager.Instance.Settings.Language);

            Closing     += AdminView_Closing;
            this.Loaded += new RoutedEventHandler(OnLoaded);
            CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);

            //Refresh Workflow UI if Workingstep gets changed automatically
            WorkflowManager.WorkingstepChanged += AdminView.Instance.refreshWorkflowUI;

            DebugInformationManager.Instance.start();

            //KinectManager.Instance.allFramesReady += new KinectManager.AllFramesReadyHandler(Instance_allFramesReady);
            CameraManager.Instance.OnAllFramesReady += Instance_allFramesReady;
            USBCameraDetector.UpdateConnectedUSBCameras();
        }
示例#12
0
 public MainWindowViewModel()
 {
     try {
         // Позиционирование
         InitLocation();
         // Настройка событий
         _window.Activated       += (o, e) => PositionSave(o, e);
         _window.Closing         += (o, e) => Closing(_window, e);
         _window.ContentRendered += (o, e) => SetUpAppSettings(_window, e);
         // Apply localization
         ResourceManagerService.ChangeLocale(Settings.Same().Localization);
         // Инициализация списков культур
         _namesOfCultures          = InitNamesOfCultures();
         ListOfLocalization        = GetListOfLocalization();
         SelectedIndexLocalization = _namesOfCultures.IndexOf(Settings.Same().Localization);
         // Временно скрываем верхнюю линейку управления, что бы не мигало при инициализации цветово палитры
         ColorZoneVisibility = Visibility.Hidden;
         // Инициализация главного меню
         MainMenuItemsInit();
         // Random ColorSet
         PaletteThemeViewModel.ThemeChanged           += () => ColorSet.Create().RedefineColors();
         MainWindowViewModel.LocalizationChangedEvent += () => ColorSet.Create().RedefineColors();
         SettingOptionsViewModel.ApplyPrimaryChanged  += () => ColorSet.Create().RedefineColors();
         SettingOptionsViewModel.ApplyAccentChanged   += () => ColorSet.Create().RedefineColors();
         _dispatcherTimerShowBusyMemory = new DispatcherTimer(TimeSpan.FromMilliseconds(1000),
                                                              DispatcherPriority.Normal,
                                                              new EventHandler(SetBusyMemoryCaption),
                                                              Dispatcher.CurrentDispatcher);
         _dispatcherTimerShowBusyMemory.Stop();
         _dispatcherTimerShowBusyMemory.Start();
     } catch (Exception e) {
         Settings.Same().AppStatus = TaskStatus.Faulted;
         ErrorProcessing.Show(e);
         (Application.Current as App).Shutdown();
     }
 }
示例#13
0
 public void EnMenu()
 {
     ResourceManagerService.ChangeLocale("en-US");
 }
示例#14
0
 public void RuMenu()
 {
     ResourceManagerService.ChangeLocale("ru-RU");
 }
示例#15
0
 private void Russian(object obj)
 {
     ResourceManagerService.ChangeLocale("ru-RU");
 }
示例#16
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     tagHandler.SaveTagsToDisk();
     ResourceManagerService.SaveImagesInfoToDisk(loadedImages, "C:\\loadedImages.txt");
 }
示例#17
0
        public static string L(string resourceKey)
        {
            var value = ResourceManagerService.GetResourceString("XbimPresentationResource", resourceKey);

            return(string.IsNullOrWhiteSpace(value) ? resourceKey : value);
        }
示例#18
0
        /// <summary>
        /// Shows childs windows
        /// </summary>
        /// <param name="pViewIndex"></param>
        /// <param name="pDataContext"></param>
        /// <param name="playerName"></param>
        public static void Show(int pViewIndex, object pDataContext, ref string playerName)
        {
            ResourceManagerService.RegisterManager("MainWindowRes", MainWindowRes.ResourceManager, true);

            Window window;

            switch (pViewIndex)
            {
            case 0:
            {
                window = new GeetingWindow();
                {
                    window.DataContext = new GreetingViewModel();
                    window.ShowDialog();
                    var panel = (Panel)window.Content;
                    foreach (var child in panel.Children)
                    {
                        if (child is TextBox)
                        {
                            playerName = (child as TextBox).Text;
                        }
                    }
                }
                break;
            }

            case 1:
            {
                window = new RatingWindow();

                {
                    var panel = (Panel)window.Content;
                    foreach (var child in panel.Children)
                    {
                        var textColumn  = new DataGridTextColumn();
                        var textColumn1 = new DataGridTextColumn();
                        if (!(child is DataGrid))
                        {
                            continue;
                        }
                        var         childGrid = child as DataGrid;
                        IEnumerable players   = (IEnumerable)pDataContext;
                        (child as DataGrid).ItemsSource = players;
                        textColumn.Header =
                            ResourceManagerService.GetResourceString("MainWindowRes", "Name_Lbl");
                        textColumn.Binding = new Binding("Name");

                        childGrid.Columns.Add(textColumn);
                        textColumn1.Header =
                            ResourceManagerService.GetResourceString("MainWindowRes", "Rating_Lbl");
                        textColumn1.Binding = new Binding("Rating");
                        childGrid.Columns.Add(textColumn1);
                    }


                    window.ShowDialog();
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(pViewIndex), @"Index out of range");
            }
        }
示例#19
0
        public static async Task Run(
            [TimerTrigger("0 0 */4 * * *", RunOnStartup = false)] TimerInfo timer,
            [Table("AuditConfig")] CloudTable configTbl,
            [Table("AuditStats")] CloudTable statsTbl,
            [Table("ResourceTypes")] CloudTable resourceTypesTbl,
            [Queue("resources-to-tag")] ICollector <string> outQueue,
            TraceWriter log)
        {
            _log = log;
            _resourceTypesTbl = resourceTypesTbl;
            log.Info("Starding subscription audit.");

            var resourceTypesQuery = await resourceTypesTbl.ExecuteQuerySegmentedAsync(new TableQuery <ResourceType>(), null);

            _resourceTypes = resourceTypesQuery.Results;
            var auditConfigQuery = await configTbl.ExecuteQuerySegmentedAsync(new TableQuery <AuditConfig>(), null);

            // Init config table if new deployment
            if (auditConfigQuery.Results.Count == 0)
            {
                AuditConfig initConfig = new AuditConfig {
                    SubscriptionId = "enter_valid_subscription_id", RowKey = Guid.NewGuid().ToString(), RequiredTags = "comma,separated,tag,list,here", PartitionKey = "init"
                };
                TableOperation insertOperation = TableOperation.InsertOrReplace(initConfig);
                await configTbl.ExecuteAsync(insertOperation);

                log.Info("First run for new deployment. Please populate the AuditConfig table.");
                return;
            }

            foreach (var auditConfig in auditConfigQuery.Results)
            {
                try
                {
                    AuditStats stats = new AuditStats {
                        JobStart = DateTime.Now, PartitionKey = auditConfig.SubscriptionId, RowKey = Guid.NewGuid().ToString()
                    };
                    IEnumerable <string> requiredTagsList = auditConfig.RequiredTags.Split(',');

                    try
                    {
                        string token = AuthenticationService.GetAccessTokenAsync();
                        _resourceManager = new ResourceManagerService(token);
                    }
                    catch (Exception ex)
                    {
                        log.Error("Unable to connect to the ARM API, Message: " + ex.Message);
                    }

                    List <ResourceItem> tagUpdates = await ProcessResourceGroups(requiredTagsList, auditConfig.SubscriptionId, stats);

                    foreach (ResourceItem resourceItem in tagUpdates)
                    {
                        string messageText = JsonConvert.SerializeObject(resourceItem);
                        _log.Info("Requesting tags for: " + resourceItem.Id);
                        outQueue.Add(messageText);
                    }

                    log.Info("Completed audit of subscription: " + auditConfig.SubscriptionId);
                    stats.JobEnd = DateTime.Now;

                    TableOperation insertOperation = TableOperation.InsertOrReplace(stats);
                    await statsTbl.ExecuteAsync(insertOperation);
                }
                catch (Exception ex)
                {
                    log.Error("Failure processing resource groups for auditConfig: " + auditConfig.RowKey);
                    log.Error(ex.Message);
                }
            }
        }
示例#20
0
 /// <summary>
 /// Listener for language switching
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 ///
 private void buttonSwitchLanguageGerman(object sender, RoutedEventArgs e)
 {
     ResourceManagerService.ChangeLocale("de-DE");
     SettingsManager.Instance.Settings.Language = "de-DE";
 }
示例#21
0
 private void English(object obj)
 {
     ResourceManagerService.ChangeLocale("en-US");
 }
示例#22
0
 /// <summary>
 /// ctor creates instance <see cref="MainWindowViewModel"/>
 /// </summary>
 public MainWindowViewModel()
 {
     ResourceManagerService.RegisterManager("LanguageRes", LanguageRes.ResourceManager, true);
 }
示例#23
0
        private void Information(object obj)
        {
            var str = ResourceManagerService.GetResourceString("MainWindowRes", "Inform_message");

            MessageBox.Show(str.Replace(@"{\n}", Environment.NewLine));
        }
示例#24
0
 public void SaveTagsToDisk()
 {
     ResourceManagerService.SaveTagsToDisk(Tags, DefaultTagFileLocation);
 }
示例#25
0
 public void BeMenu()
 {
     ResourceManagerService.ChangeLocale("be-BE");
 }
示例#26
0
 protected override void OnStartup(object sender, StartupEventArgs e)
 {
     ResourceManagerService.RegisterManager("MyResources", MyResources.ResourceManager, true);           
     DisplayRootViewFor<LoginViewModel>();
 }
示例#27
0
 public static void Register()
 {
     ResourceManagerService.RegisterManager("XbimPresentationResource", XbimPresentation.ResourceManager, true);
 }
示例#28
0
        public static string L(string managerName, string resourceKey)
        {
            var value = ResourceManagerService.GetResourceString(managerName, resourceKey);

            return(string.IsNullOrWhiteSpace(value) ? resourceKey : value);
        }
 public static void ErrorResource(this Logger logger, string resoureKey)
 {
     logger.Error(ResourceManagerService.GetResourceString("LogResources", resoureKey));
 }