示例#1
0
        public Control Create()
        {
            txt          = new FastColoredTextBox();
            txt.ReadOnly = false;
            //txt.MouseWheel += MouseWheel;
            txt.KeyDown += KeyDown;
            //txt.KeyPress += KeyPress;
            //txt.TextChanged += TextChanged;
            txt.SelectionChanged += SelectionChanged;

            //txt.Language = Language.CSharp;
            //txt.Language = Language.SQL;
            txt.Language          = Language.Custom;
            txt.DescriptionFile   = "isql_syntax_desc.xml";
            txt.Font              = new Font("Courier New", 10);
            txt.WordWrap          = true;
            txt.WordWrapMode      = WordWrapMode.CharWrapControlWidth;
            txt.ShowLineNumbers   = false;
            txt.AutoIndentNeeded += (object sender, AutoIndentEventArgs e) => { e.Shift = 0; e.AbsoluteIndentation = 0; e.ShiftNextLines = 0; };             // Disable auto-indentation

            //txt.Text = "> ";

            ClearAction        = ActionManager.CreateAction("Clear console", this, "Clear");
            PrintCommandAction = ActionManager.CreateAction("Print command to console", this, "PrintCommand");
            ActionManager.Do(ClearAction);

            return(txt);
        }
        public Slider CreateSlider(string label, float[] values)
        {
            Slider slider = new Slider(sliders.Count, values, meshBorders, meshTick, meshSlider);

            slider.label = label;
            sliders.Add(slider);
            ActionManager.Do(CustomControlValueChangedAction, slider.controlIdx, slider.Value);
            return(slider);
        }
示例#3
0
        public bool MouseDown(Size backbufferSize, MouseEventArgs e)
        {
            for (int i = 0; i < checkbars.Count; ++i)
            {
                if (checkbars[i].LabelContainsPoint(e.Location))
                {
                    if (ArgumentParameterMouseDown != null)
                    {
                        ArgumentParameterMouseDown(parameters[i], i);
                    }
                    return(true);
                }
            }

            Point tick;

            if (TickFromMousePosition(e.Location, out tick))
            {
                bool[] newIsChecked = new bool[parameters[tick.Y].isChecked.Length];

                if (tick.X == -1)
                {
                    for (int i = 0; i < parameters[tick.Y].values.Length; ++i)
                    {
                        newIsChecked[i] = true;
                    }
                    capturedTick = null;
                }
                else
                {
                    if (InputDevices.kbstate.IsKeyUp(OpenTK.Input.Key.LControl))
                    {
                        for (int i = 0; i < parameters[tick.Y].values.Length; ++i)
                        {
                            newIsChecked[i] = false;
                        }
                    }
                    else
                    {
                        for (int i = 0; i < parameters[tick.Y].values.Length; ++i)
                        {
                            newIsChecked[i] = parameters[tick.Y].isChecked[i];
                        }
                    }
                    newIsChecked[tick.X] = true;
                }

                if (ParameterChanged != null)
                {
                    ActionManager.Do(ParameterChangedAction, tick.Y, newIsChecked);
                }
                return(true);
            }
            capturedTick = null;
            return(false);
        }
