コード例 #1
0
        public void init()
        {
            title = "Analyze Stock";
            inputs = new List<FormInput>();

            FormInput symbol = new FormInput("Symbol", 4, 0, 0);
            symbol.Highlighted = true;
            symbol.ValueModified += UpdateValues;
            inputs.Add(symbol);

            FormInput nameField = new FormInput("Name", 15, 0, 0);

            inputs.Add(nameField);
            inputs.Add(new FormInput("Currency", 15, 0, 0));
            inputs.Add(new FormInput("AskPrice", 15, 0, 0));
            inputs.Add(new FormInput("BidPrice", 15, 0, 0));
            inputs.Add(new FormInput("LatestTradePrice", 15, 0, 0));
            inputs.Add(new FormInput("DayLow", 15, 0, 0));
            inputs.Add(new FormInput("DayHigh", 15, 0, 0));
            inputs.Add(new FormInput("DayValueChange", 15, 0, 0));
            inputs.Add(new FormInput("YearLow", 15, 0, 0));
            inputs.Add(new FormInput("YearHigh", 15, 0, 0));

            CalculateWindowSize();
            CalculateWindowPosition();

            textXPos = menuXPos + 2;
        }
コード例 #2
0
        public void init()
        {
            title = "Buy Stock";
            inputs = new List<FormInput>();

            FormInput symbol = new FormInput("Symbol", 4, 0, 0);
            symbol.Highlighted = true;
            symbol.ValueModified += UpdateValues;
            inputs.Add(symbol);

            FormInput quantity = new FormInput("Quantity", 6, 0, 0);
            quantity.ValueModified += UpdateValues;
            quantity.ValueText = ""+1;
            inputs.Add(quantity);

            FormInput totalValue = new FormInput("Total", 10, 0, 0);
            totalValue.ValueModified += UpdateValues;
            totalValue.ValueText = ""+0;
            inputs.Add(totalValue);

            CalculateWindowSize();
            CalculateWindowPosition();

            textXPos = menuXPos + 2;
        }
コード例 #3
0
        public LoginForm()
        {
            title = "Login";
            inputs = new List<FormInput>();

            FormInput username = new FormInput("Username", 10, 0, 0);
            username.Highlighted = true;
            inputs.Add(username);

            FormInput password = new FormInput("Password", 15, 0, 0);
            inputs.Add(password);

            CalculateWindowSize();
            CalculateWindowPosition();

            textXPos = menuXPos + 2;
        }
コード例 #4
0
        public CreateAccount()
        {
            title = "Create Account";
            inputs = new List<FormInput>();

            FormInput username = new FormInput("Username", 15, 0, 0);
            username.Highlighted = true;
            inputs.Add(username);

            FormInput password = new FormInput("Password", 15, 0, 0);
            inputs.Add(password);

            FormInput password2 = new FormInput("Confirm Pass", 15, 0, 0);
            inputs.Add(password2);

            FormInput startingAmount = new FormInput("Beginning Balance", 15, 0, 0);
            startingAmount.ValueText = "10000";
            inputs.Add(startingAmount);

            CalculateWindowSize();
            CalculateWindowPosition();

            textXPos = menuXPos + 2;
        }
