コード例 #1
0
        public AttackEditor(bool editMode, Attack attack)
        {
            InitializeComponent();

            types = ReadDatabase.getListOfCardTypes();
            RefreshTypes();

            UpdateSettings.UpdateDarkMode(this);

            if (editMode)
            {
                editAttack = true;
                AttackEditor_Window.Title = "AttackEditor - Edit mode";
                AttackEditor_CreateAttack_Button.Content = "Save";
                AttackEditor_Delete_Button.Visibility    = Visibility.Visible;
            }

            if (attack != null)
            {
                currentAttack = attack;
                AttackEditor_Name_Textbox.Text = attack.Name;

                foreach (var t in types)
                {
                    if (attack.CardTypeID == t.ID)
                    {
                        currentType = t;
                        break;
                    }
                }

                AttackEditor_Type_Combobox.SelectedItem = currentType;
                AttackEditor_Damage_Textbox.Text        = attack.Damage.ToString();
            }
        }
コード例 #2
0
        private void SetForecastComboBox(int catId)
        {
            var rows = from row in ReadDatabase.GetForecasts()
                       where row.CategoryId.Equals(catId)
                       select row;

            forecastDropdown.ItemsSource   = rows;
            forecastDropdown.SelectedIndex = 0;
        }
コード例 #3
0
        private void CardEditor_NewAttack_Button_Click(object sender, RoutedEventArgs e)
        {
            AttackEditor attackEditor = new AttackEditor(false, null);

            attackEditor.Left = this.Left;
            attackEditor.Top  = this.Top;
            attackEditor.ShowDialog();
            attacks = ReadDatabase.getListOfAttacks();
            RefreshAttacks();
        }
コード例 #4
0
        private void RefreshAttacks()
        {
            if (currentType != null)
            {
                attacks.Clear();
                foreach (Attack a in ReadDatabase.getListOfAttacks())
                {
                    if (a.CardTypeID == currentType.ID)
                    {
                        attacks.Add(a);
                    }
                }

                CardEditor_Attack1_Combobox.ItemsSource = attacks;
                CardEditor_Attack2_Combobox.ItemsSource = attacks;

                CardEditor_Attack1_Combobox.Items.Refresh();
                CardEditor_Attack2_Combobox.Items.Refresh();

                if (currentAttack1 != null)
                {
                    CardEditor_Attack1_Combobox.SelectedItem = attacks.Find(a => a.ID == currentAttack1.ID);
                }
                if (currentAttack2 != null)
                {
                    CardEditor_Attack2_Combobox.SelectedItem = attacks.Find(a => a.ID == currentAttack2.ID);
                }

                if (attacks.Count == 0)
                {
                    CardEditor_Attack1Edit_Button.IsEnabled        = false;
                    CardEditor_Attack2Edit_Button.IsEnabled        = false;
                    CardEditor_Card_Preview.Attack1.Content        = "Attack1:";
                    CardEditor_Card_Preview.Attack2.Content        = "Attack2:";
                    CardEditor_Card_Preview.Attack1_Damage.Content = "0";
                    CardEditor_Card_Preview.Attack2_Damage.Content = "0";
                }
            }
            else if (currentType == null)
            {
                attacks.Clear();
                CardEditor_Card_Preview.Type.Content = "No type";

                CardEditor_Attack1_Combobox.Items.Refresh();
                CardEditor_Attack2_Combobox.Items.Refresh();

                CardEditor_Attack1_Combobox.SelectedIndex = -1;
                CardEditor_Attack2_Combobox.SelectedIndex = -1;
            }
            else if (attacks.Count > 0)
            {
                CardEditor_Attack1_Combobox.ItemsSource = attacks;
                CardEditor_Attack2_Combobox.ItemsSource = attacks;
            }
        }
