コード例 #1
0
        private void ShowTestResult(bool flag)
        {
            FormLoading.EndLoading();
            if (flag)
            {
                string _connString = Secret.Encrypt3DES(connString, LocalVariable.Key);

                if (ConfigManager.SaveConnString(ConfigConst.ConnectionManageString, _connString, ConfigConst.ConfigPath) &&
                    ConfigManager.SaveConnString(ConfigConst.ConnectionStringWrite, _connString, ConfigConst.ConfigPath) &&
                    ConfigManager.SaveConnString(ConfigConst.ConnectionStringReadonly, _connString, ConfigConst.ConfigPath) &&
                    ConfigManager.SaveConnString(ConfigConst.ConStrManageSql, _connString, ConfigConst.ConfigPath))
                {
                    LocalVariable.SetConnStringValue(ConfigConst.ConnectionManageString, connString);
                    LocalVariable.SetConnStringValue(ConfigConst.ConnectionStringWrite, connString);
                    LocalVariable.SetConnStringValue(ConfigConst.ConnectionStringReadonly, connString);
                    LocalVariable.SetConnStringValue(ConfigConst.ConStrManageSql, connString);

                    FormMessgeBox.ShowMsg(this, "测试成功,并保存!", this.panelTop.BackColor);
                    this.myLock = true;
                    this.Close();
                }
                else
                {
                    FormMessgeBox.ShowMsg(this, "测试成功,但保存失败!", this.panelTop.BackColor);
                }
            }
            else
            {
                FormMessgeBox.ShowMsg(this, "测试失败!", this.panelTop.BackColor);
            }
            this.myLock = true;
        }
コード例 #2
0
 private void panelLogin_Click(object sender, EventArgs e)
 {
     if (this.enableFlag)
     {
         this.errorProvider.Clear();
         if (string.IsNullOrEmpty(this.tbUser.Caption.Trim()) ||
             this.tbUser.Caption.Trim() == "用户名")
         {
             Utility.Common.Validator.SetError(this.errorProvider, this.tbUser, "用户名不能为空!");
             return;
         }
         if (string.IsNullOrEmpty(this.tbPwd.Caption.Trim()) ||
             this.tbPwd.Caption.Trim() == "密码")
         {
             Utility.Common.Validator.SetError(this.errorProvider, this.tbPwd, "密码不能为空!");
             return;
         }
         FormLoading.StartLoading(this);
         this.enableFlag = false;
         this.userName   = this.tbUser.Caption.Trim();
         this.pwd        = this.tbPwd.Caption.Trim();
         this.uiHandler += new UiHandler(this.LoginResult);
         //登录验证
         ThreadPool.QueueUserWorkItem(new WaitCallback(this._Login));
     }
     else
     {
         FormMessgeBox.ShowMsg(this, "数据库连接异常!", this.panelTop.BackColor);
     }
 }
コード例 #3
0
ファイル: TextEditor.cs プロジェクト: LexouDuck/Emblem-Magic
        private void File_SaveScript_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog saveWindow = new SaveFileDialog())
            {
                saveWindow.Filter           = "Text file (*.txt)|*.txt|All files (*.*)|*.*";
                saveWindow.FilterIndex      = 1;
                saveWindow.RestoreDirectory = true;
                saveWindow.CreatePrompt     = true;
                saveWindow.OverwritePrompt  = true;

                if (saveWindow.ShowDialog() == DialogResult.OK)
                {
                    using (FormLoading loading = new FormLoading())
                    {
                        loading.Show();
                        loading.SetLoading("Dumping script...", 0);
                        UInt16 entry = 0;
                        string file  = "";
                        while (++entry < Int16.MaxValue)
                        {
                            loading.SetPercent(100 * ((float)entry / (float)0x5000));
                            try
                            {
                                file += Core_GetText(entry) + "\r\n";
                            }
                            catch { break; }
                        }
                        File.WriteAllText(saveWindow.FileName, file);
                    }
                }
            }
        }
コード例 #4
0
ファイル: TextEditor.cs プロジェクト: LexouDuck/Emblem-Magic
        private void File_SaveFolder_Click(object sender, EventArgs e)
        {
            using (var folderWindow = new FolderBrowserDialog())
            {
                folderWindow.ShowNewFolderButton = true;

                if (folderWindow.ShowDialog() == DialogResult.OK &&
                    !string.IsNullOrWhiteSpace(folderWindow.SelectedPath))
                {
                    using (FormLoading loading = new FormLoading())
                    {
                        loading.Show();
                        loading.SetLoading("Dumping script...", 0);
                        int    amount = 0;
                        UInt16 entry  = 0;
                        string name;
                        while (++entry < Int16.MaxValue)
                        {
                            loading.SetPercent(30 + 70 * ((float)entry / (float)Int16.MaxValue));
                            try
                            {
                                name = folderWindow.SelectedPath + "\\0x" + Util.UInt16ToHex((UInt16)entry) + ".txt";

                                File.WriteAllText(name, Core_GetText(entry));
                                amount++;
                            }
                            catch { break; }
                        }
                        Program.ShowMessage(amount + " text entry files have been created.");
                    }
                }
            }
        }
