Exemple #1
0
        private void fw_Renamed(object sender, System.IO.RenamedEventArgs e)
        {
            SetText wryt = new SetText(SetMsg);
            string  msg  = string.Format("{0}: {1} to {2}", e.ChangeType.ToString(), e.OldFullPath, e.FullPath);

            this.Invoke(wryt, msg);
        }
 protected override void Execute(NativeActivityContext context)
 {
     try
     {
         //ThreadInvoker.Instance.RunByUiThread(() =>
         //{
         string ScreenPath = ImagePath.Get(context);
         if ((ScreenPath != null) && (ScreenPath != string.Empty))
         {
             if (File.Exists(ScreenPath))
             {
                 string           sValue         = SetText.Get(context);
                 GetSetClick      getSetClick    = new GetSetClick();
                 ImageRecognition imgRecognition = new ImageRecognition();
                 getSetClick = GetSetClick.Set;
                 bool result = imgRecognition.GetSetClickImage(ScreenPath, getSetClick, sValue, 10000, accuracy);
                 Result.Set(context, result);
             }
         }
         //});
     }
     catch (Exception ex)
     {
         Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndSetText", Logger.LogLevel.Error);
         if (!ContinueOnError)
         {
             context.Abort();
         }
     }
 }
        /// <summary>
        /// 设置状态条的文本
        /// </summary>
        /// <param name="toolStripLabel">状态条Lable对象</param>
        /// <param name="text">待设置的文本</param>
        public void SafeSetText(ToolStripLabel toolStripLabel, string text)
        {
            if (InvokeRequired)
            {
                SetText setTextDel = delegate(ToolStripLabel toolStrip, string textVal)
                {
                    foreach (ToolStripItem item in base.Items)
                    {
                        if (item == toolStrip)
                        {
                            item.Text = textVal;
                        }
                    }
                };

                try
                {
                    Invoke(setTextDel, new object[] { toolStripLabel, text });
                }
                catch
                {
                }
            }
            else
            {
                foreach (ToolStripItem item in base.Items)
                {
                    if (item == toolStripLabel)
                    {
                        item.Text = text;
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 设置状态条的文本
        /// </summary>
        /// <param name="toolStripLabel">状态条Lable对象</param>
        /// <param name="text">待设置的文本</param>
        public void SafeSetText(ToolStripLabel toolStripLabel, string text)
        {
            if (InvokeRequired)
            {
                SetText setTextDel = delegate(ToolStripLabel toolStrip, string textVal)
                {
                    foreach (ToolStripItem item in base.Items)
                    {
                        if (item == toolStrip)
                        {
                            item.Text = textVal;
                        }
                    }
                };

                try
                {
                    Invoke(setTextDel, new object[] { toolStripLabel, text });
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(SafeStatusStrip));
                }
            }
            else
            {
                foreach (ToolStripItem item in base.Items)
                {
                    if (item == toolStripLabel)
                    {
                        item.Text = text;
                    }
                }
            }
        }
Exemple #5
0
    public void DestroyLine()
    {
        LineRenderer lr = myRoute.GetComponent <LineRenderer>();
        RouteManager rm = routeManager.GetComponent <RouteManager>();

        if (rm.getTargetPlanet().Equals(this.gameObject) || rm.getTargetPlanet().name.Equals("Background"))
        {
            Destroy(myRoute);
        }
        else
        {
            if (rm.planetDict[this.gameObject.name].Contains(rm.getTargetPlanet()))
            {
                Destroy(myRoute);
                //Debug.Log(rm.getTargetPlanet().transform.position);
            }
            else
            {
                Console = GameObject.Find("console");
                rm.CreateRoute(this.gameObject, rm.getTargetPlanet());
                //PlanetData pd = rm.getTargetPlanet().GetComponent<PlanetData>();
                lr.SetPosition(1, transform.InverseTransformPoint(rm.getTargetPlanet().transform.position));
                myRoute.GetComponent <RouteUpdater>().initialize(rm.getTargetPlanet());
                SetText st = Console.GetComponent <SetText>();
                st.newText("new Route Built from " + this.name + " to " + rm.getTargetPlanet().name);
            }
        }

        /*RaycastHit2D hit;
         * Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         * if (hit = Physics2D.Raycast(ray.origin, new Vector2(0, 0)))
         *  Debug.Log(hit.collider.name);
         */
    }
Exemple #6
0
        public delegate void SetText(string a, string b, string c);//TextChange delegate

        private void ProcessSend(object sender, DoWorkEventArgs e)
        {
            if (_sendIng && serialPort1.IsOpen)
            {
                if (!_manual)
                {
                    String a = "@";
                    if (_fire)
                    {
                        a     = "!";
                        _fire = false;
                    }
                    int xError = (int)(320 - objPoint.X);
                    int yError = (int)(240 - objPoint.Y);
                    if (xError == 320 && yError == 240)
                    {
                        xError = 0; yError = 0;
                    }
                    #region Text delegate
                    SetText      settext = new SetText(TextChange);
                    string       center  = "Center:" + ((int)objPoint.X).ToString("D3") + "," + ((int)objPoint.Y).ToString("D3");
                    string       error   = "Error:" + xError.ToString("D3") + "," + yError.ToString("D3");
                    IAsyncResult aResult = this.BeginInvoke(settext, center, error, reciveddata);
                    aResult.AsyncWaitHandle.WaitOne(1);
                    this.EndInvoke(aResult);
                    #endregion
                    if (xError >= 0)
                    {
                        a += "+";
                    }
                    else
                    {
                        a += "-";
                    }
                    a += Math.Abs(xError).ToString("D3");
                    if (yError >= 0)
                    {
                        a += "+";
                    }
                    else
                    {
                        a += "-";
                    }
                    a += Math.Abs(yError).ToString("D3");
                    try
                    {
                        serialPort1.Write(a);
                    }
                    catch (Exception)
                    {
                        serialPort1.DiscardOutBuffer();
                    }
                    finally
                    {
                        _sendIng = false;
                    }
                }
            }
        }
Exemple #7
0
        private void Loading()
        {
            for (;;)
            {
                //死循环
                for (int n = 1; n < 7; n++)
                {
                    string value = NameLoad("Link" + n.ToString());
                    if (value != null)
                    {
                        foreach (Control item in this.Controls)
                        {
                            if (item.Name == "Link" + n.ToString())
                            {
                                SetText settext = delegate()
                                {
                                    item.Text = value;
                                };
                                item.Invoke(settext);
                            }
                        }
                    }
                    value = NameLoad("Address" + n.ToString());
                    if (value != null)
                    {
                        value = value.Replace("$", "/");
                        switch (n)
                        {
                        case 1:
                            Link1_Address = value;
                            break;

                        case 2:
                            Link2_Address = value;
                            break;

                        case 3:
                            Link3_Address = value;
                            break;

                        case 4:
                            Link4_Address = value;
                            break;

                        case 5:
                            Link5_Address = value;
                            break;

                        case 6:
                            Link6_Address = value;
                            break;
                        }
                    }
                }
                GC.Collect();
                Thread.Sleep(900000);//挂起15分钟
            }
        }//加载消息
Exemple #8
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.R))
     {
         time = 0f;
     }
     SetText.UpdateText(time.ToString("0.##"));
     time += Time.deltaTime;
 }