コード例 #5
0
        public CardEditor(bool editCard, Card card)
        {
            InitializeComponent();

            UpdateSettings.UpdateDarkMode(this);

            cardTypes = ReadDatabase.getListOfCardTypes();
            attacks   = ReadDatabase.getListOfAttacks();

            this.editCard = editCard;
            currentCard   = card;
            RefreshTypes();

            if (CardEditor_Type_Combobox.SelectedIndex == -1)
            {
                CardEditor_EditType_Button.IsEnabled = false;
            }

            if (editCard)
            {
                CardEditor_Tab_Window.Title                 = "CardEditor - Edit mode";
                CardEditor_CreateCard_Button.Visibility     = Visibility.Collapsed;
                CardEditor_CreateCardAndExit_Button.Content = "Save & Close";

                CardEditor_Type_Combobox.SelectedItem    = cardTypes.Find(i => i.ID == card.CardTypeID);
                CardEditor_Attack1_Combobox.SelectedItem = attacks.Find(i => i.ID == card.Attack1ID);
                CardEditor_Attack2_Combobox.SelectedItem = attacks.Find(i => i.ID == card.Attack2ID);
            }

            if (card != null)
            {
                CardEditor_Name_Textbox.Text = card.Name;

                CardEditor_HP_Textbox.Text = card.HP.ToString();

                ImageSourceConverter converter = new ImageSourceConverter();
                CardEditor_Card_Preview.Image.Source = (ImageSource)converter.ConvertFromString(card.ImagePath);

                currentType    = cardTypes.Find(t => t.ID == card.CardTypeID);
                currentAttack1 = attacks.Find(i => i.ID == card.Attack1ID);
                currentAttack2 = attacks.Find(i => i.ID == card.Attack2ID);



                CardEditor_Type_Combobox.SelectedItem = currentType;
                if (currentAttack1 != null)
                {
                    CardEditor_Attack1_Combobox.SelectedItem = attacks.Find(a => a.ID == currentAttack1.ID);
                }
                if (currentAttack2 != null)
                {
                    CardEditor_Attack2_Combobox.SelectedItem = attacks.Find(a => a.ID == currentAttack2.ID);
                }
            }
        }
コード例 #6
0
        public void LoadTabs()
        {
            List <Region>      regions  = ReadDatabase.GetRegions();
            List <StationInfo> stations = ReadDatabase.GetStations();

            tab1.Content = new StationTab(regions, stations, 0);
            tab2.Content = new StationTab(regions, stations, 1);
            tab3.Content = new StationTab(regions, stations, 2);
            tab4.Content = new StationTab(regions, stations, 8);
            tab5.Content = new StationTab(regions, stations, 7);
        }
コード例 #7
0
        private void CardEditor_Attack2Edit_Button_Click(object sender, RoutedEventArgs e)
        {
            AttackEditor attackEditor = new AttackEditor(true, currentAttack2);

            attackEditor.Left = this.Left;
            attackEditor.Top  = this.Top;
            attackEditor.ShowDialog();
            attacks = ReadDatabase.getListOfAttacks();
            RefreshTypes();
            RefreshAttacks();
        }
コード例 #8
0
        private void CardEditor_NewType_Button_Click(object sender, RoutedEventArgs e)
        {
            TypeEditor typeEditor = new TypeEditor(false, null);

            typeEditor.Left = this.Left;
            typeEditor.Top  = this.Top;
            typeEditor.ShowDialog();
            cardTypes = ReadDatabase.getListOfCardTypes();
            RefreshTypes();
            RefreshAttacks();
        }
コード例 #9
0
        private void MainWindow_CreateCard_Button_Click(object sender, RoutedEventArgs e)
        {
            CardEditor cardEditor = new CardEditor(false, null);

            cardEditor.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            cardEditor.ShowDialog();
            cards       = ReadDatabase.getListOfCards();
            cardsToView = cards.ToList();
            cardTypes   = ReadDatabase.getListOfCardTypes();
            MainWindow_FilterBy_Type_ListBox.ItemsSource = cardTypes;
            MainWindow_Cards_ListView.ItemsSource        = cards;
            RefreshListView();
        }
コード例 #10
0
        private void MainWindow_LoadCard_Button_Click(object sender, RoutedEventArgs e)
        {
            Card selectedCard = (Card)MainWindow_Cards_ListView.SelectedItem;

            if (selectedCard != null)
            {
                CardEditor editCard = new CardEditor(true, selectedCard);
                editCard.ShowDialog();
                cards       = ReadDatabase.getListOfCards();
                cardsToView = cards.ToList();
                cardTypes   = ReadDatabase.getListOfCardTypes();
                MainWindow_FilterBy_Type_ListBox.ItemsSource = cardTypes;
                MainWindow_Cards_ListView.ItemsSource        = cards;
                RefreshListView();
            }
        }
コード例 #11
0
        /// <summary>
        /// 人员上传结果处理
        /// </summary>
        private static void HumanResultHandle(string result = null)
        {
            if (String.IsNullOrEmpty(result) || result == "false")
            {
                LogUtil.WaringLog("上传失败(验证不通过)...");
                return;
            }

            /// 解析上报的结果
            List <HumanResult> results = XmlUtil.ReadHumanResultXml(result);

            LogUtil.MsgLog(result, "humanLog");

            ReadDatabase Sql = new ReadDatabase();

            Sql.HumanResultSql(results);
        }