コード例 #5
0
        private async void buttonDirect_ClickAsync(object sender, EventArgs e)
        {
            int ov1 = Helper.ShowOverlay(this);
            FormDirectConnect formDirectConnect = new FormDirectConnect();

            if (formDirectConnect.ShowDialog() == DialogResult.OK)
            {
                string      ipToConnect = formDirectConnect.IP;
                int         ov2         = Helper.ShowOverlay(this);
                FormLoading formLoading = new FormLoading("Connecting to " + ipToConnect, 20);
                formLoading.Show();
                // Try to connect
                var result = await Task.Run(() => Connection.GetServiceOnIP(ipToConnect));

                formLoading.Close();
                Helper.HideOverlay(ov2);
                if (result != null) //Connected
                {
                    bool   pass      = (result["Password"].CompareTo("True") == 0) ? true : false;
                    string groupName = result["GroupName"];
                    Connect(ipToConnect, groupName, pass);
                }
                else
                {
                    int       ov3       = Helper.ShowOverlay(this);
                    FormAlert formAlert = new FormAlert("Error", "Can't establish connection to the server. Check provided IP", true);
                    formAlert.ShowDialog();
                    Helper.HideOverlay(ov3);
                }
            }
            Helper.HideOverlay(ov1);
        }
コード例 #6
0
        private void LoginResult(object obj)
        {
            this.uiHandler -= new UiHandler(this.LoginResult);
            string errMsg = obj.ToString();

            if (!string.IsNullOrEmpty(errMsg))
            {
                FormLoading.EndLoading();
                FormMessgeBox.ShowMsg(this, errMsg, this.panelTop.BackColor);
                this.enableFlag = true;
                return;
            }


            if (GlobalStaticObj.gLoginDataSet == null ||
                GlobalStaticObj.gLoginDataSet.Tables.Count == 0 ||
                GlobalStaticObj.gLoginDataSet.Tables[0].Rows.Count < 1)
            {
                this.enableFlag = true;
                FormLoading.EndLoading();
                FormMessgeBox.ShowMsg(this, "用户名或密码错误!", this.panelTop.BackColor);
                return;
            }

            if (HXCServerWinForm.GlobalStaticObj.gLoginDataSet.Tables[0].Rows.Count < 1)
            {
                this.enableFlag = true;
                FormMessgeBox.ShowMsg(this, "数据加载失败!", this.panelTop.BackColor);
                FormLoading.EndLoading();
                return;
            }

            #region 设置全局变量
            GlobalStaticObj_Server.Instance.UserID    = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_id"].ToString();
            GlobalStaticObj_Server.Instance.UserName  = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_name"].ToString();
            GlobalStaticObj_Server.Instance.LoginName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["land_name"].ToString();
            GlobalStaticObj_Server.Instance.PassWord  = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["password"].ToString();

            GlobalStaticObj_Server.Instance.RoleID   = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["role_id"].ToString();
            GlobalStaticObj_Server.Instance.RoleName = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["role_name"].ToString();
            GlobalStaticObj_Server.Instance.OrgID    = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_id"].ToString();
            GlobalStaticObj_Server.Instance.OrgName  = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_name"].ToString();

            GlobalStaticObj_Server.Instance.ComID     = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_id"].ToString();
            GlobalStaticObj_Server.Instance.ComName   = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_name"].ToString();
            GlobalStaticObj_Server.Instance.LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            #endregion

            //预加载信息
            //LocalCache.PreLoad();

            //登录记忆保存
            this.SaveMemery();

            FormLoading.EndLoading();
            this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态
        }
コード例 #7
0
        private void panelLogin_Click(object sender, EventArgs e)
        {
            if (this.enableFlag)
            {
                if (this.dtDb.Rows.Count == 0)
                {
                    MessageBoxEx.Show("帐套信息加载中…");
                    this.RefreshAccData();
                    return;
                }
                this.errorProvider.Clear();
                if (string.IsNullOrEmpty(this.tbUser.Caption.Trim()) ||
                    this.tbUser.Caption.Trim() == "用户名")
                {
                    Utility.Common.Validator.SetError(this.errorProvider, this.tbUser, "用户名不能为空!");
                    return;
                }
                if (string.IsNullOrEmpty(this.tbPwd.Caption.Trim()) ||
                    this.tbPwd.Caption.Trim() == "密码")
                {
                    Utility.Common.Validator.SetError(this.errorProvider, this.tbPwd, "密码不能为空!");
                    return;
                }
                FormLoading.StartLoading(this, new Size(110, 120));
                this.enableFlag = false;
                this.userName   = this.tbUser.Caption.Trim();
                this.pwd        = this.tbPwd.Caption.Trim();
                this.uiHandler += new UiHandler(this.LoginResult);

                //保存帐套信息
                string  dbId = this.tbDb.Tag.ToString();
                DataRow dr   = this.dtDb.Select("Value='" + dbId + "'")[0];

                GlobalStaticObj.CurrAccID    = dbId;
                GlobalStaticObj.CurrAccCode  = dr["Code"].ToString();
                GlobalStaticObj.CurrAccName  = dr["Name"].ToString();
                GlobalStaticObj.IsDefaultAcc = dr["Status"].ToString() == DataSources.EnumYesNo.Yes.ToString("d");

                this.timer.Enabled = true;

                //登录验证
                ThreadPool.QueueUserWorkItem(new WaitCallback(this._Login));
            }
            else
            {
                MessageBoxEx.Show("服务连接异常!");
            }
        }
コード例 #8
0
 private void timer_Tick(object sender, EventArgs e)
 {
     if (!this.enableFlag)
     {
         FormLoading.EndLoading();
         if (!InetetTest(GlobalStaticObj.DataServerIp, 200))
         {
             FormMessgeBox.ShowMsg(this, "无法连接服务器!", this.panelTop.BackColor);
         }
         else
         {
             FormMessgeBox.ShowMsg(this, "服务器登录超时!", this.panelTop.BackColor);
         }
         this.enableFlag = true;
     }
     this.timer.Enabled = false;
 }