Exemple #9
0
 private void Awake()
 {
     _rigidbody   = GetComponent <Rigidbody>();
     _boxCollider = GetComponent <BoxCollider>();
     SetBoxCollider(true);
     Vibration.Init();
     _moneyText = GameObject.FindWithTag("Money").GetComponent <SetText>();
     _scoreText = GameObject.FindWithTag("Score").GetComponent <ScoreText>();
 }
Exemple #10
0
 internal static void SetKey(string key)
 {
     if (Form.InvokeRequired)
     {
         SetText setTextDel = SetKey;
         Form.Invoke(setTextDel, new object[] { key });
         return;
     }
     Form.keybox.Text = key;
 }
Exemple #11
0
 public void SetText(String text)
 {
     lock (lockshow)
     {
         if (textBox1.InvokeRequired)
         {
             SetText d = new SetText(SetTextSafe);
             Invoke(d, new object[]{ text });
         }
         else SetTextSafe(text);
     }
 }
Exemple #12
0
 private void Set(string text)
 {
     if (this.textBox2.InvokeRequired)
     {
         SetText d = new SetText(Set);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.textBox2.Text = text;
     }
 }
Exemple #13
0
 private void SetAwardName(string name)
 {
     if (lbAwardName.InvokeRequired)
     {
         SetText st = new SetText(SetAwardName);
         lbAwardName.Invoke(st, new object[] { name });
     }
     else
     {
         lbAwardName.Text = name;
     }
 }
Exemple #14
0
 public void SetInfo(String str)
 {
     lock (lockshow)
     {
         if (labelx.InvokeRequired)
         {
             SetText d = new SetText(SetInfoSafe);
             Invoke(d, new object[] { str });
         }
         else SetInfoSafe(str);
     }
 }
Exemple #15
0
        public void CommandTextCommand()
        {
            var command = new SetText(0, "Hallo!");
            var bytes   = command.GetBytes();

            Assert.AreEqual(bytes.Length, 6);
            Assert.AreEqual(bytes[0], 72);
            Assert.AreEqual(bytes[1], 97);
            Assert.AreEqual(bytes[2], 108);
            Assert.AreEqual(bytes[3], 108);
            Assert.AreEqual(bytes[4], 111);
            Assert.AreEqual(bytes[5], 33);
        }
        public static Dictionary <string, object> ToParameters(this SetText setText, Domain domain, IEnumerable <IDevice> devices)
        {
            switch (domain)
            {
            case Domain.InputText:
                return(new Dictionary <string, object>
                {
                    { "value", setText.Value }
                }
                       .Add(devices));

            default:
                throw new NotSupportedException($"Domain '{domain}' does not support command SetSpeed, but one or more device tries to use it ({devices.Select(d => d.Id.ToString()).JoinBy(", ")})");
            }
        }
Exemple #17
0
        //下载和保存壁纸
        private void downloadPic(string url, string path)
        {
            SetText setText = () => { state.Text = "正在下载壁纸..."; };

            state.Invoke(setText);
            try
            {
                HttpWebRequest getImage = (HttpWebRequest)WebRequest.Create(url);
                getImage.ServicePoint.Expect100Continue = false;
                getImage.Method      = "GET";
                getImage.KeepAlive   = true;
                getImage.Credentials = CredentialCache.DefaultCredentials;
                getImage.Accept      = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
                getImage.Headers.Add("Accept-Language", "zh-CN");
                getImage.UserAgent   = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1)";
                getImage.ContentType = "application/x-www-form-urlencoded";
                HttpWebResponse image  = (HttpWebResponse)getImage.GetResponse();
                Stream          stream = null;
                stream = image.GetResponseStream();
                if (stream != null)
                {
                    Image.FromStream(stream).Save(@"temp/temp.jpg");
                    JPGtoBMP(@"temp/temp.jpg", path);
                    stream.Dispose();
                    stream.Close();
                    image.Close();
                    System.IO.File.Delete(@"temp/temp.jpg");
                }
                else
                {
                    stream.Dispose();
                    stream.Close();
                    image.Close();
                    errorTimer();
                }
                setText = () => { state.Text = ""; };
                state.Invoke(setText);
            }
            catch (Exception ex)
            {
                if (debug)
                {
                    MessageBox.Show("下载壁纸时出错:" + ex.Message + "\n详细信息:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                errorTimer();
            }
        }
Exemple #18
0
 internal static void SetStatus(string input)
 {
     if (Form.InvokeRequired)
     {
         SetText setTextDel = SetStatus;
         Form.Invoke(setTextDel, new object[] { input });
         return;
     }
     if (_doResize)
     {
         Form.SetStatus(input);
     }
     else
     {
         Form.status.Text = input;
     }
 }
Exemple #19
0
        public static string[] GenerateLinesFromText(string input, int counter)
        {
            //TODO: improve italic support
            var text = Utilities.RemoveSsaTags(input);

            text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagFont, HtmlUtil.TagBold);
            var results = new List <string>();
            var bytes   = new List <byte>();
            var italic  = text.StartsWith("<i>");

            text = HtmlUtil.RemoveOpenCloseTags(text, HtmlUtil.TagItalic);
            var lines    = text.SplitToLines();
            var commands = new List <ICea708Command>
            {
                new DefineWindow(lines.Count),
                new SetWindowAttributes(SetWindowAttributes.JustifyCenter),
                new SetPenAttributes(italic),
                new SetPenColor(),
            };

            foreach (var command in commands)
            {
                bytes.AddRange(command.GetBytes());
            }
            commands.Clear();

            foreach (var line in lines)
            {
                var c1 = new SetPenLocation();
                if (c1.GetBytes().Length + bytes.Count > 32)
                {
                    counter = FlushCommands(counter, bytes, results);
                }
                bytes.AddRange(c1.GetBytes());

                var c2 = new SetText(line);
                if (c2.GetBytes().Length + bytes.Count > 32)
                {
                    counter = FlushCommands(counter, bytes, results);
                }
                bytes.AddRange(c2.GetBytes());
            }

            FlushCommands(counter, bytes, results);
            return(results.ToArray());
        }