コード例 #12
0
        private void MainWindow_Cards_ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Card selectedCard = (Card)MainWindow_Cards_ListView.SelectedItem;

            if (selectedCard != null)
            {
                CardEditor editCard = new CardEditor(true, selectedCard);
                editCard.Left = this.Left;
                editCard.Top  = this.Top;
                editCard.ShowDialog();
                cards     = ReadDatabase.getListOfCards();
                cardTypes = ReadDatabase.getListOfCardTypes();
                MainWindow_FilterBy_Type_ListBox.ItemsSource = cardTypes;
                MainWindow_Cards_ListView.ItemsSource        = cards;
                RefreshListView();
            }
        }
コード例 #13
0
ファイル: LawMangerDal.cs プロジェクト: laulunsi/JYNLSL
        /// <summary>
        /// add by lpl
        /// 2019-1-9
        /// 法律法规表数据查询
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public List<LawMangerEntity> QueryList(LawMangerEntity entity)
        {
            var strSql = new StringBuilder(" Where Rowsatus = 1");
            var args = new List<object>();

            if (!string.IsNullOrEmpty(entity.Id))
            {
                strSql.AppendFormat(" AND Id = '{0}'", entity.Id);
            }

            if (!string.IsNullOrEmpty(entity.ParentId))
            {
                strSql.Append(" AND ParentId = @ParentId");
                args.Add(new{ ParentId = entity.ParentId});
            }

            return ReadDatabase.Query<LawMangerEntity>(strSql.ToString(), args.ToArray()).ToList();
        }
コード例 #14
0
        /// <summary>
        /// 创建EF上下文对象,已存在就直接取,不存在就创建,保证线程内是唯一。
        /// </summary>
        public static DbContext Create()
        {
            DbContext dbContext = CallContext.GetData("DbContext") as DbContext;

            if (dbContext == null)
            {
                var dbType = ReadDatabase.CreateInstance().ReadTypeOfDataBase();
                switch (dbType)
                {
                case Enum.DBTYPE.MySql:
                    dbContext = new DBContext(ReadDatabase.CreateInstance().ReadConnectionStrOfDataBase());
                    break;

                default:
                    break;
                }
                CallContext.SetData("DbContext", dbContext);
            }
            return(dbContext);
        }
コード例 #15
0
        /// <summary>
        /// 读取人员信息并发送
        /// </summary>
        static void ReadHumanData()
        {
            LogUtil.MsgLog("human up start!", "humanLog");
            while (true)
            {
                // 根据网络状况同步信息
                if (!NetStateUtil.LocalConnectionStatus())
                {
                    LogUtil.MsgLog("Network connectionless! Try again in 5 minutes", "humanLog");
                    Thread.Sleep(5 * 60000);
                    continue;
                }

                // 从数据库读取数据并转换未Xml字符串
                ReadDatabase read = new ReadDatabase();
                List <Human> data = read.ReadHumanInfo();
                if (data == null || data.Count() == 0)
                {
                    LogUtil.MsgLog("There is no new data!", "humanLog");
                    Thread.Sleep(15 * 60000);
                    continue;
                }

                // 调用webservice上传人员读卡信息
                try
                {
                    string ListHuman = XmlUtil.CreateHumanXml(data);
                    UploadWebservice.UploadWebservice webservice = new UploadWebservice.UploadWebservice();
                    webservice.Timeout = 15000;
                    // 执行WebService并返回结果
                    string result = webservice.UpHumanInfo(ListHuman);
                    HumanResultHandle(result);
                }
                catch
                {
                    Thread.Sleep(5 * 60000);
                    LogUtil.MsgLog("WebService not runing! Try again in 5 minutes", "humanLog");
                }
                Thread.Sleep(60000);
            }
        }
