예제 #1
0
        public ScrollValuePopup(int dy, CircuitElm e, CirSim s) : base()
        {
            mMyElm  = e;
            mDeltaY = 0;
            mSim    = s;
            mSim.PushUndo();
            setupValues();

            Text = mName;

            mPnlV = new Panel();
            {
                mPnlV.Left = 4;
                mPnlV.Top  = 4;
                int ofsY = 0;
                /* label */
                mLabels = new Label()
                {
                    Text = "---"
                };
                mLabels.AutoSize = true;
                mLabels.Left     = 4;
                mLabels.Top      = ofsY;
                mPnlV.Controls.Add(mLabels);
                ofsY += mLabels.Height;
                /* trbValue */
                mTrbValue = new TrackBar()
                {
                    Minimum       = 0,
                    Maximum       = mNValues - 1,
                    SmallChange   = 1,
                    LargeChange   = 1,
                    TickFrequency = mNValues / 24,
                    TickStyle     = TickStyle.TopLeft,
                    Width         = 300,
                    Height        = 21,
                    Left          = 4,
                    Top           = ofsY
                };
                ofsY += mTrbValue.Height * 2 / 3;
                mTrbValue.ValueChanged += new EventHandler((sender, ev) => { setElmValue((TrackBar)sender); });
                mPnlV.Width             = mTrbValue.Width + 8;
                mPnlV.Height            = ofsY + 4;
                mPnlV.Controls.Add(mTrbValue);
                /* */
                Controls.Add(mPnlV);
            }

            doDeltaY(dy);
            Width           = mPnlV.Width + 24;
            Height          = mPnlV.Height + 48;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
        }
예제 #2
0
        public SliderDialog(CircuitElm ce, CirSim f) : base()
        {
            Text = "Add Sliders";
            sim  = f;
            elm  = ce;

            vp = new Panel();

            einfos = new ElementInfo[10];
            hp     = new Panel();
            {
                hp.AutoSize = true;
                /* Apply */
                applyButton = new Button()
                {
                    Text = "Apply"
                };
                applyButton.Click += new EventHandler((sender, e) => { apply(); });
                ctrlInsert(hp, applyButton);
                /* OK */
                okButton = new Button()
                {
                    Text = "OK"
                };
                okButton.Click += new EventHandler((sender, e) => {
                    apply();
                    closeDialog();
                });
                ctrlInsert(hp, okButton);
                /* Cancel */
                cancelButton = new Button()
                {
                    Text = "Cancel"
                };
                cancelButton.Click += new EventHandler((sender, e) => {
                    closeDialog();
                });
                ctrlInsert(hp, cancelButton);
            }
            /* */
            ctrlInsert(vp, hp);
            /* */
            vp.Left = 4;
            vp.Top  = 4;
            Controls.Add(vp);
            /* */
            buildDialog();
            Width   = vp.Width + 24;
            Height  = vp.Height + 64;
            Visible = false;
        }
예제 #3
0
        public Adjustable(StringTokenizer st, CirSim sim)
        {
            int e = st.nextTokenInt();

            if (e == -1)
            {
                return;
            }
            Elm        = sim.getElm(e);
            EditItem   = st.nextTokenInt();
            MinValue   = st.nextTokenDouble();
            MaxValue   = st.nextTokenDouble();
            SliderText = CustomLogicModel.unescape(st.nextToken());
        }
