public HttpResponseMessage Put(string id, Sticky sticky) { using (var session = RavenDatabase.GetSession()) { var boardRepo = new BoardRepository(session); var board = boardRepo.Get(); var existingSticky = board.Stickies.Where(s => s.Id == id).FirstOrDefault(); if (existingSticky == null) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Sticky with that id not found."); } else { existingSticky.Content = sticky.Content; existingSticky.X = sticky.X; existingSticky.Y = sticky.Y; existingSticky.Height = sticky.Height; existingSticky.Width = sticky.Width; boardRepo.Save(board); return Request.CreateResponse(HttpStatusCode.OK); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Text,Timestamp,SortOrder,CategoryId")] Sticky sticky) { if (id != sticky.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sticky); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StickyExists(sticky.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", sticky.CategoryId); return(View(sticky)); }
/// <summary> /// Sticky의 위치를 전환한다. /// </summary> /// <param name="paper">The paper.</param> /// <param name="defualtSticky">if set to <c>true</c> [defualt sticky].</param> public void ChangeSticky(Paper paper, bool defualtSticky = false) { //Sticky 결정 Sticky sticky = this.CurrentSticky; if (defualtSticky) { switch (paper) { case Paper.p80x80: case Paper.p56x80: case Paper.p104x80: sticky = Sticky.Top; break; case Paper.p80x104: case Paper.p80x56: sticky = Sticky.Left; break; } } else { sticky = (Sticky)(((int)sticky + 1) % Enum.GetNames(typeof(Sticky)).Length); while (!StickyCtrl.IsAllowSticky(paper, sticky)) { sticky = (Sticky)(((int)sticky + 1) % Enum.GetNames(typeof(Sticky)).Length); } } //Sticky 반영 this.ChangeSticky(paper, sticky); }
public HttpResponseMessage Put(string id, Sticky sticky) { using (var session = RavenDatabase.GetSession()) { var boardRepo = new BoardRepository(session); var board = boardRepo.Get(); var existingSticky = board.Stickies.Where(s => s.Id == id).FirstOrDefault(); if (existingSticky == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Sticky with that id not found.")); } else { existingSticky.Content = sticky.Content; existingSticky.X = sticky.X; existingSticky.Y = sticky.Y; existingSticky.Height = sticky.Height; existingSticky.Width = sticky.Width; boardRepo.Save(board); return(Request.CreateResponse(HttpStatusCode.OK)); } } }
//hàm xử lý khi nút pin note được nhấn private void tSBtnPinNote_Click(object sender, EventArgs e) { try { //tạo một sticky tạm thời để lấy độ dài, rộng của sticky Sticky temp = new Sticky(); //cập nhật giá trị của hai biến x, y, hai biến này sẽ là quyết định vị trí của sticky trên màn hình int x = (aStickyNote.Count + 1) * temp.Width; int y = (aStickyNote.Count + 1) * temp.Height; //thêm sticky mới vào list aStickyNote.Add(new Sticky(x, y)); //copy nội dung từ RichTextBox qua Sticky aStickyNote.Last().getTxtUser = rTBMain.Text; //giải phóng temp Sticky temp.Dispose(); //bật timer1 if (timer1.Enabled != true) { timer1.Start(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Sticky의 위치를 전환한다. /// </summary> /// <param name="paper">The paper.</param> /// <param name="sticky">The sticky.</param> public void ChangeSticky(Paper paper, Sticky sticky) { Size formSize = NemonicApp.FormSize[paper]; formSize.Height -= MenuCtrl.MenuHeight; //formSize.Height -= MenuCtrl.MenuHeight; switch (sticky) { case Sticky.Top: this.Location = new Point(0, 0); this.Size = new Size(formSize.Width, Thickness); break; case Sticky.Right: this.Location = new Point(formSize.Width - Thickness, 0); this.Size = new Size(Thickness, formSize.Height); break; case Sticky.Bottom: this.Location = new Point(0, formSize.Height - Thickness); this.Size = new Size(formSize.Width, Thickness); break; case Sticky.Left: this.Location = new Point(0, 0); this.Size = new Size(Thickness, formSize.Height); break; } CurrentSticky = sticky; //this.Validate(); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Content,Order")] Sticky sticky) { if (id != sticky.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sticky); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StickyExists(sticky.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sticky)); }
public void CreateSticky(string tagName, List <List <Vector3> > strokes, GameObject linkedObj) { Sticky sticky = new Sticky(tagName, strokes, linkedObj); StartCoroutine(StickyFade(sticky, true)); stickyList.Add(sticky); Debug.Log(string.Format("[{0}]: Create new sticky.", tagName)); }
private void SetupSticky(GameObject stikcy, Texture2D tex2D) { stikcy.transform.parent = stickyHolder.transform; stikcy.transform.localPosition = Vector3.zero; stikcy.transform.localRotation = Quaternion.identity; Sticky sk = stikcy.GetComponent <Sticky>(); sk.SetTexture(tex2D); }
/// <summary> /// Agrega un plan de ejecución al final de la cola /// </summary> /// <param name="sticky">Plan de ejecución</param> /// <param name="forceExecution">Indica si es necesario forzar su inmediata ejecución</param> internal void AttachWork(Sticky <T> sticky, bool forceExecution = false) { if (_workers == null) { _workers = new Queue <Sticky <T> >(); _workersForceExecutions = new Queue <bool>(); } _workers.Enqueue(sticky); _workersForceExecutions.Enqueue(forceExecution); }
void Start() { sticky = GetComponent<Sticky>(); particleSystems = new List<ParticleSystem>(); ParticleSystem[] systems = GetComponentsInChildren<ParticleSystem>(); foreach(ParticleSystem system in systems){ particleSystems.Add (system); } }
public async Task <IActionResult> Create([Bind("ID,Content,Order")] Sticky sticky) { if (ModelState.IsValid) { _context.Add(sticky); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sticky)); }
public int GenerateAsagiHash() { unchecked { int hashCode = Sticky.GetHashCode(); hashCode = (hashCode * 397) ^ Closed.GetHashCode(); hashCode = (hashCode * 397) ^ (Comment?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (OriginalFilename?.GetHashCode() ?? 0); return(hashCode); } }
public HttpResponseMessage Post(Sticky sticky) { using (var session = RavenDatabase.GetSession()) { var boardRepo = new BoardRepository(session); var board = boardRepo.Get(); board.AddSticky(sticky); boardRepo.Save(board); } return(Request.CreateResponse <string>(HttpStatusCode.OK, sticky.Id)); }
public HttpResponseMessage Post(Sticky sticky) { using (var session = RavenDatabase.GetSession()) { var boardRepo = new BoardRepository(session); var board = boardRepo.Get(); board.AddSticky(sticky); boardRepo.Save(board); } return Request.CreateResponse<string>(HttpStatusCode.OK, sticky.Id); }
public void ClickWhiteBoard(GameObject target) { if (HoldingStickyState.isHolding.Value) { Sticky sticky = HoldingStickyState.targetSticky.GetComponent <Sticky>(); sticky.SetParent(target.transform.parent.transform.parent.gameObject); HoldingStickyState.targetSticky.transform.SetPositionAndRotation(DestinationMarker.DestinationMarkerPos, target.transform.rotation); HoldingStickyState.targetSticky.transform.position = HoldingStickyState.targetSticky.transform.TransformPoint(new Vector3(0f, 0f, -0.2f)); HoldingStickyState.targetSticky = null; HoldingStickyState.isHolding.Value = false; } }
public async Task <IActionResult> Create([Bind("Id,Text,Timestamp,SortOrder,CategoryId")] Sticky sticky) { if (ModelState.IsValid) { _context.Add(sticky); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", sticky.CategoryId); return(View(sticky)); }
public bool AttachBlob(Sticky otherSticky) { if (coreObject != null) { Rigidbody2D blobRB = otherSticky.GetComponent <Rigidbody2D>(); Destroy(blobRB); otherSticky.gameObject.transform.SetParent(this.transform); otherSticky.coreObject = coreObject; return(true); } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="NemonicForm"/> class. /// </summary> /// <param name="paper">The paper.</param> /// <param name="sticky">The sticky.</param> /// <param name="color">The color.</param> /// <param name="template">The template.</param> /// <param name="path">The path.</param> public NemonicForm(Paper paper = Paper.p80x80, Sticky sticky = Sticky.Top, ColorType color = ColorType.White, Image template = null, string path = null) { InitializeComponent(); // Enable double duffering to stop flickering. /* * this.SetStyle(ControlStyles.DoubleBuffer, true); * this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); * this.SetStyle(ControlStyles.UserPaint, true); * this.SetStyle(ControlStyles.SupportsTransparentBackColor, false); * this.SetStyle(ControlStyles.Opaque, false); * this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); * this.SetStyle(ControlStyles.ResizeRedraw, true); */ this.CurrentPaper = paper; this.CurrentColor = color; this.SettingsForm = new SettingsForm(this); this.ActiveControl = this.LayersCtrl; //this.ChangePaper(this.CurrentPaper); this.IsSaved = false; this.AllowResize = false; this.saveJsonDialog.InitialDirectory = NemonicApp.MemoPath; this.openJsonDialog.InitialDirectory = NemonicApp.MemoPath; if (template != null) { this.LayersCtrl.ChangeTemplate(new Bitmap(template)); } if (!string.IsNullOrEmpty(path)) { string ext = Path.GetExtension(path); if (ext.Equals(NemonicApp.Extension)) { this.OpenJson(path); } } this.Size = NemonicApp.FormSize[this.CurrentPaper]; this.Height -= nemonic.MenuCtrl.MenuHeight; this.LayersCtrl.ChangeSticky(this.CurrentPaper, sticky); this.MenuCtrl.ChangeColor(this.CurrentColor); }
/// <summary> /// 새로운 메모장을 연다. /// </summary> /// <param name="templatepath">적용할 템플릿 이미지</param> /// <param name="path">새 메모장에 로드할 JSON 파일 위치</param> public void OpenNew(string templatepath = "null", string path = "null") { Paper paper = this.CurrentPaper; Sticky sticky = this.LayersCtrl.StickyCtrl.CurrentSticky; ColorType color = this.CurrentColor; Image template = null; if (!templatepath.Equals("null")) { template = Image.FromFile(templatepath); } NemonicForm form = new NemonicForm(paper, sticky, color, template, path); NemonicApp.AppContext.OpenNew(form); }
void OnTriggerEnter2D(Collider2D other) { if(other.tag == "KillZone") { stuck = false; if (stuckSticky) stuckSticky.Unstick(); stuckSticky = null; transform.position = respawnPoint.position; rb.velocity = Vector2.zero; rb.angularVelocity = 0f; transform.localScale = new Vector3(1f, 1f, 1f); } }
public IActionResult AddSticky(int categoryId, string text) { // add the sticky Sticky sticky = new Sticky(); sticky.CategoryId = categoryId; sticky.Text = text; sticky.Timestamp = DateTime.Now; sticky.SortOrder = 0; db.Stickies.Add(sticky); db.SaveChanges(); // go back to index return(RedirectToAction("Index")); }
public string ReorderStickies(List <int> Ids) { // right here // Ids holds an list of ints // that are in the order we want our stickies // to be in for (int i = 0; i < Ids.Count; i++) { // grab the current sticky // set its sort order to the current // place in the array Sticky currentSticky = db.Stickies.Find(Ids[i]); currentSticky.SortOrder = i; } db.SaveChanges(); return("hello"); }
/// <summary>s /// Ejecuta un proceso en segundo plano o lo coloca en la cola de ejecución /// en caso de no quedar ningún hilo libre /// </summary> /// <typeparam name="T">Tipo de parámetro del delegado a invocar</typeparam> /// <param name="sticky">Plan de ejecución</param> /// <param name="forceExecution">Indica que se ejecuta sin tener en cuenta el número de procesos en ejecución</param> /// <param name="exeCxt">Contexto de ejecución </param> /// <returns>Identificador del plan de ejecución</returns> public static long AddWork <T>(Sticky <T> sticky, bool forceExecution, ExecutionContext <T> exeCxt) { //Iniciamos el sonar si no estaba activo if (Hal.Sonar == null) { Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; Hal.Sonar = new Dictionary <long, BackgroundWorker>(Hal.MaxParallelsProcess + 5); Hal.Results = new Dictionary <long, object>(Hal.MaxParallelsProcess + 5); SonarProgress = new Dictionary <long, int>(); SonarCache = new Dictionary <string, object>(); ProcessInQueue = new Queue <object>(); ProcessInQueueIndex = new List <long>(); CacheDependencies = new Dictionary <string, IList <long> >(); IndexDependencies = new Dictionary <string, string>(); } if (exeCxt != null) { exeCxt.AttachWork(sticky, forceExecution); return(-1); } //Asignamos un ticket de ejecución al trabajo sticky.Id = Hal.GetTicket(); //Creamos el trabajo y lo ejecutamos si no excede //el limite de hilos en ejecución o es prioritario if (Hal.Sonar.Count < Hal.MaxParallelsProcess || forceExecution) { RunWork(sticky); } else { //Si hay demasiados trabajos en paralelo //se encola para su futura ejecución ProcessInQueue.Enqueue(sticky); ProcessInQueueIndex.Add(sticky.Id); } return(sticky.Id); }
/// <summary> /// Ejecuta un proceso en segundo plano /// </summary> /// <typeparam name="T">Tipo de parámetro del delegado a invocar</typeparam> /// <param name="sticky">Plan de ejecución</param> private static void RunWork <T>(Sticky <T> sticky) { var work = CreateWork(); string wHash = work.GetHashCode().ToString(CultureInfo.InvariantCulture); Hal.Sonar.Add(sticky.Id, work); //Se comprueba si en el plan de ejecución se tiene en cuenta el cacheo if (sticky.IsCacheable) { lock (CacheDependencies) { if (!CacheDependencies.ContainsKey(sticky.Hash)) { //Creamos el proceso maestro que servirá de referencia para los demás CacheDependencies[sticky.Hash] = new List <long>(); IndexDependencies[wHash] = sticky.Hash; } else { CacheDependencies[sticky.Hash].Add(sticky.Id); return; } } } //Comprobamos si el nuevo proceso es el más prioritario if (Hal.KingHill == null) { Hal.KingHill = new KingHill(wHash, sticky.PriorityPercent); } else { lock (Hal.KingHill) { Hal.KingHill.AddWorker(wHash, sticky.PriorityPercent); } } //Ejecutamos el trabajo work.RunWorkerAsync(sticky); }
private IEnumerator StickyFade(Sticky sticky, bool flag) { if (flag) { // Open for (float i = 0; i <= STICKY_FADE_TIME; i += Time.deltaTime) { float percentage = i / STICKY_FADE_TIME; sticky.MainCanvas.transform.localScale = Vector3.one * STICKY_SCALE * percentage; yield return(null); } sticky.MainCanvas.transform.localScale = Vector3.one * STICKY_SCALE; } else { // Close yield return(null); } }
public void ClickSticky(GameObject target) { if (!HoldingStickyState.isHolding.Value) { HoldingStickyState.targetSticky = target; PhotonView view = target.GetComponent <PhotonView>(); if (!view.IsMine) { view.TransferOwnership(PhotonNetwork.LocalPlayer.ActorNumber); } target.transform.parent = StickyAnchor; Sticky sticky = target.GetComponent <Sticky>(); sticky.RemoveParent(); target.transform.SetPositionAndRotation(StickyAnchor.transform.position, Quaternion.identity); HoldingStickyState.isHolding.Value = true; } }
private void Initialize(INetworkEngineConnector networkEngineConnector) { sticky = gameObject.GetComponent <Sticky>(); image = sticky.displayImage; textureSharingComponent = gameObject.GetComponent <TextureSharingComponent>(); textureBroadcastComponent = gameObject.GetComponent <TextureBroadcastComponent>(); textureSharingComponent.OnReceivedRawTexture .Subscribe(tex2d => SetTexture(tex2d)) .AddTo(this); textureBroadcastComponent.OnReceivedRawTexture .Subscribe(tex2d => SetTexture(tex2d)) .AddTo(this); networkEngineConnector.OnJoinedRoomAsObservable .Where(_ => sticky.displayText.text.Equals(string.Empty)) .Subscribe(_ => StartTextureSharing()) .AddTo(this); }
public void ChangeStickyIcon(Sticky sticky) { switch (sticky) { case Sticky.Top: this.Button_Sticky.BackgroundImage = nemonic.Properties.Resources.icon_menu_sticky_top; break; case Sticky.Left: this.Button_Sticky.BackgroundImage = nemonic.Properties.Resources.icon_menu_sticky_left; break; case Sticky.Bottom: this.Button_Sticky.BackgroundImage = nemonic.Properties.Resources.icon_menu_sticky_bottom; break; case Sticky.Right: this.Button_Sticky.BackgroundImage = nemonic.Properties.Resources.icon_menu_sticky_right; break; } }
private void OnCollisionEnter2D(Collision2D other) { if (!isAttached) { Sticky otherStick = other.collider.gameObject.GetComponent <Sticky>(); Sticky myStick = GetComponent <Sticky>(); if (otherStick != null) { // calculate difference in colors int colorDifference = 0; colorDifference = ColorDifference(otherStick.colorID, myStick.colorID); if (colorDifference <= 1) { bool success = otherStick.AttachBlob(this.GetComponent <Sticky>()); this.isAttached = success; } } } }
private void OnTriggerStay2D(Collider2D other) { if (!isAttached) { RepellTrigger repellTrigger = other.GetComponent <RepellTrigger>(); if (repellTrigger != null) { Sticky otherSticky = repellTrigger.attachedTo.GetComponent <Sticky>(); Sticky mySticky = GetComponent <Sticky>(); if (otherSticky != mySticky) { int dif = ColorDifference(mySticky.colorID, otherSticky.colorID); if (dif > 1) { // repell Vector2 delta = transform.position - otherSticky.transform.position; rb.AddForce(delta.normalized * rb.mass * repellForce); } } } } }
public void AddSticky(Sticky sticky) { sticky.Id = NextStickyId.ToString(); NextStickyId++; Stickies.Add(sticky); }
//get nearest sticky to the position giving, pass in the toplevel sticky you are checking from private Sticky GetNearest(Vector3 inPos, Sticky sticky) { Sticky closest = null; float minDist = float.MaxValue; Queue<Sticky> toCheck = new Queue<Sticky>(); toCheck.Enqueue(sticky); //gross flat queue recursion. while(toCheck.Count > 0){ Sticky testing = toCheck.Dequeue(); Vector3 testPos = testing.gameObject.transform.position; float testDist = Vector3.Distance(testPos,inPos); if(testDist < minDist){ minDist = testDist; closest = testing; } foreach(Sticky s in testing.children.Keys){ toCheck.Enqueue(s); } } return closest; }
void ProcessStickyInput() { if (stuck && ((Input.GetButtonUp("LeftStickyP"+playerNum)&&leftSticky.isStuck) || (Input.GetButtonUp("RightStickyP"+playerNum)&& rightSticky.isStuck))) { stuck = false; stuckSticky.Unstick(); stuckSticky = null; } else if(Input.GetButton("LeftStickyP"+playerNum) && leftSticky.canStick && !stuck) { if(stuckSticky) stuckSticky.Unstick(); leftSticky.StickToThatThing(); stuck = true; stuckSticky = leftSticky; } else if(Input.GetButton("RightStickyP"+playerNum) && rightSticky.canStick && !stuck) { if(stuckSticky) stuckSticky.Unstick(); rightSticky.StickToThatThing(); stuck = true; stuckSticky = rightSticky; } }
/// <summary> /// Ejecuta un proceso en segundo plano o lo coloca en la cola de ejecución /// en caso de no quedar ningún hilo libre /// </summary> /// <typeparam name="T">Tipo de parámetro del delegado a invocar</typeparam> /// <param name="sticky">Plan de ejecución</param> /// <param name="forceExecution">Indica que se ejecuta sin tener en cuenta el número de procesos en ejecución</param> /// <returns>Identificador del plan de ejecución</returns> public static long AddWork <T>(Sticky <T> sticky, bool forceExecution) { return(AddWork(sticky, forceExecution, null)); }
/// <summary> /// Actualiza los datos de ejecución de un proceso en segundo plano /// </summary> /// <typeparam name="T">Tipo de parámetro del delegado a invocar</typeparam> /// <param name="sticky">Plan de ejecución</param> public static void UpdateWork <T>(Sticky <T> sticky) { RemoveWork(sticky); AddWork(sticky); }
/// <summary> /// Elimina un proceso en segundo plano /// </summary> /// <typeparam name="T">Tipo de parámetro del delegado a invocar</typeparam> /// <param name="sticky">Plan de ejecución</param> public static void RemoveWork <T>(Sticky <T> sticky) { RemoveWork(sticky.Id); }