コード例 #5
0
    private void AddState(Auxiliary auxiliary, FormInput form)
    {
        Type type = Type.GetType(tool.Name + "AuxiliaryState");

        if (type != null)
        {
            AuxiliaryState auxiliaryState = (AuxiliaryState)Activator.CreateInstance(type, tool, auxiliary, geometry);
            auxiliaryState.OnClickDelete = () => geoController.RemoveAuxiliaryOperation(auxiliary);

            //state单击
            auxiliaryState.DoubleClick = () => this.TurnToFront(auxiliary, form);

            //Action OnElementHighLight  0925 Requirement_1
            auxiliaryState.OnElementHighlight = () =>
            {
                //Hightlight face
                ChangeFaceColorIndex((GeoFace)auxiliary.elements[0], 1);

                //Hide coordinate
                geoUI.navPanel.OnCoordinateButtonClick(1);
                geoUI.navPanel.SetCoordinateButtonStatus(1); //Change Button status

                //Hide grid
                geoUI.navPanel.OnGridButtonClick(1);
                geoUI.navPanel.SetGridButtonStatus(1);


                //Measure Line length
                if (auxiliary.elements[0] is GeoFace)
                {
                    GeoFace geoFace = (GeoFace)auxiliary.elements[0];
                    for (int i = 0; i < geoFace.Ids.Length; i++)
                    {
                        int vertex1 = i;
                        int vertex2 = (i + 1) % geoFace.Ids.Length;

                        Measure measure = new LineLengthMeasure(geoFace.Ids[vertex1], geoFace.Ids[vertex2]);

                        measure_list.Add((Measure)measure);

                        measure.InitWithGeometry(geometry);
                        bool result = geometry.Implement.AddMeasure(measure);
                        if (result)
                        {
                            List <ToolGroup> toolGroups            = geoUI.toolPanel.ToolGroups();
                            Tool             lineLengthMeasureTool = toolGroups[3].Tools[0];
                            AddState_Measure(measure, lineLengthMeasureTool);

                            Gizmo[] gizmos = measure.gizmos;
                            if (gizmos != null)
                            {
                                foreach (Gizmo gizmo in gizmos)
                                {
                                    geometry.AddGizmo(gizmo);
                                    geometryBehaviour.AddGizmo(gizmo);
                                }
                            }
                        }
                        else
                        {
                            // TODO
                        }
                    }
                }
                //Measure CornerAngle
                if (auxiliary.elements[0] is GeoFace)
                {
                    GeoFace geoFace = (GeoFace)auxiliary.elements[0];
                    for (int i = 0; i < geoFace.Ids.Length; i++)
                    {
                        int vertex1 = i;
                        int vertex2 = (i + 1) % geoFace.Ids.Length;
                        int vertex3 = (i + 2) % geoFace.Ids.Length;

                        Measure measure = new CornerAngleMeasure(geoFace.Ids[vertex1], geoFace.Ids[vertex2], geoFace.Ids[vertex3]);

                        measure_list.Add((Measure)measure);

                        measure.InitWithGeometry(geometry);


                        bool result = geometry.Implement.AddMeasure(measure);

                        if (result)
                        {
                            List <ToolGroup> toolGroups             = geoUI.toolPanel.ToolGroups();
                            Tool             cornerAngleMeasureTool = toolGroups[3].Tools[1];
                            AddState_Measure(measure, cornerAngleMeasureTool);

                            Gizmo[] gizmos = measure.gizmos;
                            if (gizmos != null)
                            {
                                foreach (Gizmo gizmo in gizmos)
                                {
                                    geometry.AddGizmo(gizmo);
                                    geometryBehaviour.AddGizmo(gizmo);
                                }
                            }
                        }
                        else
                        {
                            // TODO
                        }
                    }
                }
                //Measure Plane Area
                if (auxiliary.elements[0] is GeoFace)
                {
                    GeoFace geoFace = (GeoFace)auxiliary.elements[0];
                    //Debug.Log(geoFace.Ids);
                    Measure measure = new PlaneAreaMeasure(geoFace.Ids);

                    measure_list.Add(measure);

                    measure.InitWithGeometry(geometry);


                    bool result = geometry.Implement.AddMeasure(measure);

                    if (result)
                    {
                        List <ToolGroup> toolGroups           = geoUI.toolPanel.ToolGroups();
                        Tool             planeAreaMeasureTool = toolGroups[3].Tools[2];
                        AddState_Measure(measure, planeAreaMeasureTool);

                        Gizmo[] gizmos = measure.gizmos;
                        if (gizmos != null)
                        {
                            foreach (Gizmo gizmo in gizmos)
                            {
                                geometry.AddGizmo(gizmo);
                                geometryBehaviour.AddGizmo(gizmo);
                            }
                        }
                    }
                    else
                    {
                        // TODO
                    }
                }

                // Hide elements beyond the Highlighted face
                GeoVertex[] geoVertices = geometry.GeoVertices();
                if (auxiliary.elements[0] is GeoFace)
                {
                    GeoFace      geoFace      = (GeoFace)auxiliary.elements[0];
                    VertexUnit[] faceVertices = geoFace.get_vertices();
                    Vector3      side1        = faceVertices[0].Position() - faceVertices[1].Position();
                    Vector3      side2        = faceVertices[2].Position() - faceVertices[1].Position();
                    Vector3      normalVector = Vector3.Cross(side1, side2);

                    if (normalVector.x < 0)
                    {
                        normalVector.x = -normalVector.x;
                        normalVector.y = -normalVector.y;
                        normalVector.z = -normalVector.z;
                    }
                    if (normalVector.x == 0)
                    {
                        if (normalVector.z < 0)
                        {
                            normalVector.y = -normalVector.y;
                            normalVector.z = -normalVector.z;
                        }
                    }

                    Vector3 anchor = faceVertices[1].Position() + normalVector * 2;

                    float     min   = 1000;
                    GeoEdge[] edges = geometry.GeoEdges();
                    foreach (VertexUnit vertexUnit in geoFace.get_vertices())
                    {
                        float face_vertex_distance = Vector3.Distance(vertexUnit.Position(), anchor);
                        if (face_vertex_distance < min)
                        {
                            min = face_vertex_distance;
                        }
                    }
                    foreach (GeoVertex geoVertex in geoVertices)
                    {
                        float distance = Vector3.Distance(geoVertex.VertexUnit().Position(), anchor);
                        if (distance < min)
                        {
                            //隐藏该顶点
                            ElementBehaviour vertexElementBehaviour = geometryBehaviour.elementMap[geoVertex];
                            vertexElementBehaviour.SetVisible(false);
                            elementBehaviour_list.Add(vertexElementBehaviour);
                            //隐藏该顶点起始的所有边
                            foreach (GeoEdge geoEdge in edges)
                            {
                                if (geoVertex.Id == geoEdge.Id1 || geoVertex.Id == geoEdge.Id2)
                                {
                                    ElementBehaviour edgeElementBehaviour = geometryBehaviour.elementMap[geoEdge];
                                    edgeElementBehaviour.SetVisible(false);
                                    elementBehaviour_list.Add(edgeElementBehaviour);
                                }
                            }
                        }
                    }
                }
            };

            auxiliaryState.UndoFaceHighlight = () =>
            {
                //Undo Hightlight face
                ChangeFaceColorIndex((GeoFace)auxiliary.elements[0], 0);


                //Undo Hide coordinate
                geoUI.navPanel.OnCoordinateButtonClick(0);
                geoUI.navPanel.SetCoordinateButtonStatus(0); //Change Button status

                //Hide grid
                geoUI.navPanel.OnGridButtonClick(0);
                geoUI.navPanel.SetGridButtonStatus(0);

                //Claer All Face_MeasureStates
                foreach (Measure measure in measure_list)
                {
                    geoController.RemoveMeasure(measure);
                }
                foreach (ElementBehaviour elementBehaviour in elementBehaviour_list)
                {
                    elementBehaviour.SetVisible(true);
                }
            };



            stateController.AddAuxiliaryState(auxiliaryState);
        }
    }
