public static Result getAddressList(int lang) { Dictionary dic; param p; List <param> list = new List <param>(); foreach (string key in dicAddress.Keys) { dic = (Dictionary)dicAddress[key]; p = new param { key = dic.id, extra = dic.extra, extra2 = dic.extra2 }; if (lang == 1) { p.value = dic.name; } else { p.value = dic.name2; } list.Add(p); } Result res = new Result(true); res.Data = Func.ObjectToJson(list); return(res); }
public HttpResponseMessage Updatepass(param param) { string result = string.Empty; try { using (YYPlayContext db = new YYPlayContext()) { tbleMerchant merchant = (from x in db.tbleMerchant where x.fldMaPass == param.pass && x.fldMerchID == param.MerchantID select x).Single(); merchant.fldMaPass = param.newpass; int count = db.SaveChanges(); if (count > 0) { result = rule.JsonStr("ok", "", true); } else { result = rule.JsonStr("error", "", false); } } } catch (Exception e) { result = rule.JsonStr("error", "", e.Message); } return(new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }); }
public static sourceTechnique_common MakeAccessor(string type, string[] components, int stride, int elements, string arrayId) { var sourceTechnique = new sourceTechnique_common(); var accessor = new accessor(); var accessorParams = new List <param>(); foreach (var component in components) { var param = new param(); if (component.Length > 0) { param.name = component; } param.type = type; accessorParams.Add(param); } accessor.param = accessorParams.ToArray(); accessor.source = "#" + arrayId; accessor.stride = (ulong)(components.Length * stride); accessor.offset = 0; accessor.count = (ulong)(elements / stride); sourceTechnique.accessor = accessor; return(sourceTechnique); }
public void AddParam(string paramName, string paramValue) { param p = new param(); p.paramName = paramName; p.paramValue = paramValue; _paramList.Add(p); }
private static source GenerateSource <T>(string id, string[] paramnames, List <T> list, Func <T, double[]> converter) { float_array verts = new float_array(); source source = new source { id = id, name = id, Item = verts }; List <double> values = new List <double>(); int length = -1; foreach (T item in list) { double[] vals = converter(item); if (length == -1) { length = vals.Length; } else if (vals.Length != length) { throw new Exception("Incompatable lengths!"); } values.AddRange(vals); } verts.Values = values.ToArray(); verts.count = (ulong)verts.Values.LongLength; verts.id = id + "-data"; verts.name = verts.id; param[] indexes = new param[paramnames.Length]; for (int i = 0; i < paramnames.Length; i++) { indexes[i] = new param { name = paramnames[i], type = "float" }; } source.technique_common = new sourceTechnique_common { accessor = new accessor { source = "#" + verts.id, count = (ulong)list.Count, stride = (ulong)length, param = indexes } }; return(source); }
/// <summary> /// Вспомогательная функция. Разделяет строку. /// </summary> /// <param name="str"></param> /// <returns></returns> public static param read_params(string str) { param buf = new param(); try { string[] st = str.Split(';'); buf.name_of_param = st[0].Split('=')[0].Trim(); if (buf.name_of_param == "start_time") { buf.other = st[0].Split('=')[1]; return(buf); } try { buf.value = Convert.ToDecimal(st[0].Split('=')[1].Trim().Replace('.', ',')); } catch { buf.value_bool = Convert.ToBoolean(st[0].Split('=')[1].Trim()); } buf.deskription = st[1]; return(buf); } catch { } return(null); }
private static param MakeParam(string name, string type) { param p = new param(); p.name = name; p.type = type; return(p); }
public void Param_GivenNameAndValue_HaveValuesInXml() { var param = new param("Тип", "моноблок"); var xParam = new YmlSerializer().ToXDocument(param).Root; xParam.Should().NotBeNull(); xParam.Should().HaveAttribute("name", "Тип"); xParam.Should().HaveValue("моноблок"); }
private void Add_Click(object sender, RoutedEventArgs e) { param pa = (Source.SelectedItem as param); Source.Items.Remove(pa); Dest.Items.Add(new Param_APPRes() { p_name = pa.Name, app_res = "" }); }
public void Param_GivenNameValueAndUnit_HaveValuesInXml() { var param = new param("Размер экрана", 27.ToString(), "дюйм"); var xParam = new YmlSerializer().ToXDocument(param).Root; xParam.Should().NotBeNull(); xParam.Should().HaveAttribute("name", "Размер экрана"); xParam.Should().HaveAttribute("unit", "дюйм"); xParam.Should().HaveValue(27.ToString()); }
public void AddLineToMesh(param _params) { verticies.Add(_params.points[0]); verticies.Add(_params.points[1]); colors.Add(_params.color); colors.Add(_params.color); lineID++; indicies.Add(lineID); lineID++; indicies.Add(lineID); }
public void Confi_Param(param pa) { ObservableCollection <LinkParam> lv_source = new ObservableCollection <LinkParam>(); AddNewParam par_win = new AddNewParam(); par_win.Owner = this; par_win.name.Text = pa.Name; par_win.name.IsEnabled = false; par_win.desc.Text = pa.Desc; par_win.type.SelectedItem = pa.Type; List <ConfigEvent> evs = main_proj.CurrentWF.GetAllEvents(); foreach (ConfigEvent ce in evs) { lv_source.Add(new LinkParam() { Name = ce.name, Selected = ce.LinkParams.ContainsKey(pa.Name), App_res = (ce.LinkParams.ContainsKey(pa.Name) ? ce.LinkParams[pa.Name] : "") }); } par_win.Event_List.ItemsSource = lv_source; if (par_win.ShowDialog().Value == true) { pa.Type = par_win.type.Text; pa.Desc = par_win.desc.Text; foreach (LinkParam it in par_win.Event_List.Items) { foreach (ConfigEvent ee in evs) { if (ee.name == it.Name) { if (it.Selected == true) { if (!ee.LinkParams.ContainsKey(par_win.name.Text)) { ee.LinkParams.Add(par_win.name.Text, it.App_res); } else { ee.LinkParams[par_win.name.Text] = it.App_res; } } } } } } }
[Route("api/clientes/detalle/")]//Le da el nombre al cual quiere que llegue public HttpResponseMessage GetClientesConParametro(param input) { try { var respuesta = _acceso.ObtieneReportePorCliente(input.Id);//Llama al metodo y devuelve la informacion, esta podria llevar un servicio entremedio para mapear otras cosas, //hacer calculos, cambiar propiedades etc return(Request.CreateResponse(HttpStatusCode.OK, respuesta)); // devuelve la respuesta } catch (Exception e) { //Esto ya es configurable de acuerdo al error devuelto o simplemente se deja un tipo de error return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e)); } }
/* * @brief */ public override bool initialize(ref Player in_player, object in_data) { base.initialize(ref in_player, in_data); if ((in_data != null) && (in_data.GetType() == typeof(NormalDmgAction.param))) { m_param = in_data as NormalDmgAction.param; } else { m_param = new param(); } in_player.param.hp = Mathf.Max(0, in_player.param.hp - m_param.damage); m_vec = m_param.moveVec * m_param.speedPow; return(true); }
public static Result getDicList(string type, string parent_id, int lang) { Dictionary dic; param p; List <param> list = new List <param>(); foreach (string key in dicTable.Keys) { if (type == key.ToLower().Split("*".ToCharArray())[0]) { dic = (Dictionary)dicTable[key]; p = new param { key = dic.id, extra = dic.extra, extra2 = dic.extra2 }; if (lang == 1) { p.value = dic.name; } else { p.value = dic.name2; } if (Func.ToStr(parent_id) != "") { if (dic.extra2 == parent_id) { list.Add(p); } } else { list.Add(p); } } } Result res = new Result(true); res.Data = Func.ObjectToJson(list); return(res); }
public HttpResponseMessage GetMerchant(param param) { string result = string.Empty; try { using (YYPlayContext db = new YYPlayContext()) { var merchant = db.tbleMerchant.Select(x => new { x.fldSecretKey, x.fldMerchID, x.fldMerchName }).Where(x => x.fldMerchID == param.MerchantID).DefaultIfEmpty(); result = rule.JsonStr("ok", "", merchant); } } catch (Exception e) { result = rule.JsonStr("error", "", e.Message); } return(new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }); }
protected void Import_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("确实要从工作流" + (WorkFlows.SelectedItem as WorkFlowMan).Name + "中导入变量(重名变量将不被导入)", "确定导入", MessageBoxButton.OKCancel) != MessageBoxResult.OK) { return; } foreach (param pa in (WorkFlows.SelectedItem as WorkFlowMan).params_table) { param newP = new param() { Name = pa.Name, Desc = pa.Desc, Type = pa.Type }; if (((MainWindow)Application.Current.MainWindow).main_proj.CurrentWF.params_table.Where(s => s.Name == newP.Name).Count() == 0) { ((MainWindow)Application.Current.MainWindow).main_proj.CurrentWF.params_table.Add(newP); } } }
internal bool TrySetParam(object item) { bool result = false; param param = item as param; if (param != null) { result = true; StringBuilder txt = new StringBuilder(); param.Text.Each(s => { txt.Append(s); }); ParamInfo info = new ParamInfo(); info.Description = txt.ToString(); info.Name = param.name; AddParamInfo(info); } return(result); }
/// <summary> Example => AddParam(ParamTypes.summonerIds, new List<long>() { 466244, 457724 /// }); Example => AddParam(ParamTypes.region, "tr"); </summary> public static void AddParam <T>(this RiotApiCaller <T> rac, param key, object value) where T : class { string val = ""; if (value is List <long> ) { val = string.Join(",", (value as List <long>)); } else if (value is List <string> ) { val = string.Join(",", (value as List <string>)); } else if (value is List <int> ) { val = string.Join(",", (value as List <int>)); } else if (value is DateTime) { val = ((long)((DateTime)value - new DateTime(1970, 1, 1, 0, 0, 0, 0)) .TotalMilliseconds).ToString(); } else if (value is List <queue> ) { val = string.Join(",", (value as List <queue>)); } else if (value is List <season> ) { val = string.Join(",", (value as List <season>)); } else { val = value.ToString(); } rac.Url = rac.Url.Replace(string.Format("{{{0}}}", key.ToString()), val); rac.cacheBuild.Add(value.ToString().ToLower()); }
private void btnUploadFile_Click(object sender, EventArgs e) { string relativeFolder = DateTime.Now.Year.ToString() + Path.DirectorySeparatorChar + DateTime.Now.Month.ToString() + Path.DirectorySeparatorChar; string folder = BlogSettings.Instance.StorageLocation + "files" + Path.DirectorySeparatorChar; string fileName = txtUploadFile.FileName; Upload(folder + relativeFolder, txtUploadFile, fileName); //string a = "<p><a href=\"{0}file.axd?file={1}\">{2}</a></p>"; string a = "<p><a href=\"{0}file.axd?file={1}\">{2}</a></p>"; string a = "<p><object width="240" height="196" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> <param name="src" value="moviefile.mov"> <param name="controller" value="true"> <param name="autoplay" value="false"> <embed src="moviefile.mov" width="240" height="196" autoplay="false" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> </embed> </object></p>" string text = txtUploadFile.FileName + " (" + SizeFormat(txtUploadFile.FileBytes.Length, "N") + ")"; txtContent.Text += string.Format(a, Utils.RelativeWebRoot, Server.UrlEncode(relativeFolder.Replace("\\", "/") + fileName), text); }
private void recvThreadFunc() { bool is_mid_msg = false; try { UInt16 wireProtoVersion = streamreader.ReadUInt16(); if (wireProtoVersion != 0x0000) { state = CONNSTATE.Unsupported; form.updateConnectionListEntry(this); return; } UInt16 J2534ProtoVersion = streamreader.ReadUInt16(); switch (J2534ProtoVersion) { case 0x0404: interpreter = new J2534ProtocolInterpreter_0404(); break; default: state = CONNSTATE.Unsupported; form.updateConnectionListEntry(this); return; } state = CONNSTATE.Connected; form.updateConnectionListEntry(this); //Setup complete, Loop forever processing messages. while (state == CONNSTATE.Connected) { msgtype mtype = (msgtype)streamreader.ReadByte(); checkEnum(typeof(msgtype), mtype); is_mid_msg = true; switch (mtype) { case msgtype.reportParam: StringBuilder logentry = new StringBuilder(); param p = (param)streamreader.ReadByte(); checkEnum(typeof(param), p); switch (p) { case param.client: Client = streamreader.ReadString(); form.updateConnectionListEntry(this); logentry.Append("Client: " + Client); //logWriter.WriteLine("Client: " + Client); break; case param.driver: Driver = streamreader.ReadString(); logentry.Append("Driver: " + Driver); //logWriter.WriteLine("Driver: " + Driver); int driverstatus = streamreader.ReadInt32(); if (driverstatus != 0) { close(); state = CONNSTATE.Error; if (driverstatus > 0) { state = CONNSTATE.BadDriver; } else if (driverstatus == -1) { state = CONNSTATE.MissingDriver; } } form.updateConnectionListEntry(this); break; } saveLogEntry(logentry.ToString()); break; case msgtype.J2534Msg: saveLogEntry(interpreter.interpret(streamreader)); EventCount++; form.updateConnectionListEntry(this); break; } is_mid_msg = false; } } catch (System.ObjectDisposedException) { Console.WriteLine("Connectionclosed, unable to do stuff."); state = CONNSTATE.Disconnected; form.updateConnectionListEntry(this); } catch (System.Net.Sockets.SocketException e) { catchSocketException(e); } catch (System.IO.IOException e) { if (e.InnerException is System.Net.Sockets.SocketException) { catchSocketException((System.Net.Sockets.SocketException)e.InnerException); } else if (!is_mid_msg) { state = CONNSTATE.Disconnected; form.updateConnectionListEntry(this); socket.Close(); } else { die(); } } catch (InvalidEnumException e) { Console.WriteLine(e.ToString()); die(); } }
private static void AddMethod(ref Tree tree, string exemp, ref bool root) //Adding a method { //name[] - type and name of the method string[] name = exemp.Substring(0, exemp.IndexOf('(')).Split(' '); //t1 - type of the method Type t1 = new Type(); t1 = CaseOfTypes(name, t1, 0); Onewaylist list = null; string str = exemp.Substring(exemp.IndexOf('(') + 1, exemp.IndexOf(')') - (exemp.IndexOf('(') + 1)).Replace(" ", ""); if (str != "") { //par - array of parameters of the method (e.g. "ref char x2") string[] par = exemp.Substring(exemp.IndexOf('(') + 1, exemp.IndexOf(')') - (exemp.IndexOf('(') + 1)).Split(','); //variables - array of [way of transmission,type, name] or [type, name] string[] variables; variables = par[0].Split(' '); //p - way of transmission param p = new param(); //telem - type of the parameter Type telem = new Type(); //if there are only 2 words in variables: p = ExecuteArgument(variables, ref telem); //list - unidirectional list with 3 fields: way of transmission,type, next_element list = new Onewaylist(telem, p); //beg - link to list, to go through it and add elements Onewaylist beg = list; //Until all parameters are executed: for (int i = 1; i < par.Length; i++) { //delete the first ' ' in par[i][0] if it exists if (par[i][0] == ' ') { par[i] = par[i].Substring(1); } //variables - array of [way of transmission,type, name] or [type, name] variables = par[i].Split(' '); //if there are only 2 words in variables: p = ExecuteArgument(variables, ref telem); //Adding element to the list and putting a pointer on the next element beg.next = new Onewaylist(telem, p); beg = beg.next; } } //Adding identificator to the tree Method_id met_t = new Method_id(name[1], Way.Methods, t1, list); //If it is the first element: if (root) { tree = new Tree(met_t); root = false; } //If some elements already exist in the tree: else { tree.Addtree(met_t); } }
void commendReceiveThreadFunction(object tmpSocket) { NetworkStream stream; TextWriter write; TextReader read; Socket newsocket = (Socket)tmpSocket; int ID=0; //控制线程的状态 for (int i = 0; i < 10; i++) { if (threadIsRunning[i] == false) { ID = i; break; } } threadIsRunning[ID] = true; // tempSocket.Close(); stream = new NetworkStream(newsocket); write = new StreamWriter(stream); read = new StreamReader(stream); // write.WriteLine("hello"); // write.Flush(); string readtemp; newsocket.Blocking = true; // newsocket.ReceiveTimeout = 500; IPEndPoint remot = (IPEndPoint)newsocket.RemoteEndPoint; textBox1.Text = "TCP控制已连接:\r\n" + remot.Address.ToString() + ":" + remot.Port.ToString() + "\r\n" + textBox1.Text; string listinfo = "还没有赋值"; param myparm = new param(); myparm.threadsocket = newsocket; myparm.threadID = ID; //屏幕截图发送线程 sendpicture = new Thread(new ParameterizedThreadStart(sendPictureThreadFunction)); sendpicture.Priority = ThreadPriority.AboveNormal; sendpicture.Start(myparm); while (threadIsRunning[ID]) { try { #region /************************************ * * java通过tcp发送的数据全部都是byte字节的, * 所以必须使用stream来接收 * 绝对不可也使用readline,因为java的writeline和C# * 的最后格式不一样,读取不成功,会卡死 // * *********************************/ /******************************** * java端不人为的加上\r\n换行符的话就得用这个方法 * 读取字符串 //byte[] by = new byte[256]; //stream.Read(by, 0, by.Length); //readtemp = Encoding.UTF8.GetString(by);// * *********************************/ /*********************** * java端在发送的字符上增加\r\n换行 * 符就可使用readline()了 * *******************/ /******************************************** // C#的writeLine()和readLine()一行的结束是\r\n //Java的writeLine()和readLine()一行的结束是\n\r //注意转换 ********************************************/ #region readtemp = read.ReadLine(); if (readtemp != "\n" || readtemp != "") { //textBox1.Text = readtemp + "\r\n" + textBox1.Text; string[] splitstr = readtemp.Split('+'); if (splitstr[0] == "HOSTNAME") { listBox1.Items.Add(splitstr[1] + ":" + remot.Address.ToString() + ":" + remot.Port.ToString()); listinfo = splitstr[1] + ":" + remot.Address.ToString() + ":" + remot.Port.ToString(); } if (splitstr[0] == "CLEAR") { if (splitstr[2] == "OK") { lock (clearlevel) { clarity = Convert.ToInt32(splitstr[1]); } } } if (splitstr[0] =="SCREEN") { if (splitstr[3] == "OK") { lock (getsizew) { phonescreen_w = (int)(Convert.ToDouble(splitstr[1]) * screenDPI[0]); phonescreen_h=(int)(Convert.ToDouble(splitstr[2])*screenDPI[1]); } } } if (splitstr[0] == "FULL") { if (splitstr[1] == "START") { lock (fullscreen) { isfullscreen = true; } } else { lock (fullscreen) { isfullscreen = false; } } } if (splitstr[0] == "MOUSE") { //鼠标控制 // mouse_event(int dwFlags, int dx, int dy, int wheel, int dwExtraInfo); string mouseinfo = splitstr[1]; if (mouseinfo == "LEFT_CLICK") { //单机左键 mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } if (mouseinfo == "RIGHT_CLICK") { //单机右键 mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); } if (mouseinfo == "LEFT_DOUBLECLICK") { //双击左键 mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); Thread.Sleep(200); mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } if (mouseinfo == "RIGHT_DOUBLECLICK") { //双击右键 mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); Thread.Sleep(200); mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); } if (mouseinfo == "LEFT_DOWN") { //左键按下 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); } if (mouseinfo == "LEFT_UP") { //左键抬起 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } if (mouseinfo == "RIGHT_DOWN") { //右键按下 mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); } if (mouseinfo == "RIGHT_UP") { //右键抬起 mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); } if (mouseinfo == "MOVE") { //移动鼠标 mouse_event(MOUSEEVENTF_MOVE, Convert.ToInt32(splitstr[2]), Convert.ToInt32(splitstr[3]), 0, 0); } if (mouseinfo == "WHEEL") { //滚动滚轮 //dwData:如果dwFlags为MOOSEEVENTF_WHEEL,则dwData指定鼠标轮移动的数量。正值表明鼠标轮向前转动,即远离用户的方向;负值表明鼠标轮向后转动,即朝向用户。一个轮击定义为WHEEL_DELTA,即120。 mouse_event(MOUSEEVENTF_WHEEL, 0, 0, Convert.ToInt32(splitstr[2]), 0); } lock (lockup) { isreceive = true; } } if (splitstr[0] == "SPECIAL") { string specialkey = splitstr[1]; if (specialkey == "ENTER_DOWN") { keybd_event((byte)(Keys.Enter), MapVirtualKey((byte)(Keys.Enter), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); lock (lockup) { isreceive = true; } } if (specialkey == "ENTER_UP") { keybd_event((byte)(Keys.Enter), MapVirtualKey((byte)(Keys.Enter), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); lock (lockup) { isreceive = true; } } if (specialkey == "BACKSPACE_DOWN") { keybd_event((byte)(Keys.Back), MapVirtualKey((byte)(Keys.Back), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); lock (lockup) { isreceive = true; } } if (specialkey == "BACKSPACE_UP") { keybd_event((byte)(Keys.Back), MapVirtualKey((byte)(Keys.Back), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); lock (lockup) { isreceive = true; } } if (specialkey == "SPACE_DOWN") { keybd_event((byte)(Keys.Space), MapVirtualKey((byte)(Keys.Space), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "SPACE_UP") { keybd_event((byte)(Keys.Space), MapVirtualKey((byte)(Keys.Space), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "ESC_DOWN") { keybd_event((byte)(Keys.Escape), MapVirtualKey((byte)(Keys.Escape), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "ESC_UP") { keybd_event((byte)(Keys.Escape), MapVirtualKey((byte)(Keys.Escape), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "SHIFT_DOWN") { keybd_event((byte)(Keys.ShiftKey), MapVirtualKey((byte)(Keys.ShiftKey), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "SHIFT_UP") { keybd_event((byte)(Keys.ShiftKey), MapVirtualKey((byte)(Keys.ShiftKey), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "CTRL_DOWN") { keybd_event((byte)(Keys.ControlKey), MapVirtualKey((byte)(Keys.ControlKey), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "CTRL_UP") { keybd_event((byte)(Keys.ControlKey), MapVirtualKey((byte)(Keys.ControlKey), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "ALT_DOWN") { keybd_event((byte)(Keys.Menu), MapVirtualKey((byte)(Keys.Menu), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "ALT_UP") { keybd_event((byte)(Keys.Menu), MapVirtualKey((byte)(Keys.Menu), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "TAB_DOWN") { keybd_event((byte)(Keys.Tab), MapVirtualKey((byte)(Keys.Tab), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "TAB_UP") { keybd_event((byte)(Keys.Tab), MapVirtualKey((byte)(Keys.Tab), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "WIN_DOWN") { keybd_event((byte)(Keys.LWin), MapVirtualKey((byte)(Keys.LWin), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "WIN_UP") { keybd_event((byte)(Keys.LWin), MapVirtualKey((byte)(Keys.LWin), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F1_DOWN") { keybd_event((byte)(Keys.F1), MapVirtualKey((byte)(Keys.F1), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F1_UP") { keybd_event((byte)(Keys.F1), MapVirtualKey((byte)(Keys.F1), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F2_DOWN") { keybd_event((byte)(Keys.F2), MapVirtualKey((byte)(Keys.F2), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F2_UP") { keybd_event((byte)(Keys.F2), MapVirtualKey((byte)(Keys.F2), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F3_DOWN") { keybd_event((byte)(Keys.F3), MapVirtualKey((byte)(Keys.F3), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F3_UP") { keybd_event((byte)(Keys.F3), MapVirtualKey((byte)(Keys.F3), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F4_DOWN") { keybd_event((byte)(Keys.F4), MapVirtualKey((byte)(Keys.F4), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F4_UP") { keybd_event((byte)(Keys.F4), MapVirtualKey((byte)(Keys.F4), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F5_DOWN") { keybd_event((byte)(Keys.F5), MapVirtualKey((byte)(Keys.F5), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F5_UP") { keybd_event((byte)(Keys.F5), MapVirtualKey((byte)(Keys.F5), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F6_DOWN") { keybd_event((byte)(Keys.F6), MapVirtualKey((byte)(Keys.F6), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F6_UP") { keybd_event((byte)(Keys.F6), MapVirtualKey((byte)(Keys.F6), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F7_DOWN") { keybd_event((byte)(Keys.F7), MapVirtualKey((byte)(Keys.F7), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F7_UP") { keybd_event((byte)(Keys.F7), MapVirtualKey((byte)(Keys.F7), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F8_DOWN") { keybd_event((byte)(Keys.F8), MapVirtualKey((byte)(Keys.F8), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F8_UP") { keybd_event((byte)(Keys.F8), MapVirtualKey((byte)(Keys.F8), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F9_DOWN") { keybd_event((byte)(Keys.F9), MapVirtualKey((byte)(Keys.F9), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F9_UP") { keybd_event((byte)(Keys.F9), MapVirtualKey((byte)(Keys.F9), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F10_DOWN") { keybd_event((byte)(Keys.F10), MapVirtualKey((byte)(Keys.F10), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F1_UP") { keybd_event((byte)(Keys.F10), MapVirtualKey((byte)(Keys.F10), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F11_DOWN") { keybd_event((byte)(Keys.F11), MapVirtualKey((byte)(Keys.F11), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F11_UP") { keybd_event((byte)(Keys.F11), MapVirtualKey((byte)(Keys.F11), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "F12_DOWN") { keybd_event((byte)(Keys.F12), MapVirtualKey((byte)(Keys.F12), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "F12_UP") { keybd_event((byte)(Keys.F12), MapVirtualKey((byte)(Keys.F12), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "END_DOWN") { keybd_event((byte)(Keys.End), MapVirtualKey((byte)(Keys.End), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "END_UP") { keybd_event((byte)(Keys.End), MapVirtualKey((byte)(Keys.End), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "HOME_DOWN") { keybd_event((byte)(Keys.Home), MapVirtualKey((byte)(Keys.Home), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "HOME_UP") { keybd_event((byte)(Keys.Home), MapVirtualKey((byte)(Keys.Home), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "DELETE_DOWN") { keybd_event((byte)(Keys.Delete), MapVirtualKey((byte)(Keys.Delete), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "DELETE_UP") { keybd_event((byte)(Keys.Delete), MapVirtualKey((byte)(Keys.Delete), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "PRTSC_DOWN") { keybd_event((byte)(Keys.PrintScreen), MapVirtualKey((byte)(Keys.PrintScreen), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "PRTSC_UP") { keybd_event((byte)(Keys.PrintScreen), MapVirtualKey((byte)(Keys.PrintScreen), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "INTERT_DOWN") { keybd_event((byte)(Keys.Insert), MapVirtualKey((byte)(Keys.Insert), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "INTERT_UP") { keybd_event((byte)(Keys.Insert), MapVirtualKey((byte)(Keys.Insert), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "NUMLOCK_DOWN") { keybd_event((byte)(Keys.NumLock), MapVirtualKey((byte)(Keys.NumLock), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "NUMLOCK_UP") { keybd_event((byte)(Keys.NumLock), MapVirtualKey((byte)(Keys.NumLock), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "PAGEUP_DOWN") { keybd_event((byte)(Keys.PageUp), MapVirtualKey((byte)(Keys.PageUp), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "PAGEUP_UP") { keybd_event((byte)(Keys.PageUp), MapVirtualKey((byte)(Keys.PageUp), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "PAGEDOWN_DOWN") { keybd_event((byte)(Keys.PageDown), MapVirtualKey((byte)(Keys.PageDown), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "PAGEDOWN_UP") { keybd_event((byte)(Keys.PageDown), MapVirtualKey((byte)(Keys.PageDown), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "UPKEY_DOWN") { keybd_event((byte)(Keys.Up), MapVirtualKey((byte)(Keys.Up), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "UPKEY_UP") { keybd_event((byte)(Keys.Up), MapVirtualKey((byte)(Keys.Up), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "DOWNKEY_DOWN") { keybd_event((byte)(Keys.Down), MapVirtualKey((byte)(Keys.Down), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "DOWNKEY_UP") { keybd_event((byte)(Keys.Down), MapVirtualKey((byte)(Keys.Down), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "LEFTKEY_DOWN") { keybd_event((byte)(Keys.Left), MapVirtualKey((byte)(Keys.Left), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "LEFTKEY_UP") { keybd_event((byte)(Keys.Left), MapVirtualKey((byte)(Keys.Left), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "RIGHTKEY_DOWN") { keybd_event((byte)(Keys.Right), MapVirtualKey((byte)(Keys.Right), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "RIGHTKEY_UP") { keybd_event((byte)(Keys.Right), MapVirtualKey((byte)(Keys.Right), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (specialkey == "CAPSLOCK_DOWN") { keybd_event((byte)(Keys.CapsLock), MapVirtualKey((byte)(Keys.CapsLock), 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (specialkey == "CAPSLOCK_UP") { keybd_event((byte)(Keys.CapsLock), MapVirtualKey((byte)(Keys.CapsLock), 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } } #endregion if (splitstr[0] == "KEY") { //键盘输入 if (splitstr[2] == "OK") { string getinfo = splitstr[1]; //MessageBox.Show(splitstr[1]); SendKeys.SendWait(getinfo); lock (lockup) { isreceive = true; } } } if (splitstr[0] == "FUN") { //电脑功能控制 if (splitstr[1] == "SHUTDOWN") { // ExitWindowsEx(1, 0); DoExitWin(EWX_SHUTDOWN); //ProcessStartInfo ps = new ProcessStartInfo(); //ps.FileName = "shutdown.exe"; //ps.Arguments = "-s -t 1"; //Process.Start(ps); } else if (splitstr[1] == "RESTSRRT") { // ExitWindowsEx(2, 0); DoExitWin(EWX_REBOOT); //ProcessStartInfo ps = new ProcessStartInfo(); //ps.FileName = "shutdown.exe"; //ps.Arguments = "-r -t 1"; //Process.Start(ps); } else if (splitstr[1] == "MANGER") { ProcessStartInfo ps = new ProcessStartInfo(); ps.FileName = @"C:\WINDOWS\system32\taskmgr.exe"; Process.Start(ps); } else if (splitstr[1] == "SLEEP") { //ProcessStartInfo ps = new ProcessStartInfo(); //ps.FileName = "shutdown.exe"; //ps.Arguments = "-h -t 1"; //Process.Start(ps); Application.SetSuspendState(PowerState.Hibernate, true, true); } else if (splitstr[1] == "LOGOUT") { // ExitWindowsEx(0, 0); DoExitWin(EWX_LOGOFF); //ProcessStartInfo ps = new ProcessStartInfo(); //ps.FileName = "shutdown.exe"; //ps.Arguments = "-l -t 1"; //Process.Start(ps); } else if (splitstr[1] == "LOCK") { LockWorkStation(); } else if (splitstr[1] == "SHUTDOWNTIME") { myshutdowntime(Convert.ToInt32(splitstr[2])); //ProcessStartInfo ps = new ProcessStartInfo(); //ps.FileName = "shutdown.exe"; //ps.Arguments = "-s -t "+splitstr[2].ToString(); //Process.Start(ps); } else if (splitstr[1] == "SHUTDOWNCANCEL") { lock (shutdown) { isshutdown = false; } //ProcessStartInfo ps = new ProcessStartInfo(); //ps.FileName = "shutdown.exe"; //ps.Arguments = "-a"; //Process.Start(ps); } } if (splitstr[0] == "GAME") { //游戏控制 if (splitstr[1] == "UP_DOWN") { keybd_event((byte)(up_button), MapVirtualKey((byte)up_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); // MessageBox.Show(up_button.ToString()); } if (splitstr[1] == "UP_UP") { keybd_event((byte)(up_button), MapVirtualKey((byte)up_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "DOWN_DOWN") { keybd_event((byte)(down_button), MapVirtualKey((byte)down_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (splitstr[1] == "DOWN_UP") { keybd_event((byte)(down_button), MapVirtualKey((byte)down_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "LEFT_DOWN") { keybd_event((byte)(left_button), MapVirtualKey((byte)left_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (splitstr[1] == "LEFT_UP") { keybd_event((byte)(left_button), MapVirtualKey((byte)left_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "RIGHT_DOWN") { keybd_event((byte)(right_button), MapVirtualKey((byte)right_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (splitstr[1] == "RIGHT_UP") { keybd_event((byte)(right_button), MapVirtualKey((byte)right_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "A_DOWN") { keybd_event((byte)(A_button), MapVirtualKey((byte)A_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (splitstr[1] == "A_UP") { keybd_event((byte)(A_button), MapVirtualKey((byte)A_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "B_DOWN") { keybd_event((byte)(B_button), MapVirtualKey((byte)B_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (splitstr[1] == "B_UP") { keybd_event((byte)(B_button), MapVirtualKey((byte)B_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "C_DOWN") { keybd_event((byte)(C_button), MapVirtualKey((byte)C_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (splitstr[1] == "C_UP") { keybd_event((byte)(C_button), MapVirtualKey((byte)C_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "D_DOWN") { keybd_event((byte)(D_button), MapVirtualKey((byte)D_button, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); } if (splitstr[1] == "D_UP") { keybd_event((byte)(D_button), MapVirtualKey((byte)D_button, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "START") { keybd_event((byte)(Start), MapVirtualKey((byte)Start, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); Thread.Sleep(100); keybd_event((byte)(Start), MapVirtualKey((byte)Start, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); // SendKeys.SendWait("{l}"); } if (splitstr[1] == "STOP") { keybd_event((byte)(Stop), MapVirtualKey((byte)Stop, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); Thread.Sleep(100); keybd_event((byte)(Stop), MapVirtualKey((byte)Stop, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); // SendKeys.SendWait("{o}"); } if (splitstr[1] == "OTHER1") { keybd_event((byte)(Other1), MapVirtualKey((byte)Other1, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); Thread.Sleep(100); keybd_event((byte)(Other1), MapVirtualKey((byte)Other1, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "OTHER2") { keybd_event((byte)(Other2), MapVirtualKey((byte)Other2, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); Thread.Sleep(100); keybd_event((byte)(Other2), MapVirtualKey((byte)Other2, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "OTHER3") { keybd_event((byte)(Other3), MapVirtualKey((byte)Other3, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); Thread.Sleep(100); keybd_event((byte)(Other3), MapVirtualKey((byte)Other3, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } if (splitstr[1] == "OTHER4") { keybd_event((byte)(Other4), MapVirtualKey((byte)Other4, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); Thread.Sleep(100); keybd_event((byte)(Other4), MapVirtualKey((byte)Other4, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); } } if (splitstr[0] == "MOVE") { if (splitstr[1] == "START") { lock (lockup) { ismove = true; isreceive = true; } } if (splitstr[1] == "STOP") { lock (lockup) { ismove = false; isreceive = true; } } } if (splitstr[0] == "EXIT") { if (splitstr[1] == "OFF" && splitstr[2] == "OK" && splitstr[3] == "OUT") { //sendpicture[numthread].Abort(); threadIsRunning[ID] = false; sendpicture.Abort(); break; } } if(splitstr[0] == "PICTURE") { if(splitstr[1] == "START") { isreceive=true; } else { isreceive=false; } } } #endregion } catch { textBox1.Text = "远程客户端给跪了\r\n" + textBox1.Text; // sendpicture[numthread].Abort(); // isok = false; threadIsRunning[ID] = false; sendpicture.Abort(); break; } } textBox1.Text = "当前TCP连接退出\r\n" + textBox1.Text; threadIsRunning[ID] = false; if (numthread >= 0) listBox1.Items.Remove(listinfo); read.Close(); write.Close(); stream.Close(); newsocket.Close(); numthread--; //清理资源 Process A = Process.GetCurrentProcess(); A.MaxWorkingSet = Process.GetCurrentProcess().MaxWorkingSet; A.Dispose(); }
public void UpdateParam() { if (KEY.IsDown(Keys.LeftShift)) { if (KEY.IsDown(Keys.X)) { currentParam = param.X; } if (KEY.IsDown(Keys.Y)) { currentParam = param.Y; } if (KEY.IsDown(Keys.W)) { currentParam = param.W; } if (KEY.IsDown(Keys.H)) { currentParam = param.H; } if (KEY.IsDown(Keys.A)) { currentParam = param.Alpha; } if (KEY.IsDown(Keys.R)) { currentParam = param.Rot; } if (KEY.IsDown(Keys.F)) { currentParam = param.Frame; } if (KEY.IsDown(Keys.S)) { currentParam = param.S; } if (KEY.IsDown(Keys.D)) { currentParam = param.SW; } if (KEY.IsDown(Keys.E)) { currentParam = param.SH; } if (KEY.IsDown(Keys.Space)) { if (KEY.IsDown(Keys.X)) { currentParam = param.RX; } if (KEY.IsDown(Keys.Y)) { currentParam = param.RY; } if (KEY.IsDown(Keys.A)) { currentParam = param.RAlpha; } if (KEY.IsDown(Keys.S)) { currentParam = param.RS; } if (KEY.IsDown(Keys.D)) { currentParam = param.RSW; } if (KEY.IsDown(Keys.E)) { currentParam = param.RSH; } } } }
public Onewaylist next; //next element public Onewaylist(Type tp, param par) { t = tp; p = par; next = null; }
public static bool Is <T>(this T instance, param Type[] types)
static void threadStart(object obj1) { param para = (param)obj1; long N = para.N; int th = para.thread; Random random = new Random(); while (true) { long x = random.Next((int)(N - 1)) + 1; if (!coPrime(x, N)) { continue; } System.Console.WriteLine($"Thread {th} --- Trying x = {x},N = {N}"); double p = QfindOrder(x, N, th); if (Math.Abs(p) < 1e-9) { continue; } Console.WriteLine($"Thread {th} --- The result of order finding is: {p.ToString()}"); //Console.WriteLine($"{N} = {p} * {N / p}"); long ans = -1; long[] CFE = new long[102], P = new long[102], Q = new long[102]; CFE[0] = 0; Console.Write($"Thread {th} --- The result of continued fraction expansion is: "); for (int i = 1; i <= 100; i++) { CFE[i] = (long)Math.Floor(1.0 / p + eps); Console.Write($"{CFE[i]} "); p = 1.0 / p + eps - CFE[i]; P[i + 1] = 0; Q[i + 1] = 1; for (int j = i; j >= 1; j--) { P[j] = Q[j + 1]; Q[j] = P[j + 1] + Q[j + 1] * CFE[j]; long g = gcd(P[j], Q[j]); P[j] /= g; Q[j] /= g; // P[1], Q[1]: similar fraction, CFE[i]: continued fraction expansion if (Q[1] != 0 && (Q[1] & 1) == 0 && qpow(x, Q[1], N) == 1) { ans = Q[1]; break; } } if (ans != -1) { break; } if (Math.Abs(p) < 1e-9) { break; } } Console.WriteLine(""); if (ans == -1) { continue; } Console.WriteLine($"Thread {th} --- Found {x}^{ans} MOD {N} = 1, ans = {ans}"); long p1 = (qpow(x, ans / 2, N) - 1 + N) % N, p2 = (qpow(x, ans / 2, N) + 1 + N) % N; System.Console.WriteLine($"p1 = ({x}^({ans} / 2) - 1) MOD {N} = {p1}, p2 = ({x}^({ans} / 2) + 1) MOD {N} = {p2}"); if (p1 == 0 || p2 == 0) { continue; } p1 = gcd(p1, N); p2 = gcd(p2, N); if (p1 > 1) { System.Console.WriteLine($"Thread {th} --- Result: {N} = {p1} * {N / p1}"); } else { System.Console.WriteLine($"Thread {th} --- Result: {N} = {p2} * {N / p2}"); } Console.WriteLine($"Press any key to exit ..."); for (int i = 1; i <= 10; i++) { if (i != th) { threadList[i].Abort(); } } Console.ReadKey(); System.Environment.Exit(0); } }
public int[] GetNewArray(param P, int K) { int[] NewArr = new int[Arr.Length]; int NewArrCount = 0; int Elem = Arr[0]; int ElemCount = 1; bool add = false; for (int i = 1; i <= Arr.Length; i++) { if (i == Arr.Length || Elem != Arr[i]) { add = false; switch (P) { case param.less: if (ElemCount >= K) { add = true; } break; case param.more: if (ElemCount <= K) { add = true; } break; case param.equal: if (ElemCount != K) { add = true; } break; } if (add) { for (int j = 0; j < ElemCount; j++) { NewArr[NewArrCount++] = Elem; } } else { NewArr[NewArrCount++] = 0; } if (i != Arr.Length) { Elem = Arr[i]; ElemCount = 1; } } else { ElemCount++; } } int[] FinalArr = new int[NewArrCount]; Array.Copy(NewArr, FinalArr, NewArrCount); return(FinalArr); }
public void ParamValue_GivenWhitespaceValue_ThrowsArgumentException() { var param = new param("Тип", "моноблок"); Call(() => param.value = " ").ShouldThrow <ArgumentException>(); }
public void ParamName_GivenEmptyName_ThrowsArgumentException() { var param = new param("Тип", "моноблок"); Call(() => param.name = "").ShouldThrow <ArgumentException>(); }
foreach (var(param, value) in parameters)
public static void RemoveParam <T>(this RiotApiCaller <T> rac, param key) where T : class { string find = string.Format("&{0}={{{0}}}", key.ToString()); rac.Url = rac.Url.Replace(find, ""); }