예제 #4
0
        public static void Init(CirSim sim)
        {
            int ofsY = 0;

            VerticalPanel = new Panel();

            /* Reset */
            BtnReset = new Button()
            {
                AutoSize = true, Text = "Reset"
            };
            BtnReset.Click += new EventHandler((s, e) => { sim.ResetButton_onClick(); });
            BtnReset.Left   = 4;
            BtnReset.Top    = ofsY;
            VerticalPanel.Controls.Add(BtnReset);
            ofsY += BtnReset.Height + 4;

            /* Run */
            BtnRunStop = new Button()
            {
                AutoSize = true, Text = "RUN"
            };
            BtnRunStop.Click += new EventHandler((s, e) => { sim.SetSimRunning(!sim.IsRunning); });
            BtnRunStop.Left   = 4;
            BtnRunStop.Top    = ofsY;
            VerticalPanel.Controls.Add(BtnRunStop);
            ofsY += BtnRunStop.Height + 4;

            /* Simulation Speed */
            var lbl = new Label()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "Simulation Speed"
            };

            VerticalPanel.Controls.Add(lbl);
            ofsY    += lbl.Height;
            TrbSpeed = new TrackBar()
            {
                Left          = 4,
                Top           = ofsY,
                Minimum       = 0,
                Maximum       = 1000,
                SmallChange   = 1,
                LargeChange   = 10,
                TickFrequency = 100,
                TickStyle     = TickStyle.TopLeft,
                Value         = 10,
                Width         = 200
            };
            VerticalPanel.Controls.Add(TrbSpeed);
            ofsY += TrbSpeed.Height + 4;

            /* Current Speed */
            lbl = new Label()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "Current Speed"
            };
            VerticalPanel.Controls.Add(lbl);
            ofsY      += lbl.Height;
            TrbCurrent = new TrackBar()
            {
                Left          = 4,
                Top           = ofsY,
                Minimum       = 1,
                Maximum       = 100,
                SmallChange   = 1,
                LargeChange   = 10,
                TickFrequency = 10,
                TickStyle     = TickStyle.TopLeft,
                Value         = 50,
                Width         = 200
            };
            VerticalPanel.Controls.Add(TrbCurrent);
            ofsY += TrbCurrent.Height + 4;

            /* Show Current */
            ChkShowDots = new CheckBox()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "電流を表示"
            };
            VerticalPanel.Controls.Add(ChkShowDots);
            ofsY += ChkShowDots.Height + 4;

            /* Show Values */
            ChkShowValues = new CheckBox()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "値を表示"
            };
            VerticalPanel.Controls.Add(ChkShowValues);
            ofsY += ChkShowValues.Height + 4;

            /* Show Name */
            ChkShowName = new CheckBox()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "名前を表示"
            };
            VerticalPanel.Controls.Add(ChkShowName);
            ofsY += ChkShowName.Height + 4;

            /* ANSI */
            ChkUseAnsiSymbols = new CheckBox()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "ANSI"
            };
            ChkUseAnsiSymbols.CheckedChanged += new EventHandler((s, e) => {
                setOptionInStorage("ansiResistors", ChkUseAnsiSymbols.Checked);
            });
            VerticalPanel.Controls.Add(ChkUseAnsiSymbols);
            ofsY += ChkUseAnsiSymbols.Height + 4;

            /* White Background */
            ChkPrintable = new CheckBox()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "白黒表示"
            };
            ChkPrintable.CheckedChanged += new EventHandler((s, e) => {
                for (int i = 0; i < sim.mScopeCount; i++)
                {
                    sim.mScopes[i].SetRect(sim.mScopes[i].BoundingBox);
                }
                setOptionInStorage("whiteBackground", ChkPrintable.Checked);
            });
            VerticalPanel.Controls.Add(ChkPrintable);
            ofsY += ChkPrintable.Height + 4;

            /* Show Cursor Cross Hairs */
            ChkCrossHair = new CheckBox()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "ポインターを表示"
            };
            ChkCrossHair.CheckedChanged += new EventHandler((s, e) => {
                setOptionInStorage("crossHair", ChkCrossHair.Checked);
            });
            VerticalPanel.Controls.Add(ChkCrossHair);
            ofsY += ChkCrossHair.Height + 4;

            /* TimeStep */
            ofsY += 8;
            var lblTimeStep = new Label()
            {
                Left = 4, Top = ofsY, AutoSize = true, Text = "単位時間(sec)"
            };

            VerticalPanel.Controls.Add(lblTimeStep);
            ofsY        += lblTimeStep.Height + 4;
            mTxtTimeStep = new TextBox()
            {
                Left = 4, Top = ofsY, Width = 80
            };
            mTxtTimeStep.TextChanged += new EventHandler((s, e) => {
                var tmp = 0.0;
                if (Utils.TextToNum(mTxtTimeStep.Text, out tmp))
                {
                    mTimeStep = tmp;
                }
                else
                {
                    mTxtTimeStep.Text = Utils.UnitText(mTimeStep, "");
                }
            });
            VerticalPanel.Controls.Add(mTxtTimeStep);
            ofsY += mTxtTimeStep.Height + 4;

            /* SliderPanel */
            mSliderPanel = new Panel()
            {
                Left        = 4,
                Top         = ofsY,
                BorderStyle = BorderStyle.FixedSingle,
                AutoScroll  = true
            };
            VerticalPanel.Controls.Add(mSliderPanel);

            /* */
            VerticalPanel.Width  = TrbSpeed.Width + 12;
            VerticalPanel.Height = ofsY;
        }