コード例 #16
0
        private void rightConfig_Click(object sender, EventArgs e)
        {
            this.serviceLog.Items.Clear();
            string ProjectNum  = this.projectId.Text;
            string ProjectName = this.projectName.Text;
            string OnloadUrl   = this.onloadUrl.Text;

            // 检查配置信息
            if (String.IsNullOrEmpty(ProjectNum) ||
                String.IsNullOrEmpty(ProjectName) ||
                String.IsNullOrEmpty(OnloadUrl))
            {
                MessageBox.Show("三项都不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            // 向Xml写入配置文件
            Config config = new Config();

            config.projectNum  = ProjectNum;
            config.projectName = ProjectName;
            config.onloadUrl   = OnloadUrl;
            XmlUtil.WriteConfig(config);

            // 初始化数据库种子数据
            ReadDatabase database = new ReadDatabase();

            if (database.InitDatabase())
            {
                this.serviceLog.Items.Add($"{DateTime.Now}:数据插入成功!");
            }
            else
            {
                this.serviceLog.Items.Add($"{DateTime.Now}:数据插入失败!");
            }

            this.serviceLog.Items.Add($"{DateTime.Now}:配置成功!");
            iniEnabledAllButton(false);
        }
コード例 #17
0
        public MainWindow()
        {
            InitializeComponent();

            cards         = ReadDatabase.getListOfCards();
            cardTypes     = ReadDatabase.getListOfCardTypes();
            cardsToView   = cards.ToList();
            selectedTypes = cardTypes.ToList();
            MainWindow_Cards_ListView.ItemsSource = cardsToView;

            MainWindow_SortBy_ComboBox.ItemsSource   = Enum.GetNames(typeof(CardSortBy));
            MainWindow_SortBy_ComboBox.SelectedIndex = 0;

            MainWindow_FilterBy_Type_ListBox.ItemsSource = cardTypes;

            UpdateSettings.UpdateDarkMode(this);
            if (Settings.Default.darkmode)
            {
                darkMode.IsChecked = true;
            }

            RefreshListView();
        }
コード例 #18
0
        public TypeEditor(bool editMode, CardType type)
        {
            InitializeComponent();
            UpdateSettings.UpdateDarkMode(this);

            TypeEditor_Color_Combobox.ItemsSource = typeof(Colors).GetProperties();

            if (editMode)
            {
                editType = true;
                TypeEditor_Window.Title             = "TypeEditor - Edit mode";
                TypeEditor_Save_Button.Content      = "Save";
                TypeEditor_Delete_Button.Visibility = Visibility.Visible;

                attacks = ReadDatabase.getListOfAttacks();
            }

            if (type != null)
            {
                currentType = type;
                TypeEditor_Name_Textbox.Text = type.Name;

                foreach (var c in TypeEditor_Color_Combobox.ItemsSource)
                {
                    if ((c as PropertyInfo).Name == type.Cardcolor)
                    {
                        TypeEditor_Color_Combobox.SelectedItem = c;
                        break;
                    }
                }

                TypeEditor_MinHP_Textbox.Text        = type.MinHP.ToString();
                TypeEditor_Max_HP_textbox.Text       = type.MaxHP.ToString();
                TypeEditor_MinAttackDMG_Textbox.Text = type.MinAttackDMG.ToString();
                TypeEditor_MaxAttackDMG_Textbox.Text = type.MaxAttackDMG.ToString();
            }
        }
コード例 #19
0
ファイル: StartScript.cs プロジェクト: davidmalmstrom/Kex
 // Use this for initialization
 void Start()
 {
     ReadDatabase.readDatabase();
     Debug.Log("End of code; finished");
 }
コード例 #20
0
 void App_Startup(object sender, StartupEventArgs e)
 {
     ReadDatabase.MigrateDatabase();
 }
コード例 #21
0
        private void RefreshListView()
        {
            cards = ReadDatabase.getListOfCards();

            //1: add matching searches if search has input
            if (cards != null)
            {
                if (string.IsNullOrWhiteSpace(SearchBox.Text) || SearchBox.Text == "" || SearchBox.Text == "Search...")
                {
                    cardsToView = cards.ToList();
                }
                else
                {
                    cardsToView.Clear();

                    foreach (Card c in cards)
                    {
                        if (c.Name.ToLower().Contains(SearchBox.Text.ToLower()))
                        {
                            cardsToView.Add(c);
                        }
                    }
                }
            }

            //2: remove cards if any filters have been checked
            if (selectedTypes != null)
            {
                if (selectedTypes.Count < cardTypes.Count && selectedTypes.Count != 0)
                {
                    foreach (Card c in cardsToView.ToList())
                    {
                        bool removeCard = true;
                        foreach (CardType t in selectedTypes.ToList())
                        {
                            if (c.CardTypeID == t.ID)
                            {
                                removeCard = false;
                            }
                        }
                        if (removeCard)
                        {
                            cardsToView.Remove(c);
                        }
                    }
                }
            }

            //3: sort by current sorting criteria
            if (MainWindow_SortBy_ComboBox != null)
            {
                switch (Enum.Parse(typeof(CardSortBy), MainWindow_SortBy_ComboBox.SelectedItem.ToString()))
                {
                case CardSortBy.ID:
                    cardsToView = cardsToView.OrderBy(c => c.ID).ToList();
                    break;

                case CardSortBy.Name:
                    cardsToView = cardsToView.OrderBy(c => c.Name).ToList();
                    break;

                case CardSortBy.Type:
                    cardsToView = cardsToView.OrderBy(c => c.CardTypeID).ToList();
                    break;

                case CardSortBy.Health:
                    cardsToView = cardsToView.OrderByDescending(c => c.HP).ToList();
                    break;
                }
            }

            MainWindow_Cards_ListView.ItemsSource = cardsToView;
            MainWindow_Cards_ListView.Items.Refresh();
        }