public LoginControl(Grid WorkerGrid) { this.WorkerGrid = WorkerGrid; InitializeComponent(); LoginUserControl = LoginPanel; LoginPanel.Loaded += LoginPanel_Loaded; SetEvents(); LoginPanel.ButtonConnectionName.Foreground = GetColors.Get("Dark-003"); LoginPanel.txbxUserName.Text = XmlClass.GetCurrentUserName(); LoginPanel.ButtonConnectionName.Content = XmlClass.GetSelectedConnectionName(); if (LoginPanel.ButtonConnectionName.Content.ToString() == "") { ShowMessage("Подключение не создано. Создайте новое подключение.", "Red-001"); LoginPanel.ButtonConnectionName.Foreground = GetColors.Get("Red-001"); LoginUserControl = CreateConnectionPanel; } else { LoginPanel.ButtonConnectionName.Foreground = GetColors.Get("Dark-003"); ShowMessage(""); } }
IEnumerator BuildingsInst(GameObject goInst, XmlClass buidings, int _id) { goInst = buidings.analyseGO(_id, (int)WhatBlockParse.Builings, prefabBuildings, avatarBuildings, infoBuildings, downbarBuildings, xmlDoc.text); goInst = Instantiate(goInst); goInst.transform.SetParent(parentGOBuildings); goInst.transform.localScale = new Vector3(1, 1, 1); BlockController blc = goInst.GetComponent <BlockController>(); blc.SetBlockName(); blc.SetAvatar(); blc.SetBlockLevel(_id, WhatBlockParse.Builings); blc.SetTitle(); blc.SetDesc(); blc.SetPrices(); blc.SetTimeToBuild(); blc.SetRequairments(xmlDoc.text, WhatBlockParse.Builings); if (blc.blockId == 45) { blc.SetCapitolium(); } upGradeBtnBuildings = goInst.transform.FindChild("DownBar").FindChild("UpgradeButton").GetComponent <Button>(); upGradeBtnBuildings.onClick.AddListener(() => { UpGradeBuildResearchTech((int)WhatBlockParse.Builings); }); yield return(null); }
// Событие: Клик кнопки "Проверить соединение" (окно: Create Connection) ------------------------------------------ private void ButtonCreatedConnectionCheck_Click(object sender, RoutedEventArgs e) { string conName = CreateConnectionPanel.txbxConnectionName.Text; ShowMessage(""); Loader = LC; LC.WaitText = "Проверка соединения..."; CreateConnectionPanel.ButtonCloseCreatedConnectionPanel.IsEnabled = false; CreateConnectionPanel.BorderConnValues.IsEnabled = false; CreateConnectionPanel.BorderButtons.IsEnabled = false; if (XmlClass.CheckConnectionName(conName) == false) { new Thread(() => { CheckCreatedConnection(); }).Start(); } else { ShowMessage("Подключение с названием " + '"' + conName + '"' + " уже создано.\nИзмените название для подключения и попробуйте снова.", "Red-001"); CreateConnectionPanel.ButtonCloseCreatedConnectionPanel.IsEnabled = true; CreateConnectionPanel.BorderConnValues.IsEnabled = true; CreateConnectionPanel.BorderButtons.IsEnabled = true; Loader = null; } }
IEnumerator DefInst(GameObject goInst, XmlClass buidings, int _id) { goInst = buidings.analyseGO(_id, (int)WhatBlockParse.Defence, prefabDef, avatarDef, infoDef, downbarDef, xmlDoc.text); goInst = Instantiate(goInst); goInst.transform.SetParent(parentGODef); goInst.transform.localScale = new Vector3(1, 1, 1); BlockController blc = goInst.GetComponent <BlockController>(); allDef.Add(blc); blc.SetBlockName(); blc.SetAvatar(); blc.SetBlockLevel(_id, WhatBlockParse.Defence); blc.SetTitleForDoc(); blc.SetDesc(); blc.SetPrices(); blc.SetTimeToBuild(); blc.SetRequairments(xmlDoc.text, WhatBlockParse.Defence); upGradeBtnDoc = goInst.transform.FindChild("DownBar").FindChild("UpgradeButton").GetComponent <Button>(); upGradeBtnDoc.onClick.AddListener(() => { UpGradeBuildResearchTech((int)WhatBlockParse.Defence); }); inputFieldBtn = goInst.transform.FindChild("DownBar").FindChild("InputField").GetComponent <Button>(); inputFieldBtn.onClick.AddListener(() => { OpenSlider(); }); yield return(null); }
IEnumerator Start() { loading.SetActive(true); foreach (var mm in allLeftBtn) { mm.interactable = true; } pathToXml = Application.dataPath + "/config.xml"; xmlDoc = (TextAsset)Resources.Load("config"); MainResourcesController mrc = TopBlock.GetComponent <MainResourcesController>(); MainResourcesController.CreadeDictionaryBuildingsLevel(); MainResourcesController.CreadeDictionaryResearchLevel(); mrc.CreateDictionaryResources(xmlDoc.text); canBuild = Root_build_conf.LoadFromText(xmlDoc.text); helpTextList = Root_helper_tech.LoadFromText(xmlDoc.text); XmlClass buidings = new XmlClass(); foreach (var mm in canBuild.build_conf.allow_planet.canBuildList) { StartCoroutine(BuildingsInst(goInst, buidings, mm.canBuildId)); StartCoroutine(TechInst(goInst, buidings, mm.canBuildId)); yield return(null); } foreach (var mm in canBuild.build_conf.allow_planet.canResearchList) { StartCoroutine(ResearchInst(goInst, buidings, mm.canResearchId)); StartCoroutine(TechInst(goInst, buidings, mm.canResearchId)); yield return(null); } foreach (var mm in canBuild.build_conf.allow_planet.canFleetList) { StartCoroutine(DocInst(goInst, buidings, mm.canFleetId)); StartCoroutine(TechInst(goInst, buidings, mm.canFleetId)); yield return(null); } foreach (var mm in canBuild.build_conf.allow_planet.canDefenseList) { StartCoroutine(DefInst(goInst, buidings, mm.canDefenseId)); StartCoroutine(TechInst(goInst, buidings, mm.canDefenseId)); yield return(null); } ScreenManager scr = GameObject.Find("ScreenManager").GetComponent <ScreenManager>(); scr.currentPanel = planetBlock; planetBlock.SetActive(true); loading.SetActive(false); }
// Метод: Запись выбранного подключения в Xml-файл, файл конфигурации --------------------------------------------- void WriteSelectedConnection(object sender) { Action ac = () => { XmlClass.SetSelectConnection(((ConnectionRB)sender).Content.ToString()); LoginPanel.ButtonConnectionName.Content = ((ConnectionRB)sender).Content.ToString(); Loader = null; }; Dispatcher.Invoke(ac); }
static void loadingServer() { try { XmlDocument a = new XmlClass().read("xml/server.xml"); ConfigClass.serverPort = int.Parse(a.GetElementsByTagName("port").Item(0).InnerXml); } catch (Exception error) { new MessageClass().writeLog("ComputerServer->loadingServer Error:" + error); } }
// Метод: Возвращает интерйфейс для пользователя ------------------------------------------------------------------ private UserControl GetUserInterface(string UserInterfaceName) { switch (UserInterfaceName) { case "Администратор": return(new Administrator(this, XmlClass.GetSelectedConnectionString()) { Name = GetUserControlName() }); } return(new SelectUserInterface(LoginCC, WorkerGrid, XmlClass.GetSelectedConnectionString(), GetUserControlName())); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { XmlDocument xmlDoc = null; string xmlname = $"{System.AppDomain.CurrentDomain.BaseDirectory}CardRoute.xml"; try { xmlDoc = new XmlDocument(); xmlDoc.Load(xmlname); } catch (Exception ex) { return; } string connectionString = $"Server={XmlClass.GetDataXml(xmlDoc, "Database/server", null)};" + $"Database={XmlClass.GetDataXml(xmlDoc, "Database/name", null)};" + $"Uid={XmlClass.GetDataXml(xmlDoc, "Database/uid", null)};" + $"Pwd={XmlClass.GetDataXml(xmlDoc, "Database/password", null)};"; DataSet ds = new DataSet(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = connectionString; conn.Open(); using (SqlCommand comm = conn.CreateCommand()) { comm.CommandText = "select c.*, cd.CardData from cards c inner join CardsData cd on c.CardId=cd.CardId"; using (SqlDataAdapter adapter = new SqlDataAdapter(comm)) { adapter.Fill(ds, "Table"); } } conn.Close(); } ds.Tables[0].Columns.Add("CardStatus"); ds.Tables[0].Columns.Add("CardPriority"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ds.Tables[0].Rows[i]["CardStatus"] = GetStatus((int)ds.Tables[0].Rows[i]["CardStatusId"]); ds.Tables[0].Rows[i]["CardPriority"] = GetPriority((int)ds.Tables[0].Rows[i]["CardPriorityId"]); } this.Dispatcher.Invoke(new Action(delegate() { dgCards.DataContext = ds.Tables[0].DefaultView; })); }
// Метод: Сохранение создаваемого подключения --------------------------------------------------------------------- private void SaveConnection() { SqlConnectionStringBuilder ConnectionStringBuilder = new SqlConnectionStringBuilder() { Pooling = true }; try { bool ok = false; Action aa = () => { ok = (bool)CreateConnectionPanel.ConnectionCreateModeCheckBox.IsChecked; }; Dispatcher.Invoke(aa); if (ok) { Action aC = () => { ConnectionStringBuilder.ConnectionString = CreateConnectionPanel.txbxConnectionString.Text; }; Dispatcher.Invoke(aC); } else { Action aC = () => { ConnectionStringBuilder.DataSource = CreateConnectionPanel.txbxServerName.Text; ConnectionStringBuilder.InitialCatalog = CreateConnectionPanel.txbxDataBase.Text; ConnectionStringBuilder.UserID = CreateConnectionPanel.txbxUserID.Text; ConnectionStringBuilder.Password = CreateConnectionPanel.psbxUserPassword.Password; }; Dispatcher.Invoke(aC); } Action action = () => { XmlClass.AddConnectSetting(CreateConnectionPanel.txbxConnectionName.Text, ConnectionStringBuilder.ConnectionString); Loader = null; CreateConnectionPanel.ButtonSaveCreatedConnection.IsEnabled = false; ClearTextBoxs(); ShowMessage("Подключение успешно сохранено.", "Green-003"); }; Dispatcher.Invoke(action); } catch (Exception ex) { Action action = () => { Loader = null; CreateConnectionPanel.ButtonSaveCreatedConnection.IsEnabled = false; ShowMessage(ex.Message, "Red-001"); }; Dispatcher.Invoke(action); } }
public bool IsSupported(XmlClass clazz) { if (clazz is Configuration) { Configuration configuration = clazz as Configuration; return IsSupported(configuration.processor_architecture_filter); } else if (clazz is Component) { Component component = clazz as Component; return IsSupported(component.processor_architecture_filter); } return true; }
/// <summary> /// make instance of current class /// </summary> /// <returns></returns> public static Settings instance() { // load setting from path string path = Application.StartupPath + "\\" + filename; if (File.Exists(path)) { inst = XmlClass <Settings> .Load(path, SerializedFormat.Document); } else { inst = new Settings(); XmlClass <Settings> .Save(inst, path, SerializedFormat.Document); } return(inst); }
// Метод: Авторизация пользователья ------------------------------------------------------------------------------- void UserAuthorization() { string message = ""; if (CheckSelectedConnection()) { Action ac = () => { if (DataBaseRequest.CheckAuthorization(LoginPanel.txbxUserName.Text, LoginPanel.psbxUserPassword.Password, ref message)) { if (!CheckUserInterface()) { XmlClass.WriteCurrentUserName(LoginPanel.txbxUserName.Text.ToString()); WorkerGrid.Children.Add(GetUserInterface(DataBaseRequest.GetUserInterfaceName(LoginPanel.txbxUserName.Text.ToString()))); } else { foreach (UserControl UC in WorkerGrid.Children) { if (UC.Name == GetUserControlName()) { UC.Visibility = Visibility.Visible; } else { UC.Visibility = Visibility.Hidden; } } } Visibility = Visibility.Hidden; LoginPanel.psbxUserPassword.Clear(); ShowMessage(""); } else { LoginPanel.psbxUserPassword.SelectAll(); LoginPanel.psbxUserPassword.Focus(); ShowMessage(message, "Red-001"); } Loader = null; LoginPanel.ButtonConnectionName.IsEnabled = true; }; Dispatcher.Invoke(ac); } }
// Событие: Клик кнопки "X" (окно: Create Connection) ------------------------------------------------------------- private void ButtonCloseCreatedConnectionPanel_Click(object sender, RoutedEventArgs e) { LoginUserControl = LoginPanel; LoginPanel.ButtonConnectionName.Content = XmlClass.GetSelectedConnectionName(); if (LoginPanel.ButtonConnectionName.Content.ToString() == "") { ShowMessage("Подключение не создано. Создайте новое подключение.", "Red-001"); LoginPanel.ButtonConnectionName.Foreground = GetColors.Get("Red-001"); LoginPanel.ButtonAuthorization.IsEnabled = LoginTextChanged(); } else { LoginPanel.ButtonConnectionName.Foreground = GetColors.Get("Dark-003"); LoginPanel.ButtonAuthorization.IsEnabled = LoginTextChanged(); ShowMessage(""); } }
public formAnalyse() { InitializeComponent(); // disable qrs detection from graph graph1.detection = EcgDetectionType.None; ribon1.add("Start", box.play, true, () => { // start thread for processing if (!working) { Thread trd = new Thread(new ThreadStart(run)); trd.Start(); working = true; } }); ribon1.add("Load", box.folder, true, () => { // open sample files OpenFileDialog op = new OpenFileDialog(); op.Filter = "Sample Files (*.sample)|*.sample"; if (op.ShowDialog() == DialogResult.OK) { // load samples from file graph1.samples = XmlClass <SignalSamples> .Load(op.FileName, SerializedFormat.Binary); graph1.sampleRate = graph1.samples.sampleRate; graph1.zoom = (float)graph1.samples.Count / (float)graph1.sampleRate; graph1.Refresh(); } }); ribon1.add("Save", box.save, true, () => { // save samples if (graph1.samples != null) { SaveFileDialog op = new SaveFileDialog(); op.Filter = "Sample Files (*.sample)|*.sample"; if (op.ShowDialog() == DialogResult.OK) { XmlClass <SignalSamples> .Save(graph1.samples, op.FileName, SerializedFormat.Binary); } } }); }
// Метод: Загрузка списка подключений (окно: Connection List) ----------------------------------------------------- private void LoadAllConnections() { string connName = XmlClass.GetSelectedConnectionName(); if (connName == "") { Action ac = () => { ConnectionListPanel.ButtonSelectedConnectionCheck.IsEnabled = false; }; Dispatcher.Invoke(ac); } else { Action ac = () => { ConnectionListPanel.ButtonSelectedConnectionCheck.IsEnabled = true; }; Dispatcher.Invoke(ac); } Action action = () => { ArrayList Connectionslist = XmlClass.ReadAllConnectionsName(); for (int i = 0; i < Connectionslist.Count; i++) { ConnectionRB CRB = new ConnectionRB(); CRB.FontFamily = new FontFamily("Roboto Condensed"); CRB.Foreground = new SolidColorBrush((Color)Application.Current.FindResource("Dark-003")); CRB.Deleted += CRB_Deleted;; CRB.Checked += CRB_Checked;; CRB.Content = Connectionslist[i].ToString(); ConnectionListPanel.stpConnectionList.Children.Add(CRB); if (CRB.Content.ToString() == connName) { CRB.IsChecked = true; } } Loader = null; if (ConnectionListPanel.stpConnectionList.Children.Count > 0) { ShowMessage("Выберите подключение или создайте новое подключение.", "Blue-004"); } else { ShowMessage("Cоздайте новое подключение.", "Red-001"); } }; Dispatcher.Invoke(action); }
private void GenerateChildren(XmlClass parent, int level) { if (level >= 5) return; object[] childAttributes = parent.GetType().GetCustomAttributes(typeof(XmlChild), true); if (childAttributes != null) { foreach (object childAttribute in childAttributes) { if (childAttribute is XmlNoChildren) continue; XmlChild xmlchild = (XmlChild)childAttribute; if (level < 2) { Console.WriteLine("{0}{1}", new string(' ', level), xmlchild.Type.Name); } else { Console.Write("."); } List<Type> implementsTypes = new List<Type>(); implementsTypes.Add(xmlchild.Type); implementsTypes.AddRange(GetNestedTypes(xmlchild.Type)); foreach (Type implementsType in implementsTypes) { if (implementsType.IsAbstract) continue; for (int i = 0; i < Math.Min(3, xmlchild.Max); i++) { XmlClass xmlclazz = GenerateClass(implementsType); parent.Children.Add(xmlclazz); GenerateChildren(xmlclazz, level + 1); } } } } }
private void GenerateChildren(XmlClass parent) { GenerateChildren(parent, 0); }
IEnumerator TechInst(GameObject goInst, XmlClass buidings, int _id) { goInst = buidings.analyseGO(_id, (int)WhatBlockParse.Technology, prefabTech, avatarTech, infoTech, downbarTech, xmlDoc.text); goInst = Instantiate(goInst); goInst.transform.SetParent(parentGOTech); goInst.transform.localScale = new Vector3(1, 1, 1); BlockController blc = goInst.GetComponent<BlockController>(); blc.SetBlockName(); blc.SetAvatar(); blc.SetBlockLevel(_id, WhatBlockParse.Technology); blc.SetTitle(); blc.SetDesc(); blc.ClearRequairments(); blc.SetRequairments(xmlDoc.text, WhatBlockParse.Technology); upGradeBtnTech = goInst.transform.FindChild("DownBar").FindChild("UpgradeButton").GetComponent<Button>(); upGradeBtnTech.onClick.AddListener(() => { UpGradeBuildResearchTech((int)WhatBlockParse.Technology); }); yield return null; }
IEnumerator Start() { loading.SetActive(true); foreach(var mm in allLeftBtn) { mm.interactable = true; } pathToXml = Application.dataPath + "/config.xml"; xmlDoc = (TextAsset)Resources.Load("config"); MainResourcesController mrc = TopBlock.GetComponent<MainResourcesController>(); MainResourcesController.CreadeDictionaryBuildingsLevel(); MainResourcesController.CreadeDictionaryResearchLevel(); mrc.CreateDictionaryResources(xmlDoc.text); canBuild = Root_build_conf.LoadFromText(xmlDoc.text); helpTextList = Root_helper_tech.LoadFromText(xmlDoc.text); XmlClass buidings = new XmlClass(); foreach (var mm in canBuild.build_conf.allow_planet.canBuildList) { StartCoroutine(BuildingsInst(goInst, buidings, mm.canBuildId)); StartCoroutine(TechInst(goInst, buidings, mm.canBuildId)); yield return null; } foreach (var mm in canBuild.build_conf.allow_planet.canResearchList) { StartCoroutine(ResearchInst(goInst, buidings, mm.canResearchId)); StartCoroutine(TechInst(goInst, buidings, mm.canResearchId)); yield return null; } foreach (var mm in canBuild.build_conf.allow_planet.canFleetList) { StartCoroutine(DocInst(goInst, buidings, mm.canFleetId)); StartCoroutine(TechInst(goInst, buidings, mm.canFleetId)); yield return null; } foreach (var mm in canBuild.build_conf.allow_planet.canDefenseList) { StartCoroutine(DefInst(goInst, buidings, mm.canDefenseId)); StartCoroutine(TechInst(goInst, buidings, mm.canDefenseId)); yield return null; } ScreenManager scr = GameObject.Find("ScreenManager").GetComponent<ScreenManager>(); scr.currentPanel = planetBlock; planetBlock.SetActive(true); loading.SetActive(false); }
IEnumerator DocInst(GameObject goInst, XmlClass buidings, int _id) { goInst = buidings.analyseGO(_id, (int)WhatBlockParse.Weapon, prefabDoc, avatarDoc, infoDoc, downbarDoc, xmlDoc.text); goInst = Instantiate(goInst); goInst.transform.SetParent(parentGODoc); goInst.transform.localScale = new Vector3(1, 1, 1); BlockController blc = goInst.GetComponent<BlockController>(); allDoc.Add(blc); blc.SetBlockName(); blc.SetAvatar(); blc.SetBlockLevel(_id, WhatBlockParse.Weapon); blc.SetTitleForDoc(); blc.SetDesc(); blc.SetPrices(); blc.SetTimeToBuild(); blc.SetRequairments(xmlDoc.text, WhatBlockParse.Weapon); upGradeBtnDoc = goInst.transform.FindChild("DownBar").FindChild("UpgradeButton").GetComponent<Button>(); upGradeBtnDoc.onClick.AddListener(() => { UpGradeBuildResearchTech((int)WhatBlockParse.Weapon); }); inputFieldBtn = goInst.transform.FindChild("DownBar").FindChild("InputField").GetComponent<Button>(); inputFieldBtn.onClick.AddListener(() => { OpenSlider(); }); yield return null; }
IEnumerator BuildingsInst(GameObject goInst, XmlClass buidings, int _id) { goInst = buidings.analyseGO(_id, (int)WhatBlockParse.Builings, prefabBuildings, avatarBuildings, infoBuildings, downbarBuildings, xmlDoc.text); goInst = Instantiate(goInst); goInst.transform.SetParent(parentGOBuildings); goInst.transform.localScale = new Vector3(1, 1, 1); BlockController blc = goInst.GetComponent<BlockController>(); blc.SetBlockName(); blc.SetAvatar(); blc.SetBlockLevel(_id, WhatBlockParse.Builings); blc.SetTitle(); blc.SetDesc(); blc.SetPrices(); blc.SetTimeToBuild(); blc.SetRequairments(xmlDoc.text, WhatBlockParse.Builings); if (blc.blockId == 45) blc.SetCapitolium(); upGradeBtnBuildings = goInst.transform.FindChild("DownBar").FindChild("UpgradeButton").GetComponent<Button>(); upGradeBtnBuildings.onClick.AddListener(() => { UpGradeBuildResearchTech((int)WhatBlockParse.Builings); }); yield return null; }