예제 #5
0
 public CircuitSim()
 {
     InitializeComponent();
     sim = new CirSim();
 }
예제 #6
0
 public MenuItems(CirSim sim)
 {
     mSim = sim;
 }
예제 #7
0
 public Circuit(CirSim sim)
 {
     mSim = sim;
 }
예제 #8
0
 public ScopePopupMenu(CirSim sim)
 {
     mMenuItems = new List <ToolStripMenuItem>();
     /* */
     mMenuItems.Add(mRemoveScope = new ToolStripMenuItem()
     {
         Text = "Remove Scope"
     });
     mRemoveScope.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.REMOVE_SCOPE);
     });
     mMenuItems.Add(mDock = new ToolStripMenuItem()
     {
         Text = "Dock Scope"
     });
     mDock.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.DOCK);
     });
     mMenuItems.Add(mUndock = new ToolStripMenuItem()
     {
         Text = "Undock Scope"
     });
     mUndock.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.UNDOCK);
     });
     mMenuItems.Add(mMaxScale = new ToolStripMenuItem()
     {
         Text = "Max Scale"
     });
     mMaxScale.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.MAX_SCALE);
     });
     mMenuItems.Add(mStack = new ToolStripMenuItem()
     {
         Text = "Stack"
     });
     mStack.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.STACK);
     });
     mMenuItems.Add(mUnstack = new ToolStripMenuItem()
     {
         Text = "Unstack"
     });
     mUnstack.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.UNSTACK);
     });
     mMenuItems.Add(mCombine = new ToolStripMenuItem()
     {
         Text = "Combine"
     });
     mCombine.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.COMBINE);
     });
     mMenuItems.Add(mRemovePlot = new ToolStripMenuItem()
     {
         Text = "Remove Plot"
     });
     mRemovePlot.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.REMOVE_PLOT);
     });
     mMenuItems.Add(mReset = new ToolStripMenuItem()
     {
         Text = "Reset"
     });
     mReset.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.RESET);
     });
     mMenuItems.Add(mProperties = new ToolStripMenuItem()
     {
         Text = "Properties..."
     });
     mProperties.Click += new EventHandler((s, e) => {
         sim.Performed(SCOPE_MENU_ITEM.PROPERTIES);
     });
 }
예제 #9
0
        public ElementPopupMenu(CirSim sim)
        {
            mMenuItems           = new List <ToolStripMenuItem>();
            mMenuItems.Add(mEdit = new ToolStripMenuItem()
            {
                Text = "Edit..."
            });
            mEdit.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.EDIT);
            });
            var cut = new ToolStripMenuItem()
            {
                Text = "Cut"
            };

            mMenuItems.Add(cut);
            cut.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.CUT);
            });
            var copy = new ToolStripMenuItem()
            {
                Text = "Copy"
            };

            mMenuItems.Add(copy);
            copy.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.COPY);
            });
            var delete = new ToolStripMenuItem()
            {
                Text = "Delete"
            };

            mMenuItems.Add(delete);
            delete.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.DELETE);
            });
            var dup = new ToolStripMenuItem()
            {
                Text = "Duplicate"
            };

            mMenuItems.Add(dup);
            dup.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.DUPLICATE);
            });
            mMenuItems.Add(mScope = new ToolStripMenuItem()
            {
                Text = "View in Scope"
            });
            mScope.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.VIEW_IN_SCOPE);
            });
            mMenuItems.Add(mFloatScope = new ToolStripMenuItem()
            {
                Text = "View in Undocked Scope"
            });
            mFloatScope.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.VIEW_IN_FLOAT_SCOPE);
            });
            mMenuItems.Add(mFlip = new ToolStripMenuItem()
            {
                Text = "Swap Terminals"
            });
            mFlip.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.FLIP);
            });
            mMenuItems.Add(mSplit = new ToolStripMenuItem()
            {
                Text = "Split Wire"
            });
            mSplit.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.SPLIT);
            });
            mMenuItems.Add(mSlider = new ToolStripMenuItem()
            {
                Text = "Sliders..."
            });
            mSlider.Click += new EventHandler((s, e) => {
                sim.Performed(ELEMENT_MENU_ITEM.SLIDERS);
            });
        }