Exemple #20
0
        private void SetLbText(string str)
        {
            str = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + str + "\n";

            if (textBox2.InvokeRequired)
            {
                SetText st = new SetText(delegate(string text)
                {
                    textBox2.AppendText(text);
                });
                textBox2.Invoke(st, str);
            }
            else
            {
                textBox2.AppendText(str);
            }
        }
 public void SetRichBoxText(string text)
 {
     if (richTextBox_status.InvokeRequired)
     {
         SetText objSet = new SetText(SetRichBoxText);
         richTextBox_status.Invoke(objSet, new object[] { text });
     }
     else
     {
         if (text.Contains("警告"))
         {
             richTextBox_status.SelectionColor = Color.Red;
         }
         richTextBox_status.AppendText(text + "\n");
         richTextBox_status.SelectionStart = richTextBox_status.TextLength;
         richTextBox_status.ScrollToCaret();
     }
 }
Exemple #22
0
        public static void Show(object sender, CalculatorEventArgs e)
        {
            try
            {
                string Str;
                Str = "Количество полупростых чисел на промежутке [" + e.begin + ";" + e.end + "] : " + e.amount + "\n";

                set_t = new SetText(SetT);
                Form1.textBox1.Invoke(set_t, Str);
                Thread.Sleep(e.time);

                Calculator calc = new Calculator(e.time);
                calc.Calc += Demonstrator.Show;
                calc.Calculate();
            }
            catch (Exception)
            { }
        }
Exemple #23
0
        // note that this function runs in a separate thread and thus we must use a
        // delegate in order
        // to display the results in the richTextBox.
        private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            // instantiate the delegate to be invoked by this thread
            setText = new SetText(mySetText);
            // load the data into the string
            try
            {
                //str = serialPort1.ReadExisting();
                str = serialPort1.ReadLine(); // Read until we have a linefeed
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error – port_DataReceived Exception: " + ex);
            }

            // invoke the delegate in the MainForm thread
            this.Invoke(setText);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {

                    //XMLDictionaryListRequest request = new XMLDictionaryListRequest();

                    //request.database = "2";
                    //ListResponse<XMLDictionary> resp = _systemService.ChildGetAll<XMLDictionary>(request);
                    //if (!resp.Success)
                    //{
                    //    Common.errorMessage(resp);
                    //    return;
                    //}
                    salaryTypeList.AddRange(Common.XMLDictionaryList(_systemService,"2"));
                    FillSalaryTypeStore();
                    //  salaryTypeId.Select(0);
                    if (string.IsNullOrEmpty(Width))
                    {
                     
                        this.salaryTypeId.SetWidth(Convert.ToInt16(Width));
                    }

                    if (string.IsNullOrEmpty(SetText))

                        this.salaryTypeId.EmptyText = GetGlobalResourceObject("Common", "SalaryType").ToString();
                    else
                        this.salaryTypeId.FieldLabel = SetText.ToString();
                    if (!string.IsNullOrEmpty(setLabelWidth))
                        this.salaryTypeId.LabelWidth = Convert.ToInt32(setLabelWidth);
                    
                }
                
            }
            catch(Exception exp)

            {
             

            }
        }
