コード例 #1
0
        public IToggleButtonCommand AddToggleButtonCommand(string id)
        {
            var cmd = new ToggleButtonCommand();

            commands.Add(id, cmd);
            return(cmd);
        }
コード例 #2
0
        public void TestOrderInRibbonXml()
        {
            var _startMeasureCommand = new ToggleButtonCommand();
            var callbacks            = new CallbackRegsMock();
            var builder = new RibbonBuilder()
            {
                CallbackRegister = callbacks
            };

            builder.CustomUi.Ribbon.Tabs(ts => ts.AddTab("测量管理工具")
                                         .Groups(g => g.AddGroup("测量管理工具")
                                                 .Items(items => {
                //<toggleButton id="Id_StartMeasuring" description="开始测量" getLabel="GetLabel" getPressed = "GetPressed" size = "large" onAction = "OnToggleButtonAction" getImage = "GetImage" getEnabled = "GetEnabled" />
                items.AddToggleButton("开始测量").LargeSize().Callback(_startMeasureCommand);
                items.AddSeparator();
                items.AddCheckbox("跟踪测量单元格")
                .Supertip("如果选中此项,在测量时会选中正在进行的 测量数据单元格,用来指示当前测量的位置")
                .Callback(chk => chk.GetChecked(() => true).OnChecked(b => Console.WriteLine("跟踪测量单元格" + b)));
                //<toggleButton id="Id_SpeechValue" imageMso="SpeakCells" label = "语音报读" supertip = "选中此项,会朗读测量读数,需要系统语音支持" onAction = "OnToggleButtonAction"getPressed = "GetPressed" />
                items.AddToggleButton("语音报读").Supertip("选中此项,会朗读测量读数,需要系统语音支持").Callback(t => t.OnPressed((b) => Console.WriteLine(t.ControlId + " " + b)));
                //button id="SetMeasureValuesRange" label="测量数据区域" imageMso="ImportSharePointList" supertip = "设置当前工作表的数据采集区域" onAction = "OnButtonAction" getEnabled = "GetEnabled" />
                items.AddButton("测量数据区域").ImageMso("ImportSharePointList").Supertip("设置当前工作表的数据采集区域")
                .Callback(t => t.OnAction(() => Console.WriteLine($"{t.ControlId} Action")));
            }
                                                        )));
            Console.WriteLine(builder.GetXmlString());
            TestCallback(callbacks.Commands);
        }
コード例 #3
0
        public bool Toggle(string buttonName)
        {
            var command = new ToggleButtonCommand
            {
                AutomationIdentifier = CreateAutomationIdentifier(buttonName)
            };

            return(SyncExecuteCommand(command) is SuccessResult);
        }
コード例 #4
0
        /// <summary>
        /// Prepares all key bindings on the UI to allow for quick classification and navigation.
        /// </summary>
        /// <param name="boxes"></param>
        private void PrepareAllInputBindings(List <System.Windows.Controls.Primitives.ToggleButton> boxes)
        {
            this.InputBindings.Clear();

            int keyIdx = 0;

            System.Windows.Input.Key[] keys = new Key[]
            {
                System.Windows.Input.Key.NumPad1,
                System.Windows.Input.Key.NumPad2,
                System.Windows.Input.Key.NumPad3,
                System.Windows.Input.Key.NumPad4,
                System.Windows.Input.Key.NumPad5,
                System.Windows.Input.Key.NumPad6,
                System.Windows.Input.Key.NumPad7,
                System.Windows.Input.Key.NumPad8,
                System.Windows.Input.Key.NumPad9
            };

            foreach (System.Windows.Controls.Primitives.ToggleButton cb in boxes)
            {
                // Tool tip so user knows what key activates it
                cb.ToolTip = string.Format("Use numeric key {0} key to activate", (keyIdx + 1).ToString());

                // Prepare the input binding
                ToggleButtonCommand cmd = new ToggleButtonCommand(cb);
                cmd.ClassificationsChanged += this.ForceClassificationUpdate;
                this.PrepareInputBindings(cmd, keys[keyIdx++]);
            }

            if (this.ApplicationContext.SelectedDataSource != null && this.ApplicationContext.SelectedDataSource.ImageControl != null)
            {
                foreach (KeyBinding binding in this.ApplicationContext.SelectedDataSource.ImageControl.Bindings)
                {
                    this.InputBindings.Add(binding);
                }
            }
        }
        public bool Toggle(string buttonName)
        {
            var command = new ToggleButtonCommand
                {
                    AutomationIdentifier = CreateAutomationIdentifier(buttonName)
                };

            return SyncExecuteCommand(command) is SuccessResult;
        }