public void updateAllPulseIndicators() { foreach (Control con in timeStepsFlowPanel.Controls) { TimestepEditor ed = con as TimestepEditor; if (ed != null) { ed.updatePulsesIndicator(); } } }
public void unmarkAllTimesteps() { foreach (Control con in timeStepsFlowPanel.Controls) { TimestepEditor ed = con as TimestepEditor; if (ed != null) { ed.Marked = false; } } }
public TimestepEditor getTimestepEditor(TimeStep timeStep) { foreach (Control con in timeStepsFlowPanel.Controls) { TimestepEditor editor = con as TimestepEditor; if (editor != null) { if (editor.StepData == timeStep) { return(editor); } } } return(null); }
public void updateTimestepEditorNumbers() { foreach (Control con in timeStepsFlowPanel.Controls) { TimestepEditor ed = con as TimestepEditor; if (ed != null) { TimeStep step = ed.StepData; if (Storage.sequenceData.TimeSteps.Contains(step)) { int num = Storage.sequenceData.TimeSteps.IndexOf(step) + 1; ed.StepNumber = num; } } } }
public void scrollToTimestep(TimeStep step) { foreach (Control con in timeStepsFlowPanel.Controls) { TimestepEditor ed = con as TimestepEditor; if (ed != null) { if (ed.StepData == step) { timeStepsPanel.ScrollControlIntoView(ed); forceUpdateAllScrollbars(); return; } } } }
private void insertTimestepBeforeToolStripMenuItem_Click(object sender, EventArgs e) { TimeStep newStep = new TimeStep("New timestep."); Storage.sequenceData.TimeSteps.Insert(stepNumber - 1, newStep); Storage.sequenceData.populateWithChannels(Storage.settingsData); Storage.sequenceData.timestepsInsertedOrMoved(); TimestepEditor te = new TimestepEditor(newStep, stepNumber); WordGenerator.MainClientForm.instance.sequencePage.insertTimestepEditor(te, stepNumber - 1); // WordGenerator.mainClientForm.instance.RefreshSequenceDataToUI(Storage.sequenceData); // WordGenerator.mainClientForm.instance.sequencePage1.scrollToTimestep(newStep); }
protected override void OnMouseLeave(EventArgs e) { if (!WordGenerator.MainClientForm.instance.lockDigitalCheckBox.Checked) { // base.OnMouseLeave(e); if (mouseClicking) { mouseClicking = false; drawDrag(); } else { if (buffer == null) { createBuffer(); createAndPaintNewBuffer(); } Graphics g = Graphics.FromImage(buffer); uncolorHover(g, oldHoverPoint); if (oldTe != null) { oldTe.BorderStyle = BorderStyle.None; oldTe = null; } if (oldChanLab != null) { oldChanLab.BorderStyle = BorderStyle.None; oldChanLab = null; } oldHoverPoint = new Point(-1, -1); g.Dispose(); this.Refresh(); } } }
private void TimestepEditor_DragEnter(object sender, DragEventArgs e) { TimestepEditor otherEditor = (e.Data.GetData(typeof(TimestepEditor))) as TimestepEditor; if (otherEditor != null && otherEditor != this) { e.Effect = DragDropEffects.Move; bool rightHalf = dragToRightHalf(e); // exclude drags that don't actually move the object int myNumber = this.StepNumber; int otherNumber = otherEditor.StepNumber; if ((myNumber == otherNumber + 1) && !rightHalf) { e.Effect = DragDropEffects.None; return; } if ((myNumber == otherNumber - 1) && rightHalf) { e.Effect = DragDropEffects.None; return; } if (rightHalf) { insertRight.Visible = true; insertLeft.Visible = false; } else { insertRight.Visible = false; insertLeft.Visible = true; } } else { e.Effect = DragDropEffects.None; } }
private void TimestepEditor_DragDrop(object sender, DragEventArgs e) { TimestepEditor otherEditor = (e.Data.GetData(typeof(TimestepEditor))) as TimestepEditor; if (otherEditor == null) { clearTimestepInsertLabels(); return; } bool rightHalf = dragToRightHalf(e); int myNumber = this.StepNumber; int otherNumber = otherEditor.StepNumber; if ((otherNumber == myNumber - 1 && !rightHalf) || (otherNumber == myNumber + 1 && rightHalf) || (otherNumber == myNumber)) { clearTimestepInsertLabels(); return; } SequenceData seq = Storage.sequenceData; TimeStep otherStep = otherEditor.stepData; seq.TimeSteps.Remove(otherStep); int insertIndex = seq.TimeSteps.IndexOf(StepData); if (rightHalf) { insertIndex++; } seq.TimeSteps.Insert(insertIndex, otherStep); seq.timestepsInsertedOrMoved(); MainClientForm.instance.RefreshSequenceDataToUI(); }
public void registerTimestepEditorEvents(TimestepEditor editor) { editor.updateGUI += new EventHandler(timeStepEditor_updateGUI); editor.messageLog += messageLog; }
/// <summary> /// This function is somewhat time consuming, especially with long sequence files. /// A 100-timestep long sequence will take ~8 seconds to run this function. /// Avoid calling it unnecessarily. /// </summary> private void layoutTimestepEditors() { this.SuspendLayout(); timeStepsFlowPanel.Visible = false; timeStepsFlowPanel.SuspendLayout(); // remove old timestep editors List<Control> temp = new List<Control>(); foreach (Control con in timeStepsFlowPanel.Controls) { temp.Add(con); } foreach (Control con in temp) { TimestepEditor ed = con as TimestepEditor; if (ed != null) { ed.unRegsiterHotkey(); ed.Dispose(); } } timeStepsFlowPanel.Controls.Clear(); int count = 0; List<TimeStep> timeSteps = Storage.sequenceData.TimeSteps; List<TimestepEditor> timestepEditors = new List<TimestepEditor>(); for (int i = 0; i < timeSteps.Count; i++) { if (timeSteps[i] != null) { // show the timestep TimestepEditor editor = new TimestepEditor(timeSteps[i], i + 1); // editor.Location = new Point(timestepEditorPlaceholder.Location.X + count * timestepEditorPlaceholder.Width, // timestepEditorPlaceholder.Location.Y); registerTimestepEditorEvents(editor); //this.timeStepsPanel.BufferedControls.Add(editor); editor.registerHotkey(); count++; if (hideHiddenTimesteps) { if (timeSteps[i].StepHidden) editor.Visible = false; } timestepEditors.Add(editor); editor.SuspendLayout(); } } this.timeStepsFlowPanel.Controls.AddRange(timestepEditors.ToArray()); this.ResumeLayout(); foreach (Control con in this.timeStepsFlowPanel.Controls) con.SuspendLayout(); this.Invalidate(); timeStepsFlowPanel.ResumeLayout(); timeStepsPanel.AutoScroll = false; timeStepsFlowPanel.AutoSize = false; timeStepsFlowPanel.Visible = true; timeStepsFlowPanel.AutoSize = true; timeStepsPanel.AutoScroll = true; foreach (Control con in this.timeStepsFlowPanel.Controls) con.ResumeLayout(); if (count == 0) { beginHintLabel.Visible = true; } else { beginHintLabel.Visible = false; } }
private void colorHover(Point temp, Graphics g) { if (!invalidated) { g.FillRectangle(trueBrush(temp.Y), temp.X * colWidth + 10, temp.Y * rowHeight + 3, colWidth - 20, rowHeight - 6); Pen whitePen = Pens.White; // g.DrawLine(whitePen, 0, temp.Y * rowHeight, Width, temp.Y * rowHeight); // g.DrawLine(whitePen, 0, (temp.Y +1)* rowHeight, Width, (temp.Y+1) * rowHeight); g.DrawLine(whitePen, temp.X * ColWidth, 0, temp.X * ColWidth, Height); g.DrawLine(whitePen, (temp.X + 1) * ColWidth, 0, (temp.X + 1) * ColWidth, Height); DigitalDataPoint dp = cellPointToDigitalDataPoint(temp); if (dp != null) { if (dp.DigitalPulse != null) { paintPulse(g, temp, dp); } } TimestepEditor te = WordGenerator.MainClientForm.instance.sequencePage.getTimestepEditor( Storage.sequenceData.getNthDisplayedTimeStep(temp.X)); /* Label chanLab = WordGenerator.mainClientForm.instance.sequencePage1.digitalChannelLabelsPanel1.channelLabels[temp.Y*2]; if (oldChanLab != chanLab) { if (oldChanLab != null) { oldChanLab.BorderStyle = BorderStyle.None; } chanLab.BorderStyle = BorderStyle.FixedSingle; oldChanLab = chanLab; } */ if (oldTe != te) { if (oldTe != null) { oldTe.BorderStyle = BorderStyle.None; } te.BorderStyle = BorderStyle.FixedSingle; oldTe = te; } /* preHoverColor = te.BackColor; te.BackColor = Color.Tan; */ } }
public void registerTimestepEditorEvents(TimestepEditor editor) { editor.updateGUI += new EventHandler(timeStepEditor_updateGUI); editor.messageLog += messageLog; }
public void removeTimestepEditor(TimestepEditor editor) { editor.unRegsiterHotkey(); timeStepsFlowPanel.Controls.Remove(editor); editor.Dispose(); updateTimestepEditorNumbers(); updateTimestepEditorsAfterSequenceModeOrTimestepGroupChange(); layoutTheRest(); }
public void insertTimestepEditor(TimestepEditor ed, int index) { registerTimestepEditorEvents(ed); timeStepsFlowPanel.Controls.Add(ed); timeStepsFlowPanel.Controls.SetChildIndex(ed, index); updateTimestepEditorNumbers(); updateTimestepEditorsAfterSequenceModeOrTimestepGroupChange(); layoutTheRest(); }
/// <summary> /// used to register timestep hotkeys. Ctrl + key. /// </summary> /// <param name="key"></param> /// <param name="hotkeyObject"></param> public void registerTimestepHotkey(char key, TimestepEditor hotkeyObject) { if (hotKeyBindings == null) hotKeyBindings = new List<object>(); // convert the character to a Keys enum element. This is weird but necessary. string keyStr = "" + char.ToUpper(key); Keys myKey = (Keys)Enum.Parse(typeof(Keys), keyStr); RegisterHotKey(Handle, hotKeyBindings.Count, KeyModifiers.Control, myKey); hotKeyBindings.Add(hotkeyObject); }
protected override void OnMouseLeave(EventArgs e) { if (!WordGenerator.MainClientForm.instance.lockDigitalCheckBox.Checked) { // base.OnMouseLeave(e); if (mouseClicking) { mouseClicking = false; drawDrag(); } else { if (buffer == null) { createBuffer(); createAndPaintNewBuffer(); } Graphics g = Graphics.FromImage(buffer); uncolorHover(g, oldHoverPoint); if (oldTe != null) { oldTe.BorderStyle = BorderStyle.None; oldTe = null; } if (oldChanLab != null) { oldChanLab.BorderStyle = BorderStyle.None; oldChanLab = null; } oldHoverPoint = new Point(-1, -1); g.Dispose(); this.Refresh(); } } }
/// <summary> /// This function is somewhat time consuming, especially with long sequence files. /// A 100-timestep long sequence will take ~8 seconds to run this function. /// Avoid calling it unnecessarily. /// </summary> private void layoutTimestepEditors() { this.SuspendLayout(); timeStepsFlowPanel.Visible = false; timeStepsFlowPanel.SuspendLayout(); // remove old timestep editors timeStepsFlowPanel.Controls.Clear(); foreach (TimestepEditor ed in timestepEditors) { ed.Dispose(); } timestepEditors.Clear(); int count = 0; List <TimeStep> timeSteps = Storage.sequenceData.TimeSteps; for (int i = 0; i < timeSteps.Count; i++) { if (timeSteps[i] != null) { // show the timestep TimestepEditor editor = new TimestepEditor(timeSteps[i], i + 1); // editor.Location = new Point(timestepEditorPlaceholder.Location.X + count * timestepEditorPlaceholder.Width, // timestepEditorPlaceholder.Location.Y); registerTimestepEditorEvents(editor); //this.timeStepsPanel.BufferedControls.Add(editor); count++; if (hideHiddenTimesteps) { if (timeSteps[i].StepHidden) { editor.Visible = false; } } timestepEditors.Add(editor); editor.SuspendLayout(); } } this.timeStepsFlowPanel.Controls.AddRange(timestepEditors.ToArray()); this.ResumeLayout(); foreach (Control con in this.timeStepsFlowPanel.Controls) { con.SuspendLayout(); } this.Invalidate(); timeStepsFlowPanel.ResumeLayout(); timeStepsPanel.AutoScroll = false; timeStepsFlowPanel.AutoSize = false; timeStepsFlowPanel.Visible = true; timeStepsFlowPanel.AutoSize = true; timeStepsPanel.AutoScroll = true; foreach (Control con in this.timeStepsFlowPanel.Controls) { con.ResumeLayout(); } if (count == 0) { beginHintLabel.Visible = true; } else { beginHintLabel.Visible = false; } }
private void insertTimestepBeforeToolStripMenuItem_Click(object sender, EventArgs e) { TimeStep newStep = new TimeStep("New timestep."); Storage.sequenceData.TimeSteps.Insert(stepNumber-1, newStep ); Storage.sequenceData.populateWithChannels(Storage.settingsData); Storage.sequenceData.timestepsInsertedOrMoved(); TimestepEditor te = new TimestepEditor(newStep, stepNumber); WordGenerator.MainClientForm.instance.sequencePage.insertTimestepEditor(te, stepNumber - 1); // WordGenerator.mainClientForm.instance.RefreshSequenceDataToUI(Storage.sequenceData); // WordGenerator.mainClientForm.instance.sequencePage1.scrollToTimestep(newStep); }