Exemple #25
0
    private void Awake()
    {
        textList.Add(topText);
        textList.Add(midleText);
        textList.Add(bottomText1);
        textList.Add(bottomText2);
        textList.Add(bottomText3);

        setBoll = false;
        if (setText == null)
        {
            setText = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
    }
Exemple #26
0
        public static string[] GenerateLinesFromText(string text, int counter)
        {
            //TODO: chunk in max 32 bytes chunks (do not split commands)
            var results  = new List <string>();
            var bytes    = new List <byte>();
            var lines    = text.SplitToLines();
            var commands = new List <ICommand>
            {
                new DefineWindow(lines.Count),
                new SetWindowAttributes(SetWindowAttributes.JustifyCenter),
                new SetPenAttributes(false),
                new SetPenColor(),
            };

            foreach (var command in commands)
            {
                bytes.AddRange(command.GetBytes());
            }
            commands.Clear();

            foreach (var line in lines)
            {
                var c1 = new SetPenLocation();
                if (c1.GetBytes().Length + bytes.Count > 32)
                {
                    counter = FlushCommands(counter, bytes, results);
                }
                bytes.AddRange(c1.GetBytes());

                var c2 = new SetText(line);
                if (c2.GetBytes().Length + bytes.Count > 32)
                {
                    counter = FlushCommands(counter, bytes, results);
                }
                bytes.AddRange(c2.GetBytes());
            }

            FlushCommands(counter, bytes, results);
            return(results.ToArray());
        }
Exemple #27
0
 //遇到错误重新执行的倒计时(只允许在非主线程上运行)
 private void errorTimer()
 {
     if (mainThreadID != Thread.CurrentThread.ManagedThreadId)
     {
         for (int i = 3; i > 0; i--)
         {
             SetText setText = () =>
             {
                 state.Text = "遇到错误,将在" + i.ToString() + "秒后重试...";
             };
             state.Invoke(setText);
             Thread.Sleep(1000);
         }
         if (backgroundOriginChoose.SelectedIndex == 0)
         {
             _downloadBingDaily("temp\\Pic.bmp");
         }
         else
         {
             _downloadBingRand("temp\\randPic.bmp");
         }
     }
 }
Exemple #28
0
        public void SetTextBoxValue(string textValue)
        {
            if (this.textBox1.InvokeRequired)
            {

                SetText del = new SetText(this.SetTextBoxValue);

                this.textBox1.Invoke(del, new object[] { textValue });

            }

            else
            {
                line++;
                if (line > 10)
                {
                    line = 1;
                    this.textBox1.Text = "";
                }
                this.textBox1.Text += "\n" + textValue + "\r\n";

            }
        }
 private void AddText(TextBox t, string text, bool flag)
 {
     if (t.InvokeRequired)
     {
         SetText d = new SetText(AddText);
         //this.Invoke(d, new object[] { t, text, f }); //???
         //is.Invoke(d, t, text); //???
         this.Invoke(d, t, text, f); //???
     }
     else
     {
         if (flag)
         {
             t.AppendText(text + Environment.NewLine);
         }
         else
         {
             textBox7.ReadOnly = false;
             textBox8.ReadOnly = false;
             t.Clear();
             t.AppendText(text);
         }
     }
 }
Exemple #30
0
        public static string AnyscMD5(string filepath, ProgressBar pBar, Label lab)
        {
            FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
            int bufferSize = 1048576; // 缓冲区大小,1MB
            byte[] buff = new byte[bufferSize];
            double blockcount = Math.Ceiling(fs.Length / Convert.ToDouble(bufferSize));
            if (pBar.InvokeRequired == true)
            {
                SetText LSetText = new SetText(DoSetText);
                SetValue PSetValue = new SetValue(DoSetMax);
                pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(blockcount) });
                lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(0) + "%" });
            }
            int i = 1;
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            md5.Initialize();
            long offset = 0;
            while (offset < fs.Length)
            {
                long readSize = bufferSize;
                if (offset + readSize > fs.Length)
                {
                    readSize = fs.Length - offset;
                }

                fs.Read(buff, 0, Convert.ToInt32(readSize)); // 读取一段数据到缓冲区

                if (offset + readSize < fs.Length) // 不是最后一块
                {
                    md5.TransformBlock(buff, 0, Convert.ToInt32(readSize), buff, 0);
                }
                else // 最后一块
                {
                    md5.TransformFinalBlock(buff, 0, Convert.ToInt32(readSize));
                }
                offset += bufferSize;
                if (pBar.InvokeRequired == true)
                {
                    SetValue PSetValue = new SetValue(DoSetValue);
                    SetText LSetText = new SetText(DoSetText);
                    pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(i) });
                    lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(Math.Ceiling((double)(i / blockcount) * 100)) + "%" });
                    i++;
                    Application.DoEvents();
                }
            }
            fs.Close();
            byte[] result = md5.Hash;
            md5.Clear();
            StringBuilder sb = new StringBuilder(32);
            for (int j = 0; j < result.Length; j++)
            {
                sb.Append(result[j].ToString("x2"));
            }
            return sb.ToString();
        }
 /// <summary>
 /// 类的初始化,当仅需要发送数据 而不接收时使用
 /// </summary>
 public SocketMessageMng()
 {
     Sendtxt = new SetText(SendRecData);
 }
Exemple #32
0
 private void SetAwardName(string name)
 {
     if (lbAwardName.InvokeRequired)
     {
         SetText st= new SetText(SetAwardName);
         lbAwardName.Invoke(st,new object[]{name});
     }
     else
     {
         lbAwardName.Text = name;
     }
 }
Exemple #33
0
    //private int m_fade_hash = Animator.StringToHash("Fade Text");
    //private int m_hidden_hash = Animator.StringToHash("Hidden Text");

    void Awake()
    {
        m_anim = GetComponent <Animator>();
        m_text = GetComponent <SetText>();
        //Debug.Log(anim.ToString());
    }
