예제 #1
0
        void OnVariableChange(object sender, RoutedEventArgs args)
        {
            Slider    slid = (Slider)sender;
            VarSlider vs   = (VarSlider)slid.Tag;

            vs.changed();

            CancelVarChange.IsEnabled = true;
            ApplyVarChange.IsEnabled  = true;
        }
예제 #2
0
        void OnLoaded_MainWindow(object sender, RoutedEventArgs args)
        {
            //myPlan = Builtin_Plans.CreateNewFamilyRoomShelf();
            myPlan = Builtin_Plans.CreateWorkbench();
            //myPlan = test_plan.CreateTenonInFaceWithHole();
            //myPlan = Builtin_Plans.CreateBookShelf();
            //myPlan = Builtin_Plans.CreateTable();
            //myPlan = test_plan.CreateMortiseInPlywood();
            //myPlan = test_plan.CreateNonManifold();
            //myPlan = test_plan.CreateCubeWithSmallHole();
            //myPlan = test_plan.CreateGlueTestPlan();
            //myPlan = test_plan.CreateSimpleTenonForShadow();
            //myPlan = test_plan.CreateTenonInFaceWithHoleBool3dBug();
            //myPlan = Builtin_Plans.CreateThreeMortisesInACube();
            //myPlan = test_plan.CreateTenonBug();
            //myPlan = test_plan.create_two_mortises_overlapping();
            //myPlan = test_plan.CreateWBTopProblem();
            //myPlan = test_plan.CreateTwoDrilledHolesInACube();
            //myPlan = Builtin_Plans.DrillHoleProblem();
            //myPlan = Builtin_Plans.CreateOneBoard();
            //myPlan = Builtin_Plans.CreateMiteredBoard();
            //myPlan = Builtin_Plans.CreateSpecifiedDovetail();
            //myPlan = Builtin_Plans.CreateDoubleDovetail();
            //myPlan = test_plan.CreateCubeIntoHole_Impossible();
            //myPlan = Builtin_Plans.CreateTestBlocks();

#if false
            StringBuilder sb = new StringBuilder();
            myPlan.WriteXML(sb);
            string xml = sb.ToString();

            XmlTextReader xr = new XmlTextReader(new StringReader(xml));
            XmlDocument   xd = new XmlDocument();
            xd.Load(xr);
            xr.Close();

            myPlan = Plan.FromXML(xd);
#endif

            Stopwatch sw = new Stopwatch();
            sw.Start();
            myPlan.Execute();
            sw.Stop();
            this.Title = string.Format("Sawdust ({0} seconds)", sw.ElapsedMilliseconds / 1000.0);

            // put variables into the tabs
            foreach (VariableDefinition vd in myPlan.Variables.Values)
            {
                if (vd.user)
                {
                    VarSlider vs = new VarSlider();

                    vs.vd = vd;

                    TabItem ti = new TabItem();
                    ti.Header = vd.name.Replace('_', ' ');

                    vs.tab = ti;

                    Label labMin = new Label();
                    labMin.Content = vd.min.ToString();
                    labMin.HorizontalContentAlignment = HorizontalAlignment.Left;
                    labMin.FontSize = 9;

                    Label labMax = new Label();
                    labMax.Content = vd.max.ToString();
                    labMax.HorizontalContentAlignment = HorizontalAlignment.Right;
                    labMax.FontSize = 9;

                    Label labValue = new Label();
                    labValue.Tag     = vd;
                    labValue.Content = utpub.FormatDimension(vd.Value);
                    labValue.Width   = 170;
                    labValue.HorizontalContentAlignment = HorizontalAlignment.Center;
                    labValue.FontSize = 14;

                    vs.label = labValue;

                    TextBox labHelp = new TextBox();
                    labHelp.Text         = vd.help;
                    labHelp.TextWrapping = TextWrapping.Wrap;
                    labHelp.IsReadOnly   = true;

                    Slider slid = new Slider();
                    // TODO tickmarks?
                    slid.Minimum       = vd.min;
                    slid.Maximum       = vd.max;
                    slid.Value         = vd.Value;
                    slid.ValueChanged += OnVariableChange;
                    slid.Tag           = vs;

                    vs.slider = slid;

                    StackPanel splabs = new StackPanel();
                    splabs.Orientation = Orientation.Horizontal;
                    splabs.Children.Add(labMin);
                    splabs.Children.Add(labValue);
                    splabs.Children.Add(labMax);

                    StackPanel sp = new StackPanel();
                    sp.Orientation = Orientation.Vertical;
                    sp.Children.Add(splabs);
                    sp.Children.Add(slid);
                    sp.Children.Add(labHelp);

                    ti.Content = sp;
                    myVariables.Items.Add(ti);

                    varsliders.Add(vs);
                }
            }

            ComboBoxItem cbiAll = new ComboBoxItem();
            cbiAll.Content = "Show all steps";
            cbiAll.Tag     = "__all";
            cbSteps.Items.Add(cbiAll);

            cbSteps.SelectedIndex = 0;

            ComboBoxItem cbiNotes = new ComboBoxItem();
            cbiNotes.Content = "Show steps with designer notes";
            cbiNotes.Tag     = "__notes";
            cbSteps.Items.Add(cbiNotes);

            Dictionary <sd.Action, int> ax = new Dictionary <sd.Action, int>();
            foreach (Step st in myPlan.Steps)
            {
                if (!ax.ContainsKey(st.action))
                {
                    ax[st.action] = 1;
                }
            }

            foreach (sd.Action a in ax.Keys)
            {
                if (a != sd.Action.INTRO)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    cbi.Content = string.Format("Show {0} steps", Step.GetActionString(a));
                    cbi.Tag     = a.ToString();
                    cbSteps.Items.Add(cbi);
                }
            }
        }