コード例 #9
0
        private void panelYes_Click(object sender, EventArgs e)
        {
            if (!myLock)
            {
                return;
            }
            this.myLock = false;

            this.errorProvider.Clear();

            if (string.IsNullOrEmpty(this.tbDBIp.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbDBIp, "服务器Ip不能为空!");
                return;
            }
            if (!InetetTest(this.tbDBIp.Caption.Trim(), 100))
            {
                FormMessgeBox.ShowMsg(this, "IP无法连接!", this.panelTop.BackColor);
                this.myLock = true;
                return;
            }
            if (string.IsNullOrEmpty(this.tbDBUser.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbDBUser, "用户名不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.tbDBPwd.Caption.Trim()))
            {
                Utility.Common.Validator.SetError(this.errorProvider, this.tbDBPwd, "密码不能为空!");
                return;
            }

            this.arrays[1] = this.tbDBIp.Caption.Trim();

            this.arrays[5] = this.tbDBUser.Caption.Trim();

            this.arrays[7] = this.tbDBPwd.Caption.Trim();

            connString = ConfigHelper.PackageConnString(this.arrays);

            FormLoading.StartLoading(this);

            ThreadPool.QueueUserWorkItem(new WaitCallback(this._DbTest), connString);
        }
コード例 #10
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            using (FormLoading form = new FormLoading(_ide))
            {
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    // Initialize the IDE interfaces
                    projectMaster.Initialize(_ide);
                    scriptEditor.Initialize(_ide);

                    SelectIDETab(IDETab.ProjectMaster);

                    // Drop the panel
                    panel_CoverLoading.Dispose();
                }
            }
        }
コード例 #11
0
 private void ShowAccData(object obj)
 {
     this.uiHandler -= new UiHandler(this.ShowAccData);
     if (obj.ToString().Length > 0)
     {
         FormLoading.EndLoading();
         if (this.formSet == null || !this.formSet.Visible)
         {
             FormMessgeBox.ShowMsg(this, "无法加载帐套数据!", this.panelTop.BackColor);
         }
     }
     this.enableFlag = true;
     //加载帐套
     if (this.dtDb.Rows.Count > 0)
     {
         this.tbDb.Caption = this.dtDb.Rows[0]["DisplayName"].ToString();
         this.tbDb.Tag     = this.dtDb.Rows[0]["Value"].ToString();
         if (this.tbUser.Caption.Trim().Length == 0)
         {
             this.tbUser.Focus();
         }
         else
         {
             if (this.tbPwd.Caption.Trim().Length == 0)
             {
                 this.tbPwd.Focus();
             }
             else
             {
                 this.panelLogin.Focus();
             }
         }
     }
     this.formCmb               = new FormCmb();
     this.formCmb.DisplayName   = "DisplayName";
     this.formCmb.ValueName     = "Value";
     this.formCmb.ItemHeight    = 35;
     this.formCmb.BackColor     = Color.White;
     this.formCmb.SelectedColor = Color.FromArgb(97, 167, 208);
     this.formCmb.ItemSelected += new FormCmb.ItemSelectedHandler(this.SeletecdAccount);
     this.formCmb.BindCmb(this.tbDb.InnerTextBox, this.dtDb, this.tbDb.Location.X,
                          this.panelDb.Height - this.tbDb.Location.Y - this.tbDb.Height, false);
 }
コード例 #12
0
        private void RefreshLevelList()
        {
            string cachedNodeText = string.Empty;

            if (treeView.SelectedNodes.Count > 0)
            {
                cachedNodeText = treeView.SelectedNodes[0].Text;

                // Reinitialize the selected level (That's for treeView_Resources in SectionLevelProperties)
                _ide.SelectedLevel = null;
                _ide.SelectedLevel = (ProjectLevel)treeView.SelectedNodes[0].Tag;
            }

            // Scan the project's /Levels/ folder using FormLoading
            using (FormLoading form = new FormLoading(_ide))
            {
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    // Refresh the level list
                    FillLevelList();

                    // If a node was selected, reselect it after refreshing
                    if (!string.IsNullOrEmpty(cachedNodeText))
                    {
                        foreach (DarkTreeNode node in treeView.Nodes)
                        {
                            if (node.Text.ToLower() == cachedNodeText.ToLower())
                            {
                                treeView.SelectNode(node);
                                treeView.ScrollTo(node.FullArea.Location);

                                break;
                            }
                        }
                    }

                    CheckItemSelection();
                }
            }
        }
コード例 #13
0
        private void ShowLoadingFormMenuItem_Click(Office.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            FormLoading loader = new FormLoading();

            loader.StartPosition = FormStartPosition.CenterScreen;
            loader.Show();

            // This is a pretty important part because on the FromCurrentSynchronizationContext() call you can get Exception
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }

            var context = TaskScheduler.FromCurrentSynchronizationContext();
            var task    = new Task(() =>
            {
                Excel.Application app = Globals.ThisAddIn.Application;
                app.Interactive       = false;

                for (int i = 0; i < 500; i++)
                {
                    app.StatusBar = string.Format("Iteration {0}", i);
                    Thread.Sleep(5);
                }

                // This code is used to call Close() method Thread safe otherwise you get Cross-thread operation not valid Exception
                ThreadSafeHelper.InvokeControlMethodThreadSafe(loader, () =>
                {
                    loader.Close();
                });

                app.StatusBar   = "Ready";
                app.Interactive = true;
            });

            task.Start();
        }