Exemple #34
0
        public static unsafe int Patch(string hPatchs, string hSources, string hDests, ProgressBar pBar, Label lab, int FileID)
        {
            try
            {
                if (pBar.InvokeRequired == true)
                {
                    SetValue PSetValue = new SetValue(DoSetValue);
                    SetText  LSetText  = new SetText(DoSetText);
                    pBar.Invoke(PSetValue, new Object[] { pBar, 0 });
                    lab.Invoke(LSetText, new Object[] { lab, "0%" });
                }
                UInt32   BLOCKSIZE = 16384;
                UInt32   temp      = 0;
                UInt32   read;
                byte[]   source_md5 = new byte[16];
                byte[]   patch_dest_md5 = new byte[16];
                byte[]   block = new byte[BLOCKSIZE];
                int      MD5Mode = 0;
                UInt32   patches = 0;
                int      already_uptodate = 0, j = 1;
                double   blocks;
                FILETIME targetModifiedTime;
                DateTime dte = new DateTime();
                //write回调方法
                FileStream Patchs  = new FileStream(hPatchs, FileMode.Open, FileAccess.Read, FileShare.Read);
                FileStream Sources = new FileStream(hSources, FileMode.Open, FileAccess.Read, FileShare.Read);
                FileStream Dests   = new FileStream(hDests, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                Hashtable  Data    = Program.filehash;
                // special 'addition' for the dll: since the patch file is now
                // in a seperate file, the VPAT header might be right at the start
                // of the file, and a pointer at the end of the file is probably missing
                // (because all patch generator versions don't append it, the linker/gui
                //  does this).
                Patchs.Seek(0, SeekOrigin.Begin);
                temp = Patchs.ReadValueU32(); read = 4;
                // it's not at the start of file -> there must be a pointer at the end of
                // file then
                if (temp != 0x54415056)
                {
                    Patchs.Seek(-4, SeekOrigin.End);
                    temp = Patchs.ReadValueU32(); read = 4;
                    Patchs.Seek(temp, SeekOrigin.Begin);
                    temp = Patchs.ReadValueU32(); read = 4;
                    if (temp != 0x54415056)
                    {
                        return(result.PATCH_CORRUPT);
                    }
                }

                // target file date is by default the current system time
                GetSystemTimeAsFileTime(&targetModifiedTime);

                // read the number of patches in the file
                patches = Patchs.ReadValueU32(); read = 4;
                if (Convert.ToBoolean(patches & 0x80000000))
                {
                    MD5Mode = 1;
                }
                // MSB is now reserved for future extensions, anyone wanting more than
                // 16 million patches in a single file is nuts anyway
                patches = patches & 0x00FFFFFF;

                if (!Convert.ToBoolean(MD5Mode))
                {
                    return(result.PATCH_UNSUPPORTED);
                }
                else
                {
                    source_md5 = checksum.FileMD5(Sources, Data, FileID, Program.AdvMOD);
                    if (source_md5 == null)
                    {
                        return(result.PATCH_ERROR);
                    }
                }

                //pBar.Maximum = Convert.ToInt32(patches);
                while (Convert.ToBoolean(patches--))
                {
                    int patch_blocks = 0, patch_size = 0;

                    // flag which needs to be set by one of the checksum checks
                    int currentPatchMatchesChecksum = 0;

                    // read the number of blocks this patch has
                    patch_blocks = Convert.ToInt32(Patchs.ReadValueU32()); blocks = patch_blocks; read = 4;
                    if (!Convert.ToBoolean(patch_blocks))
                    {
                        return(result.PATCH_CORRUPT);
                    }
                    if (pBar.InvokeRequired == true)
                    {
                        SetValue PSetValue = new SetValue(DoSetMax);
                        pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(patch_blocks) });
                    }
                    // read checksums
                    if (!Convert.ToBoolean(MD5Mode))
                    {
                        return(result.PATCH_UNSUPPORTED);
                    }
                    else
                    {
                        int    md5index;
                        byte[] patch_source_md5 = new byte[16];
                        patch_source_md5 = Patchs.ReadBytes(16); read = 16;
                        if (patch_source_md5 == null)
                        {
                            return(result.PATCH_CORRUPT);
                        }
                        patch_dest_md5 = Patchs.ReadBytes(16); read = 16;
                        if (patch_dest_md5 == null)
                        {
                            return(result.PATCH_CORRUPT);
                        }
                        // check to see if it's already up-to-date for some patch
                        for (md5index = 0; md5index < 16; md5index++)
                        {
                            if (source_md5[md5index] != patch_dest_md5[md5index])
                            {
                                break;
                            }
                            if (md5index == 15)
                            {
                                already_uptodate = 1;
                            }
                        }
                        for (md5index = 0; md5index < 16; md5index++)
                        {
                            if (source_md5[md5index] != patch_source_md5[md5index])
                            {
                                break;
                            }
                            if (md5index == 15)
                            {
                                currentPatchMatchesChecksum = 1;
                            }
                        }
                    }
                    // read the size of the patch, we can use this to skip over it
                    patch_size = Convert.ToInt32(Patchs.ReadValueU32()); read = 4;
                    if (patch_size == null)
                    {
                        return(result.PATCH_CORRUPT);
                    }

                    if (Convert.ToBoolean(currentPatchMatchesChecksum))
                    {
                        while (Convert.ToBoolean(patch_blocks--))
                        {
                            if (pBar.InvokeRequired == true)
                            {
                                SetValue PSetValue = new SetValue(DoSetValue);
                                SetText  LSetText  = new SetText(DoSetText);
                                pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(j++) });
                                var per = Convert.ToDouble(j - 1) / Convert.ToDouble(blocks);
                                lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(Math.Ceiling(per * 100)) + "%" });
                                Application.DoEvents();
                            }
                            Byte   blocktype = 0;
                            UInt32 blocksize = 0;
                            blocktype = Convert.ToByte(Patchs.ReadByte()); read = 1;
                            if (blocktype == null)
                            {
                                return(result.PATCH_CORRUPT);
                            }
                            switch (blocktype)
                            {
                            case 1:
                            case 2:
                            case 3:
                                if (blocktype == 1)
                                {
                                    Byte x;
                                    x         = Convert.ToByte(Patchs.ReadByte()); read = 1;
                                    blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                }
                                else if (blocktype == 2)
                                {
                                    UInt16 x;
                                    x         = Patchs.ReadValueU16(); read = 2;
                                    blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                }
                                else
                                {
                                    UInt32 x;
                                    x         = Patchs.ReadValueU32(); read = 4;
                                    blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                }
                                temp = Patchs.ReadValueU32(); read = 4;
                                if (!Convert.ToBoolean(blocksize) || temp == null || read != 4)
                                {
                                    return(result.PATCH_CORRUPT);
                                }
                                Sources.Seek(temp, SeekOrigin.Begin);
                                //SetFilePointer(hSource, temp, 0, EMoveMethod.Begin);

                                do
                                {
                                    Sources.Read(block, 0, Convert.ToInt32(Math.Min(BLOCKSIZE, blocksize))); read = Math.Min(BLOCKSIZE, blocksize);
                                    if (block == null)
                                    {
                                        return(result.PATCH_ERROR);
                                    }
                                    //IAsyncResult writeResult = Dests.BeginWrite(block,0,Convert.ToInt32(read),writeCallBack,"Write Target File");
                                    //Dests.EndWrite(writeResult);
                                    Dests.Write(block, 0, Convert.ToInt32(read));
                                    temp = read;
                                    //WriteFile(hDest, block, read, &temp, NULL);
                                    if (temp != Math.Min(BLOCKSIZE, blocksize))
                                    {
                                        return(result.PATCH_ERROR);
                                    }
                                    blocksize -= temp;
                                } while (Convert.ToBoolean(temp));

                                break;

                            case 5:
                            case 6:
                            case 7:
                                if (blocktype == 5)
                                {
                                    Byte x;
                                    x         = Convert.ToByte(Patchs.ReadByte()); read = 1;
                                    blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                }
                                else if (blocktype == 6)
                                {
                                    UInt16 x;
                                    x         = Patchs.ReadValueU16(); read = 2;
                                    blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                }
                                else
                                {
                                    UInt32 x;
                                    x         = Patchs.ReadValueU32(); read = 4;
                                    blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                }

                                if (!Convert.ToBoolean(blocksize))
                                {
                                    return(result.PATCH_CORRUPT);
                                }

                                do
                                {
                                    Patchs.Read(block, 0, Convert.ToInt32(Math.Min(BLOCKSIZE, blocksize))); read = Math.Min(BLOCKSIZE, blocksize);
                                    if (block == null)
                                    {
                                        return(result.PATCH_CORRUPT);
                                    }
                                    //IAsyncResult writeResult = Dests.BeginWrite(block, 0, Convert.ToInt32(read), writeCallBack, "Write Target File");
                                    //Dests.EndWrite(writeResult);
                                    Dests.Write(block, 0, Convert.ToInt32(read));
                                    temp = read;
                                    //WriteFile(hDest, block, read, &temp, NULL);
                                    if (temp != Math.Min(BLOCKSIZE, blocksize))
                                    {
                                        return(result.PATCH_ERROR);
                                    }
                                    blocksize -= temp;
                                } while (Convert.ToBoolean(temp));

                                break;

                            case 255:       // read the file modified time from the patch
                                targetModifiedTime.dwLowDateTime  = (int)Patchs.ReadValueU32();
                                targetModifiedTime.dwHighDateTime = (int)Patchs.ReadValueU32();

                                /////////////////////////////////////////////////////////////////            //from System.Runtime.InteropServices.FILETIME to System.DateTime            /////////////////////////////////////////////////////////////////
                                long _Value = (long)targetModifiedTime.dwHighDateTime << 32 | (long)(uint)targetModifiedTime.dwLowDateTime;
                                dte  = DateTime.FromFileTimeUtc(_Value);
                                read = Convert.ToUInt32(Marshal.SizeOf(targetModifiedTime));
                                //if(targetModifiedTime) {
                                //return result.PATCH_CORRUPT;
                                //}
                                break;

                            default:
                                return(result.PATCH_CORRUPT);
                            }
                        }
                        if (!Convert.ToBoolean(MD5Mode))
                        {
                            return(result.PATCH_UNSUPPORTED);
                        }
                        else
                        {
                            //int md5index;
                            byte[] dest_md5 = new byte[16];
                            Dests.Close();
                            Patchs.Close();
                            Sources.Close();
                            File.Delete(hPatchs);
                            File.Delete(hSources);
                            File.Move(hDests, hSources);
                            File.SetLastWriteTime(hSources, dte);
                            //FileStream Dest = new FileStream(hSources, FileMode.Open, FileAccess.Read, FileShare.None);
                            //dest_md5 = checksum.FileMD5(Dest, Data, -1);
                            //Dest.Close();
                            //if (dest_md5 == null)
                            //{
                            //   return result.PATCH_ERROR;
                            // }
                            //for (md5index = 0; md5index < 16; md5index++)
                            //{
                            //   if (dest_md5[md5index] != patch_dest_md5[md5index]) return result.PATCH_ERROR;
                            //}
                        }
                        // set file time

                        //SetFileTime(hDest, NULL, NULL, &targetModifiedTime);
                        return(result.PATCH_SUCCESS);
                    }
                    else
                    {
                        Patchs.Seek(patch_size, SeekOrigin.Current);
                        //SetFilePointer(hPatch, patch_size, NULL, EMoveMethod.Current);
                    }
                }

                // if already up to date, it doesn't matter that we didn't match
                if (Convert.ToBoolean(already_uptodate))
                {
                    return(result.PATCH_UPTODATE);
                }
                else
                {
                    return(result.PATCH_NOMATCH);
                }
            }
            catch (Exception Err)
            {
                MessageBox.Show("出现错误:" + Err.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(result.PATCH_ERROR);
            }
        }