コード例 #6
0
 public void SetWriteInput(FormInput writeInput)
 {
     this.writeInput = writeInput;
 }
コード例 #7
0
ファイル: GameData.cs プロジェクト: martre3/furriest-machine
 public void UpdateInput(FormInput input)
 {
     this.InputHandler.Merge(input);
 }
コード例 #8
0
ファイル: Record.cs プロジェクト: yansanbai/geospace
 public Record(ToolGroupType type, Tool tool)
 {
     this.type = type;
     this.tool = tool;
     form      = null;
 }
コード例 #9
0
 public string post_form_values(FormInput input)
 {
     return input.ToString();
 }
コード例 #10
0
 public abstract Auxiliary GenerateAuxiliary(Geometry geometry, FormInput formInput);
コード例 #11
0
 private void AddMarkLabel(FormInput formInput, HtmlElement htmlElement, HtmlContainer htmlContainer)
 {
     AddLabelMark(formInput, htmlElement, htmlContainer, false);
 }
コード例 #12
0
        private void buttonInput_Click(object sender, EventArgs e)
        {
            FormInput fInput = new FormInput();

            fInput.Show();
        }
コード例 #13
0
 public void Merge(FormInput input)
 {
     _input.Merge(input);
 }
コード例 #14
0
 public InputHandler(FormInput input)
 {
     _input = input;
 }
コード例 #15
0
    public override void Start()
    {
        FormInput formInput;

        string  sign     = geometry.VertexSign(vertexUnit.id);
        Vector3 position = vertexUnit.Position();


        formInput = new FormInput(8);
        FormNum formNumX = new FormNum(position.x);
        FormNum formNumY = new FormNum(position.y);
        FormNum formNumZ = new FormNum(position.z);

        formNumX.format = UIConstants.PointFormat;
        formNumY.format = UIConstants.PointFormat;
        formNumZ.format = UIConstants.PointFormat;

        FormElement formElement = new FormElement(1);

        formElement.fields[0] = sign;

        formInput.inputs[0] = formElement;
        formInput.inputs[1] = new FormText("(");
        formInput.inputs[2] = formNumX;
        formInput.inputs[3] = new FormText(",");
        formInput.inputs[4] = formNumY;
        formInput.inputs[5] = new FormText(",");
        formInput.inputs[6] = formNumZ;
        formInput.inputs[7] = new FormText(")");

        inputPanel.SetFormForInput(formInput);

        inputPanel.OnValidate = (form) =>
        {
            return(!formNumX.isEmpty && !formNumY.isEmpty && !formNumZ.isEmpty);
        };

        inputPanel.OnClickSubmit = (form) =>
        {
            float x = formNumX.num;
            float y = formNumY.num;
            float z = formNumZ.num;

            Vector3 newPosition = new Vector3(x, y, z);

            geometry.SetUnitVector(vertexUnit.id, newPosition);

            stateController.RefreshStateCellById(vertexUnit.id);

            geometryBehaviour.UpdateElements();
            geometryBehaviour.UpdateSignsPosition();
            geometryBehaviour.UpdateGizmos();

            geoController.EndOperation();
        };

        inputPanel.OnClickCancel = (form) =>
        {
            geoController.EndOperation();
        };
    }