示例#4
0
 public void PerformClick()
 {
     if (clickAction != null)
     {
         ActionManager.Do(clickAction);
     }
     else
     {
         ClickInternal();
     }
 }
        public bool MouseMove(Size backbufferSize, MouseEventArgs e)
        {
            if (capturedTick.HasValue)
            {
                int    y      = capturedTick.Value.Y;
                Slider slider = sliders[y];

                int x = slider.TickFromMousePosition2(e.Location);
                if (x >= 0 && x != capturedTick.Value.X)
                {
                    ActionManager.Do(CustomControlValueChangedAction, y, slider.values[x]);
                    capturedTick = new Point(x, y);
                }
            }
            return(false);
        }
        public void Init()
        {
            Vector3[] border_positions =
            {
                new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f), new Vector3(1.0f, 1.0f, 0.0f),
                new Vector3(1.0f, 1.0f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f)
            };
            meshBorders = new GLMesh(border_positions, null, null, null, null, null, PrimitiveType.Lines);

            Vector3[] tick_positions =
            {
                new Vector3(0.0f, 0.2f, 0.0f),
                new Vector3(0.0f, 0.8f, 0.0f)
            };
            meshTick = new GLMesh(tick_positions, null, null, null, null, null, PrimitiveType.Lines);

            meshSlider = new GLMesh(new Vector3[] { new Vector3(-1.0f, -0.1f, 0.0f), new Vector3(-1.0f, 1.15f, 0.0f), new Vector3(1.0f, 1.15f, 0.0f), new Vector3(1.0f, -0.1f, 0.0f) }, null, null, null, null, null, PrimitiveType.TriangleFan);

            CustomControlValueChangedAction = ActionManager.CreateAction <int, float>("Called when a custom control's value has changed", "", delegate(object[] p) {
                int controlIdx = (int)p[0];
                float value    = (float)p[1];
                if (CustomControlValueChanged != null)
                {
                    CustomControlValueChanged(controlIdx, sliders[controlIdx].Value = value);
                }
                else
                {
                    sliders[controlIdx].Value = value;
                }
                return(null);
            });
            RemoveCustomControlsAction = ActionManager.CreateAction("Remove all custom controls", "", delegate(object[] p) {
                sliders.Clear();
                return(null);
            });
            ActionManager.Do(RemoveCustomControlsAction);
        }
        public bool MouseDown(Size backbufferSize, MouseEventArgs e)
        {
            for (int i = 0; i < sliders.Count; ++i)
            {
                if (sliders[i].LabelContainsPoint(e.Location))
                {
                    /*if(ArgumentParameterMouseDown != null)
                     *      ArgumentParameterMouseDown(parameters[i], i);*/
                    return(true);
                }
            }

            Point tick;

            if (TickFromMousePosition(e.Location, out tick))
            {
                ActionManager.Do(CustomControlValueChangedAction, tick.Y, sliders[tick.Y].values[tick.X]);
                capturedTick = tick;
                return(true);
            }
            capturedTick = null;
            return(false);
        }
示例#8
0
        public void Load()
        {
            //this.images = Viewer.images;
            this.parameters = Global.parameters;

            // Create check bars for each parameter
            checkbars.Clear();
            int paramidx = 0;

            foreach (Cinema.CinemaStore.Parameter parameter in parameters)
            {
                CheckBar newcheckbar = new CheckBar(parameter, meshBorders, meshTick, meshCheck);
                newcheckbar.label      = parameter.label;
                newcheckbar.multicheck = parameter.type == "option";
                checkbars.Add(newcheckbar);

                if (ParameterChanged != null)
                {
                    bool[] initialIsChecked = new bool[parameter.isChecked.Length];
                    Array.Copy(parameter.isChecked, initialIsChecked, initialIsChecked.Length);
                    ActionManager.Do(ParameterChangedAction, paramidx++, initialIsChecked);
                }
            }
        }
示例#9
0
 public void Hide(TransformedImage image)
 {
     ActionManager.Do(HideImageAction, image);
 }
示例#10
0
 public void HideSelection()
 {
     ActionManager.Do(HideSelectionAction);
 }
示例#11
0
 public void ShowSelection()
 {
     ActionManager.Do(ShowSelectionAction);
 }
示例#12
0
 public void Hide(IEnumerable <TransformedImage> images)
 {
     ActionManager.Do(HideImagesAction, images);             //EDIT: Should be images.Clone()
 }
示例#13
0
 public void Show(TransformedImage image)
 {
     ActionManager.Do(ShowImageAction, image);
 }
示例#14
0
 public void MoveSelection(Vector3 deltapos)
 {
     ActionManager.Do(MoveSelectionAction, deltapos);
 }
示例#15
0
 public void Move(TransformedImage image, Vector3 deltapos)
 {
     ActionManager.Do(MoveImageAction, image, deltapos);
 }
示例#16
0
 public void Move(IEnumerable <TransformedImage> images, Vector3 deltapos)
 {
     ActionManager.Do(MoveImagesAction, images, deltapos);             //EDIT: Should be images.Clone()
 }
