/// <summary> /// Creates an instance of the object. /// </summary> /// <param name="viewName">Name of the view.</param> /// <param name="view">Instance of the view.</param> /// <param name="bindingResourceKey">Name of the binding resource.</param> /// <param name="model">Instance of the model or viewmodel for the view.</param> public View(string viewName, UserControl view, string bindingResourceKey, object model) { ViewInstance = view; ViewName = viewName; BindingResourceKey = bindingResourceKey; Model = model; }
public void DispatcherServiceTest() { #endif TestVM vm = new TestVM(); UserControl control = new UserControl() { DataContext = vm }; DispatcherService service = new DispatcherService(); Interactivity.Interaction.GetBehaviors(control).Add(service); Window.Content = control; #if NETFX_CORE await EnqueueShowWindow(); #else EnqueueShowWindow(); #endif EnqueueCallback(() => { Assert.IsFalse(vm.IsProgress); vm.Calculate(); Assert.IsTrue(vm.IsProgress); }); #if NETFX_CORE await WaitConditional(() => vm.Task.IsCompleted); #else EnqueueWait(() => vm.Task.IsCompleted); #endif EnqueueWindowUpdateLayout(); EnqueueCallback(() => { #if !NETFX_CORE DispatcherHelper.DoEvents(); #endif Assert.IsFalse(vm.IsProgress); Assert.IsTrue(vm.IsCompleted); }); EnqueueTestComplete(); }
/// <summary> /// Shows an user control over the current Window /// </summary> /// <param name="control">User control to show as settings window</param> /// <param name="closeAction">Method to execute when Popup is closed</param> /// <param name="width">Window Width</param> public void ShowFlyout(UserControl control, Action closeAction = null, double width = DEFAULT_WIDTH) { //Asignar acción a ejecutar al cerrar el Popup CloseAction = closeAction; //Asignar ancho y alto del Popup _popup.Width = width; _popup.Height = Window.Current.Bounds.Height; /* Asignar el ancho y alto del control * Aunque este puede ya traerlos definidos * en este caso es conveniente adecuarlo a * la estructura que hemos planteado*/ control.Width = width; control.Height = Window.Current.Bounds.Height; //Asignar el control del parámetro al Popup _popup.Child = control; //Establecer en que parte de la ventana se comienza a dibujar el Popup _popup.VerticalOffset = 0; _popup.HorizontalOffset = Window.Current.Bounds.Width - width; //Mostrar el Popup, sus contenidos _popup.IsOpen = true; }
// Use this for initialization void Awake() { userControl = this; if (!rigidBody2DUnidirectional) rigidBody2DUnidirectional = GetComponent<RigidBody2DUnidirectional>(); if (!singleMeleeAttack) singleMeleeAttack = GetComponent<SingleMeleeAttack>(); jump2d = GetComponent<Jump2D>(); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument doc = app.ActiveUIDocument; var browser = new UserControl(doc); DialogResult dr = browser.ShowDialog(); if (dr == DialogResult.OK) { } return Result.Succeeded; }
private void Awake() { UserControl._instance = this; this._character = GetComponent<CharacterManager>(); //m_Character = Intercept.ThroughProxy<ICharacterManager>( // character, // new InterfaceInterceptor(), // new IInterceptionBehavior [] { // new ExceptionInterceptionBehavior() // }); }
static void Main(string[] args) { UserControl usercontrol = new UserControl(); bool isExit = false; string input; Instruction(); while (!isExit) { input = Console.ReadLine(); Enum.TryParse(input, true, out usercontrol); switch (usercontrol) { case UserControl.Exercise1: Console.WriteLine("Solve of {0}", UserControl.Exercise1); Exercise1 exercise1 = new Exercise1(); exercise1.Show(); break; case UserControl.Exercise2: Console.WriteLine("Solve of {0}", UserControl.Exercise2); Exercise2 exercise2 = new Exercise2(); exercise2.Show(); break; case UserControl.Exercise3: Console.WriteLine("Solve of {0}", UserControl.Exercise3); Exercise3 exercise3 = new Exercise3(); exercise3.Show(); break; case UserControl.Exercise4: Console.WriteLine("Solve of {0}", UserControl.Exercise4); Exercise4 exercise4 = new Exercise4(); exercise4.Show(); break; case UserControl.Exercise5: Console.WriteLine("Solve of {0}", UserControl.Exercise5); Exercise5 exercise5 = new Exercise5(); exercise5.Show(); break; case UserControl.Exercise6: Console.WriteLine("Solve of {0}", UserControl.Exercise6); Exercise6 exercise6 = new Exercise6(); exercise6.Show(); break; case UserControl.Exercise7: Console.WriteLine("Solve of {0}", UserControl.Exercise7); Exercise7 exercise7 = new Exercise7(); exercise7.Show(); break; case UserControl.Exit: isExit = true; break; default: Instruction(); break; } } }
protected void Page_Load(object sender, EventArgs e) { userControl = (System.Web.UI.UserControl)Page.LoadControl("Controls/" + ContentControlName + ".ascx"); userControl.ID = ContentControlName + "ID"; if (PlaceHolder1 != null) { this.PlaceHolder1.Controls.Add(userControl); } if (userControl is Interfaces.INamedControl) { PageTitle = (userControl as Interfaces.INamedControl).Name; } }
public void DrawRectangle_Stroke_2px() { UserControl userControl = new UserControl(); userControl.Width = 200; userControl.Height = 200; DrawRectangleControl testControl = new DrawRectangleControl(); testControl.Pen = new Pen(new SolidColorBrush(Colors.Red), 2); userControl.Content = testControl; this.RenderToFile(userControl); this.CompareImages(); }
public static void TakeScreenShot(Screen model, UserControl view ) { var window = new Window { Content = view, Height = 550, Width = 450 }; ViewModelBinder.Bind(model, window, null); window.Show(); WpfUtils.ScreenCapture(window, model.GetType().Name.Replace("ViewModel","") + ".png"); }
public override void OnSpawned() { base.OnSpawned (); if (!player) { player = PlayerStatus.playerStatus.gameObject; rigidBody2DUnidirectional = player.GetComponent<RigidBody2DUnidirectional>(); jump2d = player.GetComponent<Jump2D>(); backgrondDarkner = Camera.main.transform.FindChild("BackgroundDarkener").GetComponent<SpriteRenderer>(); } newUserControl = null; newRigidBody2DUnidirectional = null; }
protected void Button1_Click(object sender, EventArgs e) { UserControl NewUser = new UserControl(); if (NewUser.UserAdd(TextBox1.Text, TextBox2.Text, TextBox4.Text, TextBox5.Text, TextBox6.Text) == true) { Response.Redirect("Login.aspx"); Literal1.Text="注册成功,请返回登录!"; } else { Literal1.Text = "注册失败,请重试!"; } }
static void Main(string[] args) { UserControl usercontrol = new UserControl(); bool isExit = false; string input; Instruction(); while (!isExit) { input = Console.ReadLine(); Enum.TryParse(input, true, out usercontrol); switch (usercontrol) { case UserControl.Exercise1: Console.WriteLine("Solve of {0}", UserControl.Exercise1); Exercise1 exercise1 = new Exercise1(); exercise1.Show(); break; case UserControl.Exercise2: Console.WriteLine("Solve of {0}", UserControl.Exercise2); Exercise2 exercise2 = new Exercise2(); exercise2.Show(); Vector vector1 = new Vector(10, 10); Vector vector2 = new Vector(15, 15); Console.WriteLine("Scalar multiply {0} of vectors {1} and {2}", vector1 * vector2, vector1, vector2); break; case UserControl.Exercise3: Console.WriteLine("Solve of {0}", UserControl.Exercise3); Exercise3 exercise3 = new Exercise3(); exercise3.Show(); break; case UserControl.Exercise4: Console.WriteLine("Solve of {0}", UserControl.Exercise4); Exercise4 exercise4 = new Exercise4(); exercise4.Show(); break; case UserControl.Exercise5: Console.WriteLine("Solve of {0}", UserControl.Exercise5); Exercise5 exercise5 = new Exercise5(); exercise5.Show(); break; case UserControl.Exit: isExit = true; break; default: Instruction(); break; } } }
protected void Page_Load(object sender, EventArgs e) { //obj.PageTitle = "Course Students"; /* Loading Student Enrollment List */ UserControl c = new UserControl(); if (!string.IsNullOrEmpty(Request.QueryString["user"]) && !string.IsNullOrEmpty(Request.QueryString["sku"])) { c = (UserControl)LoadControl("~/Admin/Classroom/Controls/EnrollmentsDetails.ascx"); } else { c = (UserControl)LoadControl("~/Admin/Classroom/Controls/StudentEnrollmentList.ascx"); } EnrollmentPlaceHolder.Controls.Add(c); }
public void SetTestForThisControl(Test NewTest, UserControl ControlForResultOfTest, bool UserScoreCollectionNeedToBeAddedToSession) { /*if (UserScoreCollectionNeedToBeAddedToSession) { string Script = "alert('Hello i am test control inside update panel!');"; ScriptManager..RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), Script, true); }*/ if (NewTest.CurrentCollectonOfQuestions.Count() == 0) { throw new ArgumentException(Texts.ExceptionMessageForTestControl_TestIsEmpty); } try { Label LabelFoScore = (Label)ControlForResultOfTest.FindControl("ScoreLabel"); } catch { throw new ArgumentException(Texts.ExceptionMessageForTestControl_LabelForScoreIsMissing); } HiddenFieldForStateOfTestWizard.Value = TestStates.InProgress; AccessorToSession CurrentAccessorToSession = new AccessorToSession(Session); foreach (Question Currentquestion in NewTest.CurrentCollectonOfQuestions) { WizardStep NewWizardStep = new WizardStep(); NewWizardStep.Controls.Add(CreateControlForQuestion(Currentquestion)); CurrentWizardForTest.WizardSteps.Add(NewWizardStep); } if (UserScoreCollectionNeedToBeAddedToSession) { Dictionary<uint, uint> CollectionOfUserScore = new Dictionary<uint, uint>(); foreach (Question Currentquestion in NewTest.CurrentCollectonOfQuestions) { CollectionOfUserScore[Currentquestion.ID] = 0; } CurrentAccessorToSession.CurrentUserScoreCollection = CollectionOfUserScore; } WizardStep LastWizardStep = new WizardStep(); LastWizardStep.Controls.Add(ControlForResultOfTest); CurrentWizardForTest.WizardSteps.Add(LastWizardStep); int IndexOfLastWizardStep = CurrentWizardForTest.WizardSteps.Count - 1; int IndexOfFinishStep = CurrentWizardForTest.WizardSteps.Count - 2; ConfigureWizardSteps(IndexOfLastWizardStep, IndexOfFinishStep); }
protected void Button1_Click(object sender, EventArgs e) { UserControl mylogin = new UserControl(); if (mylogin.UserLogin(TextBox1.Text, TextBox2.Text) == true) { HttpCookie cookie = new HttpCookie("MyCook");//初使化并设置Cookie的名称 DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(0, 0, 60, 0, 0);//过期时间为60分钟 cookie.Expires = dt.Add(ts);//设置过期时间 cookie.Value = TextBox1.Text; Response.AppendCookie(cookie); Response.Redirect("default.aspx"); } else { Label1.Text = "用户名或密码错误,请重新输入"; Label1.Visible = true; } }
public void Should_Be_Styled_As_UserControl() { using (UnitTestApplication.Start(TestServices.RealStyler)) { var target = new UserControl(); var root = new TestRoot { Styles = new Styles { new Style(x => x.OfType<ContentControl>()) { Setters = new[] { new Setter(TemplatedControl.TemplateProperty, GetTemplate()) } } }, Child = target, }; Assert.NotNull(target.Template); } }
public void Interprete(UserControl control) { Type type = control.GetType(); if (type == typeof(ListView)) Interprete(control as ListView); else if (type == typeof(TreeView)) Interprete(control as TreeView); else if (type == typeof(FormView)) Interprete(control as FormView); else if (type == typeof(AssetReference)) Interprete(control as AssetReference); else if (type == typeof(AssetListener)) Interprete(control as AssetListener); else if (type == typeof(TextBox)) Interprete(control as TextBox); else if (type == typeof(Page)) Interprete(control as Page); }
// Method to add order item details public void AddOrderItemDetails(UserControl control) { this.OrderItemDetailsPlaceHolder.Controls.Add(control); }
public string mainLoop(int startTime) { Information information = new Information(); ChannelActions ChanActs = new ChannelActions(); ChanModes mode = new ChanModes(); Loader load = new Loader(); CTCP ctcp = new CTCP(); UserControl users = new UserControl(); httpRegex = new Regex(@"(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*))*)))"); try { ThreadStart userThreadStart = new ThreadStart(users.userControl); Thread userThread = new Thread(userThreadStart); userThread.Start(); } catch (Exception e) { Console.WriteLine(e.ToString()); } while (true) { while ((inputLine = reader.ReadLine()) != null) { Console.WriteLine(inputLine); if (inputLine.IndexOf("376") >= 0) //End of MOTD { writer.WriteLine("JOIN " + channel); writer.Flush(); } else break; while ((inputLine = reader.ReadLine()) != null) { Console.WriteLine(inputLine); if (ctcp.isCTCP()) ctcp.processCTCPType(); else if (inputLine == ("PING :" + server)) { writer.WriteLine("PONG " + server); writer.Flush(); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": op me") >= 0 && information.sender() == owner) { mode.setMode("+o", owner); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": op") >= 0) { string realSender = information.sender(); string realMsg = information.msg(); information.sendNamesToSrv(); inputLine = reader.ReadLine(); if (information.isOped(realSender) || information.sender() == owner && information.senderHost() == ownerhost) mode.setMode("+o", realMsg.Substring(nick.Length + 5)); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": voice me") >= 0 || inputLine.ToLower().IndexOf(nick.ToLower() + ": voice ") >= 0) { mode.setMode("+v", information.sender()); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": uptime") >= 0) { Uptime uptime = new Uptime(); uptime.uptime(startTime); } else if (inputLine.IndexOf("PART " + channel) >= 0) { users.userPart(); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": die") >= 0 && information.sender() == owner) { writer.WriteLine("QUIT :My master killed me"); writer.Flush(); cleanup(); return "ok"; } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": topic") >=0 && information.sender() == owner) { mode.setTopic(); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": !load") >= 0 && information.sender() == owner) { load.createAD("load"); } else if (inputLine.ToLower().IndexOf(nick.ToLower() + ": !unload") >= 0 && information.sender() == owner) { load.createAD("unload"); } else if (Regex.IsMatch(inputLine, httpRegex.ToString()) && information.sender() != nick) { HttpHeader hh = new HttpHeader(); ThreadStart thStart = new ThreadStart(hh.processHeader); Thread th = new Thread(thStart); th.Start(); } if (inputLine.StartsWith("ERROR")) { Console.WriteLine(inputLine); return "error"; } } } } }
public static UserSession FromContext( UserControl control ) { if( control == null ) throw new ArgumentNullException( "control" ); return FromContext( control.Session ); }
/// <summary> /// Check the accessor key, find the next selectable control that matches the /// accessor key and give it the focus. /// </summary> /// <param name="sender"></param> /// <param name="usrCtrl"></param> private static void HandleAccessorKey(object sender, UserControl usrCtrl) { // Get X in the accessor key <Alt + X> int key = CheckForAccessorKey(); if (key == -1) return; Control ctrl = usrCtrl.GetNextControl((Control)sender, false); do { ctrl = usrCtrl.GetNextControl(ctrl, true); if (ctrl != null && Control.IsMnemonic(Convert.ToChar(key), ctrl.Text) && !KeyConflict(Convert.ToChar(key), usrCtrl)) { // If we land on a non-selectable control then go to the next // control in the tab order. if (!ctrl.CanSelect) { Control ctlAfterLabel = usrCtrl.GetNextControl(ctrl, true); if (ctlAfterLabel != null && ctlAfterLabel.CanFocus) ctlAfterLabel.Focus(); } else { ctrl.Focus(); } break; } // Loop until we hit the end of the tab order. If we have hit the end // of the tab order we do not want to loop back because the parent // form's controls come next in the tab order. } while (ctrl != null); }
/// <summary> /// Handle the focus of the ActiveX control, including its child controls /// </summary> /// <param name="usrCtrl">the ActiveX control</param> internal static void HandleFocus(UserControl usrCtrl) { Keyboard keyboard = new Keyboard(); if (keyboard.AltKeyDown) { // Handle accessor key HandleAccessorKey(usrCtrl.GetNextControl(null, true), usrCtrl); } else { // Move to the first control that can receive focus, taking into account // the possibility that the user pressed <Shift>+<Tab>, in which case we // need to start at the end and work backwards. for (System.Windows.Forms.Control ctrl = usrCtrl.GetNextControl(null, !keyboard.ShiftKeyDown); ctrl != null; ctrl = usrCtrl.GetNextControl(ctrl, !keyboard.ShiftKeyDown)) { if (ctrl.Enabled && ctrl.CanSelect) { ctrl.Focus(); break; } } } }
private System.Windows.Point GetControlPosition(UserControl myControl) { System.Windows.Point locationToScreen = myControl.PointToScreen(new System.Windows.Point(0, 0)); PresentationSource source = PresentationSource.FromVisual(myControl); return source.CompositionTarget.TransformFromDevice.Transform(locationToScreen); }
private void ShowContextMenu(IChartDrawable primitive, UserControl control, MouseEventArgs e) { #if GTK GtkWorkarounds.ShowContextMenu(InitContextMenu(primitive), control, e.GdkEventButton, Gdk.Rectangle.Zero); #else InitContextMenu(primitive).Show(control, e.Location); #endif }
/// <summary> /// 将用户控件转化为HTML代码 并将转化后的HTML代码转换为字符串以供输出 /// </summary> /// <param name="controlName">用户控件名称</param> /// <returns>用户控件转换后的HTML代码字符串</returns> public static string RangerUserControl(string controlName) { StringBuilder build = new StringBuilder(); HtmlTextWriter htmlWriter = new HtmlTextWriter(new StringWriter(build)); UserControl uc = new UserControl(); Control ctrl = uc.LoadControl(controlName+".ascx"); htmlWriter.Flush(); string result; try { ctrl.RenderControl(htmlWriter); } catch(Exception ex) { } finally { htmlWriter.Flush(); result= build.ToString(); } return result; }
private static bool KeyConflict(char key, UserControl u) { bool flag = false; foreach (Control ctl in u.Controls) { if (Control.IsMnemonic(key, ctl.Text)) { if (flag) { return true; } flag = true; } } return false; }
public void refreshcontrol() { UserControl uc = new UserControl(); uc.LoadControl("~/controls/clients/clientPortfolios.ascx"); ucHolder.Controls.Add(uc); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (ContentControlName != "") { userControl = (System.Web.UI.UserControl)Page.LoadControl("~/Controls/" + ContentControlName + ".ascx"); userControl.ID = ContentControlName + "ID"; HtmlForm form = (HtmlForm)Page.Master.FindControl("form1"); if (form != null) { ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder)form.FindControl("cphWithoutScroll"); if (contentPlaceHolder != null) { if (userControl is ControlBase) { MasterPageBase dmp = (MasterPageBase)Page.Master; /* if (dmp != null) { dmp.BackButtonURL = ((ControlBase) userControl).BackURL; }*/ AddOnlyBrowserTitle = ((ControlBase)userControl).AddOnlyBrowserTitle; } contentPlaceHolder.Controls.Add(userControl); } } if (userControl is Interfaces.INamedControl) { this.PageTitle = (userControl as Interfaces.INamedControl).Name; } } }
public IEnumerator UsingLightTravel(float time) { PlayerStatus.playerStatus.pause = true; for(int i = 0; i < PlayerStatus.playerStatus.othersSpriteRenderer.Length; i++) { PlayerStatus.playerStatus.othersSpriteRenderer [i].enabled = false; } PlayerStatus.playerStatus.headSpriteRenderer.enabled = false; initialMaxSpeed = rigidBody2DUnidirectional.maxSpeed; //record maxSpeed so we can return to this value later player.rigidbody2D.velocity = new Vector2 (0,0); player.rigidbody2D.gravityScale = 0.01f; backgrondDarkner.enabled = true; PlayerStatus.playerStatus.InvulnerableByXTimes(time, false); PlayerStatus.playerStatus.headSpriteRenderer.enabled = false; PlayerStatus.playerStatus.bodySpriteRenderer.enabled = false; for(int i = 0; i < PlayerStatus.playerStatus.othersSpriteRenderer.Length; i++) { PlayerStatus.playerStatus.othersSpriteRenderer[i].enabled = false; } foreach (SpriteRenderer spriteRenderer in PlayerStatus.playerStatus.othersSpriteRenderer) spriteRenderer.enabled = false; if (jump2d) { jump2d.enabled = false; newRigidBody2DUnidirectional = player.AddComponent<RigidBody2DUnidirectional>(); newRigidBody2DUnidirectional.axisToMove = Axis.y; newRigidBody2DUnidirectional.autoMove = false; newRigidBody2DUnidirectional.hasLimit = true; newRigidBody2DUnidirectional.moveForce = 15; newRigidBody2DUnidirectional.upperLimit = 20f; newRigidBody2DUnidirectional.bottomLimit = 0f; newUserControl = player.AddComponent<UserControl>(); newUserControl.axisToMove = Axis.y; newUserControl.rigidBody2DUnidirectional = newRigidBody2DUnidirectional; } while (player.rigidbody2D.velocity.x < 65 && time > 0) { rigidBody2DUnidirectional.maxSpeed *= 1.1f; time -= 0.1f; yield return new WaitForSeconds(0.1f); } yield return new WaitForSeconds (time); PlayerStatus.playerStatus.pause = false; //magneticPrefab.GetComponent<Animator>().speed = 5; //yield return new WaitForSeconds (3); PoolManager.Pools["props"].Despawn (transform); }