コード例 #16
0
 private HtmlText GetMarkHtmlText(FormInput formInput)
 {
     return(new HtmlText((formInput.IsMarkedRequired ? formInput.RequiredMark : formInput.IsMarkedOptional?formInput.OptionalMark: "").Replace(" ", "&nbsp;")));
 }
コード例 #17
0
 private string GetMarkClass(FormInput formInput)
 {
     return(formInput.IsMarkedRequired ? "formMarkRequired" : formInput.IsMarkedOptional ? "formMarkOptional" : "");
 }
コード例 #18
0
    public void addAuxiliary(Geometry geometry, FormInput form)
    {
        //Debug.Log(form.inputs[0] + " " + form.inputs[1] + " " + form.inputs[2] + " " + form.inputs[3]);
        //Debug.Log(form.inputs[0].GetType() + " " + form.inputs[1].GetType() + " " + form.inputs[2].GetType() + " " + form.inputs[3].GetType());
        //Debug.Log(form.inputs[0].GetType() + " " + form.inputs[1].GetType() + " " + form.inputs[2].GetType());
        Auxiliary auxiliary = auxiliaryTool.GenerateAuxiliary(geometry, form);

        if (auxiliary == null)
        {
            geoController.EndOperation();
            return;
        }
        auxiliary.InitWithGeometry(geometry);

        VertexUnit[] units    = auxiliary.units;
        GeoElement[] elements = auxiliary.elements;

        bool result = geometry.Assistor.AddAuxiliary(auxiliary);

        if (result)
        {
            foreach (VertexUnit unit in units)
            {
                geometry.AddVertexUnit(unit);
            }

            geometry.RefreshGeoEdges();
            foreach (GeoElement element in elements)
            {
                geometry.AddElement(element);
            }

            AddState(auxiliary, form);

            geometryBehaviour.UpdateElements();
            foreach (GeoElement element in elements)
            {
                geometryBehaviour.AddElement(element);
            }

            geometryBehaviour.UpdateSignsPosition();
            foreach (VertexUnit unit in units)
            {
                geometryBehaviour.AddSign(unit.id);
            }


            Gizmo[] gizmos = auxiliary.gizmos;
            if (gizmos != null)
            {
                foreach (Gizmo gizmo in gizmos)
                {
                    geometry.AddGizmo(gizmo);
                    geometryBehaviour.AddGizmo(gizmo);
                }
            }

            geometryBehaviour.UpdateGeometryShade();
        }
        else
        {
            // TODO
            //Debug.Log("pp");
        }

        geoController.EndOperation();
    }
コード例 #19
0
 public override bool ValidateInput(Geometry geometry, FormInput formInput)
 {
     return(true);
 }
コード例 #20
0
 private void AddLabelMark(FormInput formInput, HtmlElement htmlElement, HtmlContainer htmlContainer)
 {
     AddLabelMark(formInput, htmlElement, htmlContainer, true);
 }