示例#17
0
        private void KeyDown(object sender, KeyEventArgs e)
        {
            if ((txt.Selection.Start.iLine < txt.LinesCount - 1 || txt.Selection.Start.iChar < 2) &&
                ((char)e.KeyData == 13 || e.KeyData == (Keys.Alt | Keys.V) || e.KeyData == (Keys.Alt | Keys.X) ||
                 ((char)e.KeyData != ' ' && (char)e.KeyData != '\t' && !char.IsControl((char)e.KeyData) && (Control.ModifierKeys & ~Keys.Shift) == 0)))
            {
                if (e.KeyData == (Keys.Alt | Keys.X))
                {
                    txt.Copy();
                    e.Handled = true;
                }
                else
                {
                    txt.Selection = lastselection;
                }
            }

            switch (e.KeyCode)
            {
            /*case Keys.LButton: // Mac bugfix
             *      if((e.Modifiers & Keys.Shift) != 0)
             *              txt.Selection = new Range(txt, 0, txt.Selection.Start.iLine, txt.Selection.End.iChar, txt.Selection.End.iLine);
             *      else
             *              txt.Selection = new Range(txt, 0, txt.Selection.Start.iLine, 0, txt.Selection.Start.iLine);
             *      e.Handled = true;
             *      break;
             * case Keys.MButton: // Mac bugfix
             *      if((e.Modifiers & Keys.Shift) != 0)
             *              txt.Selection = new Range(txt, txt.GetLineLength(txt.Selection.End.iLine), txt.Selection.End.iLine, txt.Selection.End.iChar, txt.Selection.End.iLine);
             *      else
             *              txt.Selection = new Range(txt, txt.GetLineLength(txt.Selection.End.iLine), txt.Selection.End.iLine, txt.GetLineLength(txt.Selection.End.iLine), txt.Selection.End.iLine);
             *      e.Handled = true;
             *      break;*/

            case Keys.Up:
            {
                string current = txt.Lines[txt.LinesCount - 1].Substring(2);
                if (HistoryUp(ref current))
                {
                    ReplaceLastLineText(current);
                }
            }
                e.Handled = true;
                break;

            case Keys.Down:
            {
                string current = txt.Lines[txt.LinesCount - 1].Substring(2);
                if (HistoryDown(ref current))
                {
                    ReplaceLastLineText(current);
                }
            }
                e.Handled = true;
                break;

            case Keys.Left:
            case Keys.Back:
                if (txt.Selection.Start.iChar < 2 || (txt.Selection.Start.iChar == 2 && txt.SelectionLength == 0))
                {
                    e.Handled = true;
                }
                break;

            case Keys.Enter:
            case Keys.Cancel:             // Mac num-block return key
                txt.GoEnd();
                string method = txt.Lines[txt.LinesCount - 1].Substring(2);

                string output = Execute(method);

                /*if(method.Equals("clear"))
                 * {
                 *      txt.Clear();
                 *      txt.AppendText("> ");
                 *      txt.SelectionStart += 2;
                 *      e.Handled = true;
                 *      break;
                 * }
                 *
                 * if(output != null && output != "")
                 * {
                 *      //txt.AppendText('\n' + output);
                 *      string[] lines = output.Split('\n');
                 *      foreach(string line in lines)
                 *              txt.AppendText('\n' + line);
                 *      txt.GoEnd();
                 * }
                 *
                 * txt.AppendText("\n");
                 * txt.AppendText("> ");
                 * txt.SelectionStart += 3;
                 * //new Range(txt, 0, txt.Selection.Start.iLine, txt.Selection.Start.iChar, txt.Selection.Start.iLine).ReadOnly = true;*/

                printMethod = false;                 // Printing method is only required when playing back
                ActionManager.Do(PrintCommandAction, method, output);
                printMethod = true;

                e.Handled = true;
                break;

            default:
                if ((e.Modifiers & Keys.Control) != 0 && e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9)
                {
                    if ((e.Modifiers & Keys.Shift) != 0)
                    {
                        string current = txt.Lines[txt.LinesCount - 1].Substring(2);
                        StoreMacro(e.KeyCode - Keys.D0, current);
                        PrintOutput(string.Format("Macro {0} set to \"{1}\"", e.KeyCode - Keys.D0, current));
                    }
                    else
                    {
                        ReplaceLastLineText(RecallMacro(e.KeyCode - Keys.D0));
                    }
                    break;
                }
                break;
            }
        }