コード例 #14
0
        void UCOldPartsPalautusAddOrEdit_SyncEvent(object sender, EventArgs e)
        {
            #region 必要的判断
            if (dtpSTime.Value > dtpETime.Value)
            {
                MessageBoxEx.Show("创建日期范围,开始时间不能大于结束时间", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string strCurrentSMon = dtpSTime.Value.Month.ToString(); //创建日期范围开始日期的月份
            string strCurrentEMon = dtpETime.Value.Month.ToString(); //创建日期范围结束日期的月份
            if (strCurrentEMon != strCurrentSMon)
            {
                MessageBoxEx.Show("创建日期范围必须在同一个月!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                return;
            }
            string strCurrentSDay = dtpSTime.Value.Day.ToString();//创建日期范围开始日期的天
            if (strCurrentSDay != "1")
            {
                MessageBoxEx.Show("创建日期范围,开始日期必须为每月第1天!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                return;
            }
            if (dtpSTime.Value.AddMonths(1).AddDays(-1).ToShortDateString() != dtpETime.Value.ToShortDateString())
            {
                MessageBoxEx.Show("创建日期范围必须为整月份!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                return;
            }


            #endregion
            strWhere        = @" create_time_start='" + Common.LocalDateTimeToUtcLong(Convert.ToDateTime(dtpSTime.Value.ToString("yyyy-MM-dd"))).ToString() + "'and create_time_end='" + Common.LocalDateTimeToUtcLong(Convert.ToDateTime(dtpETime.Value.ToString("yyyy-MM-dd"))).ToString() + "' ";
            this.uiHandler -= new UiHandler(this.ShowData);
            this.uiHandler += new UiHandler(this.ShowData);
            //加载帐套信息
            ThreadPool.QueueUserWorkItem(new WaitCallback(this.GetWebServHandler), dtpSTime.Value.ToString("yyyy-MM-dd") + "," + dtpETime.Value.ToString("yyyy-MM-dd"));
            FormLoading.StartLoading(dgvMaterials);
        }
コード例 #15
0
        /// <summary>
        /// Automatically generates a TSA-compliant image from a 256(or fewer)-color image
        /// </summary>
        /// <param name="width">Width of the TSA (in tiles)</param>
        /// <param name="height">Height of the TSA (in tiles)</param>
        /// <param name="image">The bitmap to convert</param>
        /// <param name="paletteAmount">the maximum amount of 16-color palettes</param>
        /// <param name="checkRedundantTiles">whether or not to add all tiles found to the tileset</param>
        public TSA_Image(
            int width, int height,
            GBA.Bitmap image,
            int paletteAmount,
            bool checkRedundantTiles)
        {
            Width  = width * 8;
            Height = height * 8;

            if (image.Width != Width || image.Height != Height)
            {
                throw new Exception("Image given has invalid dimensions.\n" +
                                    "It must be " + Width + "x" + Height + " pixels.");
            }

            if (image.Colors.Count <= 16)
            {   // No need to run TSA-ifier code
                Palettes = Palette.Split(image.Colors, paletteAmount);

                Graphics = new Tileset(new Image(image));

                Tiling = TSA_Array.GetBasicTSA(width, height);
            }
            else
            {
                using (FormLoading loading = new FormLoading())
                { // Run the image TSA-ifier
                    loading.Show();

                    int    tileAmount  = width * height;
                    byte[] bytes       = image.ToBytes();
                    int[]  colorTotals = new int[image.Colors.Count];
                    int[,] colorAmounts = new int[image.Colors.Count, tileAmount];

                    loading.SetLoading("Checking colors...", 2);

                    int index;
                    int tile = 0;
                    for (int tileY = 0; tileY < height; tileY++)
                    {
                        for (int tileX = 0; tileX < width; tileX++)
                        {
                            index = tileX * 8 + tileY * 8 * Width;
                            for (int y = 0; y < 8; y++)
                            {
                                for (int x = 0; x < 8; x++)
                                {
                                    colorTotals[bytes[index]]++;
                                    colorAmounts[bytes[index], tile]++;
                                }
                                index += Width - 8;
                            }
                            tile++;
                        } // first we take a look at which colors are most present (in all, and per tile)
                    }
                    loading.SetPercent(7);

                    List <int> colors = new List <int>();
                    for (int i = 0; i < colorTotals.Length; i++)
                    {
                        index = 0;
                        while (index < colors.Count && colorTotals[i] > colors[index])
                        {
                            index++;
                        }

                        if (index < colors.Count)
                        {
                            colors.Insert(index, i);
                        }
                        else
                        {
                            colors.Add(i);
                        }

                        if (colors.Count > paletteAmount * 15)
                        {
                            colors.RemoveAt(0);
                        }
                    } // then we create a list of indices to colors with only the most used colors

                    loading.SetPercent(9);

                    Palettes = new Palette[paletteAmount];
                    for (int i = 0; i < paletteAmount; i++)
                    {
                        Palettes[i] = new GBA.Palette(16);
                        Palettes[i].Add(new GBA.Color(0x0000));
                    } // we create our palettes, forcing the 1st color to be black on each palette

                    loading.SetLoading("Asserting tile palettes...", 10);

                    byte[]    tilePalettes = new byte[tileAmount];
                    int[]     certainty    = new int[tileAmount];
                    GBA.Color color;
                    int       amount;
                    for (int i = colors.Count - 1; i >= 0; i--)
                    {
                        color = image.Colors[colors[i]];
                        tile  = 0;

                        while (tile < tilePalettes.Length)
                        {
                            amount = colorAmounts[colors[i], tile];

                            if (Palettes[tilePalettes[tile]].Contains(color))
                            {
                                certainty[tile] += amount;
                            }
                            else
                            {
                                if (Palettes[tilePalettes[tile]].IsFull)
                                {
                                    if (certainty[tile] < amount)
                                    {
                                        tilePalettes[tile]++;
                                        tilePalettes[tile] %= (byte)Palettes.Length;
                                        certainty[tile]     = 0;
                                        i++; break;
                                    }
                                    else
                                    {
                                        certainty[tile] -= amount;
                                    }
                                }
                                else if (amount != 0)
                                {
                                    Palettes[tilePalettes[tile]].Add(color);
                                    certainty[tile] += amount;
                                }
                            }
                            tile++;
                        }
                        loading.SetPercent(10 + (50 - 50 * ((float)i / (float)(colors.Count))));
                    } // and we do a loop going from  most used color to least used, setting tilePalettes and filling said palettes

                    amount = 0;
                    for (int p = 0; p < Palettes.Length; p++)
                    {
                        Palettes[p].Sort(delegate(GBA.Color first, GBA.Color second)
                        {
                            return((first.GetValueR() + first.GetValueG() + first.GetValueB())
                                   - (second.GetValueR() + second.GetValueG() + second.GetValueB()));
                        });
                        for (int i = Palettes[p].Count; i < 16; i++)
                        {
                            Palettes[p].Add(new Color(0x0000));
                        }
                    }

                    loading.SetMessage("Creating TSA information...");

                    Graphics = new Tileset(width * height);
                    Tiling   = new TSA_Array(width, height);
                    int pixel;
                    tile = 0;
                    byte HI_nibble;
                    byte LO_nibble;
                    Tile currentTile;
                    Tuple <int, bool, bool> current;
                    for (int tileY = 0; tileY < height; tileY++)
                    {
                        for (int tileX = 0; tileX < width; tileX++)
                        {
                            index = (Palettes[tilePalettes[tile]].IsFull) ? tilePalettes[tile] : 0;
                            bytes = new byte[GBA.Tile.LENGTH];

                            for (int y = 0; y < 8; y++)
                            {
                                for (int x = 0; x < 4; x++)
                                {
                                    color     = image.GetColor(tileX * 8 + x * 2, tileY * 8 + y);
                                    pixel     = GBA.Color.GetNearest(Palettes[index], color);
                                    LO_nibble = (pixel == -1) ? (byte)0x00 : (byte)(pixel);

                                    color     = image.GetColor(tileX * 8 + x * 2 + 1, tileY * 8 + y);
                                    pixel     = GBA.Color.GetNearest(Palettes[index], color);
                                    HI_nibble = (pixel == -1) ? (byte)0x00 : (byte)(pixel);

                                    bytes[x + y * 4] = (byte)((HI_nibble << 4) | LO_nibble);
                                }
                            }

                            currentTile = new Tile(bytes);

                            if (checkRedundantTiles)
                            {
                                if (currentTile.IsEmpty())
                                {
                                    current = Tuple.Create(0, false, false);
                                }
                                else
                                {
                                    current = Graphics.FindMatch(currentTile);

                                    if (current == null)
                                    {
                                        current = Tuple.Create(Graphics.Count, false, false);
                                        Graphics.Add(currentTile);
                                    }
                                }
                            }
                            else
                            {
                                current = Tuple.Create(Graphics.Count, false, false);
                                Graphics.Add(currentTile);
                            }
                            // try {
                            Tiling[tileX, tileY] = new TSA(
                                (UInt16)current.Item1,
                                tilePalettes[tile],
                                current.Item2,
                                current.Item3);
                            // } catch { }

                            loading.SetPercent(60 + 40 * ((float)tile / (float)tileAmount));
                            tile++;
                        }
                    }
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// 查询同步过的数据
        /// </summary>
        /// <param name="obj"></param>
        private void ShowData(object obj)
        {
            DataTable dt = obj as DataTable;

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    intDetailCount = dt.Rows.Count;
                    DataRow dr = dt.Rows[0];

                    #region 基础信息
                    info_status_yt = CommonCtrl.IsNullToString(dr["info_status_yt"]);                     //宇通单据状态
                    laboldpart_receipts_no.Text  = CommonCtrl.IsNullToString(dr["oldpart_receipts_no"]);  //旧件回收单号
                    labservice_station_code.Text = CommonCtrl.IsNullToString(dr["service_station_code"]); //服务站编码
                    labservice_station_name.Text = CommonCtrl.IsNullToString(dr["service_station_name"]); //服务站名称
                    string CreateTime = CommonCtrl.IsNullToString(dr["create_time_yt"]);                  //创建时间
                    if (!string.IsNullOrEmpty(CreateTime))
                    {
                        labytcreate_time.Text = Common.UtcLongToLocalDateTime(Convert.ToInt64(CreateTime)).ToString();
                    }
                    string DepotTime = CommonCtrl.IsNullToString(dr["depot_time"]);//回厂时间
                    if (!string.IsNullOrEmpty(DepotTime))
                    {
                        labdepot_time.Text = Common.UtcLongToLocalDateTime(Convert.ToInt64(DepotTime)).ToString();
                    }
                    string NitarizeTime = CommonCtrl.IsNullToString(dr["notarize_time"]);//确认时间
                    if (!string.IsNullOrEmpty(NitarizeTime))
                    {
                        labnotarize_time.Text = Common.UtcLongToLocalDateTime(Convert.ToInt64(NitarizeTime)).ToString();
                    }
                    labsum_money.Text = CommonCtrl.IsNullToString(dr["sum_money"]); //旧件回收费用
                    strId             = CommonCtrl.IsNullToString(dr["return_id"]); //旧件返厂单Id
                    #endregion

                    #region 详细信息
                    DataTable dmt = DBHelper.GetTable("宇通旧件返厂明细数据", "tb_maintain_oldpart_recycle_material_detail", "*", string.Format(" maintain_id='{0}'", strId), "", "");
                    if (dmt.Rows.Count > 0)
                    {
                        if (dmt.Rows.Count > dgvMaterials.Rows.Count)
                        {
                            dgvMaterials.Rows.Add(dmt.Rows.Count - dgvMaterials.Rows.Count + 1);
                        }
                        for (int i = 0; i < dmt.Rows.Count; i++)
                        {
                            DataRow dmr = dmt.Rows[i];
                            dgvMaterials.Rows[i].Cells["service_no"].Value          = CommonCtrl.IsNullToString(dmr["service_no"]);
                            dgvMaterials.Rows[i].Cells["parts_code"].Value          = CommonCtrl.IsNullToString(dmr["parts_code"]);
                            dgvMaterials.Rows[i].Cells["parts_name"].Value          = CommonCtrl.IsNullToString(dmr["parts_name"]);
                            dgvMaterials.Rows[i].Cells["change_num"].Value          = CommonCtrl.IsNullToString(dmr["change_num"]);
                            dgvMaterials.Rows[i].Cells["send_num"].Value            = CommonCtrl.IsNullToString(dmr["send_num"]);
                            dgvMaterials.Rows[i].Cells["receive_num"].Value         = CommonCtrl.IsNullToString(dmr["receive_num"]);
                            dgvMaterials.Rows[i].Cells["unit"].Value                = CommonCtrl.IsNullToString(dmr["unit"]);
                            dgvMaterials.Rows[i].Cells["unit_price"].Value          = CommonCtrl.IsNullToString(dmr["unit_price"]);
                            dgvMaterials.Rows[i].Cells["need_recycle_mark"].Value   = CommonCtrl.IsNullToString(dmr["need_recycle_mark"]);
                            dgvMaterials.Rows[i].Cells["all_recycle_mark"].Value    = CommonCtrl.IsNullToString(dmr["all_recycle_mark"]);
                            dgvMaterials.Rows[i].Cells["original"].Value            = CommonCtrl.IsNullToString(dmr["original"]);
                            dgvMaterials.Rows[i].Cells["identity_state"].Value      = CommonCtrl.IsNullToString(dmr["identity_state"]);
                            dgvMaterials.Rows[i].Cells["second_station_code"].Value = CommonCtrl.IsNullToString(dmr["second_station_code"]);
                            dgvMaterials.Rows[i].Cells["process_mode"].Value        = CommonCtrl.IsNullToString(dmr["process_mode"]);
                            dgvMaterials.Rows[i].Cells["remarks"].Value             = CommonCtrl.IsNullToString(dmr["remarks"]);
                            dgvMaterials.Rows[i].Cells["receive_explain"].Value     = CommonCtrl.IsNullToString(dmr["receive_explain"]);
                            dgvMaterials.Rows[i].Cells["parts_id"].Value            = CommonCtrl.IsNullToString(dmr["parts_id"]);
                        }
                    }
                    #endregion
                }
                else
                {
                    FormLoading.EndLoading();
                    MessageBoxEx.Show("该日期范围内暂无数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                    return;
                }
            }
            FormLoading.EndLoading();
        }
コード例 #17
0
        /// <summary>
        /// Processes a battle animation from a txt file, reading all referenced image files
        /// </summary>
        public BattleAnimMaker(string folder, string[] file)
        {
            FormLoading loading = new FormLoading();

            loading.SetMessage("Processing animation...");
            loading.Show();

            AnimCode = new List <string> [12];
            Graphics = new List <TileSheet>();
            for (int i = 0; i < AnimCode.Length; i++)
            {
                AnimCode[i] = new List <string>();
            }
            AddTileSheet();

            Palettes = Palette.Split(GetPaletteFromFile(folder), 4);



            Frames    = new List <OAM_Array>();
            FrameData = new List <Tuple <uint, uint> >();
            List <string> filenames = new List <string>();
            List <Tuple <string, Point, Size> > affines = new List <Tuple <string, Point, Size> >();
            CompileMode compile   = CompileMode.Usual;
            bool        new_frame = true;
            int         mode      = 0; // the current animation mode being processed
            int         frame     = 0; // the current frame number
            int         affine    = 0; // the current affine sprite number
            int         duration  = 0; // the current frame's duration

            decimal[] arguments;
            for (int line = 0; line < file.Length; line++)
            {
                loading.SetPercent(100 * ((float)line / (float)file.Length));
                loading.SetMessage("Processing Anim Mode" +
                                   ((mode == 0 || mode == 2 || mode == 8) ?
                                    "s " + (mode + 1) + " and " + (mode + 2) :
                                    " " + (mode + 1)) + "...");

                if (file[line] == null)
                {
                    continue;
                }
                else if (file[line] == "")
                {
                    continue;
                }
                else //try
                {
                    for (int i = 0; i < file[line].Length; i++)
                    {
                        // Comments
                        if (file[line][i] == '#')
                        {
                            break;
                        }
                        if (file[line][i] == '/' && file[line][i + 1] == '/')
                        {
                            break;
                        }

                        // Syntax
                        switch (file[line][i])
                        {
                        case ' ': continue;

                        case '\t': continue;

                        case 'c':
                        case 'C':
                            if (compile == CompileMode.Extra)
                            {
                                compile = CompileMode.Usual;
                            }
                            if (compile == CompileMode.Usual)
                            {
                                AnimCode[mode].Add("c" + file[line].Substring(i + 1, 2));
                                if (mode == 0 || mode == 2)
                                {
                                    AnimCode[mode + 1].Add("c" + file[line].Substring(i + 1, 2));
                                }
                                i += 2;
                                continue;
                            }
                            else
                            {
                                throw new Exception("Unexpected 'c' command read.");
                            }

                        case '0':
                        case '1':
                        case '2':
                        case '3':
                        case '4':
                        case '5':
                        case '6':
                        case '7':
                        case '8':
                        case '9':
                            if (compile == CompileMode.Extra)
                            {
                                compile = CompileMode.Usual;
                            }
                            if (compile == CompileMode.Usual)
                            {
                                int length = 0;
                                while (i + length < file[line].Length)
                                {
                                    if (file[line][i + length] == ' ' ||
                                        file[line][i + length] == '\t')
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        length++;
                                    }
                                }
                                try
                                {
                                    duration = int.Parse(file[line].Substring(i, length));
                                }
                                catch
                                {
                                    throw new Exception("Invalid duration number read:" + file[line].Substring(i, length));
                                }
                                compile = CompileMode.Frame;
                                i      += (length - 1);
                                continue;
                            }
                            else
                            {
                                throw new Exception("Unexpected frame duration number read.");
                            }

                        case 'f':
                        case 'F':
                        case 'b':
                        case 'B':
                            bool bg = (file[line][i] == 'b' || file[line][i] == 'B');
                            if ((bg && compile == CompileMode.Extra) || compile == CompileMode.Frame)
                            {
                                i++;
                                string filename = ReadArgument_FileName(ref file, ref line, ref i);
                                frame     = -1;
                                new_frame = true;
                                for (int f = 0; f < filenames.Count; f++)
                                {
                                    if (filename.Equals(filenames[f]))
                                    {
                                        frame     = f;
                                        new_frame = false;
                                        break;
                                    }
                                }
                                if (frame == -1)
                                {
                                    frame = filenames.Count;
                                    filenames.Add(filename);
                                    AddFrame(bg, new GBA.Image(folder + filename, Palettes[0]), filename);
                                }       // add the new frame's OAM if it hasn't yet been used

                                if (bg)
                                {
                                    if (mode == 0 || mode == 2 || mode == 8)
                                    {
                                        AnimCode[mode + 1][AnimCode[mode + 1].Count - 1] = duration + " f" + Util.ByteToHex((byte)frame);
                                    }
                                    else
                                    {
                                        throw new Exception("'b' background layer frame commands can only be used in animation modes 1, 3 and 9.");
                                    }
                                }
                                else
                                {
                                    AnimCode[mode].Add(duration + " f" + Util.ByteToHex((byte)frame));
                                    if (mode == 0 || mode == 2 || mode == 8)
                                    {
                                        AnimCode[mode + 1].Add(duration + " fFF");
                                    }
                                }

                                compile = CompileMode.Extra;
                                continue;
                            }
                            else
                            {
                                throw new Exception("Unexpected '" + (bg ? 'b' : 'f') + "' frame command read.");
                            }

                        case 'a':
                        case 'A':
                        case 'd':
                        case 'D':
                            bool big = (file[line][i] == 'd' || file[line][i] == 'D');
                            if (compile == CompileMode.Extra)
                            {
                                i++;
                                string affinefile = ReadArgument_FileName(ref file, ref line, ref i);
                                i++;
                                arguments = ReadArgument_Numbers(ref file, ref line, ref i);
                                if (arguments.Length != 2)
                                {
                                    throw new Exception(
                                              "Expected affine sprite X and Y screen coordinates.");
                                }
                                Point coords = new Point((int)arguments[0], (int)arguments[1]);

                                arguments = ReadArgument_Numbers(ref file, ref line, ref i);
                                if (arguments.Length != 1 && arguments.Length != 4)
                                {
                                    throw new Exception(
                                              "Expected affine sprite (angle) argument, or (Ux, Vx, Uy, and Vy) vector arguments.");
                                }
                                float[] vectors;
                                if (arguments.Length == 1)     // convert angle into (Ux Vx Uy Vy)
                                {
                                    float cos = (float)Math.Cos((double)arguments[0]);
                                    float sin = (float)Math.Sin((double)arguments[1]);
                                    vectors = new float[4] {
                                        cos, sin, -sin, cos
                                    };
                                }
                                else
                                {
                                    vectors = new float[4]
                                    {
                                        (float)arguments[0],
                                        (float)arguments[1],
                                        (float)arguments[2],
                                        (float)arguments[3]
                                    }
                                };
                                if (new_frame == false)
                                {       // if there's an affine on a preexisting frame, duplicate the OAM data
                                    if (AddDuplicateFrameWithAffines(mode, ref frame, ref filenames, coords, vectors))
                                    {   // if it returned true, that means an identical frame with identical affine exists
                                        continue;
                                    }
                                }
                                affine = -1;
                                for (int a = 0; a < affines.Count; a++)
                                {
                                    if (affinefile.Equals(affines[a].Item1))
                                    {
                                        affine = a;
                                        break;
                                    }
                                }
                                if (affine == -1)
                                {
                                    affine = affines.Count;
                                    Tuple <Point, Size> sheet = AddAffineToTilesheet(
                                        frame, new GBA.Image(folder + affinefile, Palettes[0]));
                                    affines.Add(Tuple.Create(affinefile, sheet.Item1, sheet.Item2));
                                }
                                AddAffine(big, frame, coords, vectors,
                                          affines[affine].Item2, affines[affine].Item3);
                                continue;
                            }
                            else
                            {
                                throw new Exception("Unexpected '" + (big ? 'd' : 'a') + "' affine command read.");
                            }

                        case 'e':
                        case 'E':
                            if (compile == CompileMode.Extra)
                            {
                                compile = CompileMode.Usual;
                            }
                            if (compile == CompileMode.Usual)
                            {
                                if ((file[line][i + 1] == 'n' || file[line][i + 1] == 'N') &&
                                    (file[line][i + 2] == 'd' || file[line][i + 2] == 'D'))
                                {
                                    AnimCode[mode].Add("end");
                                    if (mode == 0 || mode == 2 || mode == 8)
                                    {
                                        AnimCode[mode + 1].Add("end");
                                        mode += 2;
                                    }
                                    else
                                    {
                                        mode++;
                                    }
                                    i += 2;
                                    continue;
                                }
                                else
                                {
                                    throw new Exception("Invalid terminator read:" + file[line].Substring(i, 3));
                                }
                            }
                            else
                            {
                                throw new Exception("Unexpected terminator read.");
                            }

                        default: throw new Exception("Unexpected character: " + file[line][i]);
                        }
                    }
                }/*
                  * catch (Exception ex)
                  * {
                  * throw new Exception("At line " + line + ":\r\n'" + file[line] + "'\r\n" + ex.Message);
                  * }*/
            }
            uint emptyFrame = (uint)(Frames[0].Sprites.Count * OAM.LENGTH);

            // this uint is just the offset to the 1st terminator, so it produces an empty frame
            while (FrameData.Count < 256)
            {
                FrameData.Add(Tuple.Create((uint)0x00000000, emptyFrame));
            }   // fill framedata with empty frames so 'fFF' commands or such are proeperly compiled
            int oam_total = 0;

            for (int i = 0; i < Frames.Count; i++)
            {
                oam_total +=
                    Frames[i].Affines.Count * OAM.LENGTH +
                    Frames[i].Sprites.Count * OAM.LENGTH +
                    OAM.LENGTH;
            }
            if (oam_total > BattleAnimation.MAXIMUM_OAM_LENGTH)
            {
                Program.ShowWarning("The final OAM block is too large: " + oam_total +
                                    "\nIt should weigh " + BattleAnimation.MAXIMUM_OAM_LENGTH + " bytes or less.");
            }
        }
コード例 #18
0
        private void LoginResult(object obj)
        {
            this.uiHandler -= new UiHandler(this.LoginResult);

            if (this.enableFlag)
            {
                return;
            }

            this.timer.Enabled = false;

            string errMsg = obj.ToString();

            if (!string.IsNullOrEmpty(errMsg))
            {
                FormLoading.EndLoading();
                FormMessgeBox.ShowMsg(this, errMsg, this.panelTop.BackColor);
                this.enableFlag = true;
                return;
            }

            if (HXCPcClient.GlobalStaticObj.gLoginDataSet == null)
            {
                FormMessgeBox.ShowMsg(this, "数据加载失败!", this.panelTop.BackColor);
                FormLoading.EndLoading();
                this.enableFlag = true;
                return;
            }

            if (HXCPcClient.GlobalStaticObj.gLoginDataSet.Tables[0].Rows.Count < 1)
            {
                FormLoading.EndLoading();
                this.enableFlag = true;
                return;
            }

            try
            {
                #region  务站信息   add by kord
                var dr = DBHelper.GetTable("获取当前服务站信息", GlobalStaticObj.CommAccCode, "tb_company", "*", "data_source = '2'", "", "");
                if (dr == null || dr.Rows.Count == 0)
                {
                    GlobalStaticObj.GlobalLogService.WriteLog("无法获取当前服务站信息");
                }
                else
                {
                    GlobalStaticObj.ServerStationCode = CommonCtrl.IsNullToString(dr.Rows[0]["sap_code"]);
                    GlobalStaticObj.ServerStationName = CommonCtrl.IsNullToString(dr.Rows[0]["com_name"]);
                }
                #endregion

                GlobalStaticObj.CookieStr            = GlobalStaticObj.gLoginDataSet.Tables["cookieStr"].Rows[0][0].ToString();
                GlobalStaticObj.UserID               = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_id"].ToString();
                GlobalStaticObj.UserName             = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["user_name"].ToString();
                GlobalStaticObj.LandName             = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["land_name"].ToString();
                GlobalStaticObj.PassWord             = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["password"].ToString();
                GlobalStaticObj.CurrUserCom_Id       = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_id"].ToString();
                GlobalStaticObj.CurrUserCom_Code     = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_code"].ToString();
                GlobalStaticObj.CurrUserCom_Name     = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["com_name"].ToString();
                GlobalStaticObj.CurrUserOrg_Id       = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_id"].ToString();
                GlobalStaticObj.CurrUserOrg_Name     = GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["org_name"].ToString();
                GlobalStaticObj.CurrUserCom_Category = CommonCtrl.IsNullToString(HXCPcClient.GlobalStaticObj.gLoginDataSet.Tables[0].Rows[0]["category"]);  //modify by kord
            }
            catch (Exception ex)
            {
                //write log
            }

            ThreadPool.SetMinThreads(3, 3);
            ThreadPool.SetMaxThreads(5, 5);

            //预加载信息
            LocalCache.PreLoad();

            //记忆登录保存
            this.SaveMemery();

            FormLoading.EndLoading();
            this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态
        }