private void SaveCFGButton_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { foreach (System.Windows.Controls.ListViewItem listViewItem in (IEnumerable)this.mLoadedCFGsListView.Items) { if (listViewItem.Content.ToString().EndsWith("* (modified)", StringComparison.InvariantCulture)) { try { string fullFilePath = listViewItem.Tag.ToString(); IMConfig index = this.mLoadedCFGDict[fullFilePath]; List <IMControlScheme> imControlSchemeList = new List <IMControlScheme>(); foreach (IMControlScheme controlScheme in index.ControlSchemes) { IMControlScheme imControlScheme = controlScheme.DeepCopy(); imControlScheme.SetGameControls(this.GetFinalListOfActions(this.mSchemeTreeMapping[index][controlScheme])); imControlSchemeList.Add(imControlScheme); } index.ControlSchemes = imControlSchemeList; JsonSerializerSettings serializerSettings = Utils.GetSerializerSettings(); serializerSettings.Formatting = Formatting.Indented; this.WriteFile(fullFilePath, JsonConvert.SerializeObject((object)index, serializerSettings)); listViewItem.Content = (object)listViewItem.Content.ToString().TrimEnd("* (modified)".ToCharArray()); } catch (Exception ex) { string str = string.Format("Couldn't write to file: {0}, Ex: {1}", (object)listViewItem.Tag.ToString(), (object)ex); Logger.Error(str); int num = (int)System.Windows.MessageBox.Show(str); } } } }
private void ClearState() { this.mCurrentlySelectedCFG = (IMConfig)null; this.mLoadedCFGDict.Clear(); this.mLoadedCFGsListView.Items.Clear(); this.mSchemeTreeMapping.Clear(); this.ClearIMLists(); this.mLoadedCFGsListView.Visibility = Visibility.Collapsed; this.mSchemesListView.Visibility = Visibility.Collapsed; this.mIMActionsTreeView.Visibility = Visibility.Collapsed; }
internal void Init() { if (this.ParentWindow.SelectedConfig?.SelectedControlScheme == null) { return; } int num1 = this.ParentWindow.SelectedConfig?.SelectedControlScheme.GetHashCode().Value; if (this.mOldControlSchemeHashCode == num1) { return; } this.mOldControlSchemeHashCode = num1; this.ClearWindow(); IMConfig selectedConfig = this.ParentWindow.SelectedConfig; int num2; if (selectedConfig == null) { num2 = 0; } else { int?count = selectedConfig.SelectedControlScheme?.GameControls.Count; int num3 = 0; num2 = count.GetValueOrDefault() > num3 & count.HasValue ? 1 : 0; } if (num2 == 0) { return; } foreach (IMAction gameControl in this.ParentWindow.SelectedConfig.SelectedControlScheme.GameControls) { if (!this.IsInOverlayMode || gameControl.IsVisibleInOverlay) { this.AddCanvasElementsForAction(gameControl, true); if (gameControl.Type == KeyActionType.MOBADpad) { (gameControl as MOBADpad).mMOBAHeroDummy = new MOBAHeroDummy(gameControl as MOBADpad); this.AddCanvasElementsForAction((IMAction)(gameControl as MOBADpad).mMOBAHeroDummy, true); } } else if (!gameControl.IsVisibleInOverlay) { List <CanvasElement> canvasElement = CanvasElement.GetCanvasElement(gameControl, this, this.ParentWindow); foreach (UIElement uiElement in canvasElement) { uiElement.Visibility = Visibility.Hidden; } KMManager.listCanvasElement.Add(canvasElement); } } }
private bool CheckValidCFGAndLoad(string filePath) { bool flag = false; try { IMConfig imConfig = JsonConvert.DeserializeObject <IMConfig>(File.ReadAllText(filePath), Utils.GetSerializerSettings()); flag = true; this.mLoadedCFGDict.Add(filePath, imConfig); } catch (Exception ex) { Logger.Error("Failed to read cfg file... filepath: " + filePath + " Err : " + ex.Message); } return(flag); }
private void LoadedCFGsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.mLoadedCFGsListView.SelectedItem == null) { return; } this.ClearIMLists(); this.mCurrentlySelectedCFG = this.mLoadedCFGDict[(string)(this.mLoadedCFGsListView.SelectedItem as System.Windows.Controls.ListViewItem).Tag]; this.mSchemesList = (IList <IMControlScheme>) this.mCurrentlySelectedCFG.ControlSchemes; this.GenerateSchemesListView(); this.mIMActionsTreeView.Items.Clear(); if (this.mSchemesListView.Items.Count <= 0) { return; } this.mSchemesListView.Visibility = Visibility.Visible; }
public IMConfig DeepCopy() { IMConfig imConfig = (IMConfig)this.MemberwiseClone(); MetaData metaData = this.MetaData; imConfig.MetaData = metaData != null?metaData.DeepCopy <MetaData>() : (MetaData)null; imConfig.ControlSchemes = this.ControlSchemes?.ConvertAll <IMControlScheme>((Converter <IMControlScheme, IMControlScheme>)(cs => cs?.DeepCopy())); Dictionary <string, IMControlScheme> controlSchemesDict = this.ControlSchemesDict; imConfig.ControlSchemesDict = controlSchemesDict != null?controlSchemesDict.ToDictionary <KeyValuePair <string, IMControlScheme>, string, IMControlScheme>((Func <KeyValuePair <string, IMControlScheme>, string>)(kvp => kvp.Key), (Func <KeyValuePair <string, IMControlScheme>, IMControlScheme>)(kvp => kvp.Value?.DeepCopy())) : (Dictionary <string, IMControlScheme>)null; Dictionary <string, Dictionary <string, string> > strings = this.Strings; imConfig.Strings = strings != null?strings.ToDictionary <KeyValuePair <string, Dictionary <string, string> >, string, Dictionary <string, string> >((Func <KeyValuePair <string, Dictionary <string, string> >, string>)(kvp => kvp.Key), (Func <KeyValuePair <string, Dictionary <string, string> >, Dictionary <string, string> >)(kvp => kvp.Value)) : (Dictionary <string, Dictionary <string, string> >)null; imConfig.SelectedControlScheme = this.SelectedControlScheme?.DeepCopy(); return(imConfig); }
private void BgExport_DoWork(object sender, DoWorkEventArgs e) { try { List <object> objectList = e.Argument as List <object>; string path = objectList[0] as string; List <IMControlScheme> imControlSchemeList = objectList[1] as List <IMControlScheme>; IMConfig imConfig = new IMConfig(); imConfig.Strings = this.ParentWindow.OriginalLoadedConfig.Strings.DeepCopy <Dictionary <string, Dictionary <string, string> > >(); imConfig.ControlSchemes = imControlSchemeList; JsonSerializerSettings serializerSettings = Utils.GetSerializerSettings(); serializerSettings.Formatting = Formatting.Indented; string contents = JsonConvert.SerializeObject((object)imConfig, serializerSettings); File.WriteAllText(path, contents); this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.CanvasWindow.SidebarWindow, LocaleStrings.GetLocalizedString("STRING_CONTROLS_EXPORTED", ""), 1.3, false); } catch (Exception ex) { Logger.Error("Error in creating exported file " + e.ToString()); } }
public TranslationApiClient(IMemoryCache cache, IMConfig config) { this.cache = cache; this.config = config; }
public VideoApiClient(IMConfig config) { this.config = config; }
public StorageClient(CloudBlobClient blobClient, IMConfig config) { this.blobClient = blobClient; this.config = config; }
public VisionApiClient(IMConfig config) { this.config = config; this.baseUrl = this.config.CSEndpoints.ComputerVision; }
public SpeakerIdApiClient(IMConfig config) { this.config = config; }
public ServiceFactory(IMConfig config) { this.config = config; }
public StorageClient(BlobServiceClient blobServiceClient, IMConfig config) { this.blobServiceClient = blobServiceClient; this.config = config; }
public TextApiClient(IMConfig config) { this.config = config; }