コード例 #21
0
    public void Classify(String str)
    {
        str = str.ToUpper();
        str = str.Replace(" ", "");

        /*
         * 正方体/立方体ABCD-A1B1C1D1
         * 三棱锥P-ABC
         * 旋转体  矩形旋转体、三角形旋转体
         * 长宽高
         *
         * 作空间中一点A(1,1,1)
         * 作两点、线段中点              作AB中点C
         *      线段描点                     取AB上一点C
         *  作平面重心                   作面ABC..重心M
         *  连接两点                     连接MN
         * 过点作线段垂线               过点A作线段MN垂线交线段于点P
         *  过点作平面垂线               过点A作面ABC..垂线交面于点Q
         * 连接点作平面                 连接ABC..作平面
         * 测量长度、角度、面积          ...的长度/角度/面积
         */
        if (state != GeoState.Normal)
        {
            return;
        }
        if (str == "旋转")
        {
            Debug.Log("旋转");
            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[0];
            //Debug.Log(tool.Type);  //reslovedBody
            SetState(GeoState.Auxiliary);

            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            currentOperation.Start();
        }
        else if (str == "展开")
        {
            Debug.Log("展开");
            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[1];
            //Debug.Log(tool.Type);  //reslovedBody
            SetState(GeoState.Auxiliary);

            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            currentOperation.Start();
        }
        else if (str.Length < 3)
        {
            Debug.Log("input error");
        }
        else if (str.Substring(0, 3) == "正方体" || str.Substring(0, 3) == "立方体")
        {
            Debug.Log("正方体");
            Tool tool = geoUI.toolPanel.toolGroups[0].Tools[0];
            currentOperation = new GeometryOperation(this, toolController, stateController, tool, geometryBehaviour);
            String list = "";

            if (str.Length > 3)
            {
                //Debug.Log(str.Substring(3));
                String cuboidName = str.Substring(3);

                if (cuboidName.Length >= 9)
                {
                    for (int i = 0; i < cuboidName.Length; i++)
                    {
                        String item = cuboidName.Substring(i, 1);
                        if (Regex.IsMatch(cuboidName.Substring(i, 1), @"^[A-Za-z]+$"))
                        {
                            if (i == cuboidName.Length - 1)
                            {
                                list += item;
                            }
                            else
                            {
                                if (Regex.IsMatch(cuboidName.Substring(i + 1, 1), @"^[0-9]*$"))
                                {
                                    list += cuboidName.Substring(i, 2);
                                    if (i != cuboidName.Length - 2)
                                    {
                                        list += " ";
                                    }
                                    i++;
                                }
                                else
                                {
                                    list += item + " ";
                                }
                            }
                        }
                    }
                    //Debug.Log(list);
                    GeometryOperation opt = (GeometryOperation)currentOperation;
                    opt.ReSetSign(list);
                }
                else
                {
                    // default name
                }
            }

            currentOperation.Start();
        }
        else if (str.Substring(0, 3) == "三棱锥")
        {
            Debug.Log("三棱锥");
            Tool tool = geoUI.toolPanel.toolGroups[0].Tools[1];
            currentOperation = new GeometryOperation(this, toolController, stateController, tool, geometryBehaviour);
            String list = "";

            if (str.Length > 3)
            {
                Debug.Log(str.Substring(3));
                String triName = str.Substring(3);

                if (triName.Length >= 5)
                {
                    for (int i = 0; i < triName.Length; i++)
                    {
                        String item = triName.Substring(i, 1);
                        if (Regex.IsMatch(triName.Substring(i, 1), @"^[A-Za-z]+$"))
                        {
                            if (i == triName.Length - 1)
                            {
                                list += item;
                            }
                            else
                            {
                                if (Regex.IsMatch(triName.Substring(i + 1, 1), @"^[0-9]*$"))
                                {
                                    list += triName.Substring(i, 2);
                                    if (i != triName.Length - 2)
                                    {
                                        list += " ";
                                    }
                                    i++;
                                }
                                else
                                {
                                    list += item + " ";
                                }
                            }
                        }
                    }
                    Debug.Log(list);
                    GeometryOperation opt = (GeometryOperation)currentOperation;
                    opt.ReSetSign(list);
                }
                else
                {
                    // default name
                }
            }

            currentOperation.Start();
        }
        else if (str.IndexOf("旋转体") != -1)
        {
            Debug.Log("旋转体");
            Tool tool = geoUI.toolPanel.toolGroups[0].Tools[2];
            currentOperation = new GeometryOperation(this, toolController, stateController, tool, geometryBehaviour);
            currentOperation.Start();
            if (str == "矩形旋转体" || str == "长方形旋转体")
            {
                Tool tool1 = geoUI.toolPanel.toolGroups[1].Tools[0];
                Debug.Log(tool1.Description);
                //Debug.Log(tool1.Type);

                SetState(GeoState.Condition);

                currentOperation = new AddConditionOperation(this, stateController, geometry, geometryBehaviour, geoUI, tool1);
                currentOperation.Start();
            }
            else if (str == "三角形旋转体")
            {
                Tool tool1 = geoUI.toolPanel.toolGroups[1].Tools[1];
                Debug.Log(tool1.Description);
                //Debug.Log(tool1.Type);

                SetState(GeoState.Condition);

                currentOperation = new AddConditionOperation(this, stateController, geometry, geometryBehaviour, geoUI, tool1);
                currentOperation.Start();
            }
        }
        else if (str.IndexOf("空间一点") != -1)
        {
            Debug.Log("取空间一点");
        }
        else if (str.IndexOf("中点") != -1)
        {
            Debug.Log("中点");
            String line = "";
            for (int i = 1; i < str.Length - 2; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        line += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        line += str.Substring(i, 1) + " ";
                    }
                }
            }

            FormText    text1 = new FormText("作");
            String[]    eles  = line.Split(' ');
            FormElement ele1  = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText    text2 = new FormText("中点");
            FormElement ele2  = new FormElement(1);
            if (Regex.IsMatch(str.Substring(str.Length - 2), @"^[A-Za-z0-9]+$"))
            {
                ele2.fields[0] = str.Substring(str.Length - 2);
            }
            else
            {
                ele2.fields[0] = str.Substring(str.Length - 1);
            }

            FormInput writeInput = new FormInput(4);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;
            writeInput.inputs[3] = ele2;

            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[1];
            SetState(GeoState.Auxiliary);


            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddAuxiliaryOperation opt = (AddAuxiliaryOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if ((str.IndexOf("一点") != -1 && str.IndexOf("线段") != -1) || ((str.IndexOf("作线段") != -1 || str.IndexOf("做线段") != -1) && str.IndexOf("的点") != -1))
        {
            Debug.Log("取线段一点");

            String line = "";
            for (int i = 1; i < str.Length - 2; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        line += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        line += str.Substring(i, 1) + " ";
                    }
                }
            }
            //Debug.Log(line);
            FormText    text1 = new FormText("作线段");
            String[]    eles  = line.Split(' ');
            FormElement ele1  = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText    text2 = new FormText("的点");
            FormElement ele2  = new FormElement(1);
            if (Regex.IsMatch(str.Substring(str.Length - 2), @"^[A-Za-z0-9]+$"))
            {
                ele2.fields[0] = str.Substring(str.Length - 2);
            }
            else
            {
                ele2.fields[0] = str.Substring(str.Length - 1);
            }
            //Debug.Log(ele2.fields[0]);
            FormInput writeInput = new FormInput(4);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;
            writeInput.inputs[3] = ele2;

            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[2];
            SetState(GeoState.Auxiliary);


            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddAuxiliaryOperation opt = (AddAuxiliaryOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("重心") != -1 || str.IndexOf("中心") != -1)
        {
            Debug.Log("重心");
            String face = "";
            for (int i = 1; i < str.Length - 3; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        face += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        face += str.Substring(i, 1) + " ";
                    }
                }
            }

            FormText    text1 = new FormText("作平面");
            String[]    eles  = face.Split(' ');
            FormElement ele1  = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText    text2 = new FormText("的重心");
            FormElement ele2  = new FormElement(1);
            if (Regex.IsMatch(str.Substring(str.Length - 2), @"^[A-Za-z0-9]+$"))
            {
                ele2.fields[0] = str.Substring(str.Length - 2);
            }
            else
            {
                ele2.fields[0] = str.Substring(str.Length - 1);
            }
            FormInput writeInput = new FormInput(4);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;
            writeInput.inputs[3] = ele2;

            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[3];
            SetState(GeoState.Auxiliary);


            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddAuxiliaryOperation opt = (AddAuxiliaryOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("连接") != -1 && Regex.IsMatch(str.Substring(2), @"^[A-Za-z0-9]+$"))
        {
            Debug.Log("连接两点");

            String line = "";
            for (int i = 2; i < str.Length - 1; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        line += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        line += str.Substring(i, 1) + " ";
                        if (i == str.Length - 2)
                        {
                            line += str.Substring(i + 1);
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            FormText    text1 = new FormText("连接");
            String[]    eles  = line.Split(' ');
            FormElement ele1  = new FormElement(eles.Length);
            for (int i = 0; i < eles.Length; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText text2 = new FormText("作线段");

            FormInput writeInput = new FormInput(3);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;

            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[4];
            SetState(GeoState.Auxiliary);


            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddAuxiliaryOperation opt = (AddAuxiliaryOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("垂线") != -1 && str.IndexOf("线段") != -1)
        {
            Debug.Log("线段垂线");
            String point1 = "";
            for (int i = 1; i < 4; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        point1 += str.Substring(i, 2);
                        //Debug.Log(point1 + "---");
                        break;
                    }
                    else
                    {
                        point1 += str.Substring(i, 1);
                        break;
                    }
                }
            }

            String face = "";
            for (int i = 5; i < str.Length - 2; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        face += str.Substring(i, 2) + " ";
                        i++;
                    }
                    else
                    {
                        face += str.Substring(i, 1) + " ";
                    }
                }
            }

            String point2 = "";
            if (Regex.IsMatch(str.Substring(str.Length - 2), @"^[A-Za-z0-9]+$"))
            {
                point2 = str.Substring(str.Length - 2);
            }
            else if (Regex.IsMatch(str.Substring(str.Length - 1), @"^[A-Za-z]+$"))
            {
                point2 = str.Substring(str.Length - 1);
            }
            else
            {
                Debug.Log("point lost error");
                return;
            }

            FormText text1 = new FormText("过点");
            //Debug.Log(text1);
            FormElement ele1 = new FormElement(1);
            ele1.fields[0] = point1;
            //Debug.Log(ele1);
            FormText text2 = new FormText("作平面");
            //Debug.Log(text2);
            String[]    eles = face.Split(' ');
            FormElement ele2 = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele2.fields[i] = eles[i];
                //Debug.Log(eles[i] +"*");
            }
            FormText text3 = new FormText("的垂线");
            //Debug.Log(text3);
            FormText text4 = new FormText("交于点");
            //Debug.Log(text4);
            FormElement ele3 = new FormElement(1);
            ele3.fields[0] = point2;
            //Debug.Log(point2);

            FormInput writeInput = new FormInput(7);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;
            writeInput.inputs[3] = ele2;
            writeInput.inputs[4] = text3;
            writeInput.inputs[5] = text4;
            writeInput.inputs[6] = ele3;

            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[5];
            SetState(GeoState.Auxiliary);


            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddAuxiliaryOperation opt = (AddAuxiliaryOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("垂线") != -1 && str.IndexOf("平面") != -1)
        {
            Debug.Log("面垂线");

            String point1 = "";
            for (int i = 1; i < 4; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        point1 += str.Substring(i, 2);
                        //Debug.Log(point1 + "---");
                        break;
                    }
                    else
                    {
                        point1 += str.Substring(i, 1);
                        break;
                    }
                }
            }

            String line = "";
            for (int i = 5; i < str.Length - 2; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        line += str.Substring(i, 2) + " ";
                        i++;
                    }
                    else
                    {
                        line += str.Substring(i, 1) + " ";
                    }
                }
            }

            String point2 = "";
            if (Regex.IsMatch(str.Substring(str.Length - 2), @"^[A-Za-z0-9]+$"))
            {
                point2 = str.Substring(str.Length - 2);
            }
            else if (Regex.IsMatch(str.Substring(str.Length - 1), @"^[A-Za-z]+$"))
            {
                point2 = str.Substring(str.Length - 1);
            }
            else
            {
                Debug.Log("point lost error");
                return;
            }

            FormText text1 = new FormText("过点");
            //Debug.Log(text1);
            FormElement ele1 = new FormElement(1);
            ele1.fields[0] = point1;
            //Debug.Log(ele1);
            FormText text2 = new FormText("作线段");
            //Debug.Log(text2);
            String[]    eles = line.Split(' ');
            FormElement ele2 = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele2.fields[i] = eles[i];
                //Debug.Log(eles[i] +"*");
            }
            FormText text3 = new FormText("的垂线");
            //Debug.Log(text3);
            FormText text4 = new FormText("交于点");
            //Debug.Log(text4);
            FormElement ele3 = new FormElement(1);
            ele3.fields[0] = point2;
            //Debug.Log(point2);

            FormInput writeInput = new FormInput(7);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;
            writeInput.inputs[3] = ele2;
            writeInput.inputs[4] = text3;
            writeInput.inputs[5] = text4;
            writeInput.inputs[6] = ele3;

            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[6];
            SetState(GeoState.Auxiliary);


            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddAuxiliaryOperation opt = (AddAuxiliaryOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("连接") != -1 && (str.IndexOf("作平面") != -1 || str.IndexOf("做平面") != -1))
        {
            Debug.Log("平面");

            String face = "";
            for (int i = 2; i < str.Length - 3; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        face += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        face += str.Substring(i, 1) + " ";
                    }
                }
            }

            FormText    text1 = new FormText("连接");
            String[]    eles  = face.Split(' ');
            FormElement ele1  = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText  text2      = new FormText("作平面");
            FormInput writeInput = new FormInput(3);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;

            Tool tool = geoUI.toolPanel.toolGroups[2].Tools[7];
            SetState(GeoState.Auxiliary);


            currentOperation = new AddAuxiliaryOperation(this, geoCamera, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddAuxiliaryOperation opt = (AddAuxiliaryOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("长度") != -1)
        {
            Debug.Log("测量长度");

            String line = "";
            for (int i = 0; i < str.Length - 1; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        line += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        line += str.Substring(i, 1) + " ";
                    }
                }
            }

            FormText    text1 = new FormText("线段");
            String[]    eles  = line.Split(' ');
            FormElement ele1  = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText  text2      = new FormText("的长度");
            FormInput writeInput = new FormInput(3);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;

            Tool tool = geoUI.toolPanel.toolGroups[3].Tools[0];
            SetState(GeoState.Measure);

            currentOperation = new AddMeasureOperation(this, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddMeasureOperation opt = (AddMeasureOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("角度") != -1)
        {
            Debug.Log("测量角度");

            String angle = "";
            for (int i = 0; i < str.Length - 1; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        angle += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        angle += str.Substring(i, 1) + " ";
                    }
                }
            }

            FormText text1 = new FormText("∠");
            String[] eles  = angle.Split(' ');
            if (eles.Length - 1 != 3)
            {
                Debug.Log("angle input error");
                return;
            }
            FormElement ele1 = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText  text2      = new FormText("的角度");
            FormInput writeInput = new FormInput(3);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;

            Tool tool = geoUI.toolPanel.toolGroups[3].Tools[1];
            SetState(GeoState.Measure);

            currentOperation = new AddMeasureOperation(this, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddMeasureOperation opt = (AddMeasureOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else if (str.IndexOf("面积") != -1)
        {
            Debug.Log("测量面积");

            String face = "";
            for (int i = 1; i < str.Length - 1; i++)
            {
                if (Regex.IsMatch(str.Substring(i, 1), @"^[A-Za-z]+$"))
                {
                    if (Regex.IsMatch(str.Substring(i + 1, 1), @"^[0-9]*$"))
                    {
                        face += str.Substring(i, 1) + str.Substring(i + 1, 1) + " ";
                    }
                    else
                    {
                        face += str.Substring(i, 1) + " ";
                    }
                }
            }

            FormText    text1 = new FormText("平面");
            String[]    eles  = face.Split(' ');
            FormElement ele1  = new FormElement(eles.Length - 1);
            for (int i = 0; i < eles.Length - 1; i++)
            {
                ele1.fields[i] = eles[i];
            }
            FormText  text2      = new FormText("的面积");
            FormInput writeInput = new FormInput(3);
            writeInput.inputs[0] = text1;
            writeInput.inputs[1] = ele1;
            writeInput.inputs[2] = text2;

            Tool tool = geoUI.toolPanel.toolGroups[3].Tools[2];
            SetState(GeoState.Measure);

            currentOperation = new AddMeasureOperation(this, stateController, geometry, geometryBehaviour, geoUI, tool);
            AddMeasureOperation opt = (AddMeasureOperation)currentOperation;
            opt.SetWriteInput(writeInput);
            currentOperation.Start();
        }
        else
        {
            Debug.Log("analysis error");
        }
    }
コード例 #22
0
ファイル: Measure.cs プロジェクト: Y-dc/GeoSpace
 public abstract Measure GenerateMeasure(Geometry geometry, FormInput formInput);
コード例 #23
0
 public abstract bool ValidateInput(Geometry geometry, FormInput formInput);
コード例 #24
0
ファイル: InputPanel.cs プロジェクト: yansanbai/geospace
    public void SetFormForMessage(FormInput formInput)
    {
        SetForm(formInput);

        SetState(InputPanelState.Message);
    }
コード例 #25
0
ファイル: Record.cs プロジェクト: yansanbai/geospace
 public void SetForm(FormInput form)
 {
     this.form = form;
 }
コード例 #26
0
ファイル: FormHDFS.cs プロジェクト: skyfrog0/HDFSWind
        // 新建目录
        private void menuMkdir_Click(object sender, EventArgs e)
        {
            try
            {
                TreeNode currNod = this.treeView1.SelectedNode;
                if (null == currNod)
                {
                    return;
                }

                FormInput fm = new FormInput();
                fm.Content = "newdirectory";
                if (DialogResult.OK == fm.ShowDialog())
                {
                    string name = fm.Content;
                    if (string.IsNullOrWhiteSpace(name))
                    {
                        MessageBox.Show("目录名称不能为空!");
                        return;
                    }
                    string dirname = name.Replace(":", "").Replace("/", "")
                                     .Replace(" ", "").Replace("*", "");
                    if (string.IsNullOrWhiteSpace(dirname))
                    {
                        return;
                    }

                    string parentDir = currNod.Name;
                    string hdfsDir   = (parentDir.Length > 1) ? parentDir + "/" : parentDir;
                    hdfsDir = hdfsDir + dirname;

                    bool bok = HdfsHelper.MkDir(hdfsDir);
                    if (bok)
                    {
                        // update cache
                        if (_fileinfoCache.ContainsKey(parentDir))
                        {
                            List <HdfsFileInfo> fis = _fileinfoCache[parentDir];
                            if (null != fis)
                            {
                                fis.Add(new HdfsFileInfo()
                                {
                                    Name        = dirname,
                                    PathName    = hdfsDir,
                                    IsDirectory = true,
                                });
                            }
                        }
                        // Refresh TreeNodes
                        TreeNode nod = currNod.Nodes.Add(dirname, dirname, 0);
                        nod.Name = hdfsDir;
                    }
                    else
                    {
                        MessageBox.Show("目录创建失败");
                    }
                }
            }
            catch (System.Exception ex)
            {
                DebugHelper.Error(ex);
                MessageBox.Show(ex.Message);
            }
        }