Exemple #35
0
 public Form1()
 {
     InitializeComponent();
     setText = new SetText((msg) => lblRandom.Text = msg);
 }
Exemple #36
0
 public IndexBuilder(string sourceFolder, string invertedFile, SetText setLabelText)
 {
     _sourceFolder = sourceFolder;
     _invertedFilePath = invertedFile;
     SetLabelText = setLabelText;
 }
Exemple #37
0
 private void fw_Renamed(object sender, System.IO.RenamedEventArgs e)
 {
     SetText wryt = new SetText(SetMsg);
     string msg = string.Format("{0}: {1} to {2}", e.ChangeType.ToString(), e.OldFullPath, e.FullPath);
     this.Invoke(wryt, msg);
 }
Exemple #38
0
        public static unsafe int Patch(string hPatchs, string hSources, string    hDests,ProgressBar pBar,Label lab,int FileID)
        {
            try
            {
                if (pBar.InvokeRequired == true)
                {
                    SetValue PSetValue = new SetValue(DoSetValue);
                    SetText LSetText = new SetText(DoSetText);
                    pBar.Invoke(PSetValue, new Object[] { pBar, 0 });
                    lab.Invoke(LSetText, new Object[] { lab, "0%" });
                }
                UInt32 BLOCKSIZE = 16384;
                UInt32 temp = 0;
                UInt32 read;
                byte[] source_md5 = new byte[16];
                byte[] patch_dest_md5 = new byte[16];
                byte[] block = new byte[BLOCKSIZE];
                int MD5Mode = 0;
                UInt32 patches = 0;
                int already_uptodate = 0,j=1;
                double blocks;
                FILETIME targetModifiedTime;
                DateTime dte = new DateTime() ;
                //write回调方法
                FileStream Patchs = new FileStream(hPatchs, FileMode.Open, FileAccess.Read, FileShare.Read);
                FileStream Sources = new FileStream(hSources, FileMode.Open, FileAccess.Read, FileShare.Read);
                FileStream Dests = new FileStream(hDests, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                Hashtable Data = Program.filehash;
                // special 'addition' for the dll: since the patch file is now
                // in a seperate file, the VPAT header might be right at the start
                // of the file, and a pointer at the end of the file is probably missing
                // (because all patch generator versions don't append it, the linker/gui
                //  does this).
                Patchs.Seek(0, SeekOrigin.Begin);
                temp = Patchs.ReadValueU32(); read = 4;
                // it's not at the start of file -> there must be a pointer at the end of
                // file then
                if (temp != 0x54415056)
                {
                    Patchs.Seek(-4, SeekOrigin.End);
                    temp = Patchs.ReadValueU32(); read = 4;
                    Patchs.Seek(temp, SeekOrigin.Begin);
                    temp = Patchs.ReadValueU32(); read = 4;
                    if (temp != 0x54415056)
                        return result.PATCH_CORRUPT;
                }

                // target file date is by default the current system time
                GetSystemTimeAsFileTime(&targetModifiedTime);

                // read the number of patches in the file
                patches = Patchs.ReadValueU32(); read = 4;
                if (Convert.ToBoolean(patches & 0x80000000)) MD5Mode = 1;
                // MSB is now reserved for future extensions, anyone wanting more than
                // 16 million patches in a single file is nuts anyway
                patches = patches & 0x00FFFFFF;

                if (!Convert.ToBoolean(MD5Mode))
                {
                    return result.PATCH_UNSUPPORTED;
                }
                else
                {
                    source_md5 = checksum.FileMD5(Sources, Data, FileID,Program.AdvMOD);
                    if (source_md5 == null)
                        return result.PATCH_ERROR;
                }

                //pBar.Maximum = Convert.ToInt32(patches);
                while (Convert.ToBoolean(patches--))
                {
                    int patch_blocks = 0, patch_size = 0;

                    // flag which needs to be set by one of the checksum checks
                    int currentPatchMatchesChecksum = 0;

                    // read the number of blocks this patch has
                    patch_blocks = Convert.ToInt32(Patchs.ReadValueU32()); blocks = patch_blocks; read = 4;
                    if (!Convert.ToBoolean(patch_blocks))
                    {
                        return result.PATCH_CORRUPT;
                    }
                    if (pBar.InvokeRequired == true)
                    {
                        SetValue PSetValue = new SetValue(DoSetMax);
                        pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(patch_blocks) });
                    }
                    // read checksums
                    if (!Convert.ToBoolean(MD5Mode))
                    {
                        return result.PATCH_UNSUPPORTED;
                    }
                    else
                    {
                        int md5index;
                        byte[] patch_source_md5 = new byte[16];
                        patch_source_md5 = Patchs.ReadBytes(16); read = 16;
                        if (patch_source_md5 == null)
                        {
                            return result.PATCH_CORRUPT;
                        }
                        patch_dest_md5 = Patchs.ReadBytes(16); read = 16;
                        if (patch_dest_md5 == null)
                        {
                            return result.PATCH_CORRUPT;
                        }
                        // check to see if it's already up-to-date for some patch
                        for (md5index = 0; md5index < 16; md5index++)
                        {
                            if (source_md5[md5index] != patch_dest_md5[md5index]) break;
                            if (md5index == 15) already_uptodate = 1;
                        }
                        for (md5index = 0; md5index < 16; md5index++)
                        {
                            if (source_md5[md5index] != patch_source_md5[md5index]) break;
                            if (md5index == 15) currentPatchMatchesChecksum = 1;
                        }
                    }
                    // read the size of the patch, we can use this to skip over it
                    patch_size = Convert.ToInt32(Patchs.ReadValueU32()); read = 4;
                    if (patch_size == null)
                    {
                        return result.PATCH_CORRUPT;
                    }

                    if (Convert.ToBoolean(currentPatchMatchesChecksum))
                    {
                        while (Convert.ToBoolean(patch_blocks--))
                        {
                            if (pBar.InvokeRequired == true)
                            {
                                SetValue PSetValue = new SetValue(DoSetValue);
                                SetText LSetText = new SetText(DoSetText);
                                pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(j++) });
                                var per = Convert.ToDouble(j-1)/Convert.ToDouble(blocks);
                                lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(Math.Ceiling(per*100)) + "%" });
                                Application.DoEvents();
                            }
                            Byte blocktype = 0;
                            UInt32 blocksize = 0;
                            blocktype = Convert.ToByte(Patchs.ReadByte()); read = 1;
                            if (blocktype==null)
                            {
                                return result.PATCH_CORRUPT;
                            }
                            switch (blocktype)
                            {
                                case 1:
                                case 2:
                                case 3:
                                    if (blocktype == 1)
                                    {
                                        Byte x;
                                        x = Convert.ToByte(Patchs.ReadByte()); read = 1;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else if (blocktype == 2)
                                    {
                                        UInt16 x;
                                        x = Patchs.ReadValueU16(); read = 2;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else
                                    {
                                        UInt32 x;
                                        x = Patchs.ReadValueU32(); read = 4;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    temp = Patchs.ReadValueU32(); read = 4;
                                    if (!Convert.ToBoolean(blocksize) || temp == null || read != 4)
                                        return result.PATCH_CORRUPT;
                                    Sources.Seek(temp, SeekOrigin.Begin);
                                    //SetFilePointer(hSource, temp, 0, EMoveMethod.Begin);

                                    do
                                    {
                                        Sources.Read(block, 0, Convert.ToInt32(Math.Min(BLOCKSIZE, blocksize))); read = Math.Min(BLOCKSIZE, blocksize);
                                        if (block == null)
                                        {
                                            return result.PATCH_ERROR;
                                        }
                                        //IAsyncResult writeResult = Dests.BeginWrite(block,0,Convert.ToInt32(read),writeCallBack,"Write Target File");
                                        //Dests.EndWrite(writeResult);
                                        Dests.Write(block, 0, Convert.ToInt32(read));
                                        temp = read;
                                        //WriteFile(hDest, block, read, &temp, NULL);
                                        if (temp != Math.Min(BLOCKSIZE, blocksize))
                                            return result.PATCH_ERROR;
                                        blocksize -= temp;
                                    } while (Convert.ToBoolean(temp));

                                    break;

                                case 5:
                                case 6:
                                case 7:
                                    if (blocktype == 5)
                                    {
                                        Byte x;
                                        x = Convert.ToByte(Patchs.ReadByte()); read = 1;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else if (blocktype == 6)
                                    {
                                        UInt16 x;
                                        x = Patchs.ReadValueU16(); read = 2;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else
                                    {
                                        UInt32 x;
                                        x = Patchs.ReadValueU32(); read = 4;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }

                                    if (!Convert.ToBoolean(blocksize))
                                        return result.PATCH_CORRUPT;

                                    do
                                    {
                                        Patchs.Read(block, 0, Convert.ToInt32(Math.Min(BLOCKSIZE, blocksize))); read = Math.Min(BLOCKSIZE, blocksize);
                                        if (block == null)
                                        {
                                            return result.PATCH_CORRUPT;
                                        }
                                        //IAsyncResult writeResult = Dests.BeginWrite(block, 0, Convert.ToInt32(read), writeCallBack, "Write Target File");
                                        //Dests.EndWrite(writeResult);
                                        Dests.Write(block, 0, Convert.ToInt32(read));
                                        temp = read;
                                        //WriteFile(hDest, block, read, &temp, NULL);
                                        if (temp != Math.Min(BLOCKSIZE, blocksize))
                                            return result.PATCH_ERROR;
                                        blocksize -= temp;
                                    } while (Convert.ToBoolean(temp));

                                    break;

                                case 255:   // read the file modified time from the patch
                                    targetModifiedTime.dwLowDateTime = (int)Patchs.ReadValueU32();
                                    targetModifiedTime.dwHighDateTime = (int)Patchs.ReadValueU32();

                                    /////////////////////////////////////////////////////////////////            //from System.Runtime.InteropServices.FILETIME to System.DateTime            /////////////////////////////////////////////////////////////////
                                    long _Value = (long) targetModifiedTime.dwHighDateTime << 32 | (long)(uint)targetModifiedTime.dwLowDateTime;
                                    dte = DateTime.FromFileTimeUtc(_Value);
                                    read = Convert.ToUInt32(Marshal.SizeOf(targetModifiedTime));
                                    //if(targetModifiedTime) {
                                    //return result.PATCH_CORRUPT;
                                    //}
                                    break;

                                default:
                                    return result.PATCH_CORRUPT;
                            }
                        }
                        if (!Convert.ToBoolean(MD5Mode))
                        {
                            return result.PATCH_UNSUPPORTED;
                        }
                        else
                        {

                           //int md5index;
                            byte[] dest_md5 = new byte[16];
                            Dests.Close();
                            Patchs.Close();
                            Sources.Close();
                            File.Delete(hPatchs);
                            File.Delete(hSources);
                            File.Move(hDests, hSources);
                            File.SetLastWriteTime(hSources, dte);
                            //FileStream Dest = new FileStream(hSources, FileMode.Open, FileAccess.Read, FileShare.None);
                            //dest_md5 = checksum.FileMD5(Dest, Data, -1);
                            //Dest.Close();
                            //if (dest_md5 == null)
                            //{
                             //   return result.PATCH_ERROR;
                           // }
                            //for (md5index = 0; md5index < 16; md5index++)
                            //{
                             //   if (dest_md5[md5index] != patch_dest_md5[md5index]) return result.PATCH_ERROR;
                            //}
                        }
                        // set file time

                        //SetFileTime(hDest, NULL, NULL, &targetModifiedTime);
                        return result.PATCH_SUCCESS;
                    }
                    else
                    {
                        Patchs.Seek(patch_size, SeekOrigin.Current);
                        //SetFilePointer(hPatch, patch_size, NULL, EMoveMethod.Current);
                    }
                }

                // if already up to date, it doesn't matter that we didn't match
                if (Convert.ToBoolean(already_uptodate))
                {
                    return result.PATCH_UPTODATE;
                }
                else
                {
                    return result.PATCH_NOMATCH;
                }
            }
            catch (Exception Err)
            {
                MessageBox.Show("出现错误:" + Err.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return result.PATCH_ERROR;
            }
        }
Exemple #39
0
        private void SetLbText(string str)
        {
            str = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + str + "\n";

            if (textBox2.InvokeRequired)
            {
                SetText st = new SetText(delegate(string text)
                {
                    textBox2.AppendText(text);
                });
                textBox2.Invoke(st, str);
            }
            else
            {
                textBox2.AppendText(str);
            }
        }
 /// <summary> convenience constructor. </summary>
 public Access(GetText get, SetText set)
 {
     this.get = get; this.set = set;
 }
Exemple #41
0
 public void On(SetText cmd)
 {
     text = cmd.Text;
 }
Exemple #42
0
        byte startI; // начальный код костяшки домино на позиции (0,0). С нее начинается проверка. Нужно для распараллеливания процесса.

        #endregion Fields

        #region Constructors

        public DominoTable(byte MaxY, byte CRC, byte startI, byte endI, SetText SetInfo, SetText SetTableText, int RefreshTo = 1000000000)
        {
            this.MaxY = MaxY;
            this.MaxX = (byte)(MaxY * 2);
            this.MaxN = (byte)(MaxX * MaxY);

            this.CRC = CRC;
            this.startI = startI;

            this.RefreshTo = RefreshTo;

            this.SetInfo = SetInfo;
            this.SetTableText = SetTableText;

            NotSolve = true;

            NumDomino = new Domino[28]; // Больше чем 28 костяшек домино от (0;0) до (6;6) нет.

            byte num = 0;
            for(byte top = 0; top < 7; top++)
            {
                for (byte bottom = top; bottom < 7; bottom++)
                {
                    //if (top + bottom > 8) continue; // нам не подойдут домино с суммой чисел больше 8
                    NumDomino[num] = new Domino(top, bottom, num);
                    num++;
                }
            }
            MaxI = num;

            if (endI == 0) this.endI = MaxI; // определяем если нужно максимальное значение
            else this.endI = endI;
        }